Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: ui/display/chromeos/display_configurator_unittest.cc

Issue 2427843002: Delay display configuration after waking up from suspend with multi displays (Closed)
Patch Set: Nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 15 matching lines...) Expand all
26 int64_t kDisplayIds[3] = {123, 456, 789}; 26 int64_t kDisplayIds[3] = {123, 456, 789};
27 27
28 std::unique_ptr<ui::DisplayMode> MakeDisplayMode(int width, 28 std::unique_ptr<ui::DisplayMode> MakeDisplayMode(int width,
29 int height, 29 int height,
30 bool is_interlaced, 30 bool is_interlaced,
31 float refresh_rate) { 31 float refresh_rate) {
32 return base::MakeUnique<ui::DisplayMode>(gfx::Size(width, height), 32 return base::MakeUnique<ui::DisplayMode>(gfx::Size(width, height),
33 is_interlaced, refresh_rate); 33 is_interlaced, refresh_rate);
34 } 34 }
35 35
36 enum CallbackResult {
37 CALLBACK_FAILURE,
38 CALLBACK_SUCCESS,
39 CALLBACK_NOT_CALLED,
40 };
41
42 // Expected immediate configurations should be done without any delays.
43 constexpr base::TimeDelta kNoDelay = base::TimeDelta::FromMilliseconds(0);
44
45 // The expected configuration delay when resuming from suspend while in 2+
46 // display mode.
47 constexpr base::TimeDelta kLongDelay = base::TimeDelta::FromMilliseconds(
48 DisplayConfigurator::kResumeConfigureMultiDisplayDelayMs);
49
36 class TestObserver : public DisplayConfigurator::Observer { 50 class TestObserver : public DisplayConfigurator::Observer {
37 public: 51 public:
38 explicit TestObserver(DisplayConfigurator* configurator) 52 explicit TestObserver(DisplayConfigurator* configurator)
39 : configurator_(configurator) { 53 : configurator_(configurator) {
40 Reset(); 54 Reset();
41 configurator_->AddObserver(this); 55 configurator_->AddObserver(this);
42 } 56 }
43 ~TestObserver() override { configurator_->RemoveObserver(this); } 57 ~TestObserver() override { configurator_->RemoveObserver(this); }
44 58
45 int num_changes() const { return num_changes_; } 59 int num_changes() const { return num_changes_; }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 bool SoftwareMirroringEnabled() const override { 136 bool SoftwareMirroringEnabled() const override {
123 return software_mirroring_enabled_; 137 return software_mirroring_enabled_;
124 } 138 }
125 139
126 private: 140 private:
127 bool software_mirroring_enabled_; 141 bool software_mirroring_enabled_;
128 142
129 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); 143 DISALLOW_COPY_AND_ASSIGN(TestMirroringController);
130 }; 144 };
131 145
146 // Abstracts waiting for the display configuration to be completed and getting
147 // the time it took to complete.
148 class ConfigurationWaiter {
149 public:
150 ConfigurationWaiter(DisplayConfigurator::TestApi* test_api)
151 : on_configured_callback_(base::Bind(&ConfigurationWaiter::OnConfigured,
152 base::Unretained(this))),
153 test_api_(test_api),
154 callback_result_(CALLBACK_NOT_CALLED) {}
155
156 ~ConfigurationWaiter() = default;
157
158 const DisplayConfigurator::ConfigurationCallback& on_configuration_callback()
159 const {
160 return on_configured_callback_;
161 }
162
163 CallbackResult callback_result() const { return callback_result_; }
164
165 void Reset() { callback_result_ = CALLBACK_NOT_CALLED; }
166
167 // Simulates waiting for the next configuration. If an async task is pending,
168 // runs it and returns base::TimeDelta(). Otherwise, triggers the
169 // configuration timer and returns its delay. If the timer wasn't running,
170 // returns base::TimeDelta::Max().
171 base::TimeDelta Wait() WARN_UNUSED_RESULT {
172 base::RunLoop().RunUntilIdle();
173 if (callback_result_ != CALLBACK_NOT_CALLED)
174 return base::TimeDelta();
175
176 const base::TimeDelta delay = test_api_->GetConfigureDelay();
177 if (!test_api_->TriggerConfigureTimeout())
178 return base::TimeDelta::Max();
179
180 return delay;
181 }
182
183 private:
184 void OnConfigured(bool status) {
185 CHECK_EQ(callback_result_, CALLBACK_NOT_CALLED);
186 callback_result_ = status ? CALLBACK_SUCCESS : CALLBACK_FAILURE;
187 }
188
189 // Passed with configuration requests to run OnConfigured().
190 const DisplayConfigurator::ConfigurationCallback on_configured_callback_;
191
192 DisplayConfigurator::TestApi* test_api_; // Not owned.
193
194 // The status of the display configuration.
195 CallbackResult callback_result_;
196
197 DISALLOW_COPY_AND_ASSIGN(ConfigurationWaiter);
198 };
199
132 class DisplayConfiguratorTest : public testing::Test { 200 class DisplayConfiguratorTest : public testing::Test {
133 public: 201 public:
134 enum CallbackResult {
135 CALLBACK_FAILURE,
136 CALLBACK_SUCCESS,
137 CALLBACK_NOT_CALLED,
138 };
139
140 DisplayConfiguratorTest() 202 DisplayConfiguratorTest()
141 : small_mode_(gfx::Size(1366, 768), false, 60.0f), 203 : small_mode_(gfx::Size(1366, 768), false, 60.0f),
142 big_mode_(gfx::Size(2560, 1600), false, 60.0f), 204 big_mode_(gfx::Size(2560, 1600), false, 60.0f),
143 observer_(&configurator_), 205 observer_(&configurator_),
144 test_api_(&configurator_), 206 test_api_(&configurator_),
207 config_waiter_(&test_api_),
145 enable_content_protection_status_(0), 208 enable_content_protection_status_(0),
146 enable_content_protection_call_count_(0), 209 enable_content_protection_call_count_(0),
147 query_content_protection_call_count_(0), 210 query_content_protection_call_count_(0),
148 callback_result_(CALLBACK_NOT_CALLED),
149 display_control_result_(CALLBACK_NOT_CALLED) {} 211 display_control_result_(CALLBACK_NOT_CALLED) {}
150 ~DisplayConfiguratorTest() override {} 212 ~DisplayConfiguratorTest() override {}
151 213
152 void SetUp() override { 214 void SetUp() override {
153 log_.reset(new ActionLogger()); 215 log_.reset(new ActionLogger());
154 216
155 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); 217 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get());
156 configurator_.SetDelegateForTesting( 218 configurator_.SetDelegateForTesting(
157 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); 219 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_));
158 220
(...skipping 21 matching lines...) Expand all
180 .SetId(kDisplayIds[2]) 242 .SetId(kDisplayIds[2])
181 .SetNativeMode(small_mode_.Clone()) 243 .SetNativeMode(small_mode_.Clone())
182 .SetCurrentMode(small_mode_.Clone()) 244 .SetCurrentMode(small_mode_.Clone())
183 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) 245 .SetType(DISPLAY_CONNECTION_TYPE_HDMI)
184 .SetIsAspectPerservingScaling(true) 246 .SetIsAspectPerservingScaling(true)
185 .Build(); 247 .Build();
186 248
187 UpdateOutputs(2, false); 249 UpdateOutputs(2, false);
188 } 250 }
189 251
190 void OnConfiguredCallback(bool status) {
191 callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE);
192 }
193
194 void OnDisplayControlUpdated(bool status) { 252 void OnDisplayControlUpdated(bool status) {
195 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); 253 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE);
196 } 254 }
197 255
198 void EnableContentProtectionCallback(bool status) { 256 void EnableContentProtectionCallback(bool status) {
199 enable_content_protection_status_ = status; 257 enable_content_protection_status_ = status;
200 enable_content_protection_call_count_++; 258 enable_content_protection_call_count_++;
201 } 259 }
202 260
203 void QueryContentProtectionCallback( 261 void QueryContentProtectionCallback(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 EXPECT_EQ( 302 EXPECT_EQ(
245 JoinActions( 303 JoinActions(
246 kInitXRandR, kGrab, 304 kInitXRandR, kGrab,
247 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) 305 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
248 .c_str(), 306 .c_str(),
249 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 307 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
250 kForceDPMS, kUngrab, nullptr), 308 kForceDPMS, kUngrab, nullptr),
251 log_->GetActionsAndClear()); 309 log_->GetActionsAndClear());
252 } 310 }
253 311
254 CallbackResult PopCallbackResult() {
255 CallbackResult result = callback_result_;
256 callback_result_ = CALLBACK_NOT_CALLED;
257 return result;
258 }
259
260 CallbackResult PopDisplayControlResult() { 312 CallbackResult PopDisplayControlResult() {
261 CallbackResult result = display_control_result_; 313 CallbackResult result = display_control_result_;
262 display_control_result_ = CALLBACK_NOT_CALLED; 314 display_control_result_ = CALLBACK_NOT_CALLED;
263 return result; 315 return result;
264 } 316 }
265 317
266 base::MessageLoop message_loop_; 318 base::MessageLoop message_loop_;
267 TestStateController state_controller_; 319 TestStateController state_controller_;
268 TestMirroringController mirroring_controller_; 320 TestMirroringController mirroring_controller_;
269 DisplayConfigurator configurator_; 321 DisplayConfigurator configurator_;
270 TestObserver observer_; 322 TestObserver observer_;
271 std::unique_ptr<ActionLogger> log_; 323 std::unique_ptr<ActionLogger> log_;
272 TestNativeDisplayDelegate* native_display_delegate_; // not owned 324 TestNativeDisplayDelegate* native_display_delegate_; // not owned
273 DisplayConfigurator::TestApi test_api_; 325 DisplayConfigurator::TestApi test_api_;
274 326 ConfigurationWaiter config_waiter_;
275 bool enable_content_protection_status_; 327 bool enable_content_protection_status_;
276 int enable_content_protection_call_count_; 328 int enable_content_protection_call_count_;
277 DisplayConfigurator::QueryProtectionResponse 329 DisplayConfigurator::QueryProtectionResponse
278 query_content_protection_response_; 330 query_content_protection_response_;
279 int query_content_protection_call_count_; 331 int query_content_protection_call_count_;
280 332
281 std::unique_ptr<DisplaySnapshot> outputs_[3]; 333 std::unique_ptr<DisplaySnapshot> outputs_[3];
282 334
283 CallbackResult callback_result_;
284 CallbackResult display_control_result_; 335 CallbackResult display_control_result_;
285 336
286 private: 337 private:
287 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); 338 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest);
288 }; 339 };
289 340
290 } // namespace 341 } // namespace
291 342
292 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { 343 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) {
293 std::unique_ptr<ui::DisplaySnapshot> output = 344 std::unique_ptr<ui::DisplaySnapshot> output =
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 701 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
651 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 702 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
652 kUngrab, nullptr), 703 kUngrab, nullptr),
653 log_->GetActionsAndClear()); 704 log_->GetActionsAndClear());
654 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); 705 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
655 EXPECT_EQ(1, observer_.num_changes()); 706 EXPECT_EQ(1, observer_.num_changes());
656 707
657 // Turning off the internal display should switch the external display to 708 // Turning off the internal display should switch the external display to
658 // its native mode. 709 // its native mode.
659 observer_.Reset(); 710 observer_.Reset();
711 config_waiter_.Reset();
660 configurator_.SetDisplayPower( 712 configurator_.SetDisplayPower(
661 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 713 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
662 DisplayConfigurator::kSetDisplayPowerNoFlags, 714 DisplayConfigurator::kSetDisplayPowerNoFlags,
663 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 715 config_waiter_.on_configuration_callback());
664 base::Unretained(this))); 716 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
665 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 717 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
666 EXPECT_EQ( 718 EXPECT_EQ(
667 JoinActions( 719 JoinActions(
668 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(), 720 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(),
669 outputs_[1].get()) 721 outputs_[1].get())
670 .c_str(), 722 .c_str(),
671 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 723 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
672 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), 724 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(),
673 kForceDPMS, kUngrab, nullptr), 725 kForceDPMS, kUngrab, nullptr),
674 log_->GetActionsAndClear()); 726 log_->GetActionsAndClear());
675 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); 727 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state());
676 EXPECT_EQ(1, observer_.num_changes()); 728 EXPECT_EQ(1, observer_.num_changes());
677 729
678 // When all displays are turned off, the framebuffer should switch back 730 // When all displays are turned off, the framebuffer should switch back
679 // to the mirrored size. 731 // to the mirrored size.
680 observer_.Reset(); 732 observer_.Reset();
681 configurator_.SetDisplayPower( 733 config_waiter_.Reset();
682 chromeos::DISPLAY_POWER_ALL_OFF, 734 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
683 DisplayConfigurator::kSetDisplayPowerNoFlags, 735 DisplayConfigurator::kSetDisplayPowerNoFlags,
684 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 736 config_waiter_.on_configuration_callback());
685 base::Unretained(this))); 737 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
686 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 738 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
687 EXPECT_EQ( 739 EXPECT_EQ(
688 JoinActions( 740 JoinActions(
689 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 741 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
690 outputs_[1].get()) 742 outputs_[1].get())
691 .c_str(), 743 .c_str(),
692 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 744 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
693 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(), 745 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(),
694 kUngrab, nullptr), 746 kUngrab, nullptr),
695 log_->GetActionsAndClear()); 747 log_->GetActionsAndClear());
696 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); 748 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state());
697 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); 749 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
698 EXPECT_EQ(1, observer_.num_changes()); 750 EXPECT_EQ(1, observer_.num_changes());
699 751
700 // Turn all displays on and check that mirroring is still used. 752 // Turn all displays on and check that mirroring is still used.
701 observer_.Reset(); 753 observer_.Reset();
702 configurator_.SetDisplayPower( 754 config_waiter_.Reset();
703 chromeos::DISPLAY_POWER_ALL_ON, 755 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
704 DisplayConfigurator::kSetDisplayPowerNoFlags, 756 DisplayConfigurator::kSetDisplayPowerNoFlags,
705 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 757 config_waiter_.on_configuration_callback());
706 base::Unretained(this))); 758 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
707 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 759 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
708 EXPECT_EQ( 760 EXPECT_EQ(
709 JoinActions( 761 JoinActions(
710 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 762 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
711 outputs_[1].get()) 763 outputs_[1].get())
712 .c_str(), 764 .c_str(),
713 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 765 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
714 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 766 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
715 kForceDPMS, kUngrab, nullptr), 767 kForceDPMS, kUngrab, nullptr),
716 log_->GetActionsAndClear()); 768 log_->GetActionsAndClear());
717 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); 769 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state());
(...skipping 29 matching lines...) Expand all
747 kUngrab, nullptr), 799 kUngrab, nullptr),
748 log_->GetActionsAndClear()); 800 log_->GetActionsAndClear());
749 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, 801 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
750 configurator_.display_state()); 802 configurator_.display_state());
751 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); 803 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
752 EXPECT_EQ(1, observer_.num_changes()); 804 EXPECT_EQ(1, observer_.num_changes());
753 805
754 // Turning off the internal display should switch the external display to 806 // Turning off the internal display should switch the external display to
755 // its native mode. 807 // its native mode.
756 observer_.Reset(); 808 observer_.Reset();
809 config_waiter_.Reset();
757 configurator_.SetDisplayPower( 810 configurator_.SetDisplayPower(
758 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 811 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
759 DisplayConfigurator::kSetDisplayPowerNoFlags, 812 DisplayConfigurator::kSetDisplayPowerNoFlags,
760 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 813 config_waiter_.on_configuration_callback());
761 base::Unretained(this))); 814 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
762 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 815 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
763 EXPECT_EQ( 816 EXPECT_EQ(
764 JoinActions( 817 JoinActions(
765 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(), 818 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(),
766 outputs_[1].get()) 819 outputs_[1].get())
767 .c_str(), 820 .c_str(),
768 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 821 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
769 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), 822 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(),
770 kForceDPMS, kUngrab, nullptr), 823 kForceDPMS, kUngrab, nullptr),
771 log_->GetActionsAndClear()); 824 log_->GetActionsAndClear());
772 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); 825 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state());
773 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); 826 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
774 EXPECT_EQ(1, observer_.num_changes()); 827 EXPECT_EQ(1, observer_.num_changes());
775 828
776 // When all displays are turned off, the framebuffer should switch back 829 // When all displays are turned off, the framebuffer should switch back
777 // to the extended + software mirroring. 830 // to the extended + software mirroring.
778 observer_.Reset(); 831 observer_.Reset();
779 configurator_.SetDisplayPower( 832 config_waiter_.Reset();
780 chromeos::DISPLAY_POWER_ALL_OFF, 833 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
781 DisplayConfigurator::kSetDisplayPowerNoFlags, 834 DisplayConfigurator::kSetDisplayPowerNoFlags,
782 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 835 config_waiter_.on_configuration_callback());
783 base::Unretained(this))); 836 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
784 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 837 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
785 EXPECT_EQ( 838 EXPECT_EQ(
786 JoinActions( 839 JoinActions(
787 kGrab, 840 kGrab,
788 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 841 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
789 outputs_[0].get(), outputs_[1].get()) 842 outputs_[0].get(), outputs_[1].get())
790 .c_str(), 843 .c_str(),
791 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 844 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
792 GetCrtcAction(*outputs_[1], nullptr, 845 GetCrtcAction(*outputs_[1], nullptr,
793 gfx::Point(0, small_mode_.size().height() + 846 gfx::Point(0, small_mode_.size().height() +
794 DisplayConfigurator::kVerticalGap)) 847 DisplayConfigurator::kVerticalGap))
795 .c_str(), 848 .c_str(),
796 kUngrab, nullptr), 849 kUngrab, nullptr),
797 log_->GetActionsAndClear()); 850 log_->GetActionsAndClear());
798 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, 851 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
799 configurator_.display_state()); 852 configurator_.display_state());
800 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); 853 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
801 EXPECT_EQ(1, observer_.num_changes()); 854 EXPECT_EQ(1, observer_.num_changes());
802 855
803 // Turn all displays on and check that mirroring is still used. 856 // Turn all displays on and check that mirroring is still used.
804 observer_.Reset(); 857 observer_.Reset();
805 configurator_.SetDisplayPower( 858 config_waiter_.Reset();
806 chromeos::DISPLAY_POWER_ALL_ON, 859 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
807 DisplayConfigurator::kSetDisplayPowerNoFlags, 860 DisplayConfigurator::kSetDisplayPowerNoFlags,
808 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 861 config_waiter_.on_configuration_callback());
809 base::Unretained(this))); 862 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
810 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 863 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
811 EXPECT_EQ( 864 EXPECT_EQ(
812 JoinActions( 865 JoinActions(
813 kGrab, 866 kGrab,
814 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 867 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
815 outputs_[0].get(), outputs_[1].get()) 868 outputs_[0].get(), outputs_[1].get())
816 .c_str(), 869 .c_str(),
817 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 870 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
818 GetCrtcAction(*outputs_[1], &big_mode_, 871 GetCrtcAction(*outputs_[1], &big_mode_,
819 gfx::Point(0, small_mode_.size().height() + 872 gfx::Point(0, small_mode_.size().height() +
820 DisplayConfigurator::kVerticalGap)) 873 DisplayConfigurator::kVerticalGap))
821 .c_str(), 874 .c_str(),
822 kForceDPMS, kUngrab, nullptr), 875 kForceDPMS, kUngrab, nullptr),
823 log_->GetActionsAndClear()); 876 log_->GetActionsAndClear());
824 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, 877 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
825 configurator_.display_state()); 878 configurator_.display_state());
826 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); 879 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
827 EXPECT_EQ(1, observer_.num_changes()); 880 EXPECT_EQ(1, observer_.num_changes());
828 } 881 }
829 882
830 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { 883 TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
831 InitWithSingleOutput(); 884 InitWithSingleOutput();
832 885
833 // No preparation is needed before suspending when the display is already 886 // No preparation is needed before suspending when the display is already
834 // on. The configurator should still reprobe on resume in case a display 887 // on. The configurator should still reprobe on resume in case a display
835 // was connected while suspended. 888 // was connected while suspended.
836 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); 889 const gfx::Size framebuffer_size = configurator_.framebuffer_size();
837 DCHECK(!framebuffer_size.IsEmpty()); 890 DCHECK(!framebuffer_size.IsEmpty());
838 configurator_.SuspendDisplays(base::Bind( 891 config_waiter_.Reset();
839 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); 892 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
840 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 893 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
894 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
841 EXPECT_EQ(framebuffer_size.ToString(), 895 EXPECT_EQ(framebuffer_size.ToString(),
842 configurator_.framebuffer_size().ToString()); 896 configurator_.framebuffer_size().ToString());
843 EXPECT_EQ(JoinActions( 897 EXPECT_EQ(JoinActions(
844 kGrab, GetFramebufferAction(small_mode_.size(), 898 kGrab, GetFramebufferAction(small_mode_.size(),
845 outputs_[0].get(), nullptr) 899 outputs_[0].get(), nullptr)
846 .c_str(), 900 .c_str(),
847 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 901 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
848 kUngrab, kSync, nullptr), 902 kUngrab, kSync, nullptr),
849 log_->GetActionsAndClear()); 903 log_->GetActionsAndClear());
904
905 // No resume delay in single display mode.
906 config_waiter_.Reset();
850 configurator_.ResumeDisplays(); 907 configurator_.ResumeDisplays();
908 // The timer should not be running.
909 EXPECT_EQ(base::TimeDelta::Max(), config_waiter_.Wait());
851 EXPECT_EQ( 910 EXPECT_EQ(
852 JoinActions( 911 JoinActions(
853 kGrab, 912 kGrab,
854 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) 913 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
855 .c_str(), 914 .c_str(),
856 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 915 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
857 kForceDPMS, kUngrab, nullptr), 916 kForceDPMS, kUngrab, nullptr),
858 log_->GetActionsAndClear()); 917 log_->GetActionsAndClear());
859 918
860 // Now turn the display off before suspending and check that the 919 // Now turn the display off before suspending and check that the
861 // configurator turns it back on and syncs with the server. 920 // configurator turns it back on and syncs with the server.
862 configurator_.SetDisplayPower( 921 config_waiter_.Reset();
863 chromeos::DISPLAY_POWER_ALL_OFF, 922 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
864 DisplayConfigurator::kSetDisplayPowerNoFlags, 923 DisplayConfigurator::kSetDisplayPowerNoFlags,
865 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 924 config_waiter_.on_configuration_callback());
866 base::Unretained(this))); 925 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
867 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 926 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
868 EXPECT_EQ(JoinActions( 927 EXPECT_EQ(JoinActions(
869 kGrab, GetFramebufferAction(small_mode_.size(), 928 kGrab, GetFramebufferAction(small_mode_.size(),
870 outputs_[0].get(), nullptr) 929 outputs_[0].get(), nullptr)
871 .c_str(), 930 .c_str(),
872 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 931 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
873 kUngrab, nullptr), 932 kUngrab, nullptr),
874 log_->GetActionsAndClear()); 933 log_->GetActionsAndClear());
875 934
876 configurator_.SuspendDisplays(base::Bind( 935 config_waiter_.Reset();
877 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); 936 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
878 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 937 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
938 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
879 EXPECT_EQ(kSync, log_->GetActionsAndClear()); 939 EXPECT_EQ(kSync, log_->GetActionsAndClear());
880 940
941 config_waiter_.Reset();
881 configurator_.ResumeDisplays(); 942 configurator_.ResumeDisplays();
943 // The timer should not be running.
944 EXPECT_EQ(base::TimeDelta::Max(), config_waiter_.Wait());
882 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 945 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
883 946
884 configurator_.SetDisplayPower( 947 config_waiter_.Reset();
885 chromeos::DISPLAY_POWER_ALL_ON, 948 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
886 DisplayConfigurator::kSetDisplayPowerNoFlags, 949 DisplayConfigurator::kSetDisplayPowerNoFlags,
887 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 950 config_waiter_.on_configuration_callback());
888 base::Unretained(this))); 951 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
952 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
889 EXPECT_EQ( 953 EXPECT_EQ(
890 JoinActions( 954 JoinActions(
891 kGrab, 955 kGrab,
892 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) 956 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
893 .c_str(), 957 .c_str(),
894 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 958 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
895 kForceDPMS, kUngrab, nullptr), 959 kForceDPMS, kUngrab, nullptr),
896 log_->GetActionsAndClear()); 960 log_->GetActionsAndClear());
897 961
898 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); 962 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
899 UpdateOutputs(2, true); 963 UpdateOutputs(2, true);
900 EXPECT_EQ( 964 EXPECT_EQ(
901 JoinActions( 965 JoinActions(
902 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 966 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
903 outputs_[1].get()) 967 outputs_[1].get())
904 .c_str(), 968 .c_str(),
905 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 969 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
906 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 970 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
907 kUngrab, nullptr), 971 kUngrab, nullptr),
908 log_->GetActionsAndClear()); 972 log_->GetActionsAndClear());
909 973
910 configurator_.SetDisplayPower( 974 config_waiter_.Reset();
911 chromeos::DISPLAY_POWER_ALL_OFF, 975 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
912 DisplayConfigurator::kSetDisplayPowerNoFlags, 976 DisplayConfigurator::kSetDisplayPowerNoFlags,
913 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 977 config_waiter_.on_configuration_callback());
914 base::Unretained(this))); 978 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
915 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 979 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
980 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state());
916 EXPECT_EQ( 981 EXPECT_EQ(
917 JoinActions( 982 JoinActions(
918 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 983 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
919 outputs_[1].get()) 984 outputs_[1].get())
920 .c_str(), 985 .c_str(),
921 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 986 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
922 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(), 987 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(),
923 kUngrab, nullptr), 988 kUngrab, nullptr),
924 log_->GetActionsAndClear()); 989 log_->GetActionsAndClear());
925 990
926 configurator_.SuspendDisplays(base::Bind( 991 // No delay in suspend.
927 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); 992 config_waiter_.Reset();
928 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 993 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
994 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
995 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
996 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF,
997 configurator_.current_power_state());
998 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state());
929 EXPECT_EQ(kSync, log_->GetActionsAndClear()); 999 EXPECT_EQ(kSync, log_->GetActionsAndClear());
930 1000
931 // If a display is disconnected while suspended, the configurator should 1001 // If a display is disconnected while suspended, the configurator should
932 // pick up the change and only turn on the internal display. 1002 // pick up the change and only turn on the internal display. The should be
1003 // a longer configuration delay when we set the displays back to on.
933 UpdateOutputs(1, false); 1004 UpdateOutputs(1, false);
1005 config_waiter_.Reset();
934 configurator_.ResumeDisplays(); 1006 configurator_.ResumeDisplays();
1007 // Since we were in dual display mirror mode before suspend, the timer should
1008 // be running with kMinLongDelayMs.
1009 EXPECT_EQ(kLongDelay, test_api_.GetConfigureDelay());
935 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1010 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
936 1011
937 configurator_.SetDisplayPower( 1012 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
938 chromeos::DISPLAY_POWER_ALL_ON, 1013 DisplayConfigurator::kSetDisplayPowerNoFlags,
939 DisplayConfigurator::kSetDisplayPowerNoFlags, 1014 config_waiter_.on_configuration_callback());
940 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1015 EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result());
941 base::Unretained(this))); 1016 EXPECT_EQ(kLongDelay, config_waiter_.Wait());
1017 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
942 EXPECT_EQ( 1018 EXPECT_EQ(
943 JoinActions( 1019 JoinActions(
944 kGrab, 1020 kGrab,
945 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) 1021 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
946 .c_str(), 1022 .c_str(),
947 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1023 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
948 kForceDPMS, kUngrab, nullptr), 1024 kForceDPMS, kUngrab, nullptr),
949 log_->GetActionsAndClear()); 1025 log_->GetActionsAndClear());
950 } 1026 }
951 1027
952 TEST_F(DisplayConfiguratorTest, Headless) { 1028 TEST_F(DisplayConfiguratorTest, Headless) {
953 UpdateOutputs(0, false); 1029 UpdateOutputs(0, false);
954 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1030 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
955 Init(false); 1031 Init(false);
956 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1032 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
957 configurator_.ForceInitialConfigure(0); 1033 configurator_.ForceInitialConfigure(0);
958 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, nullptr), 1034 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, nullptr),
959 log_->GetActionsAndClear()); 1035 log_->GetActionsAndClear());
960 1036
961 // Not much should happen when the display power state is changed while 1037 // Not much should happen when the display power state is changed while
962 // no displays are connected. 1038 // no displays are connected.
963 configurator_.SetDisplayPower( 1039 config_waiter_.Reset();
964 chromeos::DISPLAY_POWER_ALL_OFF, 1040 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
965 DisplayConfigurator::kSetDisplayPowerNoFlags, 1041 DisplayConfigurator::kSetDisplayPowerNoFlags,
966 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1042 config_waiter_.on_configuration_callback());
967 base::Unretained(this))); 1043 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
968 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1044 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
969 EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_->GetActionsAndClear()); 1045 EXPECT_EQ(JoinActions(kGrab, kUngrab, nullptr), log_->GetActionsAndClear());
970 configurator_.SetDisplayPower( 1046 config_waiter_.Reset();
971 chromeos::DISPLAY_POWER_ALL_ON, 1047 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
972 DisplayConfigurator::kSetDisplayPowerNoFlags, 1048 DisplayConfigurator::kSetDisplayPowerNoFlags,
973 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1049 config_waiter_.on_configuration_callback());
974 base::Unretained(this))); 1050 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
975 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1051 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
976 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, nullptr), 1052 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, nullptr),
977 log_->GetActionsAndClear()); 1053 log_->GetActionsAndClear());
978 1054
979 // Connect an external display and check that it's configured correctly. 1055 // Connect an external display and check that it's configured correctly.
980 outputs_[0] = display::FakeDisplaySnapshot::Builder() 1056 outputs_[0] = display::FakeDisplaySnapshot::Builder()
981 .SetId(kDisplayIds[0]) 1057 .SetId(kDisplayIds[0])
982 .SetNativeMode(big_mode_.Clone()) 1058 .SetNativeMode(big_mode_.Clone())
983 .SetCurrentMode(big_mode_.Clone()) 1059 .SetCurrentMode(big_mode_.Clone())
984 .AddMode(small_mode_.Clone()) 1060 .AddMode(small_mode_.Clone())
985 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) 1061 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL)
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 log_->GetActionsAndClear()); 1285 log_->GetActionsAndClear());
1210 } 1286 }
1211 1287
1212 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { 1288 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) {
1213 InitWithSingleOutput(); 1289 InitWithSingleOutput();
1214 1290
1215 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() 1291 // The DisplayConfigurator may occasionally receive OnConfigurationChanged()
1216 // after the displays have been suspended. This event should be ignored since 1292 // after the displays have been suspended. This event should be ignored since
1217 // the DisplayConfigurator will force a probe and reconfiguration of displays 1293 // the DisplayConfigurator will force a probe and reconfiguration of displays
1218 // at resume time. 1294 // at resume time.
1219 configurator_.SuspendDisplays(base::Bind( 1295 config_waiter_.Reset();
1220 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); 1296 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
1221 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1297 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1298 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1222 EXPECT_EQ(JoinActions( 1299 EXPECT_EQ(JoinActions(
1223 kGrab, GetFramebufferAction(small_mode_.size(), 1300 kGrab, GetFramebufferAction(small_mode_.size(),
1224 outputs_[0].get(), nullptr) 1301 outputs_[0].get(), nullptr)
1225 .c_str(), 1302 .c_str(),
1226 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1303 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1227 kUngrab, kSync, nullptr), 1304 kUngrab, kSync, nullptr),
1228 log_->GetActionsAndClear()); 1305 log_->GetActionsAndClear());
1229 1306
1230 // The configuration timer should not be started when the displays 1307 // The configuration timer should not be started when the displays
1231 // are suspended. 1308 // are suspended.
1232 configurator_.OnConfigurationChanged(); 1309 configurator_.OnConfigurationChanged();
1233 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); 1310 EXPECT_FALSE(test_api_.TriggerConfigureTimeout());
1234 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1311 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1235 1312
1236 // Calls to SetDisplayPower should do nothing if the power state doesn't 1313 // Calls to SetDisplayPower should do nothing if the power state doesn't
1237 // change. 1314 // change.
1238 configurator_.SetDisplayPower( 1315 config_waiter_.Reset();
1239 chromeos::DISPLAY_POWER_ALL_OFF, 1316 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
1240 DisplayConfigurator::kSetDisplayPowerNoFlags, 1317 DisplayConfigurator::kSetDisplayPowerNoFlags,
1241 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1318 config_waiter_.on_configuration_callback());
1242 base::Unretained(this))); 1319 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1243 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1320 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1244 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1321 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1245 configurator_.SetDisplayPower( 1322 config_waiter_.Reset();
1246 chromeos::DISPLAY_POWER_ALL_ON, 1323 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
1247 DisplayConfigurator::kSetDisplayPowerNoFlags, 1324 DisplayConfigurator::kSetDisplayPowerNoFlags,
1248 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1325 config_waiter_.on_configuration_callback());
1249 base::Unretained(this))); 1326 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1250 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1327 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1251 EXPECT_EQ( 1328 EXPECT_EQ(
1252 JoinActions( 1329 JoinActions(
1253 kGrab, 1330 kGrab,
1254 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) 1331 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
1255 .c_str(), 1332 .c_str(),
1256 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1333 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1257 kForceDPMS, kUngrab, nullptr), 1334 kForceDPMS, kUngrab, nullptr),
1258 log_->GetActionsAndClear()); 1335 log_->GetActionsAndClear());
1259 1336
1260 UpdateOutputs(2, false); 1337 UpdateOutputs(2, false);
1261 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); 1338 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
1262 EXPECT_EQ( 1339 EXPECT_EQ(
1263 JoinActions( 1340 JoinActions(
1264 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 1341 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
1265 outputs_[1].get()) 1342 outputs_[1].get())
1266 .c_str(), 1343 .c_str(),
1267 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1344 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1268 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 1345 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
1269 kUngrab, nullptr), 1346 kUngrab, nullptr),
1270 log_->GetActionsAndClear()); 1347 log_->GetActionsAndClear());
1271 1348
1272 // The DisplayConfigurator should do nothing at resume time if there is no 1349 // The DisplayConfigurator should do nothing at resume time if there is no
1273 // state change. 1350 // state change.
1351 config_waiter_.Reset();
1274 UpdateOutputs(1, false); 1352 UpdateOutputs(1, false);
1275 configurator_.ResumeDisplays(); 1353 configurator_.ResumeDisplays();
1276 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1354 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1277 1355
1278 // If a configuration task is pending when the displays are suspended, that 1356 // If a configuration task is pending when the displays are suspended, that
1279 // task should not run either and the timer should be stopped. The displays 1357 // task should not run either and the timer should be stopped. The displays
1280 // should be turned off by suspend. 1358 // should be turned off by suspend.
1281 configurator_.OnConfigurationChanged(); 1359 configurator_.OnConfigurationChanged();
1282 configurator_.SuspendDisplays(base::Bind( 1360 config_waiter_.Reset();
1283 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); 1361 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
1284 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1362 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1363 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1285 EXPECT_EQ(JoinActions( 1364 EXPECT_EQ(JoinActions(
1286 kGrab, GetFramebufferAction(small_mode_.size(), 1365 kGrab, GetFramebufferAction(small_mode_.size(),
1287 outputs_[0].get(), nullptr) 1366 outputs_[0].get(), nullptr)
1288 .c_str(), 1367 .c_str(),
1289 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1368 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1290 kUngrab, kSync, nullptr), 1369 kUngrab, kSync, nullptr),
1291 log_->GetActionsAndClear()); 1370 log_->GetActionsAndClear());
1292
1293 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); 1371 EXPECT_FALSE(test_api_.TriggerConfigureTimeout());
1294 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1372 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1295 1373
1374 config_waiter_.Reset();
1296 configurator_.ResumeDisplays(); 1375 configurator_.ResumeDisplays();
1376 // The timer should not be running.
1377 EXPECT_EQ(base::TimeDelta::Max(), config_waiter_.Wait());
1297 EXPECT_EQ( 1378 EXPECT_EQ(
1298 JoinActions( 1379 JoinActions(
1299 kGrab, 1380 kGrab,
1300 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) 1381 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
1301 .c_str(), 1382 .c_str(),
1302 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1383 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1303 kForceDPMS, kUngrab, nullptr), 1384 kForceDPMS, kUngrab, nullptr),
1304 log_->GetActionsAndClear()); 1385 log_->GetActionsAndClear());
1305 } 1386 }
1306 1387
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 // so they can be reused later: http://crosbug.com/p/31571 1598 // so they can be reused later: http://crosbug.com/p/31571
1518 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { 1599 TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) {
1519 // Start out with two displays in extended mode. 1600 // Start out with two displays in extended mode.
1520 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); 1601 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
1521 Init(false); 1602 Init(false);
1522 configurator_.ForceInitialConfigure(0); 1603 configurator_.ForceInitialConfigure(0);
1523 log_->GetActionsAndClear(); 1604 log_->GetActionsAndClear();
1524 observer_.Reset(); 1605 observer_.Reset();
1525 1606
1526 // Turn off the internal display, simulating docked mode. 1607 // Turn off the internal display, simulating docked mode.
1608 config_waiter_.Reset();
1527 configurator_.SetDisplayPower( 1609 configurator_.SetDisplayPower(
1528 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 1610 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
1529 DisplayConfigurator::kSetDisplayPowerNoFlags, 1611 DisplayConfigurator::kSetDisplayPowerNoFlags,
1530 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1612 config_waiter_.on_configuration_callback());
1531 base::Unretained(this))); 1613 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1532 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1614 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1533 EXPECT_EQ(1, observer_.num_changes()); 1615 EXPECT_EQ(1, observer_.num_changes());
1534 EXPECT_EQ(0, observer_.num_failures()); 1616 EXPECT_EQ(0, observer_.num_failures());
1535 log_->GetActionsAndClear(); 1617 log_->GetActionsAndClear();
1536 1618
1537 // Make all subsequent configuration requests fail and try to turn the 1619 // Make all subsequent configuration requests fail and try to turn the
1538 // internal display back on. 1620 // internal display back on.
1621 config_waiter_.Reset();
1539 native_display_delegate_->set_max_configurable_pixels(1); 1622 native_display_delegate_->set_max_configurable_pixels(1);
1540 configurator_.SetDisplayPower( 1623 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
1541 chromeos::DISPLAY_POWER_ALL_ON, 1624 DisplayConfigurator::kSetDisplayPowerNoFlags,
1542 DisplayConfigurator::kSetDisplayPowerNoFlags, 1625 config_waiter_.on_configuration_callback());
1543 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1626 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1544 base::Unretained(this))); 1627 EXPECT_EQ(CALLBACK_FAILURE, config_waiter_.callback_result());
1545 EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult());
1546 EXPECT_EQ(1, observer_.num_changes()); 1628 EXPECT_EQ(1, observer_.num_changes());
1547 EXPECT_EQ(1, observer_.num_failures()); 1629 EXPECT_EQ(1, observer_.num_failures());
1548 log_->GetActionsAndClear(); 1630 log_->GetActionsAndClear();
1549 1631
1550 // Simulate the external display getting disconnected and check that the 1632 // Simulate the external display getting disconnected and check that the
1551 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather 1633 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather
1552 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. 1634 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state.
1553 native_display_delegate_->set_max_configurable_pixels(0); 1635 native_display_delegate_->set_max_configurable_pixels(0);
1554 UpdateOutputs(1, true); 1636 UpdateOutputs(1, true);
1555 EXPECT_EQ( 1637 EXPECT_EQ(
(...skipping 14 matching lines...) Expand all
1570 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); 1652 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
1571 Init(false); 1653 Init(false);
1572 configurator_.ForceInitialConfigure(0); 1654 configurator_.ForceInitialConfigure(0);
1573 log_->GetActionsAndClear(); 1655 log_->GetActionsAndClear();
1574 observer_.Reset(); 1656 observer_.Reset();
1575 1657
1576 // Turn off the internal display, simulating docked mode. 1658 // Turn off the internal display, simulating docked mode.
1577 configurator_.SetDisplayPower( 1659 configurator_.SetDisplayPower(
1578 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 1660 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
1579 DisplayConfigurator::kSetDisplayPowerNoFlags, 1661 DisplayConfigurator::kSetDisplayPowerNoFlags,
1580 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1662 config_waiter_.on_configuration_callback());
1581 base::Unretained(this))); 1663 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1582 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1664 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1583 EXPECT_EQ(1, observer_.num_changes()); 1665 EXPECT_EQ(1, observer_.num_changes());
1584 EXPECT_EQ(0, observer_.num_failures()); 1666 EXPECT_EQ(0, observer_.num_failures());
1585 EXPECT_EQ( 1667 EXPECT_EQ(
1586 JoinActions( 1668 JoinActions(
1587 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(), 1669 kGrab, GetFramebufferAction(big_mode_.size(), outputs_[0].get(),
1588 outputs_[1].get()) 1670 outputs_[1].get())
1589 .c_str(), 1671 .c_str(),
1590 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1672 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1591 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), 1673 GetCrtcAction(*outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(),
1592 kForceDPMS, kUngrab, nullptr), 1674 kForceDPMS, kUngrab, nullptr),
1593 log_->GetActionsAndClear()); 1675 log_->GetActionsAndClear());
1594 1676
1595 // Suspend and resume the system. Resuming should restore the previous power 1677 // Suspend and resume the system. Resuming should restore the previous power
1596 // state and force a probe. Suspend should turn off the displays since an 1678 // state and force a probe. Suspend should turn off the displays since an
1597 // external monitor is connected. 1679 // external monitor is connected.
1598 configurator_.SuspendDisplays(base::Bind( 1680 config_waiter_.Reset();
1599 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); 1681 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
1600 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1682 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1683 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1601 EXPECT_EQ(2, observer_.num_changes()); 1684 EXPECT_EQ(2, observer_.num_changes());
1602 EXPECT_EQ( 1685 EXPECT_EQ(
1603 JoinActions( 1686 JoinActions(
1604 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 1687 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
1605 outputs_[1].get()) 1688 outputs_[1].get())
1606 .c_str(), 1689 .c_str(),
1607 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1690 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1608 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(), 1691 GetCrtcAction(*outputs_[1], nullptr, gfx::Point(0, 0)).c_str(),
1609 kUngrab, kSync, nullptr), 1692 kUngrab, kSync, nullptr),
1610 log_->GetActionsAndClear()); 1693 log_->GetActionsAndClear());
1611 1694
1612 // Before the task runs, exit docked mode. 1695 // Before the task runs, exit docked mode.
1613 configurator_.SetDisplayPower( 1696 config_waiter_.Reset();
1614 chromeos::DISPLAY_POWER_ALL_ON, 1697 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
1615 DisplayConfigurator::kSetDisplayPowerNoFlags, 1698 DisplayConfigurator::kSetDisplayPowerNoFlags,
1616 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1699 config_waiter_.on_configuration_callback());
1617 base::Unretained(this))); 1700 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1618 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1701 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1619 EXPECT_EQ(3, observer_.num_changes()); 1702 EXPECT_EQ(3, observer_.num_changes());
1620 EXPECT_EQ(0, observer_.num_failures()); 1703 EXPECT_EQ(0, observer_.num_failures());
1621 EXPECT_EQ( 1704 EXPECT_EQ(
1622 JoinActions( 1705 JoinActions(
1623 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(), 1706 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
1624 outputs_[1].get()) 1707 outputs_[1].get())
1625 .c_str(), 1708 .c_str(),
1626 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1709 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1627 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 1710 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
1628 kForceDPMS, kUngrab, nullptr), 1711 kForceDPMS, kUngrab, nullptr),
1629 log_->GetActionsAndClear()); 1712 log_->GetActionsAndClear());
1630 1713
1631 // Check that the display states are not changed after resuming. 1714 // Check that the display states are not changed after resuming.
1715 config_waiter_.Reset();
1716 // Since we are in dual display mode, a configuration task is scheduled after
1717 // kMinLongDelayMs delay.
1632 configurator_.ResumeDisplays(); 1718 configurator_.ResumeDisplays();
1719 EXPECT_EQ(kLongDelay, test_api_.GetConfigureDelay());
1720 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
1721 configurator_.current_power_state());
1633 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1722 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1723 // Now trigger that delayed configuration.
1724 EXPECT_EQ(kLongDelay, config_waiter_.Wait());
1725 EXPECT_EQ(
1726 JoinActions(
1727 kGrab, GetFramebufferAction(small_mode_.size(), outputs_[0].get(),
1728 outputs_[1].get())
1729 .c_str(),
1730 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1731 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
1732 kUngrab, nullptr),
1733 log_->GetActionsAndClear());
1634 } 1734 }
1635 1735
1636 TEST_F(DisplayConfiguratorTest, ExternalControl) { 1736 TEST_F(DisplayConfiguratorTest, ExternalControl) {
1637 InitWithSingleOutput(); 1737 InitWithSingleOutput();
1638 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); 1738 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE);
1639 configurator_.RelinquishControl( 1739 configurator_.RelinquishControl(
1640 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, 1740 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated,
1641 base::Unretained(this))); 1741 base::Unretained(this)));
1642 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); 1742 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult());
1643 EXPECT_EQ(JoinActions(kRelinquishDisplayControl, nullptr), 1743 EXPECT_EQ(JoinActions(kRelinquishDisplayControl, nullptr),
(...skipping 16 matching lines...) Expand all
1660 SetDisplayPowerWhilePendingConfigurationTaskRunning) { 1760 SetDisplayPowerWhilePendingConfigurationTaskRunning) {
1661 // Start out with two displays in extended mode. 1761 // Start out with two displays in extended mode.
1662 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); 1762 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
1663 Init(false); 1763 Init(false);
1664 configurator_.ForceInitialConfigure(0); 1764 configurator_.ForceInitialConfigure(0);
1665 log_->GetActionsAndClear(); 1765 log_->GetActionsAndClear();
1666 observer_.Reset(); 1766 observer_.Reset();
1667 1767
1668 native_display_delegate_->set_run_async(true); 1768 native_display_delegate_->set_run_async(true);
1669 1769
1670 configurator_.SetDisplayPower( 1770 config_waiter_.Reset();
1671 chromeos::DISPLAY_POWER_ALL_OFF, 1771 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
1672 DisplayConfigurator::kSetDisplayPowerNoFlags, 1772 DisplayConfigurator::kSetDisplayPowerNoFlags,
1673 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1773 config_waiter_.on_configuration_callback());
1674 base::Unretained(this))); 1774 EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result());
1675 1775
1676 configurator_.SetDisplayPower( 1776 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
1677 chromeos::DISPLAY_POWER_ALL_ON, 1777 DisplayConfigurator::kSetDisplayPowerNoFlags,
1678 DisplayConfigurator::kSetDisplayPowerNoFlags, 1778 config_waiter_.on_configuration_callback());
1679 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
1680 base::Unretained(this)));
1681 1779
1682 EXPECT_EQ(CALLBACK_NOT_CALLED, PopCallbackResult()); 1780 EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result());
1683 base::RunLoop().RunUntilIdle(); 1781 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1684 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1782 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1685 EXPECT_EQ(1, observer_.num_changes()); 1783 EXPECT_EQ(1, observer_.num_changes());
1686 EXPECT_EQ(0, observer_.num_failures()); 1784 EXPECT_EQ(0, observer_.num_failures());
1687 1785
1688 const int kDualHeight = small_mode_.size().height() + 1786 const int kDualHeight = small_mode_.size().height() +
1689 DisplayConfigurator::kVerticalGap + 1787 DisplayConfigurator::kVerticalGap +
1690 big_mode_.size().height(); 1788 big_mode_.size().height();
1691 EXPECT_EQ( 1789 EXPECT_EQ(
1692 JoinActions( 1790 JoinActions(
1693 kGrab, 1791 kGrab,
1694 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 1792 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
1695 outputs_[0].get(), outputs_[1].get()) 1793 outputs_[0].get(), outputs_[1].get())
1696 .c_str(), 1794 .c_str(),
1697 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1795 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1698 GetCrtcAction(*outputs_[1], nullptr, 1796 GetCrtcAction(*outputs_[1], nullptr,
1699 gfx::Point(0, small_mode_.size().height() + 1797 gfx::Point(0, small_mode_.size().height() +
1700 DisplayConfigurator::kVerticalGap)) 1798 DisplayConfigurator::kVerticalGap))
1701 .c_str(), 1799 .c_str(),
1702 kUngrab, nullptr), 1800 kUngrab, nullptr),
1703 log_->GetActionsAndClear()); 1801 log_->GetActionsAndClear());
1704 1802
1705 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); 1803 config_waiter_.Reset();
1706 base::RunLoop().RunUntilIdle(); 1804 EXPECT_EQ(
1707 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); 1805 base::TimeDelta::FromMilliseconds(DisplayConfigurator::kConfigureDelayMs),
1806 config_waiter_.Wait());
1807 EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result());
1808 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1809 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1708 EXPECT_EQ(2, observer_.num_changes()); 1810 EXPECT_EQ(2, observer_.num_changes());
1709 EXPECT_EQ(0, observer_.num_failures()); 1811 EXPECT_EQ(0, observer_.num_failures());
1710 1812
1711 EXPECT_EQ( 1813 EXPECT_EQ(
1712 JoinActions( 1814 JoinActions(
1713 kGrab, 1815 kGrab,
1714 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 1816 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
1715 outputs_[0].get(), outputs_[1].get()) 1817 outputs_[0].get(), outputs_[1].get())
1716 .c_str(), 1818 .c_str(),
1717 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1819 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
(...skipping 10 matching lines...) Expand all
1728 // Start out with two displays in extended mode. 1830 // Start out with two displays in extended mode.
1729 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); 1831 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
1730 Init(false); 1832 Init(false);
1731 configurator_.ForceInitialConfigure(0); 1833 configurator_.ForceInitialConfigure(0);
1732 log_->GetActionsAndClear(); 1834 log_->GetActionsAndClear();
1733 observer_.Reset(); 1835 observer_.Reset();
1734 1836
1735 // Fail display configuration. 1837 // Fail display configuration.
1736 native_display_delegate_->set_max_configurable_pixels(-1); 1838 native_display_delegate_->set_max_configurable_pixels(-1);
1737 1839
1738 configurator_.SetDisplayPower( 1840 config_waiter_.Reset();
1739 chromeos::DISPLAY_POWER_ALL_OFF, 1841 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
1740 DisplayConfigurator::kSetDisplayPowerNoFlags, 1842 DisplayConfigurator::kSetDisplayPowerNoFlags,
1741 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1843 config_waiter_.on_configuration_callback());
1742 base::Unretained(this))); 1844 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1743 1845 EXPECT_EQ(CALLBACK_FAILURE, config_waiter_.callback_result());
1744 EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult());
1745 EXPECT_EQ(0, observer_.num_changes()); 1846 EXPECT_EQ(0, observer_.num_changes());
1746 EXPECT_EQ(1, observer_.num_failures()); 1847 EXPECT_EQ(1, observer_.num_failures());
1747 1848
1748 const int kDualHeight = small_mode_.size().height() + 1849 const int kDualHeight = small_mode_.size().height() +
1749 DisplayConfigurator::kVerticalGap + 1850 DisplayConfigurator::kVerticalGap +
1750 big_mode_.size().height(); 1851 big_mode_.size().height();
1751 1852
1752 EXPECT_EQ( 1853 EXPECT_EQ(
1753 JoinActions( 1854 JoinActions(
1754 kGrab, 1855 kGrab,
1755 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 1856 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
1756 outputs_[0].get(), outputs_[1].get()) 1857 outputs_[0].get(), outputs_[1].get())
1757 .c_str(), 1858 .c_str(),
1758 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1859 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1759 GetCrtcAction(*outputs_[1], nullptr, 1860 GetCrtcAction(*outputs_[1], nullptr,
1760 gfx::Point(0, small_mode_.size().height() + 1861 gfx::Point(0, small_mode_.size().height() +
1761 DisplayConfigurator::kVerticalGap)) 1862 DisplayConfigurator::kVerticalGap))
1762 .c_str(), 1863 .c_str(),
1763 kUngrab, nullptr), 1864 kUngrab, nullptr),
1764 log_->GetActionsAndClear()); 1865 log_->GetActionsAndClear());
1765 1866
1766 // This configuration should trigger a display configuration since the 1867 // This configuration should trigger a display configuration since the
1767 // previous configuration failed. 1868 // previous configuration failed.
1768 configurator_.SetDisplayPower( 1869 config_waiter_.Reset();
1769 chromeos::DISPLAY_POWER_ALL_ON, 1870 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
1770 DisplayConfigurator::kSetDisplayPowerNoFlags, 1871 DisplayConfigurator::kSetDisplayPowerNoFlags,
1771 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1872 config_waiter_.on_configuration_callback());
1772 base::Unretained(this))); 1873 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1773 1874
1774 EXPECT_EQ(0, observer_.num_changes()); 1875 EXPECT_EQ(0, observer_.num_changes());
1775 EXPECT_EQ(2, observer_.num_failures()); 1876 EXPECT_EQ(2, observer_.num_failures());
1776 EXPECT_EQ( 1877 EXPECT_EQ(
1777 JoinActions( 1878 JoinActions(
1778 kGrab, 1879 kGrab,
1779 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 1880 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
1780 outputs_[0].get(), outputs_[1].get()) 1881 outputs_[0].get(), outputs_[1].get())
1781 .c_str(), 1882 .c_str(),
1782 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1883 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 GetCrtcAction( 1949 GetCrtcAction(
1849 *outputs_[2], &small_mode_, 1950 *outputs_[2], &small_mode_,
1850 gfx::Point(0, small_mode_.size().height() + 1951 gfx::Point(0, small_mode_.size().height() +
1851 big_mode_.size().height() + 1952 big_mode_.size().height() +
1852 2 * DisplayConfigurator::kVerticalGap)) 1953 2 * DisplayConfigurator::kVerticalGap))
1853 .c_str(), 1954 .c_str(),
1854 kUngrab, nullptr), 1955 kUngrab, nullptr),
1855 log_->GetActionsAndClear()); 1956 log_->GetActionsAndClear());
1856 1957
1857 // Verify that turning the power off works. 1958 // Verify that turning the power off works.
1858 configurator_.SetDisplayPower( 1959 config_waiter_.Reset();
1859 chromeos::DISPLAY_POWER_ALL_OFF, 1960 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
1860 DisplayConfigurator::kSetDisplayPowerNoFlags, 1961 DisplayConfigurator::kSetDisplayPowerNoFlags,
1861 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1962 config_waiter_.on_configuration_callback());
1862 base::Unretained(this))); 1963 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1863 1964 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1864 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
1865 EXPECT_EQ( 1965 EXPECT_EQ(
1866 JoinActions( 1966 JoinActions(
1867 kGrab, GetFramebufferAction( 1967 kGrab, GetFramebufferAction(
1868 gfx::Size(big_mode_.size().width(), kTripleHeight), 1968 gfx::Size(big_mode_.size().width(), kTripleHeight),
1869 outputs_[0].get(), outputs_[1].get()) 1969 outputs_[0].get(), outputs_[1].get())
1870 .c_str(), 1970 .c_str(),
1871 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), 1971 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
1872 GetCrtcAction(*outputs_[1], nullptr, 1972 GetCrtcAction(*outputs_[1], nullptr,
1873 gfx::Point(0, small_mode_.size().height() + 1973 gfx::Point(0, small_mode_.size().height() +
1874 DisplayConfigurator::kVerticalGap)) 1974 DisplayConfigurator::kVerticalGap))
1875 .c_str(), 1975 .c_str(),
1876 GetCrtcAction( 1976 GetCrtcAction(
1877 *outputs_[2], nullptr, 1977 *outputs_[2], nullptr,
1878 gfx::Point(0, small_mode_.size().height() + 1978 gfx::Point(0, small_mode_.size().height() +
1879 big_mode_.size().height() + 1979 big_mode_.size().height() +
1880 2 * DisplayConfigurator::kVerticalGap)) 1980 2 * DisplayConfigurator::kVerticalGap))
1881 .c_str(), 1981 .c_str(),
1882 kUngrab, nullptr), 1982 kUngrab, nullptr),
1883 log_->GetActionsAndClear()); 1983 log_->GetActionsAndClear());
1884 1984
1885 configurator_.SetDisplayPower( 1985 config_waiter_.Reset();
1886 chromeos::DISPLAY_POWER_ALL_ON, 1986 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
1887 DisplayConfigurator::kSetDisplayPowerNoFlags, 1987 DisplayConfigurator::kSetDisplayPowerNoFlags,
1888 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, 1988 config_waiter_.on_configuration_callback());
1889 base::Unretained(this))); 1989 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
1890 1990 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
1891 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
1892 EXPECT_EQ( 1991 EXPECT_EQ(
1893 JoinActions( 1992 JoinActions(
1894 kGrab, GetFramebufferAction( 1993 kGrab, GetFramebufferAction(
1895 gfx::Size(big_mode_.size().width(), kTripleHeight), 1994 gfx::Size(big_mode_.size().width(), kTripleHeight),
1896 outputs_[0].get(), outputs_[1].get()) 1995 outputs_[0].get(), outputs_[1].get())
1897 .c_str(), 1996 .c_str(),
1898 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1997 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1899 GetCrtcAction(*outputs_[1], &big_mode_, 1998 GetCrtcAction(*outputs_[1], &big_mode_,
1900 gfx::Point(0, small_mode_.size().height() + 1999 gfx::Point(0, small_mode_.size().height() +
1901 DisplayConfigurator::kVerticalGap)) 2000 DisplayConfigurator::kVerticalGap))
(...skipping 19 matching lines...) Expand all
1921 .c_str(), 2020 .c_str(),
1922 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 2021 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1923 GetCrtcAction(*outputs_[1], &big_mode_, 2022 GetCrtcAction(*outputs_[1], &big_mode_,
1924 gfx::Point(0, small_mode_.size().height() + 2023 gfx::Point(0, small_mode_.size().height() +
1925 DisplayConfigurator::kVerticalGap)) 2024 DisplayConfigurator::kVerticalGap))
1926 .c_str(), 2025 .c_str(),
1927 kUngrab, nullptr), 2026 kUngrab, nullptr),
1928 log_->GetActionsAndClear()); 2027 log_->GetActionsAndClear());
1929 } 2028 }
1930 2029
2030 // Tests the suspend and resume behavior when in dual or multi display modes.
2031 TEST_F(DisplayConfiguratorTest, SuspendResumeWithMultipleDisplays) {
2032 InitWithSingleOutput();
2033 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
2034 observer_.Reset();
2035 UpdateOutputs(2, true);
2036 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
2037 configurator_.display_state());
2038 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
2039 EXPECT_EQ(1, observer_.num_changes());
2040 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
2041 configurator_.current_power_state());
2042 const int kDualHeight = small_mode_.size().height() +
2043 DisplayConfigurator::kVerticalGap +
2044 big_mode_.size().height();
2045 EXPECT_EQ(
2046 JoinActions(
2047 kGrab,
2048 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
2049 outputs_[0].get(), outputs_[1].get())
2050 .c_str(),
2051 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
2052 GetCrtcAction(*outputs_[1], &big_mode_,
2053 gfx::Point(0, small_mode_.size().height() +
2054 DisplayConfigurator::kVerticalGap))
2055 .c_str(),
2056 kUngrab, nullptr),
2057 log_->GetActionsAndClear());
2058
2059 // Suspending displays should result in an immediate configuration without
2060 // delays, even in dual display mode.
2061 config_waiter_.Reset();
2062 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
2063 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
2064 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
2065 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF,
2066 configurator_.current_power_state());
2067 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
2068 configurator_.display_state());
2069 EXPECT_EQ(
2070 JoinActions(
2071 kGrab,
2072 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
2073 outputs_[0].get(), outputs_[1].get())
2074 .c_str(),
2075 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
2076 GetCrtcAction(*outputs_[1], nullptr,
2077 gfx::Point(0, small_mode_.size().height() +
2078 DisplayConfigurator::kVerticalGap))
2079 .c_str(),
2080 kUngrab, kSync, nullptr),
2081 log_->GetActionsAndClear());
2082
2083 // Resuming from suspend with dual displays. Configuration should be done
2084 // after a long delay. Afterwards, we should still expect to be in a dual
2085 // display mode.
2086 config_waiter_.Reset();
2087 configurator_.ResumeDisplays();
2088 EXPECT_EQ(kLongDelay, config_waiter_.Wait());
2089 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
2090 configurator_.current_power_state());
2091 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
2092 configurator_.display_state());
2093 EXPECT_EQ(
2094 JoinActions(
2095 kGrab,
2096 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
2097 outputs_[0].get(), outputs_[1].get())
2098 .c_str(),
2099 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
2100 GetCrtcAction(*outputs_[1], &big_mode_,
2101 gfx::Point(0, small_mode_.size().height() +
2102 DisplayConfigurator::kVerticalGap))
2103 .c_str(),
2104 kForceDPMS, kUngrab, nullptr),
2105 log_->GetActionsAndClear());
2106
2107 // Suspend displays and disconnect one of them while in suspend.
2108 config_waiter_.Reset();
2109 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
2110 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
2111 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
2112 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
2113 configurator_.display_state());
2114 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF,
2115 configurator_.current_power_state());
2116 EXPECT_EQ(
2117 JoinActions(
2118 kGrab,
2119 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
2120 outputs_[0].get(), outputs_[1].get())
2121 .c_str(),
2122 GetCrtcAction(*outputs_[0], nullptr, gfx::Point(0, 0)).c_str(),
2123 GetCrtcAction(*outputs_[1], nullptr,
2124 gfx::Point(0, small_mode_.size().height() +
2125 DisplayConfigurator::kVerticalGap))
2126 .c_str(),
2127 kUngrab, kSync, nullptr),
2128 log_->GetActionsAndClear());
2129 UpdateOutputs(1, false);
2130 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
2131
2132 // Now resume, and expect that we'll still have a long delay since we were in
2133 // dual mode before suspend. The configurator should pick up the change and
2134 // detect that we are in single display mode now.
2135 config_waiter_.Reset();
2136 configurator_.ResumeDisplays();
2137 EXPECT_EQ(kLongDelay, config_waiter_.Wait());
2138 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
2139 configurator_.current_power_state());
2140 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state());
2141 EXPECT_EQ(
2142 JoinActions(
2143 kGrab,
2144 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr)
2145 .c_str(),
2146 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
2147 kForceDPMS, kUngrab, nullptr),
2148 log_->GetActionsAndClear());
2149
2150 // Verify that the above is the exact same behavior for 3+ displays.
2151 UpdateOutputs(3, true);
2152 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED,
2153 configurator_.display_state());
2154
2155 // Suspend.
2156 config_waiter_.Reset();
2157 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback());
2158 EXPECT_EQ(kNoDelay, config_waiter_.Wait());
2159 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result());
2160 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED,
2161 configurator_.display_state());
2162 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF,
2163 configurator_.current_power_state());
2164
2165 // Resume and expect the correct delay.
2166 config_waiter_.Reset();
2167 configurator_.ResumeDisplays();
2168 EXPECT_EQ(kLongDelay, config_waiter_.Wait());
2169 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON,
2170 configurator_.current_power_state());
2171 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED,
2172 configurator_.display_state());
2173 }
2174
1931 } // namespace test 2175 } // namespace test
1932 } // namespace ui 2176 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698