blob: fc9b6a27aa83d361628acf497363f072978b1aa1 [file] [log] [blame]
Garfield Tan23202892022-03-02 16:10:21 -08001/*
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"
26#include "BufferStateLayer.h"
27#include "EffectLayer.h"
28#include "Layer.h"
29// TODO(b/129481165): remove the #pragma below and fix conversion issues
30#pragma clang diagnostic pop // ignored "-Wconversion"
31
32#include "TestableSurfaceFlinger.h"
33
34namespace android {
35
36class LayerFactory {
37public:
38 virtual ~LayerFactory() = default;
39
40 virtual std::string name() = 0;
41 virtual sp<Layer> createLayer(TestableSurfaceFlinger& flinger) = 0;
42
43protected:
44 static constexpr uint32_t WIDTH = 100;
45 static constexpr uint32_t HEIGHT = 100;
46 static constexpr uint32_t LAYER_FLAGS = 0;
47};
48
49class BufferStateLayerFactory : public LayerFactory {
50public:
51 std::string name() override { return "BufferStateLayer"; }
52 sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override;
53};
54
55class EffectLayerFactory : public LayerFactory {
56public:
57 std::string name() override { return "EffectLayer"; }
58 sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override;
59};
60
61std::string PrintToStringParamName(
62 const ::testing::TestParamInfo<std::shared_ptr<LayerFactory>>& info);
63
64class BaseLayerTest : public ::testing::TestWithParam<std::shared_ptr<LayerFactory>> {
65protected:
66 BaseLayerTest();
67
68 void setupScheduler();
69
70 TestableSurfaceFlinger mFlinger;
71};
72
73} // namespace android