| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/display/manager/chromeos/display_configurator.h" | 5 #include "ui/display/manager/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 class DisplayConfiguratorTest : public testing::Test { | 200 class DisplayConfiguratorTest : public testing::Test { |
| 201 public: | 201 public: |
| 202 DisplayConfiguratorTest() | 202 DisplayConfiguratorTest() |
| 203 : small_mode_(gfx::Size(1366, 768), false, 60.0f), | 203 : small_mode_(gfx::Size(1366, 768), false, 60.0f), |
| 204 big_mode_(gfx::Size(2560, 1600), false, 60.0f), | 204 big_mode_(gfx::Size(2560, 1600), false, 60.0f), |
| 205 observer_(&configurator_), | 205 observer_(&configurator_), |
| 206 test_api_(&configurator_), | 206 test_api_(&configurator_), |
| 207 config_waiter_(&test_api_), | 207 config_waiter_(&test_api_), |
| 208 enable_content_protection_status_(0), | 208 set_content_protection_status_(false), |
| 209 enable_content_protection_call_count_(0), | 209 set_content_protection_call_count_(0), |
| 210 query_content_protection_response_success_(false), |
| 211 query_content_protection_response_link_mask_(0), |
| 212 query_content_protection_response_protection_mask_(0), |
| 210 query_content_protection_call_count_(0), | 213 query_content_protection_call_count_(0), |
| 211 display_control_result_(CALLBACK_NOT_CALLED) {} | 214 display_control_result_(CALLBACK_NOT_CALLED) {} |
| 212 ~DisplayConfiguratorTest() override {} | 215 ~DisplayConfiguratorTest() override {} |
| 213 | 216 |
| 214 void SetUp() override { | 217 void SetUp() override { |
| 215 log_.reset(new ActionLogger()); | 218 log_.reset(new ActionLogger()); |
| 216 | 219 |
| 217 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 220 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
| 218 configurator_.SetDelegateForTesting( | 221 configurator_.SetDelegateForTesting( |
| 219 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 222 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 246 .SetIsAspectPerservingScaling(true) | 249 .SetIsAspectPerservingScaling(true) |
| 247 .Build(); | 250 .Build(); |
| 248 | 251 |
| 249 UpdateOutputs(2, false); | 252 UpdateOutputs(2, false); |
| 250 } | 253 } |
| 251 | 254 |
| 252 void OnDisplayControlUpdated(bool status) { | 255 void OnDisplayControlUpdated(bool status) { |
| 253 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); | 256 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); |
| 254 } | 257 } |
| 255 | 258 |
| 256 void EnableContentProtectionCallback(bool status) { | 259 void SetContentProtectionCallback(bool status) { |
| 257 enable_content_protection_status_ = status; | 260 set_content_protection_status_ = status; |
| 258 enable_content_protection_call_count_++; | 261 set_content_protection_call_count_++; |
| 259 } | 262 } |
| 260 | 263 |
| 261 void QueryContentProtectionCallback( | 264 void QueryContentProtectionCallback(bool success, |
| 262 const DisplayConfigurator::QueryProtectionResponse& response) { | 265 uint32_t link_mask, |
| 263 query_content_protection_response_ = response; | 266 uint32_t protection_mask) { |
| 267 query_content_protection_response_success_ = success; |
| 268 query_content_protection_response_link_mask_ = link_mask; |
| 269 query_content_protection_response_protection_mask_ = protection_mask; |
| 264 query_content_protection_call_count_++; | 270 query_content_protection_call_count_++; |
| 265 } | 271 } |
| 266 | 272 |
| 267 // Predefined modes that can be used by outputs. | 273 // Predefined modes that can be used by outputs. |
| 268 const DisplayMode small_mode_; | 274 const DisplayMode small_mode_; |
| 269 const DisplayMode big_mode_; | 275 const DisplayMode big_mode_; |
| 270 | 276 |
| 271 protected: | 277 protected: |
| 272 // Configures |native_display_delegate_| to return the first |num_outputs| | 278 // Configures |native_display_delegate_| to return the first |num_outputs| |
| 273 // entries from | 279 // entries from |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 323 |
| 318 base::MessageLoop message_loop_; | 324 base::MessageLoop message_loop_; |
| 319 TestStateController state_controller_; | 325 TestStateController state_controller_; |
| 320 TestMirroringController mirroring_controller_; | 326 TestMirroringController mirroring_controller_; |
| 321 DisplayConfigurator configurator_; | 327 DisplayConfigurator configurator_; |
| 322 TestObserver observer_; | 328 TestObserver observer_; |
| 323 std::unique_ptr<ActionLogger> log_; | 329 std::unique_ptr<ActionLogger> log_; |
| 324 TestNativeDisplayDelegate* native_display_delegate_; // not owned | 330 TestNativeDisplayDelegate* native_display_delegate_; // not owned |
| 325 DisplayConfigurator::TestApi test_api_; | 331 DisplayConfigurator::TestApi test_api_; |
| 326 ConfigurationWaiter config_waiter_; | 332 ConfigurationWaiter config_waiter_; |
| 327 bool enable_content_protection_status_; | 333 bool set_content_protection_status_; |
| 328 int enable_content_protection_call_count_; | 334 int set_content_protection_call_count_; |
| 329 DisplayConfigurator::QueryProtectionResponse | 335 bool query_content_protection_response_success_; |
| 330 query_content_protection_response_; | 336 uint32_t query_content_protection_response_link_mask_; |
| 337 uint32_t query_content_protection_response_protection_mask_; |
| 331 int query_content_protection_call_count_; | 338 int query_content_protection_call_count_; |
| 332 | 339 |
| 333 std::unique_ptr<DisplaySnapshot> outputs_[3]; | 340 std::unique_ptr<DisplaySnapshot> outputs_[3]; |
| 334 | 341 |
| 335 CallbackResult display_control_result_; | 342 CallbackResult display_control_result_; |
| 336 | 343 |
| 337 private: | 344 private: |
| 338 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); | 345 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); |
| 339 }; | 346 }; |
| 340 | 347 |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 // snapshot that was passed to the observer (http://crbug.com/289159). | 1222 // snapshot that was passed to the observer (http://crbug.com/289159). |
| 1216 DisplaySnapshot* state = observer_.latest_outputs()[0]; | 1223 DisplaySnapshot* state = observer_.latest_outputs()[0]; |
| 1217 ASSERT_EQ(2UL, state->modes().size()); | 1224 ASSERT_EQ(2UL, state->modes().size()); |
| 1218 } | 1225 } |
| 1219 | 1226 |
| 1220 TEST_F(DisplayConfiguratorTest, ContentProtection) { | 1227 TEST_F(DisplayConfiguratorTest, ContentProtection) { |
| 1221 Init(false); | 1228 Init(false); |
| 1222 configurator_.ForceInitialConfigure(0); | 1229 configurator_.ForceInitialConfigure(0); |
| 1223 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1230 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1224 | 1231 |
| 1225 DisplayConfigurator::ContentProtectionClientId id = | 1232 uint64_t id = configurator_.RegisterContentProtectionClient(); |
| 1226 configurator_.RegisterContentProtectionClient(); | |
| 1227 EXPECT_NE(0u, id); | 1233 EXPECT_NE(0u, id); |
| 1228 | 1234 |
| 1229 // One output. | 1235 // One output. |
| 1230 UpdateOutputs(1, true); | 1236 UpdateOutputs(1, true); |
| 1231 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1237 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1232 configurator_.QueryContentProtectionStatus( | 1238 configurator_.QueryContentProtectionStatus( |
| 1233 id, outputs_[0]->display_id(), | 1239 id, outputs_[0]->display_id(), |
| 1234 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1240 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1235 base::Unretained(this))); | 1241 base::Unretained(this))); |
| 1236 EXPECT_EQ(1, query_content_protection_call_count_); | 1242 EXPECT_EQ(1, query_content_protection_call_count_); |
| 1237 EXPECT_TRUE(query_content_protection_response_.success); | 1243 EXPECT_TRUE(query_content_protection_response_success_); |
| 1238 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_INTERNAL), | 1244 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_INTERNAL), |
| 1239 query_content_protection_response_.link_mask); | 1245 query_content_protection_response_link_mask_); |
| 1240 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), | 1246 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), |
| 1241 query_content_protection_response_.protection_mask); | 1247 query_content_protection_response_protection_mask_); |
| 1242 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1248 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1243 | 1249 |
| 1244 // Two outputs. | 1250 // Two outputs. |
| 1245 UpdateOutputs(2, true); | 1251 UpdateOutputs(2, true); |
| 1246 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1252 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1247 configurator_.QueryContentProtectionStatus( | 1253 configurator_.QueryContentProtectionStatus( |
| 1248 id, outputs_[1]->display_id(), | 1254 id, outputs_[1]->display_id(), |
| 1249 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1255 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1250 base::Unretained(this))); | 1256 base::Unretained(this))); |
| 1251 EXPECT_EQ(2, query_content_protection_call_count_); | 1257 EXPECT_EQ(2, query_content_protection_call_count_); |
| 1252 EXPECT_TRUE(query_content_protection_response_.success); | 1258 EXPECT_TRUE(query_content_protection_response_success_); |
| 1253 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1259 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1254 query_content_protection_response_.link_mask); | 1260 query_content_protection_response_link_mask_); |
| 1255 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), | 1261 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), |
| 1256 query_content_protection_response_.protection_mask); | 1262 query_content_protection_response_protection_mask_); |
| 1257 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1263 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1258 | 1264 |
| 1259 configurator_.EnableContentProtection( | 1265 configurator_.SetContentProtection( |
| 1260 id, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1266 id, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1261 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1267 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1262 base::Unretained(this))); | 1268 base::Unretained(this))); |
| 1263 EXPECT_EQ(1, enable_content_protection_call_count_); | 1269 EXPECT_EQ(1, set_content_protection_call_count_); |
| 1264 EXPECT_TRUE(enable_content_protection_status_); | 1270 EXPECT_TRUE(set_content_protection_status_); |
| 1265 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED), | 1271 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED), |
| 1266 log_->GetActionsAndClear()); | 1272 log_->GetActionsAndClear()); |
| 1267 | 1273 |
| 1268 // Enable protection. | 1274 // Enable protection. |
| 1269 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1275 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1270 configurator_.QueryContentProtectionStatus( | 1276 configurator_.QueryContentProtectionStatus( |
| 1271 id, outputs_[1]->display_id(), | 1277 id, outputs_[1]->display_id(), |
| 1272 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1278 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1273 base::Unretained(this))); | 1279 base::Unretained(this))); |
| 1274 EXPECT_EQ(3, query_content_protection_call_count_); | 1280 EXPECT_EQ(3, query_content_protection_call_count_); |
| 1275 EXPECT_TRUE(query_content_protection_response_.success); | 1281 EXPECT_TRUE(query_content_protection_response_success_); |
| 1276 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1282 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1277 query_content_protection_response_.link_mask); | 1283 query_content_protection_response_link_mask_); |
| 1278 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_HDCP), | 1284 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_HDCP), |
| 1279 query_content_protection_response_.protection_mask); | 1285 query_content_protection_response_protection_mask_); |
| 1280 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1286 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1281 | 1287 |
| 1282 // Protections should be disabled after unregister. | 1288 // Protections should be disabled after unregister. |
| 1283 configurator_.UnregisterContentProtectionClient(id); | 1289 configurator_.UnregisterContentProtectionClient(id); |
| 1284 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED), | 1290 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED), |
| 1285 log_->GetActionsAndClear()); | 1291 log_->GetActionsAndClear()); |
| 1286 } | 1292 } |
| 1287 | 1293 |
| 1288 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { | 1294 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { |
| 1289 InitWithSingleOutput(); | 1295 InitWithSingleOutput(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 JoinActions( | 1385 JoinActions( |
| 1380 kGrab, | 1386 kGrab, |
| 1381 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) | 1387 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 1382 .c_str(), | 1388 .c_str(), |
| 1383 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1389 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1384 kForceDPMS, kUngrab, nullptr), | 1390 kForceDPMS, kUngrab, nullptr), |
| 1385 log_->GetActionsAndClear()); | 1391 log_->GetActionsAndClear()); |
| 1386 } | 1392 } |
| 1387 | 1393 |
| 1388 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) { | 1394 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) { |
| 1389 DisplayConfigurator::ContentProtectionClientId client1 = | 1395 uint64_t client1 = configurator_.RegisterContentProtectionClient(); |
| 1390 configurator_.RegisterContentProtectionClient(); | 1396 uint64_t client2 = configurator_.RegisterContentProtectionClient(); |
| 1391 DisplayConfigurator::ContentProtectionClientId client2 = | |
| 1392 configurator_.RegisterContentProtectionClient(); | |
| 1393 EXPECT_NE(client1, client2); | 1397 EXPECT_NE(client1, client2); |
| 1394 | 1398 |
| 1395 Init(false); | 1399 Init(false); |
| 1396 configurator_.ForceInitialConfigure(0); | 1400 configurator_.ForceInitialConfigure(0); |
| 1397 UpdateOutputs(2, true); | 1401 UpdateOutputs(2, true); |
| 1398 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1402 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1399 | 1403 |
| 1400 // Clients never know state enableness for methods that they didn't request. | 1404 // Clients never know state enableness for methods that they didn't request. |
| 1401 configurator_.EnableContentProtection( | 1405 configurator_.SetContentProtection( |
| 1402 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1406 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1403 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1407 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1404 base::Unretained(this))); | 1408 base::Unretained(this))); |
| 1405 EXPECT_EQ(1, enable_content_protection_call_count_); | 1409 EXPECT_EQ(1, set_content_protection_call_count_); |
| 1406 EXPECT_TRUE(enable_content_protection_status_); | 1410 EXPECT_TRUE(set_content_protection_status_); |
| 1407 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), | 1411 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), |
| 1408 log_->GetActionsAndClear()); | 1412 log_->GetActionsAndClear()); |
| 1409 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1413 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1410 | 1414 |
| 1411 configurator_.QueryContentProtectionStatus( | 1415 configurator_.QueryContentProtectionStatus( |
| 1412 client1, outputs_[1]->display_id(), | 1416 client1, outputs_[1]->display_id(), |
| 1413 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1417 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1414 base::Unretained(this))); | 1418 base::Unretained(this))); |
| 1415 EXPECT_EQ(1, query_content_protection_call_count_); | 1419 EXPECT_EQ(1, query_content_protection_call_count_); |
| 1416 EXPECT_TRUE(query_content_protection_response_.success); | 1420 EXPECT_TRUE(query_content_protection_response_success_); |
| 1417 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1421 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1418 query_content_protection_response_.link_mask); | 1422 query_content_protection_response_link_mask_); |
| 1419 EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP, | 1423 EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP, |
| 1420 query_content_protection_response_.protection_mask); | 1424 query_content_protection_response_protection_mask_); |
| 1421 | 1425 |
| 1422 configurator_.QueryContentProtectionStatus( | 1426 configurator_.QueryContentProtectionStatus( |
| 1423 client2, outputs_[1]->display_id(), | 1427 client2, outputs_[1]->display_id(), |
| 1424 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1428 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1425 base::Unretained(this))); | 1429 base::Unretained(this))); |
| 1426 EXPECT_EQ(2, query_content_protection_call_count_); | 1430 EXPECT_EQ(2, query_content_protection_call_count_); |
| 1427 EXPECT_TRUE(query_content_protection_response_.success); | 1431 EXPECT_TRUE(query_content_protection_response_success_); |
| 1428 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1432 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1429 query_content_protection_response_.link_mask); | 1433 query_content_protection_response_link_mask_); |
| 1430 EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE, | 1434 EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE, |
| 1431 query_content_protection_response_.protection_mask); | 1435 query_content_protection_response_protection_mask_); |
| 1432 | 1436 |
| 1433 // Protections will be disabled only if no more clients request them. | 1437 // Protections will be disabled only if no more clients request them. |
| 1434 configurator_.EnableContentProtection( | 1438 configurator_.SetContentProtection( |
| 1435 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, | 1439 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, |
| 1436 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1440 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1437 base::Unretained(this))); | 1441 base::Unretained(this))); |
| 1438 EXPECT_EQ(2, enable_content_protection_call_count_); | 1442 EXPECT_EQ(2, set_content_protection_call_count_); |
| 1439 EXPECT_TRUE(enable_content_protection_status_); | 1443 EXPECT_TRUE(set_content_protection_status_); |
| 1440 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1444 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1441 | 1445 |
| 1442 configurator_.EnableContentProtection( | 1446 configurator_.SetContentProtection( |
| 1443 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, | 1447 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, |
| 1444 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1448 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1445 base::Unretained(this))); | 1449 base::Unretained(this))); |
| 1446 EXPECT_EQ(3, enable_content_protection_call_count_); | 1450 EXPECT_EQ(3, set_content_protection_call_count_); |
| 1447 EXPECT_TRUE(enable_content_protection_status_); | 1451 EXPECT_TRUE(set_content_protection_status_); |
| 1448 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED).c_str(), | 1452 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED).c_str(), |
| 1449 log_->GetActionsAndClear()); | 1453 log_->GetActionsAndClear()); |
| 1450 } | 1454 } |
| 1451 | 1455 |
| 1452 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClientsEnable) { | 1456 TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClientsEnable) { |
| 1453 DisplayConfigurator::ContentProtectionClientId client1 = | 1457 uint64_t client1 = configurator_.RegisterContentProtectionClient(); |
| 1454 configurator_.RegisterContentProtectionClient(); | 1458 uint64_t client2 = configurator_.RegisterContentProtectionClient(); |
| 1455 DisplayConfigurator::ContentProtectionClientId client2 = | |
| 1456 configurator_.RegisterContentProtectionClient(); | |
| 1457 EXPECT_NE(client1, client2); | 1459 EXPECT_NE(client1, client2); |
| 1458 | 1460 |
| 1459 Init(false); | 1461 Init(false); |
| 1460 configurator_.ForceInitialConfigure(0); | 1462 configurator_.ForceInitialConfigure(0); |
| 1461 UpdateOutputs(2, true); | 1463 UpdateOutputs(2, true); |
| 1462 log_->GetActionsAndClear(); | 1464 log_->GetActionsAndClear(); |
| 1463 | 1465 |
| 1464 // Only enable once if HDCP is enabling. | 1466 // Only enable once if HDCP is enabling. |
| 1465 configurator_.EnableContentProtection( | 1467 configurator_.SetContentProtection( |
| 1466 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1468 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1467 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1469 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1468 base::Unretained(this))); | 1470 base::Unretained(this))); |
| 1469 EXPECT_EQ(1, enable_content_protection_call_count_); | 1471 EXPECT_EQ(1, set_content_protection_call_count_); |
| 1470 EXPECT_TRUE(enable_content_protection_status_); | 1472 EXPECT_TRUE(set_content_protection_status_); |
| 1471 native_display_delegate_->set_hdcp_state(HDCP_STATE_DESIRED); | 1473 native_display_delegate_->set_hdcp_state(HDCP_STATE_DESIRED); |
| 1472 configurator_.EnableContentProtection( | 1474 configurator_.SetContentProtection( |
| 1473 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1475 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1474 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1476 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1475 base::Unretained(this))); | 1477 base::Unretained(this))); |
| 1476 EXPECT_EQ(2, enable_content_protection_call_count_); | 1478 EXPECT_EQ(2, set_content_protection_call_count_); |
| 1477 EXPECT_TRUE(enable_content_protection_status_); | 1479 EXPECT_TRUE(set_content_protection_status_); |
| 1478 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), | 1480 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), |
| 1479 log_->GetActionsAndClear()); | 1481 log_->GetActionsAndClear()); |
| 1480 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1482 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1481 | 1483 |
| 1482 // Don't enable again if HDCP is already active. | 1484 // Don't enable again if HDCP is already active. |
| 1483 configurator_.EnableContentProtection( | 1485 configurator_.SetContentProtection( |
| 1484 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1486 client1, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1485 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1487 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1486 base::Unretained(this))); | 1488 base::Unretained(this))); |
| 1487 EXPECT_EQ(3, enable_content_protection_call_count_); | 1489 EXPECT_EQ(3, set_content_protection_call_count_); |
| 1488 EXPECT_TRUE(enable_content_protection_status_); | 1490 EXPECT_TRUE(set_content_protection_status_); |
| 1489 configurator_.EnableContentProtection( | 1491 configurator_.SetContentProtection( |
| 1490 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1492 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1491 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1493 base::Bind(&DisplayConfiguratorTest::SetContentProtectionCallback, |
| 1492 base::Unretained(this))); | 1494 base::Unretained(this))); |
| 1493 EXPECT_EQ(4, enable_content_protection_call_count_); | 1495 EXPECT_EQ(4, set_content_protection_call_count_); |
| 1494 EXPECT_TRUE(enable_content_protection_status_); | 1496 EXPECT_TRUE(set_content_protection_status_); |
| 1495 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1497 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1496 } | 1498 } |
| 1497 | 1499 |
| 1498 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { | 1500 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { |
| 1499 InitWithSingleOutput(); | 1501 InitWithSingleOutput(); |
| 1500 | 1502 |
| 1501 std::vector<std::unique_ptr<const DisplayMode>> modes; | 1503 std::vector<std::unique_ptr<const DisplayMode>> modes; |
| 1502 // The first mode is the mode we are requesting DisplayConfigurator to choose. | 1504 // The first mode is the mode we are requesting DisplayConfigurator to choose. |
| 1503 // The test will be setup so that this mode will fail and it will have to | 1505 // The test will be setup so that this mode will fail and it will have to |
| 1504 // choose the next best option. | 1506 // choose the next best option. |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 configurator_.ResumeDisplays(); | 2174 configurator_.ResumeDisplays(); |
| 2173 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); | 2175 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); |
| 2174 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, | 2176 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2175 configurator_.current_power_state()); | 2177 configurator_.current_power_state()); |
| 2176 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, | 2178 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 2177 configurator_.display_state()); | 2179 configurator_.display_state()); |
| 2178 } | 2180 } |
| 2179 | 2181 |
| 2180 } // namespace test | 2182 } // namespace test |
| 2181 } // namespace display | 2183 } // namespace display |
| OLD | NEW |