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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // timeout if one was scheduled. | 419 // timeout if one was scheduled. |
420 void UpdateOutputs(size_t num_outputs, bool send_events) { | 420 void UpdateOutputs(size_t num_outputs, bool send_events) { |
421 ASSERT_LE(num_outputs, arraysize(outputs_)); | 421 ASSERT_LE(num_outputs, arraysize(outputs_)); |
422 std::vector<DisplaySnapshot*> outputs; | 422 std::vector<DisplaySnapshot*> outputs; |
423 for (size_t i = 0; i < num_outputs; ++i) | 423 for (size_t i = 0; i < num_outputs; ++i) |
424 outputs.push_back(&outputs_[i]); | 424 outputs.push_back(&outputs_[i]); |
425 native_display_delegate_->set_outputs(outputs); | 425 native_display_delegate_->set_outputs(outputs); |
426 | 426 |
427 if (send_events) { | 427 if (send_events) { |
428 configurator_.OnConfigurationChanged(); | 428 configurator_.OnConfigurationChanged(); |
429 test_api_.TriggerConfigureTimeout(); | 429 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 // Initializes |configurator_| with a single internal display. | 433 // Initializes |configurator_| with a single internal display. |
434 void InitWithSingleOutput() { | 434 void InitWithSingleOutput() { |
435 UpdateOutputs(1, false); | 435 UpdateOutputs(1, false); |
436 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 436 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
437 configurator_.Init(false); | 437 configurator_.Init(false); |
438 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 438 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
439 configurator_.ForceInitialConfigure(0); | 439 configurator_.ForceInitialConfigure(0); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(); |
849 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 849 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
850 configurator_.ResumeDisplays(); | 850 configurator_.ResumeDisplays(); |
| 851 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
851 EXPECT_EQ( | 852 EXPECT_EQ( |
852 JoinActions( | 853 JoinActions( |
853 kGrab, | 854 kGrab, |
854 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 855 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
855 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 856 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
856 kForceDPMS, | 857 kForceDPMS, |
857 kUngrab, | 858 kUngrab, |
858 NULL), | 859 NULL), |
859 log_->GetActionsAndClear()); | 860 log_->GetActionsAndClear()); |
860 | 861 |
(...skipping 16 matching lines...) Expand all Loading... |
877 kGrab, | 878 kGrab, |
878 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 879 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
879 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 880 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
880 kForceDPMS, | 881 kForceDPMS, |
881 kUngrab, | 882 kUngrab, |
882 kSync, | 883 kSync, |
883 NULL), | 884 NULL), |
884 log_->GetActionsAndClear()); | 885 log_->GetActionsAndClear()); |
885 | 886 |
886 configurator_.ResumeDisplays(); | 887 configurator_.ResumeDisplays(); |
| 888 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
887 EXPECT_EQ( | 889 EXPECT_EQ( |
888 JoinActions( | 890 JoinActions( |
889 kGrab, | 891 kGrab, |
890 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 892 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
891 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 893 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
892 kForceDPMS, | 894 kForceDPMS, |
893 kUngrab, | 895 kUngrab, |
894 NULL), | 896 NULL), |
895 log_->GetActionsAndClear()); | 897 log_->GetActionsAndClear()); |
896 | 898 |
(...skipping 25 matching lines...) Expand all Loading... |
922 log_->GetActionsAndClear()); | 924 log_->GetActionsAndClear()); |
923 | 925 |
924 configurator_.SuspendDisplays(); | 926 configurator_.SuspendDisplays(); |
925 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL), | 927 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL), |
926 log_->GetActionsAndClear()); | 928 log_->GetActionsAndClear()); |
927 | 929 |
928 // If a display is disconnected while suspended, the configurator should | 930 // If a display is disconnected while suspended, the configurator should |
929 // pick up the change. | 931 // pick up the change. |
930 UpdateOutputs(1, false); | 932 UpdateOutputs(1, false); |
931 configurator_.ResumeDisplays(); | 933 configurator_.ResumeDisplays(); |
| 934 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
932 EXPECT_EQ( | 935 EXPECT_EQ( |
933 JoinActions( | 936 JoinActions( |
934 kGrab, | 937 kGrab, |
935 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 938 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
936 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 939 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
937 kUngrab, | 940 kUngrab, |
938 NULL), | 941 NULL), |
939 log_->GetActionsAndClear()); | 942 log_->GetActionsAndClear()); |
940 } | 943 } |
941 | 944 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 gfx::Point(0, | 1301 gfx::Point(0, |
1299 modes[0]->size().height() + | 1302 modes[0]->size().height() + |
1300 DisplayConfigurator::kVerticalGap)) | 1303 DisplayConfigurator::kVerticalGap)) |
1301 .c_str(), | 1304 .c_str(), |
1302 kUngrab, | 1305 kUngrab, |
1303 NULL), | 1306 NULL), |
1304 log_->GetActionsAndClear()); | 1307 log_->GetActionsAndClear()); |
1305 } | 1308 } |
1306 | 1309 |
1307 } // namespace ui | 1310 } // namespace ui |
OLD | NEW |