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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 | 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); | 111 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class DisplayConfiguratorTest : public testing::Test { | 114 class DisplayConfiguratorTest : public testing::Test { |
| 115 public: | 115 public: |
| 116 DisplayConfiguratorTest() | 116 DisplayConfiguratorTest() |
| 117 : small_mode_(gfx::Size(1366, 768), false, 60.0f), | 117 : small_mode_(gfx::Size(1366, 768), false, 60.0f), |
| 118 big_mode_(gfx::Size(2560, 1600), false, 60.0f), | 118 big_mode_(gfx::Size(2560, 1600), false, 60.0f), |
| 119 observer_(&configurator_), | 119 observer_(&configurator_), |
| 120 test_api_(&configurator_) {} | 120 test_api_(&configurator_), |
| 121 callback_status_(false), | |
| 122 callback_called_(false) {} | |
| 121 ~DisplayConfiguratorTest() override {} | 123 ~DisplayConfiguratorTest() override {} |
| 122 | 124 |
| 123 void SetUp() override { | 125 void SetUp() override { |
| 124 log_.reset(new ActionLogger()); | 126 log_.reset(new ActionLogger()); |
| 125 | 127 |
| 126 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 128 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
| 127 configurator_.SetDelegateForTesting( | 129 configurator_.SetDelegateForTesting( |
| 128 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 130 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
| 129 | 131 |
| 130 configurator_.set_state_controller(&state_controller_); | 132 configurator_.set_state_controller(&state_controller_); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 146 o->set_native_mode(&big_mode_); | 148 o->set_native_mode(&big_mode_); |
| 147 modes.push_back(&big_mode_); | 149 modes.push_back(&big_mode_); |
| 148 o->set_modes(modes); | 150 o->set_modes(modes); |
| 149 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); | 151 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); |
| 150 o->set_is_aspect_preserving_scaling(true); | 152 o->set_is_aspect_preserving_scaling(true); |
| 151 o->set_display_id(456); | 153 o->set_display_id(456); |
| 152 | 154 |
| 153 UpdateOutputs(2, false); | 155 UpdateOutputs(2, false); |
| 154 } | 156 } |
| 155 | 157 |
| 158 void OnConfiguredCallback(bool status) { | |
| 159 callback_called_ = true; | |
| 160 callback_status_ = status; | |
| 161 } | |
| 162 | |
| 156 // Predefined modes that can be used by outputs. | 163 // Predefined modes that can be used by outputs. |
| 157 const DisplayMode small_mode_; | 164 const DisplayMode small_mode_; |
| 158 const DisplayMode big_mode_; | 165 const DisplayMode big_mode_; |
| 159 | 166 |
| 160 protected: | 167 protected: |
| 161 // Configures |native_display_delegate_| to return the first |num_outputs| | 168 // Configures |native_display_delegate_| to return the first |num_outputs| |
| 162 // entries from | 169 // entries from |
| 163 // |outputs_|. If |send_events| is true, also sends screen-change and | 170 // |outputs_|. If |send_events| is true, also sends screen-change and |
| 164 // output-change events to |configurator_| and triggers the configure | 171 // output-change events to |configurator_| and triggers the configure |
| 165 // timeout if one was scheduled. | 172 // timeout if one was scheduled. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 185 configurator_.ForceInitialConfigure(0); | 192 configurator_.ForceInitialConfigure(0); |
| 186 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, | 193 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, |
| 187 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 194 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 188 NULL).c_str(), | 195 NULL).c_str(), |
| 189 GetCrtcAction(outputs_[0], &small_mode_, | 196 GetCrtcAction(outputs_[0], &small_mode_, |
| 190 gfx::Point(0, 0)).c_str(), | 197 gfx::Point(0, 0)).c_str(), |
| 191 kForceDPMS, kUngrab, NULL), | 198 kForceDPMS, kUngrab, NULL), |
| 192 log_->GetActionsAndClear()); | 199 log_->GetActionsAndClear()); |
| 193 } | 200 } |
| 194 | 201 |
| 202 void CheckAndResetCallback(bool expected_status) { | |
| 203 EXPECT_TRUE(callback_called_); | |
| 204 EXPECT_EQ(expected_status, callback_status_); | |
| 205 | |
| 206 callback_status_ = false; | |
| 207 callback_called_ = false; | |
| 208 } | |
| 209 | |
| 195 base::MessageLoop message_loop_; | 210 base::MessageLoop message_loop_; |
| 196 TestStateController state_controller_; | 211 TestStateController state_controller_; |
| 197 TestMirroringController mirroring_controller_; | 212 TestMirroringController mirroring_controller_; |
| 198 DisplayConfigurator configurator_; | 213 DisplayConfigurator configurator_; |
| 199 TestObserver observer_; | 214 TestObserver observer_; |
| 200 scoped_ptr<ActionLogger> log_; | 215 scoped_ptr<ActionLogger> log_; |
| 201 TestNativeDisplayDelegate* native_display_delegate_; // not owned | 216 TestNativeDisplayDelegate* native_display_delegate_; // not owned |
| 202 DisplayConfigurator::TestApi test_api_; | 217 DisplayConfigurator::TestApi test_api_; |
| 203 | 218 |
| 204 TestDisplaySnapshot outputs_[2]; | 219 TestDisplaySnapshot outputs_[2]; |
| 205 | 220 |
| 221 bool callback_status_; | |
| 222 bool callback_called_; | |
| 223 | |
| 206 private: | 224 private: |
| 207 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); | 225 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); |
| 208 }; | 226 }; |
| 209 | 227 |
| 210 } // namespace | 228 } // namespace |
| 211 | 229 |
| 212 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { | 230 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { |
| 213 ScopedVector<const DisplayMode> modes; | 231 ScopedVector<const DisplayMode> modes; |
| 214 | 232 |
| 215 // Fields are width, height, interlaced, refresh rate. | 233 // Fields are width, height, interlaced, refresh rate. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 NULL), | 440 NULL), |
| 423 log_->GetActionsAndClear()); | 441 log_->GetActionsAndClear()); |
| 424 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 442 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 425 EXPECT_EQ(1, observer_.num_changes()); | 443 EXPECT_EQ(1, observer_.num_changes()); |
| 426 | 444 |
| 427 // Turning off the internal display should switch the external display to | 445 // Turning off the internal display should switch the external display to |
| 428 // its native mode. | 446 // its native mode. |
| 429 observer_.Reset(); | 447 observer_.Reset(); |
| 430 configurator_.SetDisplayPower( | 448 configurator_.SetDisplayPower( |
| 431 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 449 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 432 DisplayConfigurator::kSetDisplayPowerNoFlags); | 450 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 451 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 452 base::Unretained(this))); | |
| 453 CheckAndResetCallback(true); | |
|
Daniel Erat
2015/01/30 17:14:07
CheckAndResetCallback() failures won't produce mea
dnicoara
2015/01/30 18:25:28
Done.
| |
| 433 EXPECT_EQ( | 454 EXPECT_EQ( |
| 434 JoinActions( | 455 JoinActions( |
| 435 kGrab, | 456 kGrab, |
| 436 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 457 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 437 .c_str(), | 458 .c_str(), |
| 438 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 459 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 439 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 460 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 440 kForceDPMS, | 461 kForceDPMS, |
| 441 kUngrab, | 462 kUngrab, |
| 442 NULL), | 463 NULL), |
| 443 log_->GetActionsAndClear()); | 464 log_->GetActionsAndClear()); |
| 444 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 465 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 445 EXPECT_EQ(1, observer_.num_changes()); | 466 EXPECT_EQ(1, observer_.num_changes()); |
| 446 | 467 |
| 447 // When all displays are turned off, the framebuffer should switch back | 468 // When all displays are turned off, the framebuffer should switch back |
| 448 // to the mirrored size. | 469 // to the mirrored size. |
| 449 observer_.Reset(); | 470 observer_.Reset(); |
| 450 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 471 configurator_.SetDisplayPower( |
| 451 DisplayConfigurator::kSetDisplayPowerNoFlags); | 472 chromeos::DISPLAY_POWER_ALL_OFF, |
| 473 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 474 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 475 base::Unretained(this))); | |
| 476 CheckAndResetCallback(true); | |
| 452 EXPECT_EQ( | 477 EXPECT_EQ( |
| 453 JoinActions(kGrab, | 478 JoinActions(kGrab, |
| 454 GetFramebufferAction( | 479 GetFramebufferAction( |
| 455 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 480 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), |
| 456 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 481 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 457 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 482 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
| 458 kUngrab, | 483 kUngrab, |
| 459 NULL), | 484 NULL), |
| 460 log_->GetActionsAndClear()); | 485 log_->GetActionsAndClear()); |
| 461 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 486 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 462 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 487 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 463 EXPECT_EQ(1, observer_.num_changes()); | 488 EXPECT_EQ(1, observer_.num_changes()); |
| 464 | 489 |
| 465 // Turn all displays on and check that mirroring is still used. | 490 // Turn all displays on and check that mirroring is still used. |
| 466 observer_.Reset(); | 491 observer_.Reset(); |
| 467 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 492 configurator_.SetDisplayPower( |
| 468 DisplayConfigurator::kSetDisplayPowerNoFlags); | 493 chromeos::DISPLAY_POWER_ALL_ON, |
| 494 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 495 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 496 base::Unretained(this))); | |
| 497 CheckAndResetCallback(true); | |
| 469 EXPECT_EQ( | 498 EXPECT_EQ( |
| 470 JoinActions( | 499 JoinActions( |
| 471 kGrab, | 500 kGrab, |
| 472 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 501 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 473 .c_str(), | 502 .c_str(), |
| 474 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 503 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 475 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 504 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 476 kForceDPMS, | 505 kForceDPMS, |
| 477 kUngrab, | 506 kUngrab, |
| 478 NULL), | 507 NULL), |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 508 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 537 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 509 configurator_.display_state()); | 538 configurator_.display_state()); |
| 510 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 539 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 511 EXPECT_EQ(1, observer_.num_changes()); | 540 EXPECT_EQ(1, observer_.num_changes()); |
| 512 | 541 |
| 513 // Turning off the internal display should switch the external display to | 542 // Turning off the internal display should switch the external display to |
| 514 // its native mode. | 543 // its native mode. |
| 515 observer_.Reset(); | 544 observer_.Reset(); |
| 516 configurator_.SetDisplayPower( | 545 configurator_.SetDisplayPower( |
| 517 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 546 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 518 DisplayConfigurator::kSetDisplayPowerNoFlags); | 547 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 548 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 549 base::Unretained(this))); | |
| 550 CheckAndResetCallback(true); | |
| 519 EXPECT_EQ( | 551 EXPECT_EQ( |
| 520 JoinActions( | 552 JoinActions( |
| 521 kGrab, | 553 kGrab, |
| 522 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 554 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 523 .c_str(), | 555 .c_str(), |
| 524 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 556 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 525 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 557 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 526 kForceDPMS, | 558 kForceDPMS, |
| 527 kUngrab, | 559 kUngrab, |
| 528 NULL), | 560 NULL), |
| 529 log_->GetActionsAndClear()); | 561 log_->GetActionsAndClear()); |
| 530 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 562 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 531 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 563 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 532 EXPECT_EQ(1, observer_.num_changes()); | 564 EXPECT_EQ(1, observer_.num_changes()); |
| 533 | 565 |
| 534 // When all displays are turned off, the framebuffer should switch back | 566 // When all displays are turned off, the framebuffer should switch back |
| 535 // to the extended + software mirroring. | 567 // to the extended + software mirroring. |
| 536 observer_.Reset(); | 568 observer_.Reset(); |
| 537 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 569 configurator_.SetDisplayPower( |
| 538 DisplayConfigurator::kSetDisplayPowerNoFlags); | 570 chromeos::DISPLAY_POWER_ALL_OFF, |
| 571 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 572 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 573 base::Unretained(this))); | |
| 574 CheckAndResetCallback(true); | |
| 539 EXPECT_EQ( | 575 EXPECT_EQ( |
| 540 JoinActions( | 576 JoinActions( |
| 541 kGrab, | 577 kGrab, |
| 542 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 578 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 543 &outputs_[0], | 579 &outputs_[0], |
| 544 &outputs_[1]).c_str(), | 580 &outputs_[1]).c_str(), |
| 545 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 581 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 546 GetCrtcAction(outputs_[1], | 582 GetCrtcAction(outputs_[1], |
| 547 NULL, | 583 NULL, |
| 548 gfx::Point(0, | 584 gfx::Point(0, |
| 549 small_mode_.size().height() + | 585 small_mode_.size().height() + |
| 550 DisplayConfigurator::kVerticalGap)) | 586 DisplayConfigurator::kVerticalGap)) |
| 551 .c_str(), | 587 .c_str(), |
| 552 kUngrab, | 588 kUngrab, |
| 553 NULL), | 589 NULL), |
| 554 log_->GetActionsAndClear()); | 590 log_->GetActionsAndClear()); |
| 555 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 591 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 556 configurator_.display_state()); | 592 configurator_.display_state()); |
| 557 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 593 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 558 EXPECT_EQ(1, observer_.num_changes()); | 594 EXPECT_EQ(1, observer_.num_changes()); |
| 559 | 595 |
| 560 // Turn all displays on and check that mirroring is still used. | 596 // Turn all displays on and check that mirroring is still used. |
| 561 observer_.Reset(); | 597 observer_.Reset(); |
| 562 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 598 configurator_.SetDisplayPower( |
| 563 DisplayConfigurator::kSetDisplayPowerNoFlags); | 599 chromeos::DISPLAY_POWER_ALL_ON, |
| 600 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 601 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 602 base::Unretained(this))); | |
| 603 CheckAndResetCallback(true); | |
| 564 EXPECT_EQ( | 604 EXPECT_EQ( |
| 565 JoinActions( | 605 JoinActions( |
| 566 kGrab, | 606 kGrab, |
| 567 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 607 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 568 &outputs_[0], | 608 &outputs_[0], |
| 569 &outputs_[1]).c_str(), | 609 &outputs_[1]).c_str(), |
| 570 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 610 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 571 GetCrtcAction(outputs_[1], | 611 GetCrtcAction(outputs_[1], |
| 572 &big_mode_, | 612 &big_mode_, |
| 573 gfx::Point(0, | 613 gfx::Point(0, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 599 kGrab, | 639 kGrab, |
| 600 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 640 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 601 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 641 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 602 kForceDPMS, | 642 kForceDPMS, |
| 603 kUngrab, | 643 kUngrab, |
| 604 NULL), | 644 NULL), |
| 605 log_->GetActionsAndClear()); | 645 log_->GetActionsAndClear()); |
| 606 | 646 |
| 607 // Now turn the display off before suspending and check that the | 647 // Now turn the display off before suspending and check that the |
| 608 // configurator turns it back on and syncs with the server. | 648 // configurator turns it back on and syncs with the server. |
| 609 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 649 configurator_.SetDisplayPower( |
| 610 DisplayConfigurator::kSetDisplayPowerNoFlags); | 650 chromeos::DISPLAY_POWER_ALL_OFF, |
| 651 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 652 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 653 base::Unretained(this))); | |
| 654 CheckAndResetCallback(true); | |
| 611 EXPECT_EQ( | 655 EXPECT_EQ( |
| 612 JoinActions( | 656 JoinActions( |
| 613 kGrab, | 657 kGrab, |
| 614 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 658 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 615 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 659 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 616 kUngrab, | 660 kUngrab, |
| 617 NULL), | 661 NULL), |
| 618 log_->GetActionsAndClear()); | 662 log_->GetActionsAndClear()); |
| 619 | 663 |
| 620 configurator_.SuspendDisplays(); | 664 configurator_.SuspendDisplays(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 649 JoinActions( | 693 JoinActions( |
| 650 kGrab, | 694 kGrab, |
| 651 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 695 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 652 .c_str(), | 696 .c_str(), |
| 653 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 697 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 654 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 698 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 655 kUngrab, | 699 kUngrab, |
| 656 NULL), | 700 NULL), |
| 657 log_->GetActionsAndClear()); | 701 log_->GetActionsAndClear()); |
| 658 | 702 |
| 659 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 703 configurator_.SetDisplayPower( |
| 660 DisplayConfigurator::kSetDisplayPowerNoFlags); | 704 chromeos::DISPLAY_POWER_ALL_OFF, |
| 705 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 706 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 707 base::Unretained(this))); | |
| 708 CheckAndResetCallback(true); | |
| 661 EXPECT_EQ( | 709 EXPECT_EQ( |
| 662 JoinActions(kGrab, | 710 JoinActions(kGrab, |
| 663 GetFramebufferAction( | 711 GetFramebufferAction( |
| 664 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 712 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), |
| 665 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 713 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 666 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 714 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
| 667 kUngrab, | 715 kUngrab, |
| 668 NULL), | 716 NULL), |
| 669 log_->GetActionsAndClear()); | 717 log_->GetActionsAndClear()); |
| 670 | 718 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 691 UpdateOutputs(0, false); | 739 UpdateOutputs(0, false); |
| 692 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 740 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 693 configurator_.Init(false); | 741 configurator_.Init(false); |
| 694 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 742 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 695 configurator_.ForceInitialConfigure(0); | 743 configurator_.ForceInitialConfigure(0); |
| 696 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, NULL), | 744 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, NULL), |
| 697 log_->GetActionsAndClear()); | 745 log_->GetActionsAndClear()); |
| 698 | 746 |
| 699 // Not much should happen when the display power state is changed while | 747 // Not much should happen when the display power state is changed while |
| 700 // no displays are connected. | 748 // no displays are connected. |
| 701 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 749 configurator_.SetDisplayPower( |
| 702 DisplayConfigurator::kSetDisplayPowerNoFlags); | 750 chromeos::DISPLAY_POWER_ALL_OFF, |
| 751 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 752 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 753 base::Unretained(this))); | |
| 754 CheckAndResetCallback(true); | |
| 703 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 755 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 704 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 756 configurator_.SetDisplayPower( |
| 705 DisplayConfigurator::kSetDisplayPowerNoFlags); | 757 chromeos::DISPLAY_POWER_ALL_ON, |
| 758 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 759 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 760 base::Unretained(this))); | |
| 761 CheckAndResetCallback(true); | |
| 706 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), | 762 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), |
| 707 log_->GetActionsAndClear()); | 763 log_->GetActionsAndClear()); |
| 708 | 764 |
| 709 // Connect an external display and check that it's configured correctly. | 765 // Connect an external display and check that it's configured correctly. |
| 710 outputs_[0].set_current_mode(outputs_[1].current_mode()); | 766 outputs_[0].set_current_mode(outputs_[1].current_mode()); |
| 711 outputs_[0].set_native_mode(outputs_[1].native_mode()); | 767 outputs_[0].set_native_mode(outputs_[1].native_mode()); |
| 712 outputs_[0].set_modes(outputs_[1].modes()); | 768 outputs_[0].set_modes(outputs_[1].modes()); |
| 713 outputs_[0].set_type(outputs_[1].type()); | 769 outputs_[0].set_type(outputs_[1].type()); |
| 714 | 770 |
| 715 UpdateOutputs(1, true); | 771 UpdateOutputs(1, true); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1064 // Start out with two displays in extended mode. | 1120 // Start out with two displays in extended mode. |
| 1065 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1121 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1066 configurator_.Init(false); | 1122 configurator_.Init(false); |
| 1067 configurator_.ForceInitialConfigure(0); | 1123 configurator_.ForceInitialConfigure(0); |
| 1068 log_->GetActionsAndClear(); | 1124 log_->GetActionsAndClear(); |
| 1069 observer_.Reset(); | 1125 observer_.Reset(); |
| 1070 | 1126 |
| 1071 // Turn off the internal display, simulating docked mode. | 1127 // Turn off the internal display, simulating docked mode. |
| 1072 configurator_.SetDisplayPower( | 1128 configurator_.SetDisplayPower( |
| 1073 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1129 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1074 DisplayConfigurator::kSetDisplayPowerNoFlags); | 1130 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1131 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 1132 base::Unretained(this))); | |
| 1133 CheckAndResetCallback(true); | |
| 1075 EXPECT_EQ(1, observer_.num_changes()); | 1134 EXPECT_EQ(1, observer_.num_changes()); |
| 1076 EXPECT_EQ(0, observer_.num_failures()); | 1135 EXPECT_EQ(0, observer_.num_failures()); |
| 1077 log_->GetActionsAndClear(); | 1136 log_->GetActionsAndClear(); |
| 1078 | 1137 |
| 1079 // Make all subsequent configuration requests fail and try to turn the | 1138 // Make all subsequent configuration requests fail and try to turn the |
| 1080 // internal display back on. | 1139 // internal display back on. |
| 1081 native_display_delegate_->set_max_configurable_pixels(1); | 1140 native_display_delegate_->set_max_configurable_pixels(1); |
| 1082 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 1141 configurator_.SetDisplayPower( |
| 1083 DisplayConfigurator::kSetDisplayPowerNoFlags); | 1142 chromeos::DISPLAY_POWER_ALL_ON, |
| 1143 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 1144 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 1145 base::Unretained(this))); | |
| 1146 CheckAndResetCallback(false); | |
| 1084 EXPECT_EQ(1, observer_.num_changes()); | 1147 EXPECT_EQ(1, observer_.num_changes()); |
| 1085 EXPECT_EQ(1, observer_.num_failures()); | 1148 EXPECT_EQ(1, observer_.num_failures()); |
| 1086 log_->GetActionsAndClear(); | 1149 log_->GetActionsAndClear(); |
| 1087 | 1150 |
| 1088 // Simulate the external display getting disconnected and check that the | 1151 // Simulate the external display getting disconnected and check that the |
| 1089 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather | 1152 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather |
| 1090 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. | 1153 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. |
| 1091 native_display_delegate_->set_max_configurable_pixels(0); | 1154 native_display_delegate_->set_max_configurable_pixels(0); |
| 1092 UpdateOutputs(1, true); | 1155 UpdateOutputs(1, true); |
| 1093 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), | 1156 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1105 // Start out with two displays in mirrored mode. | 1168 // Start out with two displays in mirrored mode. |
| 1106 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1169 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1107 configurator_.Init(false); | 1170 configurator_.Init(false); |
| 1108 configurator_.ForceInitialConfigure(0); | 1171 configurator_.ForceInitialConfigure(0); |
| 1109 log_->GetActionsAndClear(); | 1172 log_->GetActionsAndClear(); |
| 1110 observer_.Reset(); | 1173 observer_.Reset(); |
| 1111 | 1174 |
| 1112 // Turn off the internal display, simulating docked mode. | 1175 // Turn off the internal display, simulating docked mode. |
| 1113 configurator_.SetDisplayPower( | 1176 configurator_.SetDisplayPower( |
| 1114 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1177 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1115 DisplayConfigurator::kSetDisplayPowerNoFlags); | 1178 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1179 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 1180 base::Unretained(this))); | |
| 1181 CheckAndResetCallback(true); | |
| 1116 EXPECT_EQ(1, observer_.num_changes()); | 1182 EXPECT_EQ(1, observer_.num_changes()); |
| 1117 EXPECT_EQ(0, observer_.num_failures()); | 1183 EXPECT_EQ(0, observer_.num_failures()); |
| 1118 EXPECT_EQ( | 1184 EXPECT_EQ( |
| 1119 JoinActions( | 1185 JoinActions( |
| 1120 kGrab, | 1186 kGrab, |
| 1121 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 1187 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1122 .c_str(), | 1188 .c_str(), |
| 1123 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1189 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1124 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 1190 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 1125 kForceDPMS, | 1191 kForceDPMS, |
| 1126 kUngrab, | 1192 kUngrab, |
| 1127 NULL), | 1193 NULL), |
| 1128 log_->GetActionsAndClear()); | 1194 log_->GetActionsAndClear()); |
| 1129 | 1195 |
| 1130 // Suspend and resume the system. Resuming should post a task to restore the | 1196 // Suspend and resume the system. Resuming should post a task to restore the |
| 1131 // previous power state, additionally forcing a probe. | 1197 // previous power state, additionally forcing a probe. |
| 1132 configurator_.SuspendDisplays(); | 1198 configurator_.SuspendDisplays(); |
| 1133 configurator_.ResumeDisplays(); | 1199 configurator_.ResumeDisplays(); |
| 1134 | 1200 |
| 1135 // Before the task runs, exit docked mode. | 1201 // Before the task runs, exit docked mode. |
| 1136 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 1202 configurator_.SetDisplayPower( |
| 1137 DisplayConfigurator::kSetDisplayPowerNoFlags); | 1203 chromeos::DISPLAY_POWER_ALL_ON, |
| 1204 DisplayConfigurator::kSetDisplayPowerNoFlags, | |
| 1205 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 1206 base::Unretained(this))); | |
| 1207 CheckAndResetCallback(true); | |
| 1138 EXPECT_EQ(2, observer_.num_changes()); | 1208 EXPECT_EQ(2, observer_.num_changes()); |
| 1139 EXPECT_EQ(0, observer_.num_failures()); | 1209 EXPECT_EQ(0, observer_.num_failures()); |
| 1140 EXPECT_EQ( | 1210 EXPECT_EQ( |
| 1141 JoinActions( | 1211 JoinActions( |
| 1142 kGrab, | 1212 kGrab, |
| 1143 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1213 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1144 .c_str(), | 1214 .c_str(), |
| 1145 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1215 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1146 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1216 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1147 kForceDPMS, | 1217 kForceDPMS, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1179 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1249 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 1180 nullptr).c_str(), | 1250 nullptr).c_str(), |
| 1181 GetCrtcAction(outputs_[0], &small_mode_, | 1251 GetCrtcAction(outputs_[0], &small_mode_, |
| 1182 gfx::Point(0, 0)).c_str(), | 1252 gfx::Point(0, 0)).c_str(), |
| 1183 kUngrab, NULL), | 1253 kUngrab, NULL), |
| 1184 log_->GetActionsAndClear()); | 1254 log_->GetActionsAndClear()); |
| 1185 } | 1255 } |
| 1186 | 1256 |
| 1187 } // namespace test | 1257 } // namespace test |
| 1188 } // namespace ui | 1258 } // namespace ui |
| OLD | NEW |