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