Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: ui/display/manager/chromeos/display_configurator_unittest.cc

Issue 2675743002: PPAPI: Make output protection API work with mus+ash (Closed)
Patch Set: Fix review issues Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
262 const DisplayConfigurator::QueryProtectionResponse& response) { 262 bool success, uint32_t link_mask, uint32_t protection_mask) {
263 query_content_protection_response_ = response; 263 query_content_protection_response_success_ = success;
264 query_content_protection_response_link_mask_ = link_mask;
265 query_content_protection_response_protection_mask_ = protection_mask;
264 query_content_protection_call_count_++; 266 query_content_protection_call_count_++;
265 } 267 }
266 268
267 // Predefined modes that can be used by outputs. 269 // Predefined modes that can be used by outputs.
268 const DisplayMode small_mode_; 270 const DisplayMode small_mode_;
269 const DisplayMode big_mode_; 271 const DisplayMode big_mode_;
270 272
271 protected: 273 protected:
272 // Configures |native_display_delegate_| to return the first |num_outputs| 274 // Configures |native_display_delegate_| to return the first |num_outputs|
273 // entries from 275 // entries from
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 TestStateController state_controller_; 321 TestStateController state_controller_;
320 TestMirroringController mirroring_controller_; 322 TestMirroringController mirroring_controller_;
321 DisplayConfigurator configurator_; 323 DisplayConfigurator configurator_;
322 TestObserver observer_; 324 TestObserver observer_;
323 std::unique_ptr<ActionLogger> log_; 325 std::unique_ptr<ActionLogger> log_;
324 TestNativeDisplayDelegate* native_display_delegate_; // not owned 326 TestNativeDisplayDelegate* native_display_delegate_; // not owned
325 DisplayConfigurator::TestApi test_api_; 327 DisplayConfigurator::TestApi test_api_;
326 ConfigurationWaiter config_waiter_; 328 ConfigurationWaiter config_waiter_;
327 bool enable_content_protection_status_; 329 bool enable_content_protection_status_;
328 int enable_content_protection_call_count_; 330 int enable_content_protection_call_count_;
329 DisplayConfigurator::QueryProtectionResponse 331 bool query_content_protection_response_success_;
330 query_content_protection_response_; 332 uint32_t query_content_protection_response_link_mask_;
333 uint32_t query_content_protection_response_protection_mask_;
331 int query_content_protection_call_count_; 334 int query_content_protection_call_count_;
332 335
333 std::unique_ptr<DisplaySnapshot> outputs_[3]; 336 std::unique_ptr<DisplaySnapshot> outputs_[3];
334 337
335 CallbackResult display_control_result_; 338 CallbackResult display_control_result_;
336 339
337 private: 340 private:
338 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); 341 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest);
339 }; 342 };
340 343
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_.EnableContentProtection(
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::EnableContentProtectionCallback,
1262 base::Unretained(this))); 1265 base::Unretained(this)));
1263 EXPECT_EQ(1, enable_content_protection_call_count_); 1266 EXPECT_EQ(1, enable_content_protection_call_count_);
1264 EXPECT_TRUE(enable_content_protection_status_); 1267 EXPECT_TRUE(enable_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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 EXPECT_TRUE(enable_content_protection_status_); 1409 EXPECT_TRUE(enable_content_protection_status_);
1407 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(), 1410 EXPECT_EQ(GetSetHDCPStateAction(*outputs_[1], HDCP_STATE_DESIRED).c_str(),
1408 log_->GetActionsAndClear()); 1411 log_->GetActionsAndClear());
1409 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); 1412 native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED);
1410 1413
1411 configurator_.QueryContentProtectionStatus( 1414 configurator_.QueryContentProtectionStatus(
1412 client1, outputs_[1]->display_id(), 1415 client1, outputs_[1]->display_id(),
1413 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, 1416 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback,
1414 base::Unretained(this))); 1417 base::Unretained(this)));
1415 EXPECT_EQ(1, query_content_protection_call_count_); 1418 EXPECT_EQ(1, query_content_protection_call_count_);
1416 EXPECT_TRUE(query_content_protection_response_.success); 1419 EXPECT_TRUE(query_content_protection_response_success_);
1417 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), 1420 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI),
1418 query_content_protection_response_.link_mask); 1421 query_content_protection_response_link_mask_);
1419 EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP, 1422 EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP,
1420 query_content_protection_response_.protection_mask); 1423 query_content_protection_response_protection_mask_);
1421 1424
1422 configurator_.QueryContentProtectionStatus( 1425 configurator_.QueryContentProtectionStatus(
1423 client2, outputs_[1]->display_id(), 1426 client2, outputs_[1]->display_id(),
1424 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback, 1427 base::Bind(&DisplayConfiguratorTest::QueryContentProtectionCallback,
1425 base::Unretained(this))); 1428 base::Unretained(this)));
1426 EXPECT_EQ(2, query_content_protection_call_count_); 1429 EXPECT_EQ(2, query_content_protection_call_count_);
1427 EXPECT_TRUE(query_content_protection_response_.success); 1430 EXPECT_TRUE(query_content_protection_response_success_);
1428 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI), 1431 EXPECT_EQ(static_cast<uint32_t>(DISPLAY_CONNECTION_TYPE_HDMI),
1429 query_content_protection_response_.link_mask); 1432 query_content_protection_response_link_mask_);
1430 EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE, 1433 EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE,
1431 query_content_protection_response_.protection_mask); 1434 query_content_protection_response_protection_mask_);
1432 1435
1433 // Protections will be disabled only if no more clients request them. 1436 // Protections will be disabled only if no more clients request them.
1434 configurator_.EnableContentProtection( 1437 configurator_.EnableContentProtection(
1435 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE, 1438 client2, outputs_[1]->display_id(), CONTENT_PROTECTION_METHOD_NONE,
1436 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback, 1439 base::Bind(&DisplayConfiguratorTest::EnableContentProtectionCallback,
1437 base::Unretained(this))); 1440 base::Unretained(this)));
1438 EXPECT_EQ(2, enable_content_protection_call_count_); 1441 EXPECT_EQ(2, enable_content_protection_call_count_);
1439 EXPECT_TRUE(enable_content_protection_status_); 1442 EXPECT_TRUE(enable_content_protection_status_);
1440 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1443 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1441 1444
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 configurator_.ResumeDisplays(); 2175 configurator_.ResumeDisplays();
2173 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); 2176 EXPECT_EQ(kLongDelay, config_waiter_.Wait());
2174 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, 2177 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
2175 configurator_.current_power_state()); 2178 configurator_.current_power_state());
2176 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, 2179 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED,
2177 configurator_.display_state()); 2180 configurator_.display_state());
2178 } 2181 }
2179 2182
2180 } // namespace test 2183 } // namespace test
2181 } // namespace display 2184 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698