Chromium Code Reviews| 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/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/display/chromeos/test/action_logger_util.h" | 10 #include "ui/display/chromeos/test/action_logger_util.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 EXPECT_EQ(modes[15], | 330 EXPECT_EQ(modes[15], |
| 331 DisplayConfigurator::FindDisplayModeMatchingSize( | 331 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 332 output, gfx::Size(320, 200))); | 332 output, gfx::Size(320, 200))); |
| 333 | 333 |
| 334 // No mode found. | 334 // No mode found. |
| 335 EXPECT_EQ(NULL, | 335 EXPECT_EQ(NULL, |
| 336 DisplayConfigurator::FindDisplayModeMatchingSize( | 336 DisplayConfigurator::FindDisplayModeMatchingSize( |
| 337 output, gfx::Size(1440, 900))); | 337 output, gfx::Size(1440, 900))); |
| 338 } | 338 } |
| 339 | 339 |
| 340 TEST_F(DisplayConfiguratorTest, EnableVirtualDisplay) { | |
| 341 InitWithSingleOutput(); | |
| 342 | |
| 343 observer_.Reset(); | |
| 344 const DisplayConfigurator::DisplayStateList* cached = | |
| 345 &configurator_.cached_displays(); | |
|
oshima
2015/11/24 22:19:27
const ... & cached =
(I understand this is used i
robert.bradford
2015/11/26 16:29:40
Done. And I addressed the other user of this.
| |
| 346 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | |
|
oshima
2015/11/24 22:19:27
1u
robert.bradford
2015/11/26 16:29:40
Done. And some similar ones too.
| |
| 347 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 348 | |
| 349 // Add virtual display. | |
| 350 int64_t virtual_display_id = | |
| 351 configurator_.AddVirtualDisplay(big_mode_.size()); | |
| 352 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | |
| 353 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | |
| 354 configurator_.display_state()); | |
| 355 | |
| 356 // Virtual should not trigger addition of added crtc but does change FB | |
| 357 // height. | |
| 358 const int kVirtualHeight = small_mode_.size().height() + | |
| 359 DisplayConfigurator::kVerticalGap + | |
| 360 big_mode_.size().height(); | |
| 361 EXPECT_EQ( | |
| 362 JoinActions( | |
| 363 kGrab, GetFramebufferAction( | |
| 364 gfx::Size(big_mode_.size().width(), kVirtualHeight), | |
| 365 &outputs_[0], NULL) | |
|
oshima
2015/11/24 22:19:27
nullptr. same for other files
robert.bradford
2015/11/26 16:29:40
Done.
| |
| 366 .c_str(), | |
| 367 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 368 kUngrab, NULL), | |
| 369 log_->GetActionsAndClear()); | |
| 370 EXPECT_EQ(1, observer_.num_changes()); | |
| 371 ASSERT_EQ(static_cast<size_t>(2), cached->size()); | |
| 372 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 373 EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); | |
| 374 EXPECT_EQ(virtual_display_id, (*cached)[1]->display_id()); | |
| 375 | |
| 376 // Remove virtual display. | |
| 377 observer_.Reset(); | |
| 378 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id)); | |
| 379 EXPECT_EQ( | |
| 380 JoinActions( | |
| 381 kGrab, | |
| 382 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 383 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 384 kUngrab, NULL), | |
| 385 log_->GetActionsAndClear()); | |
| 386 EXPECT_EQ(1, observer_.num_changes()); | |
| 387 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | |
| 388 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 389 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | |
| 390 } | |
| 391 | |
| 392 TEST_F(DisplayConfiguratorTest, EnableTwoVirtualDisplays) { | |
| 393 InitWithSingleOutput(); | |
| 394 | |
| 395 observer_.Reset(); | |
| 396 const DisplayConfigurator::DisplayStateList* cached = | |
| 397 &configurator_.cached_displays(); | |
| 398 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | |
| 399 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 400 | |
| 401 // Add 1st virtual display. | |
| 402 int64_t virtual_display_id_1 = | |
| 403 configurator_.AddVirtualDisplay(big_mode_.size()); | |
| 404 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | |
| 405 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | |
| 406 configurator_.display_state()); | |
| 407 | |
| 408 // Virtual should not trigger addition of added crtc but does change FB | |
| 409 // height. | |
| 410 const int kSingleVirtualHeight = small_mode_.size().height() + | |
| 411 DisplayConfigurator::kVerticalGap + | |
| 412 big_mode_.size().height(); | |
| 413 EXPECT_EQ( | |
| 414 JoinActions( | |
| 415 kGrab, GetFramebufferAction( | |
| 416 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), | |
| 417 &outputs_[0], NULL) | |
| 418 .c_str(), | |
| 419 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 420 kUngrab, NULL), | |
| 421 log_->GetActionsAndClear()); | |
| 422 EXPECT_EQ(1, observer_.num_changes()); | |
| 423 ASSERT_EQ(static_cast<size_t>(2), cached->size()); | |
| 424 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 425 EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); | |
| 426 EXPECT_EQ(virtual_display_id_1, (*cached)[1]->display_id()); | |
| 427 | |
| 428 // Add 2nd virtual display | |
| 429 int64_t virtual_display_id_2 = | |
| 430 configurator_.AddVirtualDisplay(big_mode_.size()); | |
| 431 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | |
| 432 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, | |
| 433 configurator_.display_state()); | |
| 434 | |
| 435 const int kDualVirtualHeight = | |
| 436 small_mode_.size().height() + | |
| 437 (DisplayConfigurator::kVerticalGap + big_mode_.size().height()) * 2; | |
| 438 EXPECT_EQ( | |
| 439 JoinActions( | |
| 440 kGrab, GetFramebufferAction( | |
| 441 gfx::Size(big_mode_.size().width(), kDualVirtualHeight), | |
| 442 &outputs_[0], NULL) | |
| 443 .c_str(), | |
| 444 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 445 kUngrab, NULL), | |
| 446 log_->GetActionsAndClear()); | |
| 447 EXPECT_EQ(2, observer_.num_changes()); | |
| 448 ASSERT_EQ(static_cast<size_t>(3), cached->size()); | |
| 449 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 450 EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); | |
| 451 EXPECT_EQ(big_mode_.size(), (*cached)[2]->current_mode()->size()); | |
| 452 EXPECT_EQ(virtual_display_id_1, (*cached)[1]->display_id()); | |
| 453 EXPECT_EQ(virtual_display_id_2, (*cached)[2]->display_id()); | |
| 454 | |
| 455 // Remove 1st virtual display. | |
| 456 observer_.Reset(); | |
| 457 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_1)); | |
| 458 EXPECT_EQ( | |
| 459 JoinActions( | |
| 460 kGrab, GetFramebufferAction( | |
| 461 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), | |
| 462 &outputs_[0], NULL) | |
| 463 .c_str(), | |
| 464 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 465 kUngrab, NULL), | |
| 466 log_->GetActionsAndClear()); | |
| 467 EXPECT_EQ(1, observer_.num_changes()); | |
| 468 ASSERT_EQ(static_cast<size_t>(2), cached->size()); | |
| 469 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 470 EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); | |
| 471 EXPECT_EQ(virtual_display_id_2, (*cached)[1]->display_id()); | |
| 472 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | |
| 473 configurator_.display_state()); | |
| 474 | |
| 475 // Remove 2nd virtual display. | |
| 476 observer_.Reset(); | |
| 477 EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_2)); | |
| 478 EXPECT_EQ( | |
| 479 JoinActions( | |
| 480 kGrab, | |
| 481 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | |
| 482 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | |
| 483 kUngrab, NULL), | |
| 484 log_->GetActionsAndClear()); | |
| 485 EXPECT_EQ(1, observer_.num_changes()); | |
| 486 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | |
| 487 EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); | |
| 488 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | |
| 489 } | |
| 490 | |
| 340 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { | 491 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { |
| 341 InitWithSingleOutput(); | 492 InitWithSingleOutput(); |
| 342 | 493 |
| 343 // Connect a second output and check that the configurator enters | 494 // Connect a second output and check that the configurator enters |
| 344 // extended mode. | 495 // extended mode. |
| 345 observer_.Reset(); | 496 observer_.Reset(); |
| 346 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 497 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 347 UpdateOutputs(2, true); | 498 UpdateOutputs(2, true); |
| 348 const int kDualHeight = small_mode_.size().height() + | 499 const int kDualHeight = small_mode_.size().height() + |
| 349 DisplayConfigurator::kVerticalGap + | 500 DisplayConfigurator::kVerticalGap + |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 InitWithSingleOutput(); | 1058 InitWithSingleOutput(); |
| 908 const DisplayConfigurator::DisplayStateList* cached = | 1059 const DisplayConfigurator::DisplayStateList* cached = |
| 909 &configurator_.cached_displays(); | 1060 &configurator_.cached_displays(); |
| 910 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | 1061 ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
| 911 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0]->current_mode()); | 1062 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0]->current_mode()); |
| 912 | 1063 |
| 913 // After connecting a second output, check that it shows up in | 1064 // After connecting a second output, check that it shows up in |
| 914 // |cached_displays_| even if an invalid state is requested. | 1065 // |cached_displays_| even if an invalid state is requested. |
| 915 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1066 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 916 UpdateOutputs(2, true); | 1067 UpdateOutputs(2, true); |
| 917 cached = &configurator_.cached_displays(); | |
| 918 ASSERT_EQ(static_cast<size_t>(2), cached->size()); | 1068 ASSERT_EQ(static_cast<size_t>(2), cached->size()); |
| 919 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0]->current_mode()); | 1069 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0]->current_mode()); |
| 920 EXPECT_EQ(outputs_[1].current_mode(), (*cached)[1]->current_mode()); | 1070 EXPECT_EQ(outputs_[1].current_mode(), (*cached)[1]->current_mode()); |
| 921 } | 1071 } |
| 922 | 1072 |
| 923 TEST_F(DisplayConfiguratorTest, PanelFitting) { | 1073 TEST_F(DisplayConfiguratorTest, PanelFitting) { |
| 924 // Configure the internal display to support only the big mode and the | 1074 // Configure the internal display to support only the big mode and the |
| 925 // external display to support only the small mode. | 1075 // external display to support only the small mode. |
| 926 outputs_[0].set_current_mode(&big_mode_); | 1076 outputs_[0].set_current_mode(&big_mode_); |
| 927 outputs_[0].set_native_mode(&big_mode_); | 1077 outputs_[0].set_native_mode(&big_mode_); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1464 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1614 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 1465 nullptr).c_str(), | 1615 nullptr).c_str(), |
| 1466 GetCrtcAction(outputs_[0], &small_mode_, | 1616 GetCrtcAction(outputs_[0], &small_mode_, |
| 1467 gfx::Point(0, 0)).c_str(), | 1617 gfx::Point(0, 0)).c_str(), |
| 1468 kUngrab, NULL), | 1618 kUngrab, NULL), |
| 1469 log_->GetActionsAndClear()); | 1619 log_->GetActionsAndClear()); |
| 1470 } | 1620 } |
| 1471 | 1621 |
| 1472 } // namespace test | 1622 } // namespace test |
| 1473 } // namespace ui | 1623 } // namespace ui |
| OLD | NEW |