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