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_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_PIPELINE_CONTEXT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_PIPELINE_CONTEXT_H
18 
19 #include "gmock/gmock.h"
20 
21 #include "core/pipeline_ng/pipeline_context.h"
22 
23 namespace OHOS::Ace::NG {
24 class MockPipelineContext : public PipelineContext {
25     DECLARE_ACE_TYPE(MockPipelineContext, PipelineContext);
26 
27 public:
28     MockPipelineContext() = default;
29     ~MockPipelineContext() override = default;
30 
31     static void SetUp();
32     static void TearDown();
33     static void SetCurrentWindowRect(Rect rect);
34     static RefPtr<MockPipelineContext> GetCurrent();
35     void SetRootSize(double rootWidth, double rootHeight);
36 
37     MOCK_CONST_METHOD0(GetSafeAreaWithoutProcess, SafeAreaInsets());
38     MOCK_METHOD(void, FlushUITasks, (bool triggeredByImplicitAnimation), (override));
39     MOCK_METHOD(float, GetFontScale, ());
40     MOCK_METHOD(SafeAreaInsets, GetSafeArea, (), (const));
41 
GetIsDeclarative()42     bool GetIsDeclarative() const override
43     {
44         return isDeclarative_;
45     }
46 
47     static RefPtr<MockPipelineContext> pipeline_;
48 
49 protected:
50     float fontScale_ = 1.0f;
51     bool isDeclarative_ = false;
52     double dipScale_ = 1.0;
53     RefPtr<TaskExecutor> taskExecutor_;
54 };
55 } // namespace OHOS::Ace::NG
56 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_PIPELINE_CONTEXT_H
57