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 | |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame^] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 18 | #pragma clang diagnostic push |
| 19 | #pragma clang diagnostic ignored "-Wconversion" |
| 20 | |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 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: |
| 35 | void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); } |
| 36 | |
| 37 | sp<IBinder> mDisplayToken; |
| 38 | }; |
| 39 | |
Steven Thomas | 6d2f5c3 | 2020-01-06 12:15:59 -0800 | [diff] [blame] | 40 | TEST_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 Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 48 | |
Steven Thomas | 6d2f5c3 | 2020-01-06 12:15:59 -0800 | [diff] [blame] | 49 | 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 Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame] | 72 | } |
| 73 | |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 74 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame^] | 75 | |
| 76 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 77 | #pragma clang diagnostic pop // ignored "-Wconversion" |