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

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

Powered by Google App Engine
This is Rietveld 408576698