• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace android::mock {
23 
24 class MockLayer : public Layer {
25 public:
MockLayer(SurfaceFlinger * flinger,std::string name)26     MockLayer(SurfaceFlinger* flinger, std::string name)
27           : Layer(LayerCreationArgs(flinger, nullptr, std::move(name), 0, {})) {
28         EXPECT_CALL(*this, getDefaultFrameRateCompatibility())
29                 .WillOnce(testing::Return(scheduler::FrameRateCompatibility::Default));
30     }
31 
MockLayer(SurfaceFlinger * flinger,std::string name,std::optional<uint32_t> uid)32     MockLayer(SurfaceFlinger* flinger, std::string name, std::optional<uint32_t> uid)
33           : Layer(LayerCreationArgs(flinger, nullptr, std::move(name), 0, {}, uid)) {
34         EXPECT_CALL(*this, getDefaultFrameRateCompatibility())
35                 .WillOnce(testing::Return(scheduler::FrameRateCompatibility::Default));
36     }
37 
MockLayer(SurfaceFlinger * flinger)38     explicit MockLayer(SurfaceFlinger* flinger) : MockLayer(flinger, "TestLayer") {}
39 
40     MOCK_CONST_METHOD0(getType, const char*());
41     MOCK_METHOD0(getFrameSelectionPriority, int32_t());
42     MOCK_CONST_METHOD0(isVisible, bool());
43     MOCK_METHOD0(createClone, sp<Layer>());
44     MOCK_CONST_METHOD0(getFrameRateForLayerTree, FrameRate());
45     MOCK_CONST_METHOD0(getDefaultFrameRateCompatibility, scheduler::FrameRateCompatibility());
46     MOCK_CONST_METHOD0(getOwnerUid, uid_t());
47     MOCK_CONST_METHOD0(getDataSpace, ui::Dataspace());
48     MOCK_METHOD(bool, isFrontBuffered, (), (const, override));
49 };
50 
51 } // namespace android::mock
52