1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <compositionengine/CompositionRefreshArgs.h>
20 #include <compositionengine/DisplayColorProfile.h>
21 #include <compositionengine/LayerFE.h>
22 #include <compositionengine/Output.h>
23 #include <compositionengine/OutputLayer.h>
24 #include <compositionengine/RenderSurface.h>
25 #include <compositionengine/impl/OutputCompositionState.h>
26 #include <gmock/gmock.h>
27 
28 namespace android::compositionengine::mock {
29 
30 class Output : public virtual compositionengine::Output {
31 public:
32     Output();
33     virtual ~Output();
34 
35     MOCK_CONST_METHOD0(isValid, bool());
36     MOCK_CONST_METHOD0(getDisplayId, std::optional<DisplayId>());
37 
38     MOCK_METHOD1(setCompositionEnabled, void(bool));
39     MOCK_METHOD7(setProjection,
40                  void(const ui::Transform&, uint32_t, const Rect&, const Rect&, const Rect&,
41                       const Rect&, bool));
42     MOCK_METHOD1(setBounds, void(const ui::Size&));
43     MOCK_METHOD2(setLayerStackFilter, void(uint32_t, bool));
44 
45     MOCK_METHOD1(setColorTransform, void(const compositionengine::CompositionRefreshArgs&));
46     MOCK_METHOD1(setColorProfile, void(const ColorProfile&));
47 
48     MOCK_CONST_METHOD1(dump, void(std::string&));
49     MOCK_CONST_METHOD0(getName, const std::string&());
50     MOCK_METHOD1(setName, void(const std::string&));
51 
52     MOCK_CONST_METHOD0(getDisplayColorProfile, compositionengine::DisplayColorProfile*());
53     MOCK_METHOD1(setDisplayColorProfile,
54                  void(std::unique_ptr<compositionengine::DisplayColorProfile>));
55 
56     MOCK_CONST_METHOD0(getRenderSurface, compositionengine::RenderSurface*());
57     MOCK_METHOD1(setRenderSurface, void(std::unique_ptr<compositionengine::RenderSurface>));
58 
59     MOCK_CONST_METHOD0(getState, const OutputCompositionState&());
60     MOCK_METHOD0(editState, OutputCompositionState&());
61 
62     MOCK_CONST_METHOD1(getDirtyRegion, Region(bool));
63     MOCK_CONST_METHOD2(belongsInOutput, bool(std::optional<uint32_t>, bool));
64     MOCK_CONST_METHOD1(belongsInOutput, bool(const sp<compositionengine::LayerFE>&));
65 
66     MOCK_CONST_METHOD1(getOutputLayerForLayer,
67                        compositionengine::OutputLayer*(const sp<compositionengine::LayerFE>&));
68     MOCK_METHOD0(clearOutputLayers, void());
69     MOCK_METHOD1(injectOutputLayerForTest,
70                  compositionengine::OutputLayer*(const sp<compositionengine::LayerFE>&));
71     MOCK_CONST_METHOD0(getOutputLayerCount, size_t());
72     MOCK_CONST_METHOD1(getOutputLayerOrderedByZByIndex, OutputLayer*(size_t));
73 
74     MOCK_METHOD1(setReleasedLayers, void(ReleasedLayers&&));
75 
76     MOCK_METHOD2(prepare, void(const compositionengine::CompositionRefreshArgs&, LayerFESet&));
77     MOCK_METHOD1(present, void(const compositionengine::CompositionRefreshArgs&));
78 
79     MOCK_METHOD2(rebuildLayerStacks,
80                  void(const compositionengine::CompositionRefreshArgs&, LayerFESet&));
81     MOCK_METHOD2(collectVisibleLayers,
82                  void(const compositionengine::CompositionRefreshArgs&,
83                       compositionengine::Output::CoverageState&));
84     MOCK_METHOD2(ensureOutputLayerIfVisible,
85                  void(sp<compositionengine::LayerFE>&, compositionengine::Output::CoverageState&));
86     MOCK_METHOD1(setReleasedLayers, void(const compositionengine::CompositionRefreshArgs&));
87 
88     MOCK_CONST_METHOD1(updateLayerStateFromFE, void(const CompositionRefreshArgs&));
89     MOCK_METHOD1(updateAndWriteCompositionState, void(const CompositionRefreshArgs&));
90     MOCK_METHOD1(updateColorProfile, void(const compositionengine::CompositionRefreshArgs&));
91 
92     MOCK_METHOD0(beginFrame, void());
93 
94     MOCK_METHOD0(prepareFrame, void());
95     MOCK_METHOD0(chooseCompositionStrategy, void());
96 
97     MOCK_METHOD1(devOptRepaintFlash, void(const compositionengine::CompositionRefreshArgs&));
98 
99     MOCK_METHOD1(finishFrame, void(const compositionengine::CompositionRefreshArgs&));
100 
101     MOCK_METHOD2(composeSurfaces,
102                  std::optional<base::unique_fd>(
103                          const Region&,
104                          const compositionengine::CompositionRefreshArgs& refreshArgs));
105     MOCK_CONST_METHOD0(getSkipColorTransform, bool());
106 
107     MOCK_METHOD0(postFramebuffer, void());
108     MOCK_METHOD0(presentAndGetFrameFences, compositionengine::Output::FrameFences());
109 
110     MOCK_METHOD3(generateClientCompositionRequests,
111                  std::vector<LayerFE::LayerSettings>(bool, Region&, ui::Dataspace));
112     MOCK_METHOD2(appendRegionFlashRequests,
113                  void(const Region&, std::vector<LayerFE::LayerSettings>&));
114     MOCK_METHOD1(setExpensiveRenderingExpected, void(bool));
115     MOCK_METHOD1(cacheClientCompositionRequests, void(uint32_t));
116 };
117 
118 } // namespace android::compositionengine::mock
119