blob: 74f571e1409cbff0d62a1498d81307ef31bff717 [file] [log] [blame]
Marissa Wall6bd8bfd2016-12-15 12:25:31 -08001/*
2 * Copyright (C) 2016 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#ifndef _HWC2_TEST_PROPERTIES_H
18#define _HWC2_TEST_PROPERTIES_H
19
20#include <vector>
21
22#define HWC2_INCLUDE_STRINGIFICATION
23#define HWC2_USE_CPP11
24#include <hardware/hwcomposer2.h>
25#undef HWC2_INCLUDE_STRINGIFICATION
26#undef HWC2_USE_CPP11
27
28enum class Hwc2TestCoverage {
29 Default = 0,
30 Basic,
31 Complete,
32};
33
34
35template <class T>
36class Hwc2TestProperty {
37public:
38 Hwc2TestProperty(const std::vector<T>& list)
39 : mList(list) { }
40
41 virtual ~Hwc2TestProperty() { };
42
43 virtual void reset()
44 {
45 mListIdx = 0;
46 }
47
48 virtual bool advance()
49 {
50 if (mListIdx + 1 < mList.size()) {
51 mListIdx++;
52 return true;
53 }
54 reset();
55 return false;
56 }
57
58 virtual T get() const
59 {
60 return mList.at(mListIdx);
61 }
62
63 virtual std::string dump() const = 0;
64
65protected:
66 const std::vector<T>& mList;
67 size_t mListIdx = 0;
68};
69
70
71class Hwc2TestComposition : public Hwc2TestProperty<hwc2_composition_t> {
72public:
73 Hwc2TestComposition(Hwc2TestCoverage coverage);
74
75 std::string dump() const override;
76
77protected:
78 static const std::vector<hwc2_composition_t> mDefaultCompositions;
79 static const std::vector<hwc2_composition_t> mBasicCompositions;
80 static const std::vector<hwc2_composition_t> mCompleteCompositions;
81};
82
83#endif /* ifndef _HWC2_TEST_PROPERTIES_H */