1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_NAVIGATION_ROUTE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_NAVIGATION_ROUTE_H 18 19 #include "frameworks/core/components_ng/pattern/navigation/navigation_route.h" 20 21 class MockNavigationRoute : public OHOS::Ace::NG::NavigationRoute { 22 DECLARE_ACE_TYPE(MockNavigationRoute, OHOS::Ace::NG::NavigationRoute); 23 24 public: MockNavigationRoute(const std::string & bundleName)25 explicit MockNavigationRoute(const std::string& bundleName) {} 26 27 ~MockNavigationRoute() = default; 28 LoadPage(const std::string & name)29 int32_t LoadPage(const std::string& name) override 30 { 31 if (std::find(names_.begin(), names_.end(), name) != names_.end()) { 32 return 0; 33 } 34 if (name == "error") { 35 return -1; 36 } 37 names_.push_back(name); 38 return 0; 39 } 40 GetPageNames()41 std::vector<std::string> GetPageNames() const 42 { 43 return names_; 44 } 45 46 private: 47 std::vector<std::string> names_; 48 }; 49 #endif