blob: 1b8f11b7db34cdf7d9a550b06c1053a26b09e4ca [file] [log] [blame]
Alec Mouri0a1cc962019-03-14 12:33:02 -07001/*
2 * Copyright 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#undef LOG_TAG
18#define LOG_TAG "SchedulerUnittests"
19
20#include <gmock/gmock.h>
21#include <log/log.h>
22#include <thread>
23
Ady Abraham6fb599b2020-03-05 13:48:22 -080024#include "../../Scheduler/RefreshRateConfigs.h"
Alec Mouri0a1cc962019-03-14 12:33:02 -070025#include "DisplayHardware/HWC2.h"
26#include "Scheduler/RefreshRateConfigs.h"
Ady Abrahamabc27602020-04-08 17:20:29 -070027#include "mock/DisplayHardware/MockDisplay.h"
Alec Mouri0a1cc962019-03-14 12:33:02 -070028
29using namespace std::chrono_literals;
30using testing::_;
31
32namespace android {
33namespace scheduler {
34
Alec Mouri0a1cc962019-03-14 12:33:02 -070035using RefreshRate = RefreshRateConfigs::RefreshRate;
Ady Abraham8a82ba62020-01-17 12:43:17 -080036using LayerVoteType = RefreshRateConfigs::LayerVoteType;
37using LayerRequirement = RefreshRateConfigs::LayerRequirement;
Alec Mouri0a1cc962019-03-14 12:33:02 -070038
39class RefreshRateConfigsTest : public testing::Test {
40protected:
Alec Mouri0a1cc962019-03-14 12:33:02 -070041 RefreshRateConfigsTest();
42 ~RefreshRateConfigsTest();
Ady Abrahamabc27602020-04-08 17:20:29 -070043
44 // Test config IDs
45 static inline const HwcConfigIndexType HWC_CONFIG_ID_60 = HwcConfigIndexType(0);
46 static inline const HwcConfigIndexType HWC_CONFIG_ID_90 = HwcConfigIndexType(1);
47 static inline const HwcConfigIndexType HWC_CONFIG_ID_72 = HwcConfigIndexType(2);
48 static inline const HwcConfigIndexType HWC_CONFIG_ID_120 = HwcConfigIndexType(3);
49 static inline const HwcConfigIndexType HWC_CONFIG_ID_30 = HwcConfigIndexType(4);
50
51 // Test configs
52 std::shared_ptr<const HWC2::Display::Config> mConfig60 =
53 createConfig(HWC_CONFIG_ID_60, 0, static_cast<int64_t>(1e9f / 60));
54 std::shared_ptr<const HWC2::Display::Config> mConfig90 =
55 createConfig(HWC_CONFIG_ID_90, 0, static_cast<int64_t>(1e9f / 90));
56 std::shared_ptr<const HWC2::Display::Config> mConfig90DifferentGroup =
57 createConfig(HWC_CONFIG_ID_90, 1, static_cast<int64_t>(1e9f / 90));
58 std::shared_ptr<const HWC2::Display::Config> mConfig90DifferentResolution =
59 createConfig(HWC_CONFIG_ID_90, 0, static_cast<int64_t>(1e9f / 90), 111, 222);
60 std::shared_ptr<const HWC2::Display::Config> mConfig72 =
61 createConfig(HWC_CONFIG_ID_72, 0, static_cast<int64_t>(1e9f / 72));
62 std::shared_ptr<const HWC2::Display::Config> mConfig72DifferentGroup =
63 createConfig(HWC_CONFIG_ID_72, 1, static_cast<int64_t>(1e9f / 72));
64 std::shared_ptr<const HWC2::Display::Config> mConfig120 =
65 createConfig(HWC_CONFIG_ID_120, 0, static_cast<int64_t>(1e9f / 120));
66 std::shared_ptr<const HWC2::Display::Config> mConfig120DifferentGroup =
67 createConfig(HWC_CONFIG_ID_120, 1, static_cast<int64_t>(1e9f / 120));
68 std::shared_ptr<const HWC2::Display::Config> mConfig30 =
69 createConfig(HWC_CONFIG_ID_30, 0, static_cast<int64_t>(1e9f / 30));
70
71 // Test device configurations
72 std::vector<std::shared_ptr<const HWC2::Display::Config>> m60OnlyConfigDevice = {mConfig60};
73 std::vector<std::shared_ptr<const HWC2::Display::Config>> m60_90Device = {mConfig60, mConfig90};
74 std::vector<std::shared_ptr<const HWC2::Display::Config>> m60_90DeviceWithDifferentGroups =
75 {mConfig60, mConfig90DifferentGroup};
76 std::vector<std::shared_ptr<const HWC2::Display::Config>> m60_90DeviceWithDifferentResolutions =
77 {mConfig60, mConfig90DifferentResolution};
78 std::vector<std::shared_ptr<const HWC2::Display::Config>> m60_72_90Device = {mConfig60,
79 mConfig90,
80 mConfig72};
81 std::vector<std::shared_ptr<const HWC2::Display::Config>> m60_90_72_120Device = {mConfig60,
82 mConfig90,
83 mConfig72,
84 mConfig120};
85 std::vector<std::shared_ptr<const HWC2::Display::Config>> m30_60_72_90_120Device = {mConfig60,
86 mConfig90,
87 mConfig72,
88 mConfig120,
89 mConfig30};
90 std::vector<std::shared_ptr<const HWC2::Display::Config>> m30_60Device =
91 {mConfig60, mConfig90DifferentGroup, mConfig72DifferentGroup, mConfig120DifferentGroup,
92 mConfig30};
93 std::vector<std::shared_ptr<const HWC2::Display::Config>> m30_60_72_90Device =
94 {mConfig60, mConfig90, mConfig72, mConfig120DifferentGroup, mConfig30};
95 std::vector<std::shared_ptr<const HWC2::Display::Config>> m30_60_90Device =
96 {mConfig60, mConfig90, mConfig72DifferentGroup, mConfig120DifferentGroup, mConfig30};
97
98 // Expected RefreshRate objects
99 RefreshRate mExpected60Config = {HWC_CONFIG_ID_60, mConfig60, "60fps", 60,
100 RefreshRate::ConstructorTag(0)};
101 RefreshRate mExpectedAlmost60Config = {HWC_CONFIG_ID_60,
102 createConfig(HWC_CONFIG_ID_60, 0, 16666665), "60fps", 60,
103 RefreshRate::ConstructorTag(0)};
104 RefreshRate mExpected90Config = {HWC_CONFIG_ID_90, mConfig90, "90fps", 90,
105 RefreshRate::ConstructorTag(0)};
106 RefreshRate mExpected90DifferentGroupConfig = {HWC_CONFIG_ID_90, mConfig90DifferentGroup,
107 "90fps", 90, RefreshRate::ConstructorTag(0)};
108 RefreshRate mExpected90DifferentResolutionConfig = {HWC_CONFIG_ID_90,
109 mConfig90DifferentResolution, "90fps", 90,
110 RefreshRate::ConstructorTag(0)};
111 RefreshRate mExpected72Config = {HWC_CONFIG_ID_72, mConfig72, "72fps", 72,
112 RefreshRate::ConstructorTag(0)};
113 RefreshRate mExpected30Config = {HWC_CONFIG_ID_30, mConfig30, "30fps", 30,
114 RefreshRate::ConstructorTag(0)};
115 RefreshRate mExpected120Config = {HWC_CONFIG_ID_120, mConfig120, "120fps", 120,
116 RefreshRate::ConstructorTag(0)};
117
118 Hwc2::mock::Display mDisplay;
119
120private:
121 std::shared_ptr<const HWC2::Display::Config> createConfig(HwcConfigIndexType configId,
122 int32_t configGroup,
123 int64_t vsyncPeriod,
124 int32_t hight = -1,
125 int32_t width = -1);
Alec Mouri0a1cc962019-03-14 12:33:02 -0700126};
127
Ady Abrahamabc27602020-04-08 17:20:29 -0700128using Builder = HWC2::Display::Config::Builder;
129
Alec Mouri0a1cc962019-03-14 12:33:02 -0700130RefreshRateConfigsTest::RefreshRateConfigsTest() {
131 const ::testing::TestInfo* const test_info =
132 ::testing::UnitTest::GetInstance()->current_test_info();
133 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
134}
135
136RefreshRateConfigsTest::~RefreshRateConfigsTest() {
137 const ::testing::TestInfo* const test_info =
138 ::testing::UnitTest::GetInstance()->current_test_info();
139 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
140}
141
Ady Abrahamabc27602020-04-08 17:20:29 -0700142std::shared_ptr<const HWC2::Display::Config> RefreshRateConfigsTest::createConfig(
143 HwcConfigIndexType configId, int32_t configGroup, int64_t vsyncPeriod, int32_t hight,
144 int32_t width) {
145 return HWC2::Display::Config::Builder(mDisplay, hwc2_config_t(configId.value()))
146 .setVsyncPeriod(int32_t(vsyncPeriod))
147 .setConfigGroup(configGroup)
148 .setHeight(hight)
149 .setWidth(width)
150 .build();
151}
152
Alec Mouri0a1cc962019-03-14 12:33:02 -0700153namespace {
154/* ------------------------------------------------------------------------
155 * Test cases
156 */
Ady Abraham2139f732019-11-13 18:56:40 -0800157TEST_F(RefreshRateConfigsTest, oneDeviceConfig_SwitchingSupported) {
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700158 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700159 std::make_unique<RefreshRateConfigs>(m60OnlyConfigDevice,
160 /*currentConfigId=*/HWC_CONFIG_ID_60);
Alec Mouri0a1cc962019-03-14 12:33:02 -0700161}
162
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100163TEST_F(RefreshRateConfigsTest, invalidPolicy) {
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100164 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700165 std::make_unique<RefreshRateConfigs>(m60OnlyConfigDevice,
166 /*currentConfigId=*/HWC_CONFIG_ID_60);
Steven Thomasd4071902020-03-24 16:02:53 -0700167 ASSERT_LT(refreshRateConfigs->setDisplayManagerPolicy({HwcConfigIndexType(10), 60, 60}), 0);
168 ASSERT_LT(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, 20, 40}), 0);
Ana Kruleced3a8cc2019-11-14 00:55:07 +0100169}
170
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700171TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_storesFullRefreshRateMap) {
Steven Thomas2bbaabe2019-08-28 16:08:35 -0700172 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700173 std::make_unique<RefreshRateConfigs>(m60_90Device,
174 /*currentConfigId=*/HWC_CONFIG_ID_60);
Alec Mouri0a1cc962019-03-14 12:33:02 -0700175
Ady Abraham2e1dd892020-03-05 13:48:36 -0800176 const auto& minRate = refreshRateConfigs->getMinRefreshRate();
177 const auto& performanceRate = refreshRateConfigs->getMaxRefreshRate();
Alec Mouri0a1cc962019-03-14 12:33:02 -0700178
Ady Abrahamabc27602020-04-08 17:20:29 -0700179 ASSERT_EQ(mExpected60Config, minRate);
180 ASSERT_EQ(mExpected90Config, performanceRate);
Ady Abraham2139f732019-11-13 18:56:40 -0800181
Ady Abraham2e1dd892020-03-05 13:48:36 -0800182 const auto& minRateByPolicy = refreshRateConfigs->getMinRefreshRateByPolicy();
183 const auto& performanceRateByPolicy = refreshRateConfigs->getMaxRefreshRateByPolicy();
Ady Abraham2139f732019-11-13 18:56:40 -0800184 ASSERT_EQ(minRateByPolicy, minRate);
185 ASSERT_EQ(performanceRateByPolicy, performanceRate);
Alec Mouri0a1cc962019-03-14 12:33:02 -0700186}
Ady Abraham2139f732019-11-13 18:56:40 -0800187
188TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_storesFullRefreshRateMap_differentGroups) {
Ady Abraham2139f732019-11-13 18:56:40 -0800189 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700190 std::make_unique<RefreshRateConfigs>(m60_90DeviceWithDifferentGroups,
191 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham2139f732019-11-13 18:56:40 -0800192
Ady Abraham2e1dd892020-03-05 13:48:36 -0800193 const auto& minRate = refreshRateConfigs->getMinRefreshRateByPolicy();
194 const auto& performanceRate = refreshRateConfigs->getMaxRefreshRate();
195 const auto& minRate60 = refreshRateConfigs->getMinRefreshRateByPolicy();
196 const auto& performanceRate60 = refreshRateConfigs->getMaxRefreshRateByPolicy();
Ady Abraham2139f732019-11-13 18:56:40 -0800197
Ady Abrahamabc27602020-04-08 17:20:29 -0700198 ASSERT_EQ(mExpected60Config, minRate);
199 ASSERT_EQ(mExpected60Config, minRate60);
200 ASSERT_EQ(mExpected60Config, performanceRate60);
Ady Abraham2139f732019-11-13 18:56:40 -0800201
Steven Thomasd4071902020-03-24 16:02:53 -0700202 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, 60, 90}), 0);
Ady Abraham2139f732019-11-13 18:56:40 -0800203 refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90);
204
Ady Abraham2e1dd892020-03-05 13:48:36 -0800205 const auto& minRate90 = refreshRateConfigs->getMinRefreshRateByPolicy();
206 const auto& performanceRate90 = refreshRateConfigs->getMaxRefreshRateByPolicy();
Ady Abraham2139f732019-11-13 18:56:40 -0800207
Ady Abrahamabc27602020-04-08 17:20:29 -0700208 ASSERT_EQ(mExpected90DifferentGroupConfig, performanceRate);
209 ASSERT_EQ(mExpected90DifferentGroupConfig, minRate90);
210 ASSERT_EQ(mExpected90DifferentGroupConfig, performanceRate90);
211}
212
213TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_storesFullRefreshRateMap_differentResolutions) {
214 auto refreshRateConfigs =
215 std::make_unique<RefreshRateConfigs>(m60_90DeviceWithDifferentResolutions,
216 /*currentConfigId=*/HWC_CONFIG_ID_60);
217
218 const auto& minRate = refreshRateConfigs->getMinRefreshRateByPolicy();
219 const auto& performanceRate = refreshRateConfigs->getMaxRefreshRate();
220 const auto& minRate60 = refreshRateConfigs->getMinRefreshRateByPolicy();
221 const auto& performanceRate60 = refreshRateConfigs->getMaxRefreshRateByPolicy();
222
223 ASSERT_EQ(mExpected60Config, minRate);
224 ASSERT_EQ(mExpected60Config, minRate60);
225 ASSERT_EQ(mExpected60Config, performanceRate60);
226
227 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, 60, 90}), 0);
228 refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90);
229
230 const auto& minRate90 = refreshRateConfigs->getMinRefreshRateByPolicy();
231 const auto& performanceRate90 = refreshRateConfigs->getMaxRefreshRateByPolicy();
232
233 ASSERT_EQ(mExpected90DifferentResolutionConfig, performanceRate);
234 ASSERT_EQ(mExpected90DifferentResolutionConfig, minRate90);
235 ASSERT_EQ(mExpected90DifferentResolutionConfig, performanceRate90);
Ady Abraham2139f732019-11-13 18:56:40 -0800236}
237
238TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_policyChange) {
Ady Abraham2139f732019-11-13 18:56:40 -0800239 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700240 std::make_unique<RefreshRateConfigs>(m60_90Device,
241 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ana Krulec3f6a2062020-01-23 15:48:01 -0800242
Ady Abraham2e1dd892020-03-05 13:48:36 -0800243 auto& minRate = refreshRateConfigs->getMinRefreshRateByPolicy();
244 auto& performanceRate = refreshRateConfigs->getMaxRefreshRateByPolicy();
Ady Abraham2139f732019-11-13 18:56:40 -0800245
Ady Abrahamabc27602020-04-08 17:20:29 -0700246 ASSERT_EQ(mExpected60Config, minRate);
247 ASSERT_EQ(mExpected90Config, performanceRate);
Ady Abraham2139f732019-11-13 18:56:40 -0800248
Steven Thomasd4071902020-03-24 16:02:53 -0700249 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, 60, 60}), 0);
Ady Abraham2139f732019-11-13 18:56:40 -0800250
Ady Abraham2e1dd892020-03-05 13:48:36 -0800251 auto& minRate60 = refreshRateConfigs->getMinRefreshRateByPolicy();
252 auto& performanceRate60 = refreshRateConfigs->getMaxRefreshRateByPolicy();
Ady Abrahamabc27602020-04-08 17:20:29 -0700253 ASSERT_EQ(mExpected60Config, minRate60);
254 ASSERT_EQ(mExpected60Config, performanceRate60);
Ady Abraham2139f732019-11-13 18:56:40 -0800255}
256
257TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_getCurrentRefreshRate) {
Ady Abraham2139f732019-11-13 18:56:40 -0800258 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700259 std::make_unique<RefreshRateConfigs>(m60_90Device,
260 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham2139f732019-11-13 18:56:40 -0800261 {
Ady Abraham2e1dd892020-03-05 13:48:36 -0800262 auto& current = refreshRateConfigs->getCurrentRefreshRate();
Ady Abrahamabc27602020-04-08 17:20:29 -0700263 EXPECT_EQ(current.getConfigId(), HWC_CONFIG_ID_60);
Ady Abraham2139f732019-11-13 18:56:40 -0800264 }
265
266 refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90);
267 {
Ady Abraham2e1dd892020-03-05 13:48:36 -0800268 auto& current = refreshRateConfigs->getCurrentRefreshRate();
Ady Abrahamabc27602020-04-08 17:20:29 -0700269 EXPECT_EQ(current.getConfigId(), HWC_CONFIG_ID_90);
Ady Abraham2139f732019-11-13 18:56:40 -0800270 }
271
Steven Thomasd4071902020-03-24 16:02:53 -0700272 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, 90, 90}), 0);
Ady Abraham2139f732019-11-13 18:56:40 -0800273 {
Ady Abraham2e1dd892020-03-05 13:48:36 -0800274 auto& current = refreshRateConfigs->getCurrentRefreshRate();
Ady Abrahamabc27602020-04-08 17:20:29 -0700275 EXPECT_EQ(current.getConfigId(), HWC_CONFIG_ID_90);
Ady Abraham2139f732019-11-13 18:56:40 -0800276 }
277}
278
279TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_getRefreshRateForContent) {
Ady Abraham2139f732019-11-13 18:56:40 -0800280 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700281 std::make_unique<RefreshRateConfigs>(m60_90Device,
282 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham2139f732019-11-13 18:56:40 -0800283
Ady Abraham8a82ba62020-01-17 12:43:17 -0800284 const auto makeLayerRequirements = [](float refreshRate) -> std::vector<LayerRequirement> {
285 return {{"testLayer", LayerVoteType::Heuristic, refreshRate, 1.0f}};
286 };
287
Ady Abrahamabc27602020-04-08 17:20:29 -0700288 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800289 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(90.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700290 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800291 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(60.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700292 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800293 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(45.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700294 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800295 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(30.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700296 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800297 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(24.0f)));
Ady Abraham2139f732019-11-13 18:56:40 -0800298
Steven Thomasd4071902020-03-24 16:02:53 -0700299 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, 60, 60}), 0);
Ady Abrahamabc27602020-04-08 17:20:29 -0700300 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800301 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(90.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700302 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800303 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(60.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700304 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800305 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(45.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700306 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800307 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(30.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700308 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800309 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(24.0f)));
Ady Abraham2139f732019-11-13 18:56:40 -0800310
Steven Thomasd4071902020-03-24 16:02:53 -0700311 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, 90, 90}), 0);
Ady Abrahamabc27602020-04-08 17:20:29 -0700312 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800313 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(90.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700314 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800315 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(60.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700316 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800317 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(45.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700318 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800319 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(30.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700320 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800321 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(24.0f)));
Steven Thomasd4071902020-03-24 16:02:53 -0700322 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, 0, 120}), 0);
Ady Abrahamabc27602020-04-08 17:20:29 -0700323 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800324 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(90.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700325 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800326 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(60.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700327 EXPECT_EQ(mExpected90Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800328 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(45.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700329 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800330 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(30.0f)));
Ady Abrahamabc27602020-04-08 17:20:29 -0700331 EXPECT_EQ(mExpected60Config,
Ady Abraham8a82ba62020-01-17 12:43:17 -0800332 refreshRateConfigs->getRefreshRateForContent(makeLayerRequirements(24.0f)));
333}
334
Ana Krulec3d367c82020-02-25 15:02:01 -0800335TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_noLayers) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800336 bool ignored;
Ady Abrahamabc27602020-04-08 17:20:29 -0700337 auto refreshRateConfigs =
338 std::make_unique<RefreshRateConfigs>(m60_72_90Device, /*currentConfigId=*/
339 HWC_CONFIG_ID_72);
Ana Krulec3d367c82020-02-25 15:02:01 -0800340
341 // If there are not layers, there is not content detection, so return the current
342 // refresh rate.
343 auto layers = std::vector<LayerRequirement>{};
Ady Abrahamabc27602020-04-08 17:20:29 -0700344 EXPECT_EQ(mExpected72Config,
Ana Krulec3d367c82020-02-25 15:02:01 -0800345 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/
Ady Abraham6fb599b2020-03-05 13:48:22 -0800346 false, &ignored));
Ana Krulec3d367c82020-02-25 15:02:01 -0800347
348 // Current refresh rate can always be changed.
349 refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_60);
Ady Abrahamabc27602020-04-08 17:20:29 -0700350 EXPECT_EQ(mExpected60Config,
Ana Krulec3d367c82020-02-25 15:02:01 -0800351 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/
Ady Abraham6fb599b2020-03-05 13:48:22 -0800352 false, &ignored));
Ana Krulec3d367c82020-02-25 15:02:01 -0800353}
354
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800355TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_60_90) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800356 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800357 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700358 std::make_unique<RefreshRateConfigs>(m60_90Device,
359 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800360
361 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
362 auto& lr = layers[0];
363
364 lr.vote = LayerVoteType::Min;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800365 lr.name = "Min";
Ady Abrahamabc27602020-04-08 17:20:29 -0700366 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800367 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
368 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800369
370 lr.vote = LayerVoteType::Max;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800371 lr.name = "Max";
Ady Abrahamabc27602020-04-08 17:20:29 -0700372 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800373 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
374 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800375
376 lr.desiredRefreshRate = 90.0f;
377 lr.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800378 lr.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700379 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800380 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
381 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800382
383 lr.desiredRefreshRate = 60.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800384 lr.name = "60Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700385 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800386 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
387 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800388
389 lr.desiredRefreshRate = 45.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800390 lr.name = "45Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700391 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800392 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
393 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800394
395 lr.desiredRefreshRate = 30.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800396 lr.name = "30Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700397 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800398 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
399 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800400
401 lr.desiredRefreshRate = 24.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800402 lr.name = "24Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700403 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800404 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
405 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800406
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800407 lr.name = "";
Steven Thomasd4071902020-03-24 16:02:53 -0700408 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, 60, 60}), 0);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800409
410 lr.vote = LayerVoteType::Min;
Ady Abrahamabc27602020-04-08 17:20:29 -0700411 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800412 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
413 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800414
415 lr.vote = LayerVoteType::Max;
Ady Abrahamabc27602020-04-08 17:20:29 -0700416 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800417 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
418 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800419
420 lr.desiredRefreshRate = 90.0f;
421 lr.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700422 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800423 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
424 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800425
426 lr.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700427 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800428 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
429 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800430
431 lr.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700432 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800433 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
434 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800435
436 lr.desiredRefreshRate = 30.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700437 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800438 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
439 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800440
441 lr.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700442 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800443 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
444 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800445
Steven Thomasd4071902020-03-24 16:02:53 -0700446 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, 90, 90}), 0);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800447
448 lr.vote = LayerVoteType::Min;
Ady Abrahamabc27602020-04-08 17:20:29 -0700449 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800450 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
451 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800452
453 lr.vote = LayerVoteType::Max;
Ady Abrahamabc27602020-04-08 17:20:29 -0700454 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800455 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
456 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800457
458 lr.desiredRefreshRate = 90.0f;
459 lr.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700460 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800461 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
462 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800463
464 lr.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700465 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800466 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
467 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800468
469 lr.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700470 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800471 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
472 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800473
474 lr.desiredRefreshRate = 30.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700475 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800476 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
477 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800478
479 lr.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700480 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800481 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
482 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800483
Steven Thomasd4071902020-03-24 16:02:53 -0700484 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, 0, 120}), 0);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800485 lr.vote = LayerVoteType::Min;
Ady Abrahamabc27602020-04-08 17:20:29 -0700486 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800487 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
488 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800489
490 lr.vote = LayerVoteType::Max;
Ady Abrahamabc27602020-04-08 17:20:29 -0700491 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800492 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
493 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800494
495 lr.desiredRefreshRate = 90.0f;
496 lr.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700497 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800498 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
499 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800500
501 lr.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700502 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800503 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
504 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800505
506 lr.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700507 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800508 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
509 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800510
511 lr.desiredRefreshRate = 30.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700512 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800513 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
514 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800515
516 lr.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700517 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800518 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
519 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800520}
521
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800522TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_60_72_90) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800523 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800524 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700525 std::make_unique<RefreshRateConfigs>(m60_72_90Device,
526 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800527
528 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
529 auto& lr = layers[0];
530
531 lr.vote = LayerVoteType::Min;
Ady Abrahamabc27602020-04-08 17:20:29 -0700532 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800533 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
534 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800535
536 lr.vote = LayerVoteType::Max;
Ady Abrahamabc27602020-04-08 17:20:29 -0700537 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800538 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
539 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800540
541 lr.desiredRefreshRate = 90.0f;
542 lr.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700543 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800544 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
545 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800546
547 lr.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700548 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800549 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
550 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800551
552 lr.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700553 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800554 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
555 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800556
557 lr.desiredRefreshRate = 30.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700558 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800559 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
560 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800561
562 lr.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700563 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800564 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
565 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800566}
567
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800568TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_30_60_72_90_120) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800569 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800570 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700571 std::make_unique<RefreshRateConfigs>(m30_60_72_90_120Device,
572 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800573
574 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
575 LayerRequirement{.weight = 1.0f}};
576 auto& lr1 = layers[0];
577 auto& lr2 = layers[1];
578
579 lr1.desiredRefreshRate = 24.0f;
580 lr1.vote = LayerVoteType::Heuristic;
581 lr2.desiredRefreshRate = 60.0f;
582 lr2.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700583 EXPECT_EQ(mExpected120Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800584 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
585 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800586
587 lr1.desiredRefreshRate = 24.0f;
588 lr1.vote = LayerVoteType::Heuristic;
589 lr2.desiredRefreshRate = 48.0f;
590 lr2.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700591 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800592 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
593 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800594
595 lr1.desiredRefreshRate = 24.0f;
596 lr1.vote = LayerVoteType::Heuristic;
597 lr2.desiredRefreshRate = 48.0f;
598 lr2.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700599 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800600 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
601 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800602}
603
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800604TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_30_60_90_120_DifferentTypes) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800605 bool ignored;
Ady Abraham71c437d2020-01-31 15:56:57 -0800606 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700607 std::make_unique<RefreshRateConfigs>(m30_60_72_90_120Device,
608 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham71c437d2020-01-31 15:56:57 -0800609
610 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
611 LayerRequirement{.weight = 1.0f}};
612 auto& lr1 = layers[0];
613 auto& lr2 = layers[1];
614
615 lr1.desiredRefreshRate = 24.0f;
616 lr1.vote = LayerVoteType::ExplicitDefault;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800617 lr1.name = "24Hz ExplicitDefault";
Ady Abraham71c437d2020-01-31 15:56:57 -0800618 lr2.desiredRefreshRate = 60.0f;
619 lr2.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800620 lr2.name = "60Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700621 EXPECT_EQ(mExpected120Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800622 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
623 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800624
625 lr1.desiredRefreshRate = 24.0f;
626 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800627 lr1.name = "24Hz ExplicitExactOrMultiple";
Ady Abraham71c437d2020-01-31 15:56:57 -0800628 lr2.desiredRefreshRate = 60.0f;
629 lr2.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800630 lr2.name = "60Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700631 EXPECT_EQ(mExpected120Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800632 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
633 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800634
635 lr1.desiredRefreshRate = 24.0f;
636 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800637 lr1.name = "24Hz ExplicitExactOrMultiple";
Ady Abraham71c437d2020-01-31 15:56:57 -0800638 lr2.desiredRefreshRate = 60.0f;
639 lr2.vote = LayerVoteType::ExplicitDefault;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800640 lr2.name = "60Hz ExplicitDefault";
Ady Abrahamabc27602020-04-08 17:20:29 -0700641 EXPECT_EQ(mExpected120Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800642 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
643 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800644
645 lr1.desiredRefreshRate = 24.0f;
646 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800647 lr1.name = "24Hz ExplicitExactOrMultiple";
Ady Abraham71c437d2020-01-31 15:56:57 -0800648 lr2.desiredRefreshRate = 90.0f;
649 lr2.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800650 lr2.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700651 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800652 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
653 &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800654
655 lr1.desiredRefreshRate = 24.0f;
656 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
657 lr1.name = "24Hz ExplicitExactOrMultiple";
658 lr2.desiredRefreshRate = 90.0f;
659 lr2.vote = LayerVoteType::ExplicitDefault;
660 lr2.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700661 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800662 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
663 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800664
665 lr1.desiredRefreshRate = 24.0f;
666 lr1.vote = LayerVoteType::ExplicitDefault;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800667 lr1.name = "24Hz ExplicitDefault";
Ady Abraham71c437d2020-01-31 15:56:57 -0800668 lr2.desiredRefreshRate = 90.0f;
669 lr2.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800670 lr2.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700671 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800672 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
673 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800674
675 lr1.desiredRefreshRate = 24.0f;
676 lr1.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800677 lr1.name = "24Hz Heuristic";
Ady Abraham71c437d2020-01-31 15:56:57 -0800678 lr2.desiredRefreshRate = 90.0f;
679 lr2.vote = LayerVoteType::ExplicitDefault;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800680 lr2.name = "90Hz ExplicitDefault";
Ady Abrahamabc27602020-04-08 17:20:29 -0700681 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800682 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
683 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800684
685 lr1.desiredRefreshRate = 24.0f;
686 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800687 lr1.name = "24Hz ExplicitExactOrMultiple";
Ady Abraham71c437d2020-01-31 15:56:57 -0800688 lr2.desiredRefreshRate = 90.0f;
689 lr2.vote = LayerVoteType::ExplicitDefault;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800690 lr2.name = "90Hz ExplicitDefault";
Ady Abrahamabc27602020-04-08 17:20:29 -0700691 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800692 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
693 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800694
695 lr1.desiredRefreshRate = 24.0f;
696 lr1.vote = LayerVoteType::ExplicitDefault;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800697 lr1.name = "24Hz ExplicitDefault";
Ady Abraham71c437d2020-01-31 15:56:57 -0800698 lr2.desiredRefreshRate = 90.0f;
699 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800700 lr2.name = "90Hz ExplicitExactOrMultiple";
Ady Abrahamabc27602020-04-08 17:20:29 -0700701 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800702 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
703 &ignored));
Ady Abraham71c437d2020-01-31 15:56:57 -0800704}
705
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800706TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_30_60) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800707 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800708 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700709 std::make_unique<RefreshRateConfigs>(m30_60Device,
710 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800711
712 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
713 auto& lr = layers[0];
714
715 lr.vote = LayerVoteType::Min;
Ady Abrahamabc27602020-04-08 17:20:29 -0700716 EXPECT_EQ(mExpected30Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800717 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
718 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800719
720 lr.vote = LayerVoteType::Max;
Ady Abrahamabc27602020-04-08 17:20:29 -0700721 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800722 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
723 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800724
725 lr.desiredRefreshRate = 90.0f;
726 lr.vote = LayerVoteType::Heuristic;
Ady Abrahamabc27602020-04-08 17:20:29 -0700727 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800728 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
729 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800730
731 lr.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700732 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800733 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
734 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800735
736 lr.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700737 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800738 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
739 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800740
741 lr.desiredRefreshRate = 30.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700742 EXPECT_EQ(mExpected30Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800743 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
744 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800745
746 lr.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700747 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800748 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
749 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800750}
751
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800752TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_30_60_72_90) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800753 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800754 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700755 std::make_unique<RefreshRateConfigs>(m30_60_72_90Device,
756 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800757
758 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
759 auto& lr = layers[0];
760
761 lr.vote = LayerVoteType::Min;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800762 lr.name = "Min";
Ady Abrahamabc27602020-04-08 17:20:29 -0700763 EXPECT_EQ(mExpected30Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800764 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
765 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800766
767 lr.vote = LayerVoteType::Max;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800768 lr.name = "Max";
Ady Abrahamabc27602020-04-08 17:20:29 -0700769 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800770 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
771 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800772
773 lr.desiredRefreshRate = 90.0f;
774 lr.vote = LayerVoteType::Heuristic;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800775 lr.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700776 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800777 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
778 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800779
780 lr.desiredRefreshRate = 60.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800781 lr.name = "60Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700782 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800783 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
784 &ignored));
Ady Abrahamabc27602020-04-08 17:20:29 -0700785 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800786 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ true,
787 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800788
789 lr.desiredRefreshRate = 45.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800790 lr.name = "45Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700791 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800792 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
793 &ignored));
Ady Abrahamabc27602020-04-08 17:20:29 -0700794 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800795 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ true,
796 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800797
798 lr.desiredRefreshRate = 30.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800799 lr.name = "30Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700800 EXPECT_EQ(mExpected30Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800801 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
802 &ignored));
Ady Abrahamabc27602020-04-08 17:20:29 -0700803 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800804 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ true,
805 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800806
807 lr.desiredRefreshRate = 24.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800808 lr.name = "24Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -0700809 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800810 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
811 &ignored));
Ady Abrahamabc27602020-04-08 17:20:29 -0700812 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800813 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ true,
814 &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800815
816 lr.desiredRefreshRate = 24.0f;
817 lr.vote = LayerVoteType::ExplicitExactOrMultiple;
818 lr.name = "24Hz ExplicitExactOrMultiple";
Ady Abrahamabc27602020-04-08 17:20:29 -0700819 EXPECT_EQ(mExpected72Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800820 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
821 &ignored));
Ady Abrahamabc27602020-04-08 17:20:29 -0700822 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800823 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ true,
824 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800825}
826
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800827TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_PriorityTest) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800828 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800829 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700830 std::make_unique<RefreshRateConfigs>(m30_60_90Device,
831 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800832
833 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
834 LayerRequirement{.weight = 1.0f}};
835 auto& lr1 = layers[0];
836 auto& lr2 = layers[1];
837
838 lr1.vote = LayerVoteType::Min;
839 lr2.vote = LayerVoteType::Max;
Ady Abrahamabc27602020-04-08 17:20:29 -0700840 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800841 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
842 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800843
844 lr1.vote = LayerVoteType::Min;
845 lr2.vote = LayerVoteType::Heuristic;
846 lr2.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700847 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800848 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
849 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800850
851 lr1.vote = LayerVoteType::Min;
Ady Abraham71c437d2020-01-31 15:56:57 -0800852 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800853 lr2.desiredRefreshRate = 24.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700854 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800855 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
856 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800857
858 lr1.vote = LayerVoteType::Max;
859 lr2.vote = LayerVoteType::Heuristic;
860 lr2.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700861 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800862 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
863 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800864
865 lr1.vote = LayerVoteType::Max;
Ady Abraham71c437d2020-01-31 15:56:57 -0800866 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800867 lr2.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700868 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800869 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
870 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800871
872 lr1.vote = LayerVoteType::Heuristic;
873 lr1.desiredRefreshRate = 15.0f;
874 lr2.vote = LayerVoteType::Heuristic;
875 lr2.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700876 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800877 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
878 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800879
880 lr1.vote = LayerVoteType::Heuristic;
881 lr1.desiredRefreshRate = 30.0f;
Ady Abraham71c437d2020-01-31 15:56:57 -0800882 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800883 lr2.desiredRefreshRate = 45.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700884 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800885 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
886 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800887}
888
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800889TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_24FpsVideo) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800890 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800891 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700892 std::make_unique<RefreshRateConfigs>(m60_90Device,
893 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800894
895 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
896 auto& lr = layers[0];
897
Ady Abraham71c437d2020-01-31 15:56:57 -0800898 lr.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800899 for (float fps = 23.0f; fps < 25.0f; fps += 0.1f) {
900 lr.desiredRefreshRate = fps;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800901 const auto& refreshRate =
Ady Abraham6fb599b2020-03-05 13:48:22 -0800902 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
903 &ignored);
Ady Abrahamabc27602020-04-08 17:20:29 -0700904 printf("%.2fHz chooses %s\n", fps, refreshRate.getName().c_str());
905 EXPECT_EQ(mExpected60Config, refreshRate);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800906 }
907}
908
909TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_getRefreshRateForContent_Explicit) {
Ady Abraham8a82ba62020-01-17 12:43:17 -0800910 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700911 std::make_unique<RefreshRateConfigs>(m60_90Device,
912 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800913
914 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
915 LayerRequirement{.weight = 1.0f}};
916 auto& lr1 = layers[0];
917 auto& lr2 = layers[1];
918
919 lr1.vote = LayerVoteType::Heuristic;
920 lr1.desiredRefreshRate = 60.0f;
Ady Abraham71c437d2020-01-31 15:56:57 -0800921 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800922 lr2.desiredRefreshRate = 90.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700923 EXPECT_EQ(mExpected90Config, refreshRateConfigs->getRefreshRateForContent(layers));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800924
925 lr1.vote = LayerVoteType::Heuristic;
926 lr1.desiredRefreshRate = 90.0f;
Ady Abraham71c437d2020-01-31 15:56:57 -0800927 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800928 lr2.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700929 EXPECT_EQ(mExpected60Config, refreshRateConfigs->getRefreshRateForContent(layers));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800930}
931
932TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_getRefreshRateForContentV2_Explicit) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800933 bool ignored;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800934 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700935 std::make_unique<RefreshRateConfigs>(m60_90Device,
936 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham8a82ba62020-01-17 12:43:17 -0800937
938 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
939 LayerRequirement{.weight = 1.0f}};
940 auto& lr1 = layers[0];
941 auto& lr2 = layers[1];
942
943 lr1.vote = LayerVoteType::Heuristic;
944 lr1.desiredRefreshRate = 60.0f;
Ady Abraham71c437d2020-01-31 15:56:57 -0800945 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800946 lr2.desiredRefreshRate = 90.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700947 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800948 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
949 &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800950
951 lr1.vote = LayerVoteType::ExplicitDefault;
952 lr1.desiredRefreshRate = 90.0f;
953 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
954 lr2.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700955 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800956 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
957 &ignored));
Ady Abraham8a82ba62020-01-17 12:43:17 -0800958
959 lr1.vote = LayerVoteType::Heuristic;
960 lr1.desiredRefreshRate = 90.0f;
Ady Abraham71c437d2020-01-31 15:56:57 -0800961 lr2.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abraham8a82ba62020-01-17 12:43:17 -0800962 lr2.desiredRefreshRate = 60.0f;
Ady Abrahamabc27602020-04-08 17:20:29 -0700963 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -0800964 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
965 &ignored));
Ady Abraham2139f732019-11-13 18:56:40 -0800966}
967
Ana Krulec72f0d6e2020-01-06 15:24:47 -0800968TEST_F(RefreshRateConfigsTest, testInPolicy) {
Ady Abrahamabc27602020-04-08 17:20:29 -0700969 ASSERT_TRUE(mExpectedAlmost60Config.inPolicy(60.000004f, 60.000004f));
970 ASSERT_TRUE(mExpectedAlmost60Config.inPolicy(59.0f, 60.1f));
971 ASSERT_FALSE(mExpectedAlmost60Config.inPolicy(75.0f, 90.0f));
972 ASSERT_FALSE(mExpectedAlmost60Config.inPolicy(60.0011f, 90.0f));
973 ASSERT_FALSE(mExpectedAlmost60Config.inPolicy(50.0f, 59.998f));
Ana Krulec72f0d6e2020-01-06 15:24:47 -0800974}
975
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800976TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_75HzContent) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800977 bool ignored;
Ady Abrahamf6b77072020-01-30 14:22:54 -0800978 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700979 std::make_unique<RefreshRateConfigs>(m60_90Device,
980 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abrahamf6b77072020-01-30 14:22:54 -0800981
982 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
983 auto& lr = layers[0];
984
Ady Abraham71c437d2020-01-31 15:56:57 -0800985 lr.vote = LayerVoteType::ExplicitExactOrMultiple;
Ady Abrahamf6b77072020-01-30 14:22:54 -0800986 for (float fps = 75.0f; fps < 100.0f; fps += 0.1f) {
987 lr.desiredRefreshRate = fps;
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800988 const auto& refreshRate =
Ady Abraham6fb599b2020-03-05 13:48:22 -0800989 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
990 &ignored);
Ady Abrahamabc27602020-04-08 17:20:29 -0700991 printf("%.2fHz chooses %s\n", fps, refreshRate.getName().c_str());
992 EXPECT_EQ(mExpected90Config, refreshRate);
Ady Abrahamf6b77072020-01-30 14:22:54 -0800993 }
994}
995
Ady Abraham4ccdcb42020-02-11 17:34:34 -0800996TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_Multiples) {
Ady Abraham6fb599b2020-03-05 13:48:22 -0800997 bool ignored;
Ady Abraham34702102020-02-10 14:12:05 -0800998 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -0700999 std::make_unique<RefreshRateConfigs>(m60_90Device,
1000 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham34702102020-02-10 14:12:05 -08001001
1002 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
1003 LayerRequirement{.weight = 1.0f}};
1004 auto& lr1 = layers[0];
1005 auto& lr2 = layers[1];
1006
1007 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1008 lr1.desiredRefreshRate = 60.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001009 lr1.name = "60Hz ExplicitExactOrMultiple";
Ady Abraham34702102020-02-10 14:12:05 -08001010 lr2.vote = LayerVoteType::Heuristic;
1011 lr2.desiredRefreshRate = 90.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001012 lr2.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -07001013 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001014 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
1015 &ignored));
Ady Abraham34702102020-02-10 14:12:05 -08001016
1017 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1018 lr1.desiredRefreshRate = 60.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001019 lr1.name = "60Hz ExplicitExactOrMultiple";
1020 lr2.vote = LayerVoteType::ExplicitDefault;
1021 lr2.desiredRefreshRate = 90.0f;
1022 lr2.name = "90Hz ExplicitDefault";
Ady Abrahamabc27602020-04-08 17:20:29 -07001023 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001024 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
1025 &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001026
1027 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1028 lr1.desiredRefreshRate = 60.0f;
1029 lr1.name = "60Hz ExplicitExactOrMultiple";
Ady Abraham34702102020-02-10 14:12:05 -08001030 lr2.vote = LayerVoteType::Max;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001031 lr2.name = "Max";
Ady Abrahamabc27602020-04-08 17:20:29 -07001032 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001033 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
1034 &ignored));
Ady Abraham34702102020-02-10 14:12:05 -08001035
1036 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1037 lr1.desiredRefreshRate = 30.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001038 lr1.name = "30Hz ExplicitExactOrMultiple";
Ady Abraham34702102020-02-10 14:12:05 -08001039 lr2.vote = LayerVoteType::Heuristic;
1040 lr2.desiredRefreshRate = 90.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001041 lr2.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -07001042 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001043 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
1044 &ignored));
Ady Abraham34702102020-02-10 14:12:05 -08001045
1046 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1047 lr1.desiredRefreshRate = 30.0f;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001048 lr1.name = "30Hz ExplicitExactOrMultiple";
Ady Abraham34702102020-02-10 14:12:05 -08001049 lr2.vote = LayerVoteType::Max;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001050 lr2.name = "Max";
Ady Abrahamabc27602020-04-08 17:20:29 -07001051 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001052 refreshRateConfigs->getRefreshRateForContentV2(layers, /*touchActive*/ false,
1053 &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001054}
1055
1056TEST_F(RefreshRateConfigsTest, scrollWhileWatching60fps_60_90) {
Ady Abraham6fb599b2020-03-05 13:48:22 -08001057 bool ignored;
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001058 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -07001059 std::make_unique<RefreshRateConfigs>(m60_90Device,
1060 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001061
1062 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
1063 LayerRequirement{.weight = 1.0f}};
1064 auto& lr1 = layers[0];
1065 auto& lr2 = layers[1];
1066
1067 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1068 lr1.desiredRefreshRate = 60.0f;
1069 lr1.name = "60Hz ExplicitExactOrMultiple";
1070 lr2.vote = LayerVoteType::NoVote;
1071 lr2.name = "NoVote";
Ady Abrahamabc27602020-04-08 17:20:29 -07001072 EXPECT_EQ(mExpected60Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001073 refreshRateConfigs->getRefreshRateForContentV2(layers, false, &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001074
1075 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1076 lr1.desiredRefreshRate = 60.0f;
1077 lr1.name = "60Hz ExplicitExactOrMultiple";
1078 lr2.vote = LayerVoteType::NoVote;
1079 lr2.name = "NoVote";
Ady Abrahamabc27602020-04-08 17:20:29 -07001080 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001081 refreshRateConfigs->getRefreshRateForContentV2(layers, true, &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001082
1083 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1084 lr1.desiredRefreshRate = 60.0f;
1085 lr1.name = "60Hz ExplicitExactOrMultiple";
1086 lr2.vote = LayerVoteType::Max;
1087 lr2.name = "Max";
Ady Abrahamabc27602020-04-08 17:20:29 -07001088 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001089 refreshRateConfigs->getRefreshRateForContentV2(layers, true, &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001090
1091 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1092 lr1.desiredRefreshRate = 60.0f;
1093 lr1.name = "60Hz ExplicitExactOrMultiple";
1094 lr2.vote = LayerVoteType::Max;
1095 lr2.name = "Max";
Ady Abrahamabc27602020-04-08 17:20:29 -07001096 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001097 refreshRateConfigs->getRefreshRateForContentV2(layers, false, &ignored));
Ady Abraham4ccdcb42020-02-11 17:34:34 -08001098
1099 // The other layer starts to provide buffers
1100 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1101 lr1.desiredRefreshRate = 60.0f;
1102 lr1.name = "60Hz ExplicitExactOrMultiple";
1103 lr2.vote = LayerVoteType::Heuristic;
1104 lr2.desiredRefreshRate = 90.0f;
1105 lr2.name = "90Hz Heuristic";
Ady Abrahamabc27602020-04-08 17:20:29 -07001106 EXPECT_EQ(mExpected90Config,
Ady Abraham6fb599b2020-03-05 13:48:22 -08001107 refreshRateConfigs->getRefreshRateForContentV2(layers, false, &ignored));
1108}
1109
1110TEST_F(RefreshRateConfigsTest, touchConsidered) {
1111 bool touchConsidered;
Ady Abraham6fb599b2020-03-05 13:48:22 -08001112 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -07001113 std::make_unique<RefreshRateConfigs>(m60_90Device,
1114 /*currentConfigId=*/HWC_CONFIG_ID_60);
Ady Abraham6fb599b2020-03-05 13:48:22 -08001115
1116 refreshRateConfigs->getRefreshRateForContentV2({}, false, &touchConsidered);
1117 EXPECT_EQ(false, touchConsidered);
1118
1119 refreshRateConfigs->getRefreshRateForContentV2({}, true, &touchConsidered);
1120 EXPECT_EQ(true, touchConsidered);
1121
1122 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f},
1123 LayerRequirement{.weight = 1.0f}};
1124 auto& lr1 = layers[0];
1125 auto& lr2 = layers[1];
1126
1127 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1128 lr1.desiredRefreshRate = 60.0f;
1129 lr1.name = "60Hz ExplicitExactOrMultiple";
1130 lr2.vote = LayerVoteType::Heuristic;
1131 lr2.name = "NoVote";
1132 refreshRateConfigs->getRefreshRateForContentV2(layers, true, &touchConsidered);
1133 EXPECT_EQ(true, touchConsidered);
1134
1135 lr1.vote = LayerVoteType::ExplicitDefault;
1136 lr1.desiredRefreshRate = 60.0f;
1137 lr1.name = "60Hz ExplicitExactOrMultiple";
1138 lr2.vote = LayerVoteType::Heuristic;
1139 lr2.name = "NoVote";
1140 refreshRateConfigs->getRefreshRateForContentV2(layers, true, &touchConsidered);
1141 EXPECT_EQ(false, touchConsidered);
1142
1143 lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
1144 lr1.desiredRefreshRate = 60.0f;
1145 lr1.name = "60Hz ExplicitExactOrMultiple";
1146 lr2.vote = LayerVoteType::Heuristic;
1147 lr2.name = "NoVote";
1148 refreshRateConfigs->getRefreshRateForContentV2(layers, true, &touchConsidered);
1149 EXPECT_EQ(true, touchConsidered);
1150
1151 lr1.vote = LayerVoteType::ExplicitDefault;
1152 lr1.desiredRefreshRate = 60.0f;
1153 lr1.name = "60Hz ExplicitExactrMultiple";
1154 lr2.vote = LayerVoteType::Heuristic;
1155 lr2.name = "NoVote";
1156 refreshRateConfigs->getRefreshRateForContentV2(layers, true, &touchConsidered);
1157 EXPECT_EQ(false, touchConsidered);
Ady Abraham34702102020-02-10 14:12:05 -08001158}
1159
Ady Abraham5b8afb5a2020-03-06 14:57:26 -08001160TEST_F(RefreshRateConfigsTest, getRefreshRateForContentV2_ExplicitDefault) {
1161 bool ignored;
Ady Abrahamabc27602020-04-08 17:20:29 -07001162 auto refreshRateConfigs =
1163 std::make_unique<RefreshRateConfigs>(m60_90_72_120Device, /*currentConfigId=*/
1164 HWC_CONFIG_ID_60);
Ady Abraham5b8afb5a2020-03-06 14:57:26 -08001165
1166 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
1167 auto& lr = layers[0];
1168
1169 // Prepare a table with the vote and the expected refresh rate
1170 const std::vector<std::pair<float, float>> testCases = {
1171 {130, 120}, {120, 120}, {119, 120}, {110, 120},
1172
1173 {100, 90}, {90, 90}, {89, 90},
1174
1175 {80, 72}, {73, 72}, {72, 72}, {71, 72}, {70, 72},
1176
1177 {65, 60}, {60, 60}, {59, 60}, {58, 60},
1178
1179 {55, 90}, {50, 90}, {45, 90},
1180
1181 {42, 120}, {40, 120}, {39, 120},
1182
1183 {37, 72}, {36, 72}, {35, 72},
1184
1185 {30, 60},
1186 };
1187
1188 for (const auto& test : testCases) {
1189 lr.vote = LayerVoteType::ExplicitDefault;
1190 lr.desiredRefreshRate = test.first;
1191
1192 std::stringstream ss;
1193 ss << "ExplicitDefault " << test.first << " fps";
1194 lr.name = ss.str();
1195
1196 const auto& refreshRate =
1197 refreshRateConfigs->getRefreshRateForContentV2(layers, false, &ignored);
Ady Abrahamabc27602020-04-08 17:20:29 -07001198 EXPECT_FLOAT_EQ(refreshRate.getFps(), test.second)
Ady Abraham5b8afb5a2020-03-06 14:57:26 -08001199 << "Expecting " << test.first << "fps => " << test.second << "Hz";
1200 }
Alec Mouri0a1cc962019-03-14 12:33:02 -07001201}
1202
Steven Thomasd4071902020-03-24 16:02:53 -07001203TEST_F(RefreshRateConfigsTest, groupSwitching) {
Steven Thomasd4071902020-03-24 16:02:53 -07001204 auto refreshRateConfigs =
Ady Abrahamabc27602020-04-08 17:20:29 -07001205 std::make_unique<RefreshRateConfigs>(m60_90DeviceWithDifferentGroups,
1206 /*currentConfigId=*/HWC_CONFIG_ID_60);
Steven Thomasd4071902020-03-24 16:02:53 -07001207
1208 auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
1209 auto& layer = layers[0];
1210 layer.vote = LayerVoteType::ExplicitDefault;
1211 layer.desiredRefreshRate = 90.0f;
1212 layer.name = "90Hz ExplicitDefault";
1213
1214 bool touchConsidered;
1215 ASSERT_EQ(HWC_CONFIG_ID_60,
1216 refreshRateConfigs->getRefreshRateForContentV2(layers, false, &touchConsidered)
Ady Abrahamabc27602020-04-08 17:20:29 -07001217 .getConfigId());
Steven Thomasd4071902020-03-24 16:02:53 -07001218
1219 RefreshRateConfigs::Policy policy;
1220 policy.defaultConfig = refreshRateConfigs->getCurrentPolicy().defaultConfig;
1221 policy.allowGroupSwitching = true;
1222 ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy(policy), 0);
1223 ASSERT_EQ(HWC_CONFIG_ID_90,
1224 refreshRateConfigs->getRefreshRateForContentV2(layers, false, &touchConsidered)
Ady Abrahamabc27602020-04-08 17:20:29 -07001225 .getConfigId());
Steven Thomasd4071902020-03-24 16:02:53 -07001226}
1227
Alec Mouri0a1cc962019-03-14 12:33:02 -07001228} // namespace
1229} // namespace scheduler
1230} // namespace android