1 /*
2 * Copyright (C) 2019 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 // TODO(b/129481165): remove the #pragma below and fix conversion issues
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wconversion"
20
21 #include <thread>
22 #include "LayerTransactionTest.h"
23 namespace android {
24
25 using android::hardware::graphics::common::V1_1::BufferUsage;
26
27 ::testing::Environment* const binderEnv =
28 ::testing::AddGlobalTestEnvironment(new BinderEnvironment());
29
30 /**
31 * Test class for setting display configs and passing around refresh rate ranges.
32 */
33 class RefreshRateRangeTest : public ::testing::Test {
34 protected:
SetUp()35 void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); }
36
37 sp<IBinder> mDisplayToken;
38 };
39
TEST_F(RefreshRateRangeTest,setAllConfigs)40 TEST_F(RefreshRateRangeTest, setAllConfigs) {
41 int32_t initialDefaultConfig;
42 float initialPrimaryMin;
43 float initialPrimaryMax;
44 float initialAppRequestMin;
45 float initialAppRequestMax;
46 status_t res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken,
47 &initialDefaultConfig,
48 &initialPrimaryMin,
49 &initialPrimaryMax,
50 &initialAppRequestMin,
51 &initialAppRequestMax);
52 ASSERT_EQ(res, NO_ERROR);
53
54 Vector<DisplayConfig> configs;
55 res = SurfaceComposerClient::getDisplayConfigs(mDisplayToken, &configs);
56 ASSERT_EQ(res, NO_ERROR);
57
58 for (size_t i = 0; i < configs.size(); i++) {
59 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, i,
60 configs[i].refreshRate,
61 configs[i].refreshRate,
62 configs[i].refreshRate,
63 configs[i].refreshRate);
64 ASSERT_EQ(res, NO_ERROR);
65
66 int defaultConfig;
67 float primaryRefreshRateMin;
68 float primaryRefreshRateMax;
69 float appRequestRefreshRateMin;
70 float appRequestRefreshRateMax;
71 res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfig,
72 &primaryRefreshRateMin,
73 &primaryRefreshRateMax,
74 &appRequestRefreshRateMin,
75 &appRequestRefreshRateMax);
76 ASSERT_EQ(res, NO_ERROR);
77 ASSERT_EQ(defaultConfig, i);
78 ASSERT_EQ(primaryRefreshRateMin, configs[i].refreshRate);
79 ASSERT_EQ(primaryRefreshRateMax, configs[i].refreshRate);
80 ASSERT_EQ(appRequestRefreshRateMin, configs[i].refreshRate);
81 ASSERT_EQ(appRequestRefreshRateMax, configs[i].refreshRate);
82 }
83
84 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, initialDefaultConfig,
85 initialPrimaryMin, initialPrimaryMax,
86 initialAppRequestMin,
87 initialAppRequestMax);
88 ASSERT_EQ(res, NO_ERROR);
89 }
90
91 } // namespace android
92
93 // TODO(b/129481165): remove the #pragma below and fix conversion issues
94 #pragma clang diagnostic pop // ignored "-Wconversion"