blob: d51b9a146fda17e3408d84b6478c4831d6dabb22 [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
17#include <thread>
18#include "LayerTransactionTest.h"
19namespace android {
20
21using android::hardware::graphics::common::V1_1::BufferUsage;
22
23::testing::Environment* const binderEnv =
24 ::testing::AddGlobalTestEnvironment(new BinderEnvironment());
25
26/**
27 * Test class for setting display configs and passing around refresh rate ranges.
28 */
29class RefreshRateRangeTest : public ::testing::Test {
30protected:
31 void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); }
32
33 sp<IBinder> mDisplayToken;
34};
35
Steven Thomas6d2f5c32020-01-06 12:15:59 -080036TEST_F(RefreshRateRangeTest, setAllConfigs) {
37 int32_t initialDefaultConfig;
38 float initialMin;
39 float initialMax;
40 status_t res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken,
41 &initialDefaultConfig,
42 &initialMin, &initialMax);
43 ASSERT_EQ(res, NO_ERROR);
Ana Krulec234bb162019-11-10 22:55:55 +010044
Steven Thomas6d2f5c32020-01-06 12:15:59 -080045 Vector<DisplayInfo> configs;
46 res = SurfaceComposerClient::getDisplayConfigs(mDisplayToken, &configs);
47 ASSERT_EQ(res, NO_ERROR);
48
49 for (size_t i = 0; i < configs.size(); i++) {
50 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, i, configs[i].fps,
51 configs[i].fps);
52 ASSERT_EQ(res, NO_ERROR);
53
54 int defaultConfig;
55 float minFps;
56 float maxFps;
57 res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfig,
58 &minFps, &maxFps);
59 ASSERT_EQ(res, NO_ERROR);
60 ASSERT_EQ(defaultConfig, i);
61 ASSERT_EQ(minFps, configs[i].fps);
62 ASSERT_EQ(maxFps, configs[i].fps);
63 }
64
65 res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, initialDefaultConfig,
66 initialMin, initialMax);
67 ASSERT_EQ(res, NO_ERROR);
Ana Krulec234bb162019-11-10 22:55:55 +010068}
69
Ana Krulec0782b882019-10-15 17:34:54 -070070} // namespace android