| Garfield Tan | 2320289 | 2022-03-02 16:10:21 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 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" | 
| Garfield Tan | 2320289 | 2022-03-02 16:10:21 -0800 | [diff] [blame] | 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: | 
|  | 49 | std::string name() override { return "BufferStateLayer"; } | 
|  | 50 | sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override; | 
|  | 51 | }; | 
|  | 52 |  | 
|  | 53 | class EffectLayerFactory : public LayerFactory { | 
|  | 54 | public: | 
|  | 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 | void setupScheduler(); | 
|  | 67 |  | 
|  | 68 | TestableSurfaceFlinger mFlinger; | 
|  | 69 | }; | 
|  | 70 |  | 
|  | 71 | } // namespace android |