blob: 0773d9081ee9954500d0660267733604ea793aed [file] [log] [blame]
Garfield Tan23202892022-03-02 16:10:21 -08001/*
Dominik Laskowskifb281c52023-02-11 14:24:19 -05002 * Copyright 2022 The Android Open Source Project
Garfield Tan23202892022-03-02 16:10:21 -08003 *
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 Tan23202892022-03-02 16:10:21 -080026#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
32namespace android {
33
34class LayerFactory {
35public:
36 virtual ~LayerFactory() = default;
37
38 virtual std::string name() = 0;
39 virtual sp<Layer> createLayer(TestableSurfaceFlinger& flinger) = 0;
40
41protected:
42 static constexpr uint32_t WIDTH = 100;
43 static constexpr uint32_t HEIGHT = 100;
44 static constexpr uint32_t LAYER_FLAGS = 0;
45};
46
47class BufferStateLayerFactory : public LayerFactory {
48public:
49 std::string name() override { return "BufferStateLayer"; }
50 sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override;
51};
52
53class EffectLayerFactory : public LayerFactory {
54public:
55 std::string name() override { return "EffectLayer"; }
56 sp<Layer> createLayer(TestableSurfaceFlinger& flinger) override;
57};
58
59std::string PrintToStringParamName(
60 const ::testing::TestParamInfo<std::shared_ptr<LayerFactory>>& info);
61
62class BaseLayerTest : public ::testing::TestWithParam<std::shared_ptr<LayerFactory>> {
63protected:
64 BaseLayerTest();
65
Garfield Tan23202892022-03-02 16:10:21 -080066 TestableSurfaceFlinger mFlinger;
67};
68
69} // namespace android