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; |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame^] | 34 | int32_t defaultConfigId; |
| 35 | float minRefreshRate; |
| 36 | float maxRefreshRate; |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame^] | 39 | TEST_F(RefreshRateRangeTest, simpleSetAndGet) { |
| 40 | status_t res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, 1, 45, 75); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 41 | EXPECT_EQ(res, NO_ERROR); |
Ana Krulec | 234bb16 | 2019-11-10 22:55:55 +0100 | [diff] [blame^] | 42 | |
| 43 | res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfigId, |
| 44 | &minRefreshRate, &maxRefreshRate); |
| 45 | EXPECT_EQ(res, NO_ERROR); |
| 46 | EXPECT_EQ(defaultConfigId, 1); |
| 47 | EXPECT_EQ(minRefreshRate, 45); |
| 48 | EXPECT_EQ(maxRefreshRate, 75); |
| 49 | } |
| 50 | |
| 51 | TEST_F(RefreshRateRangeTest, complexSetAndGet) { |
| 52 | status_t res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, 1, 45, 75); |
| 53 | EXPECT_EQ(res, NO_ERROR); |
| 54 | |
| 55 | res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfigId, |
| 56 | &minRefreshRate, &maxRefreshRate); |
| 57 | EXPECT_EQ(res, NO_ERROR); |
| 58 | EXPECT_EQ(defaultConfigId, 1); |
| 59 | EXPECT_EQ(minRefreshRate, 45); |
| 60 | EXPECT_EQ(maxRefreshRate, 75); |
| 61 | |
| 62 | // Second call overrides the first one. |
| 63 | res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, 10, 145, 875); |
| 64 | EXPECT_EQ(res, NO_ERROR); |
| 65 | res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfigId, |
| 66 | &minRefreshRate, &maxRefreshRate); |
| 67 | EXPECT_EQ(res, NO_ERROR); |
| 68 | EXPECT_EQ(defaultConfigId, 10); |
| 69 | EXPECT_EQ(minRefreshRate, 145); |
| 70 | EXPECT_EQ(maxRefreshRate, 875); |
Ana Krulec | 0782b88 | 2019-10-15 17:34:54 -0700 | [diff] [blame] | 71 | } |
| 72 | } // namespace android |