blob: 0ed2ffb5059f8e795ccc47481082fadda2f997b5 [file] [log] [blame]
Ana Krulec0782b882019-10-15 17:34:54 -07001/*
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
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080017// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
20
Ana Krulec0782b882019-10-15 17:34:54 -070021#include <thread>
22#include "LayerTransactionTest.h"
23namespace android {
24
25using 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 */
33class RefreshRateRangeTest : public ::testing::Test {
34protected:
35 void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); }
36
37 sp<IBinder> mDisplayToken;
38};
39
Steven Thomas6d2f5c32020-01-06 12:15:59 -080040TEST_F(RefreshRateRangeTest, setAllConfigs) {
41 int32_t initialDefaultConfig;
42 float initialMin;
43 float initialMax;
44 status_t res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken,
45 &initialDefaultConfig,
46 &initialMin, &initialMax);
47 ASSERT_EQ(res, NO_ERROR);
Ana Krulec234bb162019-11-10 22:55:55 +010048
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080049 Vector<DisplayConfig> configs;
Steven Thomas6d2f5c32020-01-06 12:15:59 -080050 res = SurfaceComposerClient::getDisplayConfigs(mDisplayToken, &configs);
51 ASSERT_EQ(res, NO_ERROR);
52
53 for (size_t i = 0; i < configs.size(); i++) {
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080054 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, i,
55 configs[i].refreshRate,
56 configs[i].refreshRate);
Steven Thomas6d2f5c32020-01-06 12:15:59 -080057 ASSERT_EQ(res, NO_ERROR);
58
59 int defaultConfig;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080060 float minRefreshRate;
61 float maxRefreshRate;
Steven Thomas6d2f5c32020-01-06 12:15:59 -080062 res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfig,
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080063 &minRefreshRate, &maxRefreshRate);
Steven Thomas6d2f5c32020-01-06 12:15:59 -080064 ASSERT_EQ(res, NO_ERROR);
65 ASSERT_EQ(defaultConfig, i);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080066 ASSERT_EQ(minRefreshRate, configs[i].refreshRate);
67 ASSERT_EQ(maxRefreshRate, configs[i].refreshRate);
Steven Thomas6d2f5c32020-01-06 12:15:59 -080068 }
69
70 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, initialDefaultConfig,
71 initialMin, initialMax);
72 ASSERT_EQ(res, NO_ERROR);
Ana Krulec234bb162019-11-10 22:55:55 +010073}
74
Ana Krulec0782b882019-10-15 17:34:54 -070075} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080076
77// TODO(b/129481165): remove the #pragma below and fix conversion issues
78#pragma clang diagnostic pop // ignored "-Wconversion"