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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 // Initializes |configurator_| with a single internal display. | 179 // Initializes |configurator_| with a single internal display. |
180 void InitWithSingleOutput() { | 180 void InitWithSingleOutput() { |
181 UpdateOutputs(1, false); | 181 UpdateOutputs(1, false); |
182 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 182 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
183 configurator_.Init(false); | 183 configurator_.Init(false); |
184 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 184 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
185 configurator_.ForceInitialConfigure(0); | 185 configurator_.ForceInitialConfigure(0); |
186 EXPECT_EQ( | 186 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, |
187 JoinActions( | 187 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
188 kGrab, | 188 NULL).c_str(), |
189 kInitXRandR, | 189 GetCrtcAction(outputs_[0], &small_mode_, |
190 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL) | 190 gfx::Point(0, 0)).c_str(), |
191 .c_str(), | 191 kForceDPMS, kUngrab, NULL), |
192 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 192 log_->GetActionsAndClear()); |
193 kForceDPMS, | |
194 kUngrab, | |
195 NULL), | |
196 log_->GetActionsAndClear()); | |
197 } | 193 } |
198 | 194 |
199 base::MessageLoop message_loop_; | 195 base::MessageLoop message_loop_; |
200 TestStateController state_controller_; | 196 TestStateController state_controller_; |
201 TestMirroringController mirroring_controller_; | 197 TestMirroringController mirroring_controller_; |
202 DisplayConfigurator configurator_; | 198 DisplayConfigurator configurator_; |
203 TestObserver observer_; | 199 TestObserver observer_; |
204 scoped_ptr<ActionLogger> log_; | 200 scoped_ptr<ActionLogger> log_; |
205 TestNativeDisplayDelegate* native_display_delegate_; // not owned | 201 TestNativeDisplayDelegate* native_display_delegate_; // not owned |
206 DisplayConfigurator::TestApi test_api_; | 202 DisplayConfigurator::TestApi test_api_; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 small_mode_.size().height() + | 309 small_mode_.size().height() + |
314 DisplayConfigurator::kVerticalGap)) | 310 DisplayConfigurator::kVerticalGap)) |
315 .c_str(), | 311 .c_str(), |
316 kUngrab, | 312 kUngrab, |
317 NULL), | 313 NULL), |
318 log_->GetActionsAndClear()); | 314 log_->GetActionsAndClear()); |
319 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 315 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
320 EXPECT_EQ(1, observer_.num_changes()); | 316 EXPECT_EQ(1, observer_.num_changes()); |
321 | 317 |
322 observer_.Reset(); | 318 observer_.Reset(); |
323 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 319 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
324 EXPECT_EQ( | 320 EXPECT_EQ( |
325 JoinActions( | 321 JoinActions( |
326 kGrab, | 322 kGrab, |
327 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 323 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
328 .c_str(), | 324 .c_str(), |
329 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 325 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
330 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 326 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
331 kUngrab, | 327 kUngrab, |
332 NULL), | 328 NULL), |
333 log_->GetActionsAndClear()); | 329 log_->GetActionsAndClear()); |
(...skipping 30 matching lines...) Expand all Loading... |
364 gfx::Point(0, | 360 gfx::Point(0, |
365 small_mode_.size().height() + | 361 small_mode_.size().height() + |
366 DisplayConfigurator::kVerticalGap)) | 362 DisplayConfigurator::kVerticalGap)) |
367 .c_str(), | 363 .c_str(), |
368 kUngrab, | 364 kUngrab, |
369 NULL), | 365 NULL), |
370 log_->GetActionsAndClear()); | 366 log_->GetActionsAndClear()); |
371 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 367 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
372 | 368 |
373 observer_.Reset(); | 369 observer_.Reset(); |
374 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 370 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
375 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 371 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
376 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 372 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
377 configurator_.display_state()); | 373 configurator_.display_state()); |
378 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 374 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
379 EXPECT_EQ(1, observer_.num_changes()); | 375 EXPECT_EQ(1, observer_.num_changes()); |
380 | 376 |
381 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. | 377 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. |
382 observer_.Reset(); | 378 observer_.Reset(); |
383 EXPECT_TRUE( | 379 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
384 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); | |
385 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); | 380 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); |
386 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 381 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
387 EXPECT_EQ(1, observer_.num_changes()); | 382 EXPECT_EQ(1, observer_.num_changes()); |
388 | 383 |
389 // Set back to software mirror mode. | 384 // Set back to software mirror mode. |
390 observer_.Reset(); | 385 observer_.Reset(); |
391 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 386 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
392 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 387 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
393 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 388 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
394 configurator_.display_state()); | 389 configurator_.display_state()); |
395 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 390 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
396 EXPECT_EQ(1, observer_.num_changes()); | 391 EXPECT_EQ(1, observer_.num_changes()); |
397 | 392 |
398 // Disconnect the second output. | 393 // Disconnect the second output. |
399 observer_.Reset(); | 394 observer_.Reset(); |
400 UpdateOutputs(1, true); | 395 UpdateOutputs(1, true); |
401 EXPECT_EQ( | 396 EXPECT_EQ( |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 NULL), | 686 NULL), |
692 log_->GetActionsAndClear()); | 687 log_->GetActionsAndClear()); |
693 } | 688 } |
694 | 689 |
695 TEST_F(DisplayConfiguratorTest, Headless) { | 690 TEST_F(DisplayConfiguratorTest, Headless) { |
696 UpdateOutputs(0, false); | 691 UpdateOutputs(0, false); |
697 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 692 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
698 configurator_.Init(false); | 693 configurator_.Init(false); |
699 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 694 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
700 configurator_.ForceInitialConfigure(0); | 695 configurator_.ForceInitialConfigure(0); |
701 EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, NULL), | 696 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, NULL), |
702 log_->GetActionsAndClear()); | 697 log_->GetActionsAndClear()); |
703 | 698 |
704 // Not much should happen when the display power state is changed while | 699 // Not much should happen when the display power state is changed while |
705 // no displays are connected. | 700 // no displays are connected. |
706 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, | 701 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
707 DisplayConfigurator::kSetDisplayPowerNoFlags); | 702 DisplayConfigurator::kSetDisplayPowerNoFlags); |
708 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 703 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
709 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 704 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
710 DisplayConfigurator::kSetDisplayPowerNoFlags); | 705 DisplayConfigurator::kSetDisplayPowerNoFlags); |
711 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), | 706 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), |
(...skipping 19 matching lines...) Expand all Loading... |
731 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { | 726 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { |
732 UpdateOutputs(2, false); | 727 UpdateOutputs(2, false); |
733 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 728 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
734 configurator_.Init(false); | 729 configurator_.Init(false); |
735 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 730 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
736 | 731 |
737 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 732 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
738 configurator_.ForceInitialConfigure(0); | 733 configurator_.ForceInitialConfigure(0); |
739 EXPECT_EQ( | 734 EXPECT_EQ( |
740 JoinActions( | 735 JoinActions( |
741 kGrab, | 736 kInitXRandR, kGrab, |
742 kInitXRandR, | |
743 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 737 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
744 .c_str(), | 738 .c_str(), |
745 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 739 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
746 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 740 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
747 kForceDPMS, | 741 kForceDPMS, kUngrab, NULL), |
748 kUngrab, | |
749 NULL), | |
750 log_->GetActionsAndClear()); | 742 log_->GetActionsAndClear()); |
751 } | 743 } |
752 | 744 |
753 TEST_F(DisplayConfiguratorTest, InvalidMultipleDisplayStates) { | 745 TEST_F(DisplayConfiguratorTest, InvalidMultipleDisplayStates) { |
754 UpdateOutputs(0, false); | 746 UpdateOutputs(0, false); |
755 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 747 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
756 configurator_.Init(false); | 748 configurator_.Init(false); |
757 configurator_.ForceInitialConfigure(0); | 749 configurator_.ForceInitialConfigure(0); |
758 observer_.Reset(); | 750 observer_.Reset(); |
759 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); | 751 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS); |
760 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); | 752 EXPECT_EQ(1, observer_.num_changes()); |
761 EXPECT_FALSE( | 753 EXPECT_EQ(0, observer_.num_failures()); |
762 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 754 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE); |
763 EXPECT_FALSE( | 755 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
764 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); | 756 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
765 EXPECT_EQ(1, observer_.num_changes()); | 757 EXPECT_EQ(1, observer_.num_changes()); |
766 EXPECT_EQ(3, observer_.num_failures()); | 758 EXPECT_EQ(3, observer_.num_failures()); |
767 | 759 |
768 UpdateOutputs(1, true); | 760 UpdateOutputs(1, true); |
769 observer_.Reset(); | 761 observer_.Reset(); |
770 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); | 762 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS); |
771 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); | 763 EXPECT_EQ(0, observer_.num_changes()); |
772 EXPECT_FALSE( | 764 EXPECT_EQ(1, observer_.num_failures()); |
773 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 765 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE); |
774 EXPECT_FALSE( | 766 EXPECT_EQ(1, observer_.num_changes()); |
775 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); | 767 EXPECT_EQ(1, observer_.num_failures()); |
| 768 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 769 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
776 EXPECT_EQ(1, observer_.num_changes()); | 770 EXPECT_EQ(1, observer_.num_changes()); |
777 EXPECT_EQ(3, observer_.num_failures()); | 771 EXPECT_EQ(3, observer_.num_failures()); |
778 | 772 |
779 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 773 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
780 UpdateOutputs(2, true); | 774 UpdateOutputs(2, true); |
781 observer_.Reset(); | 775 observer_.Reset(); |
782 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); | 776 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS); |
783 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); | 777 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE); |
784 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 778 EXPECT_EQ(0, observer_.num_changes()); |
785 EXPECT_TRUE( | 779 EXPECT_EQ(2, observer_.num_failures()); |
786 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); | 780 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 781 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
787 EXPECT_EQ(2, observer_.num_changes()); | 782 EXPECT_EQ(2, observer_.num_changes()); |
788 EXPECT_EQ(2, observer_.num_failures()); | 783 EXPECT_EQ(2, observer_.num_failures()); |
789 } | 784 } |
790 | 785 |
791 TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForMirroredDisplays) { | 786 TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForMirroredDisplays) { |
792 UpdateOutputs(2, false); | 787 UpdateOutputs(2, false); |
793 configurator_.Init(false); | 788 configurator_.Init(false); |
794 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 789 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
795 configurator_.ForceInitialConfigure(0); | 790 configurator_.ForceInitialConfigure(0); |
796 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 791 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
(...skipping 29 matching lines...) Expand all Loading... |
826 | 821 |
827 // The small mode should be added to the internal output when requesting | 822 // The small mode should be added to the internal output when requesting |
828 // mirrored mode. | 823 // mirrored mode. |
829 UpdateOutputs(2, false); | 824 UpdateOutputs(2, false); |
830 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 825 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
831 configurator_.Init(true /* is_panel_fitting_enabled */); | 826 configurator_.Init(true /* is_panel_fitting_enabled */); |
832 configurator_.ForceInitialConfigure(0); | 827 configurator_.ForceInitialConfigure(0); |
833 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 828 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
834 EXPECT_EQ( | 829 EXPECT_EQ( |
835 JoinActions( | 830 JoinActions( |
836 kGrab, | 831 kInitXRandR, kGrab, |
837 kInitXRandR, | |
838 GetAddOutputModeAction(outputs_[0], &small_mode_).c_str(), | 832 GetAddOutputModeAction(outputs_[0], &small_mode_).c_str(), |
839 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 833 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
840 .c_str(), | 834 .c_str(), |
841 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 835 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
842 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 836 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
843 kForceDPMS, | 837 kForceDPMS, kUngrab, NULL), |
844 kUngrab, | |
845 NULL), | |
846 log_->GetActionsAndClear()); | 838 log_->GetActionsAndClear()); |
847 | 839 |
848 // Both outputs should be using the small mode. | 840 // Both outputs should be using the small mode. |
849 ASSERT_EQ(1, observer_.num_changes()); | 841 ASSERT_EQ(1, observer_.num_changes()); |
850 ASSERT_EQ(static_cast<size_t>(2), observer_.latest_outputs().size()); | 842 ASSERT_EQ(static_cast<size_t>(2), observer_.latest_outputs().size()); |
851 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[0].mirror_mode); | 843 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[0].mirror_mode); |
852 EXPECT_EQ(&small_mode_, | 844 EXPECT_EQ(&small_mode_, |
853 observer_.latest_outputs()[0].display->current_mode()); | 845 observer_.latest_outputs()[0].display->current_mode()); |
854 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[1].mirror_mode); | 846 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[1].mirror_mode); |
855 EXPECT_EQ(&small_mode_, | 847 EXPECT_EQ(&small_mode_, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 | 1019 |
1028 // This test should attempt to configure a mirror mode that will not succeed | 1020 // This test should attempt to configure a mirror mode that will not succeed |
1029 // and should end up in extended mode. | 1021 // and should end up in extended mode. |
1030 native_display_delegate_->set_max_configurable_pixels( | 1022 native_display_delegate_->set_max_configurable_pixels( |
1031 modes[3]->size().GetArea()); | 1023 modes[3]->size().GetArea()); |
1032 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1024 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
1033 UpdateOutputs(2, true); | 1025 UpdateOutputs(2, true); |
1034 | 1026 |
1035 EXPECT_EQ( | 1027 EXPECT_EQ( |
1036 JoinActions( | 1028 JoinActions( |
1037 kGrab, | 1029 kGrab, GetFramebufferAction(modes[0]->size(), &outputs_[0], |
1038 GetFramebufferAction(modes[0]->size(), &outputs_[0], &outputs_[1]) | 1030 &outputs_[1]).c_str(), |
1039 .c_str(), | |
1040 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), | 1031 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), |
| 1032 // Then attempt to configure crtc1 with the first mode. |
| 1033 GetCrtcAction(outputs_[1], modes[0], gfx::Point(0, 0)).c_str(), |
1041 // First mode tried is expected to fail and it will | 1034 // First mode tried is expected to fail and it will |
1042 // retry wil the 4th mode in the list. | 1035 // retry wil the 4th mode in the list. |
1043 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), | 1036 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), |
1044 // Then attempt to configure crtc1 with the first mode. | |
1045 GetCrtcAction(outputs_[1], modes[0], gfx::Point(0, 0)).c_str(), | |
1046 GetCrtcAction(outputs_[1], modes[3], gfx::Point(0, 0)).c_str(), | 1037 GetCrtcAction(outputs_[1], modes[3], gfx::Point(0, 0)).c_str(), |
1047 // Since it was requested to go into mirror mode | 1038 // Since it was requested to go into mirror mode |
1048 // and the configured modes were different, it | 1039 // and the configured modes were different, it |
1049 // should now try and setup a valid configurable | 1040 // should now try and setup a valid configurable |
1050 // extended mode. | 1041 // extended mode. |
1051 GetFramebufferAction( | 1042 GetFramebufferAction( |
1052 gfx::Size(modes[0]->size().width(), | 1043 gfx::Size(modes[0]->size().width(), |
1053 modes[0]->size().height() + modes[0]->size().height() + | 1044 modes[0]->size().height() + modes[0]->size().height() + |
1054 DisplayConfigurator::kVerticalGap), | 1045 DisplayConfigurator::kVerticalGap), |
1055 &outputs_[0], | 1046 &outputs_[0], &outputs_[1]).c_str(), |
1056 &outputs_[1]).c_str(), | |
1057 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), | 1047 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), |
| 1048 GetCrtcAction(outputs_[1], modes[0], |
| 1049 gfx::Point(0, modes[0]->size().height() + |
| 1050 DisplayConfigurator::kVerticalGap)) |
| 1051 .c_str(), |
1058 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), | 1052 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), |
1059 GetCrtcAction(outputs_[1], | 1053 GetCrtcAction(outputs_[1], modes[3], |
1060 modes[0], | 1054 gfx::Point(0, modes[0]->size().height() + |
1061 gfx::Point(0, | 1055 DisplayConfigurator::kVerticalGap)) |
1062 modes[0]->size().height() + | |
1063 DisplayConfigurator::kVerticalGap)) | |
1064 .c_str(), | 1056 .c_str(), |
1065 GetCrtcAction(outputs_[1], | 1057 kUngrab, NULL), |
1066 modes[3], | |
1067 gfx::Point(0, | |
1068 modes[0]->size().height() + | |
1069 DisplayConfigurator::kVerticalGap)) | |
1070 .c_str(), | |
1071 kUngrab, | |
1072 NULL), | |
1073 log_->GetActionsAndClear()); | 1058 log_->GetActionsAndClear()); |
1074 } | 1059 } |
1075 | 1060 |
1076 // Tests that power state requests are saved after failed configuration attempts | 1061 // Tests that power state requests are saved after failed configuration attempts |
1077 // so they can be reused later: http://crosbug.com/p/31571 | 1062 // so they can be reused later: http://crosbug.com/p/31571 |
1078 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { | 1063 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { |
1079 // Start out with two displays in extended mode. | 1064 // Start out with two displays in extended mode. |
1080 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1065 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
1081 configurator_.Init(false); | 1066 configurator_.Init(false); |
1082 configurator_.ForceInitialConfigure(0); | 1067 configurator_.ForceInitialConfigure(0); |
1083 log_->GetActionsAndClear(); | 1068 log_->GetActionsAndClear(); |
| 1069 observer_.Reset(); |
1084 | 1070 |
1085 // Turn off the internal display, simulating docked mode. | 1071 // Turn off the internal display, simulating docked mode. |
1086 EXPECT_TRUE(configurator_.SetDisplayPower( | 1072 configurator_.SetDisplayPower( |
1087 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1073 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
1088 DisplayConfigurator::kSetDisplayPowerNoFlags)); | 1074 DisplayConfigurator::kSetDisplayPowerNoFlags); |
| 1075 EXPECT_EQ(1, observer_.num_changes()); |
| 1076 EXPECT_EQ(0, observer_.num_failures()); |
1089 log_->GetActionsAndClear(); | 1077 log_->GetActionsAndClear(); |
1090 | 1078 |
1091 // Make all subsequent configuration requests fail and try to turn the | 1079 // Make all subsequent configuration requests fail and try to turn the |
1092 // internal display back on. | 1080 // internal display back on. |
1093 native_display_delegate_->set_max_configurable_pixels(1); | 1081 native_display_delegate_->set_max_configurable_pixels(1); |
1094 EXPECT_FALSE(configurator_.SetDisplayPower( | 1082 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
1095 chromeos::DISPLAY_POWER_ALL_ON, | 1083 DisplayConfigurator::kSetDisplayPowerNoFlags); |
1096 DisplayConfigurator::kSetDisplayPowerNoFlags)); | 1084 EXPECT_EQ(1, observer_.num_changes()); |
| 1085 EXPECT_EQ(1, observer_.num_failures()); |
1097 log_->GetActionsAndClear(); | 1086 log_->GetActionsAndClear(); |
1098 | 1087 |
1099 // Simulate the external display getting disconnected and check that the | 1088 // Simulate the external display getting disconnected and check that the |
1100 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather | 1089 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather |
1101 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. | 1090 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. |
1102 native_display_delegate_->set_max_configurable_pixels(0); | 1091 native_display_delegate_->set_max_configurable_pixels(0); |
1103 UpdateOutputs(1, true); | 1092 UpdateOutputs(1, true); |
1104 EXPECT_EQ( | 1093 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), |
1105 JoinActions( | 1094 &outputs_[0], NULL).c_str(), |
1106 kGrab, | 1095 GetCrtcAction(outputs_[0], &small_mode_, |
1107 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1096 gfx::Point(0, 0)).c_str(), |
1108 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1097 kForceDPMS, kUngrab, NULL), |
1109 kUngrab, | 1098 log_->GetActionsAndClear()); |
1110 NULL), | |
1111 log_->GetActionsAndClear()); | |
1112 } | 1099 } |
1113 | 1100 |
1114 // Tests that the SetDisplayPowerState() task posted by HandleResume() doesn't | 1101 // Tests that the SetDisplayPowerState() task posted by HandleResume() doesn't |
1115 // use a stale state if a new state is requested before it runs: | 1102 // use a stale state if a new state is requested before it runs: |
1116 // http://crosbug.com/p/32393 | 1103 // http://crosbug.com/p/32393 |
1117 TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { | 1104 TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { |
1118 // Start out with two displays in mirrored mode. | 1105 // Start out with two displays in mirrored mode. |
1119 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1106 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
1120 configurator_.Init(false); | 1107 configurator_.Init(false); |
1121 configurator_.ForceInitialConfigure(0); | 1108 configurator_.ForceInitialConfigure(0); |
1122 log_->GetActionsAndClear(); | 1109 log_->GetActionsAndClear(); |
| 1110 observer_.Reset(); |
1123 | 1111 |
1124 // Turn off the internal display, simulating docked mode. | 1112 // Turn off the internal display, simulating docked mode. |
1125 EXPECT_TRUE(configurator_.SetDisplayPower( | 1113 configurator_.SetDisplayPower( |
1126 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1114 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
1127 DisplayConfigurator::kSetDisplayPowerNoFlags)); | 1115 DisplayConfigurator::kSetDisplayPowerNoFlags); |
| 1116 EXPECT_EQ(1, observer_.num_changes()); |
| 1117 EXPECT_EQ(0, observer_.num_failures()); |
1128 EXPECT_EQ( | 1118 EXPECT_EQ( |
1129 JoinActions( | 1119 JoinActions( |
1130 kGrab, | 1120 kGrab, |
1131 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 1121 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
1132 .c_str(), | 1122 .c_str(), |
1133 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1123 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
1134 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 1124 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
1135 kForceDPMS, | 1125 kForceDPMS, |
1136 kUngrab, | 1126 kUngrab, |
1137 NULL), | 1127 NULL), |
1138 log_->GetActionsAndClear()); | 1128 log_->GetActionsAndClear()); |
1139 | 1129 |
1140 // Suspend and resume the system. Resuming should post a task to restore the | 1130 // Suspend and resume the system. Resuming should post a task to restore the |
1141 // previous power state, additionally forcing a probe. | 1131 // previous power state, additionally forcing a probe. |
1142 configurator_.SuspendDisplays(); | 1132 configurator_.SuspendDisplays(); |
1143 configurator_.ResumeDisplays(); | 1133 configurator_.ResumeDisplays(); |
1144 | 1134 |
1145 // Before the task runs, exit docked mode. | 1135 // Before the task runs, exit docked mode. |
1146 EXPECT_TRUE(configurator_.SetDisplayPower( | 1136 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
1147 chromeos::DISPLAY_POWER_ALL_ON, | 1137 DisplayConfigurator::kSetDisplayPowerNoFlags); |
1148 DisplayConfigurator::kSetDisplayPowerNoFlags)); | 1138 EXPECT_EQ(2, observer_.num_changes()); |
| 1139 EXPECT_EQ(0, observer_.num_failures()); |
1149 EXPECT_EQ( | 1140 EXPECT_EQ( |
1150 JoinActions( | 1141 JoinActions( |
1151 kGrab, | 1142 kGrab, |
1152 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1143 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
1153 .c_str(), | 1144 .c_str(), |
1154 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1145 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
1155 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1146 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
1156 kForceDPMS, | 1147 kForceDPMS, |
1157 kUngrab, | 1148 kUngrab, |
1158 NULL), | 1149 NULL), |
(...skipping 28 matching lines...) Expand all Loading... |
1187 EXPECT_EQ( | 1178 EXPECT_EQ( |
1188 JoinActions( | 1179 JoinActions( |
1189 kTakeDisplayControl, | 1180 kTakeDisplayControl, |
1190 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1181 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
1191 NULL), | 1182 NULL), |
1192 log_->GetActionsAndClear()); | 1183 log_->GetActionsAndClear()); |
1193 } | 1184 } |
1194 | 1185 |
1195 } // namespace test | 1186 } // namespace test |
1196 } // namespace ui | 1187 } // namespace ui |
OLD | NEW |