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