1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HDI_DEVICE_TEST_H
17 #define HDI_DEVICE_TEST_H
18 #include <condition_variable>
19 #include <vector>
20 #include <mutex>
21 #include "gtest/gtest.h"
22 #include "v1_1/display_composer_type.h"
23 #include "v1_0/display_buffer_type.h"
24 #include "display_test_utils.h"
25 
26 namespace OHOS {
27 namespace HDI {
28 namespace Display {
29 namespace TEST {
30 using namespace OHOS::HDI::Display::Buffer::V1_0;
31 using namespace OHOS::HDI::Display::Composer::V1_1;
32 
33 class DeviceLayerDisplay : public ::testing::TestWithParam<std::vector<LayerSettings>> {
34 protected:
35     void TearDown();
36 };
37 
38 class DeviceTest : public ::testing::Test {
39 protected:
40     static void SetUpTestCase();
41     void TearDown();
42 };
43 
44 // only support single layer test
45 class LayerRotateTest : public ::testing::TestWithParam<LayerSettings> {
46 protected:
47     void TearDown();
48     static void TearDownTestCase();
49 };
50 
51 class VblankCtr {
52 public:
GetInstance()53     static VblankCtr& GetInstance()
54     {
55         static VblankCtr instance;
56         return instance;
57     }
58     void NotifyVblank(unsigned int sequence, uint64_t ns, const void* data);
59     int32_t WaitVblank(uint32_t ms);
60     bool hasVblank_ = false;
61 private:
62     std::mutex vblankMutex_;
63     std::condition_variable vblankCondition_;
VblankCtr()64     VblankCtr() {}
65     ~VblankCtr();
66 };
67 } // OHOS
68 } // HDI
69 } // Display
70 } // TEST
71 
72 #endif // HDI_DEVICE_TEST_H
73