• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 <memory>
20 
21 #include <gtest/gtest.h>
22 
23 // TODO(b/129481165): remove the #pragma below and fix conversion issues
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wconversion"
26 #include "Layer.h"
27 // TODO(b/129481165): remove the #pragma below and fix conversion issues
28 #pragma clang diagnostic pop // ignored "-Wconversion"
29 
30 #include "TestableSurfaceFlinger.h"
31 
32 namespace android {
33 
34 class LayerFactory {
35 public:
36     virtual ~LayerFactory() = default;
37 
38     virtual std::string name() = 0;
39     virtual sp<Layer> createLayer(TestableSurfaceFlinger& flinger) = 0;
40 
41 protected:
42     static constexpr uint32_t WIDTH = 100;
43     static constexpr uint32_t HEIGHT = 100;
44     static constexpr uint32_t LAYER_FLAGS = 0;
45 };
46 
47 class BufferStateLayerFactory : public LayerFactory {
48 public:
name()49     std::string name() override { return "BufferStateLayer"; }
50     sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override;
51 };
52 
53 class EffectLayerFactory : public LayerFactory {
54 public:
name()55     std::string name() override { return "EffectLayer"; }
56     sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override;
57 };
58 
59 std::string PrintToStringParamName(
60         const ::testing::TestParamInfo<std::shared_ptr<LayerFactory>>& info);
61 
62 class BaseLayerTest : public ::testing::TestWithParam<std::shared_ptr<LayerFactory>> {
63 protected:
64     BaseLayerTest();
65 
66     TestableSurfaceFlinger mFlinger;
67 };
68 
69 } // namespace android
70