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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 class TestMirroringController | 343 class TestMirroringController |
344 : public DisplayConfigurator::SoftwareMirroringController { | 344 : public DisplayConfigurator::SoftwareMirroringController { |
345 public: | 345 public: |
346 TestMirroringController() : software_mirroring_enabled_(false) {} | 346 TestMirroringController() : software_mirroring_enabled_(false) {} |
347 virtual ~TestMirroringController() {} | 347 virtual ~TestMirroringController() {} |
348 | 348 |
349 virtual void SetSoftwareMirroring(bool enabled) OVERRIDE { | 349 virtual void SetSoftwareMirroring(bool enabled) OVERRIDE { |
350 software_mirroring_enabled_ = enabled; | 350 software_mirroring_enabled_ = enabled; |
351 } | 351 } |
352 | 352 |
353 bool software_mirroring_enabled() const { | 353 virtual bool SoftwareMirroringEnabled() const OVERRIDE { |
354 return software_mirroring_enabled_; | 354 return software_mirroring_enabled_; |
355 } | 355 } |
356 | 356 |
357 private: | 357 private: |
358 bool software_mirroring_enabled_; | 358 bool software_mirroring_enabled_; |
359 | 359 |
360 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); | 360 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); |
361 }; | 361 }; |
362 | 362 |
363 class DisplayConfiguratorTest : public testing::Test { | 363 class DisplayConfiguratorTest : public testing::Test { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 559 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
560 GetCrtcAction(outputs_[1], | 560 GetCrtcAction(outputs_[1], |
561 &big_mode_, | 561 &big_mode_, |
562 gfx::Point(0, | 562 gfx::Point(0, |
563 small_mode_.size().height() + | 563 small_mode_.size().height() + |
564 DisplayConfigurator::kVerticalGap)) | 564 DisplayConfigurator::kVerticalGap)) |
565 .c_str(), | 565 .c_str(), |
566 kUngrab, | 566 kUngrab, |
567 NULL), | 567 NULL), |
568 log_->GetActionsAndClear()); | 568 log_->GetActionsAndClear()); |
569 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 569 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
570 EXPECT_EQ(1, observer_.num_changes()); | 570 EXPECT_EQ(1, observer_.num_changes()); |
571 | 571 |
572 observer_.Reset(); | 572 observer_.Reset(); |
573 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 573 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); |
574 EXPECT_EQ( | 574 EXPECT_EQ( |
575 JoinActions( | 575 JoinActions( |
576 kGrab, | 576 kGrab, |
577 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 577 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
578 .c_str(), | 578 .c_str(), |
579 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 579 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
580 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 580 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
581 kUngrab, | 581 kUngrab, |
582 NULL), | 582 NULL), |
583 log_->GetActionsAndClear()); | 583 log_->GetActionsAndClear()); |
584 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 584 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
585 EXPECT_EQ(1, observer_.num_changes()); | 585 EXPECT_EQ(1, observer_.num_changes()); |
586 | 586 |
587 // Disconnect the second output. | 587 // Disconnect the second output. |
588 observer_.Reset(); | 588 observer_.Reset(); |
589 UpdateOutputs(1, true); | 589 UpdateOutputs(1, true); |
590 EXPECT_EQ( | 590 EXPECT_EQ( |
591 JoinActions( | 591 JoinActions( |
592 kGrab, | 592 kGrab, |
593 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 593 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
594 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 594 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
595 kUngrab, | 595 kUngrab, |
596 NULL), | 596 NULL), |
597 log_->GetActionsAndClear()); | 597 log_->GetActionsAndClear()); |
598 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 598 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
599 EXPECT_EQ(1, observer_.num_changes()); | 599 EXPECT_EQ(1, observer_.num_changes()); |
600 | 600 |
601 // Get rid of shared modes to force software mirroring. | 601 // Get rid of shared modes to force software mirroring. |
602 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &big_mode_)); | 602 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &big_mode_)); |
603 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 603 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
604 UpdateOutputs(2, true); | 604 UpdateOutputs(2, true); |
605 EXPECT_EQ( | 605 EXPECT_EQ( |
606 JoinActions( | 606 JoinActions( |
607 kGrab, | 607 kGrab, |
608 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 608 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
609 &outputs_[0], | 609 &outputs_[0], |
610 &outputs_[1]).c_str(), | 610 &outputs_[1]).c_str(), |
611 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 611 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
612 GetCrtcAction(outputs_[1], | 612 GetCrtcAction(outputs_[1], |
613 &big_mode_, | 613 &big_mode_, |
614 gfx::Point(0, | 614 gfx::Point(0, |
615 small_mode_.size().height() + | 615 small_mode_.size().height() + |
616 DisplayConfigurator::kVerticalGap)) | 616 DisplayConfigurator::kVerticalGap)) |
617 .c_str(), | 617 .c_str(), |
618 kUngrab, | 618 kUngrab, |
619 NULL), | 619 NULL), |
620 log_->GetActionsAndClear()); | 620 log_->GetActionsAndClear()); |
621 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 621 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
622 | 622 |
623 observer_.Reset(); | 623 observer_.Reset(); |
624 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 624 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); |
625 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 625 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
626 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 626 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
627 configurator_.display_state()); | 627 configurator_.display_state()); |
628 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 628 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
629 EXPECT_EQ(1, observer_.num_changes()); | 629 EXPECT_EQ(1, observer_.num_changes()); |
630 | 630 |
631 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. | 631 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. |
632 observer_.Reset(); | 632 observer_.Reset(); |
633 EXPECT_TRUE( | 633 EXPECT_TRUE( |
634 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); | 634 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); |
635 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); | 635 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); |
636 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 636 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
637 EXPECT_EQ(1, observer_.num_changes()); | 637 EXPECT_EQ(1, observer_.num_changes()); |
638 | 638 |
639 // Set back to software mirror mode. | 639 // Set back to software mirror mode. |
640 observer_.Reset(); | 640 observer_.Reset(); |
641 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 641 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); |
642 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 642 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
643 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 643 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
644 configurator_.display_state()); | 644 configurator_.display_state()); |
645 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 645 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
646 EXPECT_EQ(1, observer_.num_changes()); | 646 EXPECT_EQ(1, observer_.num_changes()); |
647 | 647 |
648 // Disconnect the second output. | 648 // Disconnect the second output. |
649 observer_.Reset(); | 649 observer_.Reset(); |
650 UpdateOutputs(1, true); | 650 UpdateOutputs(1, true); |
651 EXPECT_EQ( | 651 EXPECT_EQ( |
652 JoinActions( | 652 JoinActions( |
653 kGrab, | 653 kGrab, |
654 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 654 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
655 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 655 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
656 kUngrab, | 656 kUngrab, |
657 NULL), | 657 NULL), |
658 log_->GetActionsAndClear()); | 658 log_->GetActionsAndClear()); |
659 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 659 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
660 EXPECT_EQ(1, observer_.num_changes()); | 660 EXPECT_EQ(1, observer_.num_changes()); |
661 } | 661 } |
662 | 662 |
663 TEST_F(DisplayConfiguratorTest, SetDisplayPower) { | 663 TEST_F(DisplayConfiguratorTest, SetDisplayPower) { |
664 InitWithSingleOutput(); | 664 InitWithSingleOutput(); |
665 | 665 |
666 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 666 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
667 observer_.Reset(); | 667 observer_.Reset(); |
668 UpdateOutputs(2, true); | 668 UpdateOutputs(2, true); |
669 EXPECT_EQ( | 669 EXPECT_EQ( |
670 JoinActions( | 670 JoinActions( |
671 kGrab, | 671 kGrab, |
672 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 672 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
673 .c_str(), | 673 .c_str(), |
674 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 674 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
675 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 675 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
676 kUngrab, | 676 kUngrab, |
677 NULL), | 677 NULL), |
678 log_->GetActionsAndClear()); | 678 log_->GetActionsAndClear()); |
679 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 679 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
680 EXPECT_EQ(1, observer_.num_changes()); | 680 EXPECT_EQ(1, observer_.num_changes()); |
681 | 681 |
682 // Turning off the internal display should switch the external display to | 682 // Turning off the internal display should switch the external display to |
683 // its native mode. | 683 // its native mode. |
684 observer_.Reset(); | 684 observer_.Reset(); |
685 configurator_.SetDisplayPower( | 685 configurator_.SetDisplayPower( |
686 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 686 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
687 DisplayConfigurator::kSetDisplayPowerNoFlags); | 687 DisplayConfigurator::kSetDisplayPowerNoFlags); |
688 EXPECT_EQ( | 688 EXPECT_EQ( |
689 JoinActions( | 689 JoinActions( |
(...skipping 17 matching lines...) Expand all Loading... |
707 EXPECT_EQ( | 707 EXPECT_EQ( |
708 JoinActions(kGrab, | 708 JoinActions(kGrab, |
709 GetFramebufferAction( | 709 GetFramebufferAction( |
710 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 710 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), |
711 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 711 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
712 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 712 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
713 kUngrab, | 713 kUngrab, |
714 NULL), | 714 NULL), |
715 log_->GetActionsAndClear()); | 715 log_->GetActionsAndClear()); |
716 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 716 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
717 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 717 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
718 EXPECT_EQ(1, observer_.num_changes()); | 718 EXPECT_EQ(1, observer_.num_changes()); |
719 | 719 |
720 // Turn all displays on and check that mirroring is still used. | 720 // Turn all displays on and check that mirroring is still used. |
721 observer_.Reset(); | 721 observer_.Reset(); |
722 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 722 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
723 DisplayConfigurator::kSetDisplayPowerNoFlags); | 723 DisplayConfigurator::kSetDisplayPowerNoFlags); |
724 EXPECT_EQ( | 724 EXPECT_EQ( |
725 JoinActions( | 725 JoinActions( |
726 kGrab, | 726 kGrab, |
727 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 727 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
728 .c_str(), | 728 .c_str(), |
729 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 729 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
730 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 730 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
731 kForceDPMS, | 731 kForceDPMS, |
732 kUngrab, | 732 kUngrab, |
733 NULL), | 733 NULL), |
734 log_->GetActionsAndClear()); | 734 log_->GetActionsAndClear()); |
735 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 735 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
736 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 736 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
737 EXPECT_EQ(1, observer_.num_changes()); | 737 EXPECT_EQ(1, observer_.num_changes()); |
738 | 738 |
739 // Get rid of shared modes to force software mirroring. | 739 // Get rid of shared modes to force software mirroring. |
740 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &big_mode_)); | 740 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &big_mode_)); |
741 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 741 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
742 observer_.Reset(); | 742 observer_.Reset(); |
743 UpdateOutputs(2, true); | 743 UpdateOutputs(2, true); |
744 const int kDualHeight = small_mode_.size().height() + | 744 const int kDualHeight = small_mode_.size().height() + |
745 DisplayConfigurator::kVerticalGap + | 745 DisplayConfigurator::kVerticalGap + |
746 big_mode_.size().height(); | 746 big_mode_.size().height(); |
747 EXPECT_EQ( | 747 EXPECT_EQ( |
748 JoinActions( | 748 JoinActions( |
749 kGrab, | 749 kGrab, |
750 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 750 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
751 &outputs_[0], | 751 &outputs_[0], |
752 &outputs_[1]).c_str(), | 752 &outputs_[1]).c_str(), |
753 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 753 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
754 GetCrtcAction(outputs_[1], | 754 GetCrtcAction(outputs_[1], |
755 &big_mode_, | 755 &big_mode_, |
756 gfx::Point(0, | 756 gfx::Point(0, |
757 small_mode_.size().height() + | 757 small_mode_.size().height() + |
758 DisplayConfigurator::kVerticalGap)) | 758 DisplayConfigurator::kVerticalGap)) |
759 .c_str(), | 759 .c_str(), |
760 kUngrab, | 760 kUngrab, |
761 NULL), | 761 NULL), |
762 log_->GetActionsAndClear()); | 762 log_->GetActionsAndClear()); |
763 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 763 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
764 configurator_.display_state()); | 764 configurator_.display_state()); |
765 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 765 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
766 EXPECT_EQ(1, observer_.num_changes()); | 766 EXPECT_EQ(1, observer_.num_changes()); |
767 | 767 |
768 // Turning off the internal display should switch the external display to | 768 // Turning off the internal display should switch the external display to |
769 // its native mode. | 769 // its native mode. |
770 observer_.Reset(); | 770 observer_.Reset(); |
771 configurator_.SetDisplayPower( | 771 configurator_.SetDisplayPower( |
772 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 772 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
773 DisplayConfigurator::kSetDisplayPowerNoFlags); | 773 DisplayConfigurator::kSetDisplayPowerNoFlags); |
774 EXPECT_EQ( | 774 EXPECT_EQ( |
775 JoinActions( | 775 JoinActions( |
776 kGrab, | 776 kGrab, |
777 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 777 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
778 .c_str(), | 778 .c_str(), |
779 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 779 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
780 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 780 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
781 kForceDPMS, | 781 kForceDPMS, |
782 kUngrab, | 782 kUngrab, |
783 NULL), | 783 NULL), |
784 log_->GetActionsAndClear()); | 784 log_->GetActionsAndClear()); |
785 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 785 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
786 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); | 786 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
787 EXPECT_EQ(1, observer_.num_changes()); | 787 EXPECT_EQ(1, observer_.num_changes()); |
788 | 788 |
789 // When all displays are turned off, the framebuffer should switch back | 789 // When all displays are turned off, the framebuffer should switch back |
790 // to the extended + software mirroring. | 790 // to the extended + software mirroring. |
791 observer_.Reset(); | 791 observer_.Reset(); |
792 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 792 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
793 DisplayConfigurator::kSetDisplayPowerNoFlags); | 793 DisplayConfigurator::kSetDisplayPowerNoFlags); |
794 EXPECT_EQ( | 794 EXPECT_EQ( |
795 JoinActions( | 795 JoinActions( |
796 kGrab, | 796 kGrab, |
797 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 797 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
798 &outputs_[0], | 798 &outputs_[0], |
799 &outputs_[1]).c_str(), | 799 &outputs_[1]).c_str(), |
800 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 800 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
801 GetCrtcAction(outputs_[1], | 801 GetCrtcAction(outputs_[1], |
802 NULL, | 802 NULL, |
803 gfx::Point(0, | 803 gfx::Point(0, |
804 small_mode_.size().height() + | 804 small_mode_.size().height() + |
805 DisplayConfigurator::kVerticalGap)) | 805 DisplayConfigurator::kVerticalGap)) |
806 .c_str(), | 806 .c_str(), |
807 kUngrab, | 807 kUngrab, |
808 NULL), | 808 NULL), |
809 log_->GetActionsAndClear()); | 809 log_->GetActionsAndClear()); |
810 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 810 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
811 configurator_.display_state()); | 811 configurator_.display_state()); |
812 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 812 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
813 EXPECT_EQ(1, observer_.num_changes()); | 813 EXPECT_EQ(1, observer_.num_changes()); |
814 | 814 |
815 // Turn all displays on and check that mirroring is still used. | 815 // Turn all displays on and check that mirroring is still used. |
816 observer_.Reset(); | 816 observer_.Reset(); |
817 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 817 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
818 DisplayConfigurator::kSetDisplayPowerNoFlags); | 818 DisplayConfigurator::kSetDisplayPowerNoFlags); |
819 EXPECT_EQ( | 819 EXPECT_EQ( |
820 JoinActions( | 820 JoinActions( |
821 kGrab, | 821 kGrab, |
822 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 822 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
823 &outputs_[0], | 823 &outputs_[0], |
824 &outputs_[1]).c_str(), | 824 &outputs_[1]).c_str(), |
825 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 825 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
826 GetCrtcAction(outputs_[1], | 826 GetCrtcAction(outputs_[1], |
827 &big_mode_, | 827 &big_mode_, |
828 gfx::Point(0, | 828 gfx::Point(0, |
829 small_mode_.size().height() + | 829 small_mode_.size().height() + |
830 DisplayConfigurator::kVerticalGap)) | 830 DisplayConfigurator::kVerticalGap)) |
831 .c_str(), | 831 .c_str(), |
832 kForceDPMS, | 832 kForceDPMS, |
833 kUngrab, | 833 kUngrab, |
834 NULL), | 834 NULL), |
835 log_->GetActionsAndClear()); | 835 log_->GetActionsAndClear()); |
836 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 836 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
837 configurator_.display_state()); | 837 configurator_.display_state()); |
838 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); | 838 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
839 EXPECT_EQ(1, observer_.num_changes()); | 839 EXPECT_EQ(1, observer_.num_changes()); |
840 } | 840 } |
841 | 841 |
842 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { | 842 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { |
843 InitWithSingleOutput(); | 843 InitWithSingleOutput(); |
844 | 844 |
845 // No preparation is needed before suspending when the display is already | 845 // No preparation is needed before suspending when the display is already |
846 // on. The configurator should still reprobe on resume in case a display | 846 // on. The configurator should still reprobe on resume in case a display |
847 // was connected while suspended. | 847 // was connected while suspended. |
848 configurator_.SuspendDisplays(); | 848 configurator_.SuspendDisplays(); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 gfx::Point(0, | 1298 gfx::Point(0, |
1299 modes[0]->size().height() + | 1299 modes[0]->size().height() + |
1300 DisplayConfigurator::kVerticalGap)) | 1300 DisplayConfigurator::kVerticalGap)) |
1301 .c_str(), | 1301 .c_str(), |
1302 kUngrab, | 1302 kUngrab, |
1303 NULL), | 1303 NULL), |
1304 log_->GetActionsAndClear()); | 1304 log_->GetActionsAndClear()); |
1305 } | 1305 } |
1306 | 1306 |
1307 } // namespace ui | 1307 } // namespace ui |
OLD | NEW |