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