• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace OHOS::Ace {
22 class MockNavigationRoute : public OHOS::Ace::NG::NavigationRoute {
23     DECLARE_ACE_TYPE(MockNavigationRoute, OHOS::Ace::NG::NavigationRoute);
24 
25 public:
MockNavigationRoute(const std::string & bundleName)26     explicit MockNavigationRoute(const std::string& bundleName) {}
27 
28     ~MockNavigationRoute() = default;
29 
LoadPage(const std::string & name)30     int32_t LoadPage(const std::string& name) override
31     {
32         if (std::find(names_.begin(), names_.end(), name) != names_.end()) {
33             return 0;
34         }
35         if (name == "error") {
36             return -1;
37         }
38         names_.push_back(name);
39         return 0;
40     }
41 
GetPageNames()42     std::vector<std::string> GetPageNames() const
43     {
44         return names_;
45     }
46 
47 private:
48     std::vector<std::string> names_;
49 };
50 } // namespace OHOS::Ace
51 #endif
52