xref: /aosp_15_r20/frameworks/native/services/surfaceflinger/tests/unittests/mock/MockLayer.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
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 <gmock/gmock.h>
20 #include <optional>
21 
22 #include "Layer.h"
23 
24 namespace android::mock {
25 
26 class MockLayer : public Layer {
27 public:
MockLayer(SurfaceFlinger * flinger,std::string name)28     MockLayer(SurfaceFlinger* flinger, std::string name)
29           : Layer(LayerCreationArgs(flinger, nullptr, std::move(name), 0, {})) {}
30 
MockLayer(SurfaceFlinger * flinger,std::string name,std::optional<uint32_t> id)31     MockLayer(SurfaceFlinger* flinger, std::string name, std::optional<uint32_t> id)
32           : Layer(LayerCreationArgs(flinger, nullptr, std::move(name), 0, {}, id)) {}
33 
MockLayer(SurfaceFlinger * flinger,std::optional<uint32_t> id)34     MockLayer(SurfaceFlinger* flinger, std::optional<uint32_t> id)
35           : Layer(LayerCreationArgs(flinger, nullptr, "TestLayer", 0, {}, id)) {}
36 
MockLayer(SurfaceFlinger * flinger)37     explicit MockLayer(SurfaceFlinger* flinger) : MockLayer(flinger, "TestLayer") {}
38 
39     MOCK_METHOD0(getFrameSelectionPriority, int32_t());
40     MOCK_METHOD0(createClone, sp<Layer>());
41     MOCK_CONST_METHOD0(getFrameRateForLayerTree, FrameRate());
42     MOCK_CONST_METHOD0(getDefaultFrameRateCompatibility, scheduler::FrameRateCompatibility());
43     MOCK_CONST_METHOD0(getOwnerUid, uid_t());
44 };
45 
46 } // namespace android::mock
47