• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H
17 #define FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H
18 
19 #include "gmock/gmock.h"
20 
21 #include "core/common/container.h"
22 
23 namespace OHOS::Ace {
24 class MockContainer final : public Container {
25     DECLARE_ACE_TYPE(MockContainer, Container);
26 
27 public:
pipelineContext_(pipelineContext)28     explicit MockContainer(RefPtr<PipelineBase> pipelineContext = nullptr) : pipelineContext_(pipelineContext) {}
29 
GetPipelineContext()30     RefPtr<PipelineBase> GetPipelineContext() const override
31     {
32         return pipelineContext_;
33     }
34 
GetTaskExecutor()35     RefPtr<TaskExecutor> GetTaskExecutor() const override
36     {
37         return taskExecutor_;
38     }
39 
40     static void SetUp();
41     static void TearDown();
42     static RefPtr<MockContainer> Current();
43 
44     MOCK_METHOD(void, Initialize, (), (override));
45     MOCK_METHOD(void, Destroy, (), (override));
46     MOCK_METHOD(int32_t, GetInstanceId, (), (const, override));
47     MOCK_METHOD(std::string, GetHostClassName, (), (const, override));
48 
49     MOCK_METHOD(RefPtr<Frontend>, GetFrontend, (), (const, override));
50     MOCK_METHOD(RefPtr<AssetManager>, GetAssetManager, (), (const, override));
51     MOCK_METHOD(RefPtr<PlatformResRegister>, GetPlatformResRegister, (), (const, override));
52     MOCK_METHOD(int32_t, GetViewWidth, (), (const, override));
53     MOCK_METHOD(int32_t, GetViewHeight, (), (const, override));
54     MOCK_METHOD(int32_t, GetViewPosX, (), (const, override));
55     MOCK_METHOD(int32_t, GetViewPosY, (), (const, override));
56     MOCK_METHOD(uint32_t, GetWindowId, (), (const, override));
57     MOCK_METHOD(void*, GetView, (), (const, override));
58 
59     MOCK_METHOD(void, DumpHeapSnapshot, (bool isPrivate), (override));
60     MOCK_METHOD(void, TriggerGarbageCollection, (), (override));
61     MOCK_METHOD(bool, WindowIsShow, (), (const, override));
62     MOCK_METHOD(RefPtr<DisplayInfo>, GetDisplayInfo, (), (override));
63     static RefPtr<MockContainer> container_;
64 
65 private:
66     RefPtr<TaskExecutor> taskExecutor_;
67     RefPtr<PipelineBase> pipelineContext_;
68 };
69 } // namespace OHOS::Ace
70 #endif // FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H
71