| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 EnableContentProtectionCallback(bool status) { |
| 257 enable_content_protection_status_ = status; | 257 enable_content_protection_status_ = status; |
| 258 enable_content_protection_call_count_++; | 258 enable_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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 enable_content_protection_status_; |
| 328 int enable_content_protection_call_count_; | 331 int enable_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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 EXPECT_NE(0u, id); | 1231 EXPECT_NE(0u, id); |
| 1228 | 1232 |
| 1229 // One output. | 1233 // One output. |
| 1230 UpdateOutputs(1, true); | 1234 UpdateOutputs(1, true); |
| 1231 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1235 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1232 configurator_.QueryContentProtectionStatus( | 1236 configurator_.QueryContentProtectionStatus( |
| 1233 id, outputs_[0]->display_id(), | 1237 id, outputs_[0]->display_id(), |
| 1234 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1238 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1235 base::Unretained(this))); | 1239 base::Unretained(this))); |
| 1236 EXPECT_EQ(1, query_content_protection_call_count_); | 1240 EXPECT_EQ(1, query_content_protection_call_count_); |
| 1237 EXPECT_TRUE(query_content_protection_response_.success); | 1241 EXPECT_TRUE(query_content_protection_response_success_); |
| 1238 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_INTERNAL), | 1242 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_INTERNAL), |
| 1239 query_content_protection_response_.link_mask); | 1243 query_content_protection_response_link_mask_); |
| 1240 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), | 1244 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), |
| 1241 query_content_protection_response_.protection_mask); | 1245 query_content_protection_response_protection_mask_); |
| 1242 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1246 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1243 | 1247 |
| 1244 // Two outputs. | 1248 // Two outputs. |
| 1245 UpdateOutputs(2, true); | 1249 UpdateOutputs(2, true); |
| 1246 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); | 1250 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); |
| 1247 configurator_.QueryContentProtectionStatus( | 1251 configurator_.QueryContentProtectionStatus( |
| 1248 id, outputs_[1]->display_id(), | 1252 id, outputs_[1]->display_id(), |
| 1249 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1253 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1250 base::Unretained(this))); | 1254 base::Unretained(this))); |
| 1251 EXPECT_EQ(2, query_content_protection_call_count_); | 1255 EXPECT_EQ(2, query_content_protection_call_count_); |
| 1252 EXPECT_TRUE(query_content_protection_response_.success); | 1256 EXPECT_TRUE(query_content_protection_response_success_); |
| 1253 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1257 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1254 query_content_protection_response_.link_mask); | 1258 query_content_protection_response_link_mask_); |
| 1255 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), | 1259 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_NONE), |
| 1256 query_content_protection_response_.protection_mask); | 1260 query_content_protection_response_protection_mask_); |
| 1257 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1261 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1258 | 1262 |
| 1259 configurator_.EnableContentProtection( | 1263 configurator_.EnableContentProtection( |
| 1260 id, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, | 1264 id, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_HDCP, |
| 1261 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, | 1265 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, |
| 1262 base::Unretained(this))); | 1266 base::Unretained(this))); |
| 1263 EXPECT_EQ(1, enable_content_protection_call_count_); | 1267 EXPECT_EQ(1, enable_content_protection_call_count_); |
| 1264 EXPECT_TRUE(enable_content_protection_status_); | 1268 EXPECT_TRUE(enable_content_protection_status_); |
| 1265 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED), | 1269 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED), |
| 1266 log_->GetActionsAndClear()); | 1270 log_->GetActionsAndClear()); |
| 1267 | 1271 |
| 1268 // Enable protection. | 1272 // Enable protection. |
| 1269 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); | 1273 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); |
| 1270 configurator_.QueryContentProtectionStatus( | 1274 configurator_.QueryContentProtectionStatus( |
| 1271 id, outputs_[1]->display_id(), | 1275 id, outputs_[1]->display_id(), |
| 1272 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, | 1276 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, |
| 1273 base::Unretained(this))); | 1277 base::Unretained(this))); |
| 1274 EXPECT_EQ(3, query_content_protection_call_count_); | 1278 EXPECT_EQ(3, query_content_protection_call_count_); |
| 1275 EXPECT_TRUE(query_content_protection_response_.success); | 1279 EXPECT_TRUE(query_content_protection_response_success_); |
| 1276 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), | 1280 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), |
| 1277 query_content_protection_response_.link_mask); | 1281 query_content_protection_response_link_mask_); |
| 1278 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_HDCP), | 1282 EXPECT_EQ(static_cast<uint32_t>(CONTENT_PROTECTION_METHOD_HDCP), |
| 1279 query_content_protection_response_.protection_mask); | 1283 query_content_protection_response_protection_mask_); |
| 1280 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1284 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1281 | 1285 |
| 1282 // Protections should be disabled after unregister. | 1286 // Protections should be disabled after unregister. |
| 1283 configurator_.UnregisterContentProtectionClient(id); | 1287 configurator_.UnregisterContentProtectionClient(id); |
| 1284 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED), | 1288 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_UNDESIRED), |
| 1285 log_->GetActionsAndClear()); | 1289 log_->GetActionsAndClear()); |
| 1286 } | 1290 } |
| 1287 | 1291 |
| 1288 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { | 1292 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { |
| 1289 InitWithSingleOutput(); | 1293 InitWithSingleOutput(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 EXPECT_TRUE(enable_content_protection_status_); | 1410 EXPECT_TRUE(enable_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_.EnableContentProtection( |
| 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::EnableContentProtectionCallback, |
| 1437 base::Unretained(this))); | 1441 base::Unretained(this))); |
| 1438 EXPECT_EQ(2, enable_content_protection_call_count_); | 1442 EXPECT_EQ(2, enable_content_protection_call_count_); |
| 1439 EXPECT_TRUE(enable_content_protection_status_); | 1443 EXPECT_TRUE(enable_content_protection_status_); |
| 1440 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1444 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1441 | 1445 |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 configurator_.ResumeDisplays(); | 2176 configurator_.ResumeDisplays(); |
| 2173 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); | 2177 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); |
| 2174 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, | 2178 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2175 configurator_.current_power_state()); | 2179 configurator_.current_power_state()); |
| 2176 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, | 2180 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 2177 configurator_.display_state()); | 2181 configurator_.display_state()); |
| 2178 } | 2182 } |
| 2179 | 2183 |
| 2180 } // namespace test | 2184 } // namespace test |
| 2181 } // namespace display | 2185 } // namespace display |
| OLD | NEW |