blob: 3aa4474b6b561a1b5c65dbd10ef1b9ef7a17b493 [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
Steven Thomas6d2f5c32020-01-06 12:15:59 -080049 Vector<DisplayInfo> configs;
50 res = SurfaceComposerClient::getDisplayConfigs(mDisplayToken, &configs);
51 ASSERT_EQ(res, NO_ERROR);
52
53 for (size_t i = 0; i < configs.size(); i++) {
54 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, i, configs[i].fps,
55 configs[i].fps);
56 ASSERT_EQ(res, NO_ERROR);
57
58 int defaultConfig;
59 float minFps;
60 float maxFps;
61 res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfig,
62 &minFps, &maxFps);
63 ASSERT_EQ(res, NO_ERROR);
64 ASSERT_EQ(defaultConfig, i);
65 ASSERT_EQ(minFps, configs[i].fps);
66 ASSERT_EQ(maxFps, configs[i].fps);
67 }
68
69 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, initialDefaultConfig,
70 initialMin, initialMax);
71 ASSERT_EQ(res, NO_ERROR);
Ana Krulec234bb162019-11-10 22:55:55 +010072}
73
Ana Krulec0782b882019-10-15 17:34:54 -070074} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080075
76// TODO(b/129481165): remove the #pragma below and fix conversion issues
77#pragma clang diagnostic pop // ignored "-Wconversion"