Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 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 | #include <thread> |
| 18 | #include "LayerTransactionTest.h" |
| 19 | namespace android { |
| 20 | |
| 21 | using 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 | */ |
| 29 | class RefreshRateRangeTest : public ::testing::Test { |
| 30 | protected: |
| 31 | void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); } |
| 32 | |
| 33 | sp<IBinder> mDisplayToken; |
| 34 | }; |
| 35 | |
Steven Thomas | 6d2f5c3 | 2020-01-06 12:15:59 -0800 | [diff] [blame^] | 36 | TEST_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 Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 44 | |
Steven Thomas | 6d2f5c3 | 2020-01-06 12:15:59 -0800 | [diff] [blame^] | 45 | 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 Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 68 | } |
| 69 | |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 70 | } // namespace android |