| 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/callback_helpers.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/display/chromeos/test/action_logger_util.h" | 17 #include "ui/display/chromeos/test/action_logger_util.h" |
| 17 #include "ui/display/chromeos/test/test_display_snapshot.h" | 18 #include "ui/display/chromeos/test/test_display_snapshot.h" |
| 18 #include "ui/display/chromeos/test/test_native_display_delegate.h" | 19 #include "ui/display/chromeos/test/test_native_display_delegate.h" |
| 19 #include "ui/display/util/display_util.h" | 20 #include "ui/display/util/display_util.h" |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 namespace test { | 23 namespace test { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 27 enum CallbackResult { |
| 28 CALLBACK_FAILURE, |
| 29 CALLBACK_SUCCESS, |
| 30 CALLBACK_NOT_CALLED, |
| 31 }; |
| 32 |
| 33 // The delay less than which we expect the configuration to be finished. |
| 34 constexpr base::TimeDelta kMaxShortDelayMs = base::TimeDelta::FromMilliseconds( |
| 35 DisplayConfigurator::kConfigureDelayMs / 3); |
| 36 |
| 37 // The minimum configuration delay we expect when resuming while in 2+ display |
| 38 // mode. |
| 39 constexpr base::TimeDelta kMinLongDelayMs = base::TimeDelta::FromMilliseconds( |
| 40 DisplayConfigurator::kResumeConfigureMultiDisplayDelayMs); |
| 41 |
| 26 class TestObserver : public DisplayConfigurator::Observer { | 42 class TestObserver : public DisplayConfigurator::Observer { |
| 27 public: | 43 public: |
| 28 explicit TestObserver(DisplayConfigurator* configurator) | 44 explicit TestObserver(DisplayConfigurator* configurator) |
| 29 : configurator_(configurator) { | 45 : configurator_(configurator) { |
| 30 Reset(); | 46 Reset(); |
| 31 configurator_->AddObserver(this); | 47 configurator_->AddObserver(this); |
| 32 } | 48 } |
| 33 ~TestObserver() override { configurator_->RemoveObserver(this); } | 49 ~TestObserver() override { configurator_->RemoveObserver(this); } |
| 34 | 50 |
| 35 int num_changes() const { return num_changes_; } | 51 int num_changes() const { return num_changes_; } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 bool SoftwareMirroringEnabled() const override { | 128 bool SoftwareMirroringEnabled() const override { |
| 113 return software_mirroring_enabled_; | 129 return software_mirroring_enabled_; |
| 114 } | 130 } |
| 115 | 131 |
| 116 private: | 132 private: |
| 117 bool software_mirroring_enabled_; | 133 bool software_mirroring_enabled_; |
| 118 | 134 |
| 119 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); | 135 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); |
| 120 }; | 136 }; |
| 121 | 137 |
| 138 // Abstracts waiting for the display configuration to be completed and getting |
| 139 // the time it took to complete. |
| 140 class ConfigurationWaiter { |
| 141 public: |
| 142 ConfigurationWaiter(DisplayConfigurator::TestApi* test_api) |
| 143 : on_configured_callback_(base::Bind(&ConfigurationWaiter::OnConfigured, |
| 144 base::Unretained(this))), |
| 145 test_api_(test_api), |
| 146 callback_result_(CALLBACK_NOT_CALLED), |
| 147 pending_configuration_(true) {} |
| 148 |
| 149 ~ConfigurationWaiter() = default; |
| 150 |
| 151 void Reset() { |
| 152 callback_result_ = CALLBACK_NOT_CALLED; |
| 153 pending_configuration_ = true; |
| 154 } |
| 155 |
| 156 // Simulates Waiting for the configuration to complete by manually triggering |
| 157 // the configuration timer and returns how long it was supposed to take for |
| 158 // timer task to complete. |
| 159 base::TimeDelta Wait() WARN_UNUSED_RESULT { |
| 160 base::RunLoop().RunUntilIdle(); |
| 161 if (!pending_configuration_) |
| 162 return base::TimeDelta(); |
| 163 |
| 164 const base::TimeDelta delay = test_api_->GetConfigureDelay(); |
| 165 if (!test_api_->TriggerConfigureTimeout()) |
| 166 return base::TimeDelta::Max(); |
| 167 |
| 168 return delay; |
| 169 } |
| 170 |
| 171 const DisplayConfigurator::ConfigurationCallback& on_configuration_callback() |
| 172 const { |
| 173 return on_configured_callback_; |
| 174 } |
| 175 |
| 176 CallbackResult callback_result() const { return callback_result_; } |
| 177 |
| 178 private: |
| 179 void OnConfigured(bool status) { |
| 180 callback_result_ = status ? CALLBACK_SUCCESS : CALLBACK_FAILURE; |
| 181 |
| 182 pending_configuration_ = false; |
| 183 } |
| 184 |
| 185 // The callback that should be used with the DisplayConfigurator calls to be |
| 186 // invoked with the display configuration is done. It will always execute this |
| 187 // waiter's OnConfigured(). |
| 188 const DisplayConfigurator::ConfigurationCallback on_configured_callback_; |
| 189 |
| 190 DisplayConfigurator::TestApi* test_api_; // Not owned. |
| 191 |
| 192 // The status of the display configuration. |
| 193 CallbackResult callback_result_; |
| 194 |
| 195 // True if we are expecting a display configuration completion, false if the |
| 196 // configuration has already been completed. |
| 197 bool pending_configuration_; |
| 198 |
| 199 DISALLOW_COPY_AND_ASSIGN(ConfigurationWaiter); |
| 200 }; |
| 201 |
| 122 class DisplayConfiguratorTest : public testing::Test { | 202 class DisplayConfiguratorTest : public testing::Test { |
| 123 public: | 203 public: |
| 124 enum CallbackResult { | |
| 125 CALLBACK_FAILURE, | |
| 126 CALLBACK_SUCCESS, | |
| 127 CALLBACK_NOT_CALLED, | |
| 128 }; | |
| 129 | |
| 130 DisplayConfiguratorTest() | 204 DisplayConfiguratorTest() |
| 131 : small_mode_(gfx::Size(1366, 768), false, 60.0f), | 205 : small_mode_(gfx::Size(1366, 768), false, 60.0f), |
| 132 big_mode_(gfx::Size(2560, 1600), false, 60.0f), | 206 big_mode_(gfx::Size(2560, 1600), false, 60.0f), |
| 133 observer_(&configurator_), | 207 observer_(&configurator_), |
| 134 test_api_(&configurator_), | 208 test_api_(&configurator_), |
| 209 config_waiter_(&test_api_), |
| 135 enable_content_protection_status_(0), | 210 enable_content_protection_status_(0), |
| 136 enable_content_protection_call_count_(0), | 211 enable_content_protection_call_count_(0), |
| 137 query_content_protection_call_count_(0), | 212 query_content_protection_call_count_(0), |
| 138 callback_result_(CALLBACK_NOT_CALLED), | |
| 139 display_control_result_(CALLBACK_NOT_CALLED) {} | 213 display_control_result_(CALLBACK_NOT_CALLED) {} |
| 140 ~DisplayConfiguratorTest() override {} | 214 ~DisplayConfiguratorTest() override {} |
| 141 | 215 |
| 142 void SetUp() override { | 216 void SetUp() override { |
| 143 log_.reset(new ActionLogger()); | 217 log_.reset(new ActionLogger()); |
| 144 | 218 |
| 145 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 219 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
| 146 configurator_.SetDelegateForTesting( | 220 configurator_.SetDelegateForTesting( |
| 147 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 221 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
| 148 | 222 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 177 o->set_current_mode(modes.back().get()); | 251 o->set_current_mode(modes.back().get()); |
| 178 o->set_native_mode(modes.back().get()); | 252 o->set_native_mode(modes.back().get()); |
| 179 o->set_modes(std::move(modes)); | 253 o->set_modes(std::move(modes)); |
| 180 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); | 254 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); |
| 181 o->set_is_aspect_preserving_scaling(true); | 255 o->set_is_aspect_preserving_scaling(true); |
| 182 o->set_display_id(789); | 256 o->set_display_id(789); |
| 183 | 257 |
| 184 UpdateOutputs(2, false); | 258 UpdateOutputs(2, false); |
| 185 } | 259 } |
| 186 | 260 |
| 187 void OnConfiguredCallback(bool status) { | |
| 188 callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); | |
| 189 } | |
| 190 | |
| 191 void OnDisplayControlUpdated(bool status) { | 261 void OnDisplayControlUpdated(bool status) { |
| 192 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); | 262 display_control_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE); |
| 193 } | 263 } |
| 194 | 264 |
| 195 void EnableContentProtectionCallback(bool status) { | 265 void EnableContentProtectionCallback(bool status) { |
| 196 enable_content_protection_status_ = status; | 266 enable_content_protection_status_ = status; |
| 197 enable_content_protection_call_count_++; | 267 enable_content_protection_call_count_++; |
| 198 } | 268 } |
| 199 | 269 |
| 200 void QueryContentProtectionCallback( | 270 void QueryContentProtectionCallback( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 configurator_.ForceInitialConfigure(0); | 310 configurator_.ForceInitialConfigure(0); |
| 241 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, | 311 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, |
| 242 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 312 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 243 NULL).c_str(), | 313 NULL).c_str(), |
| 244 GetCrtcAction(outputs_[0], &small_mode_, | 314 GetCrtcAction(outputs_[0], &small_mode_, |
| 245 gfx::Point(0, 0)).c_str(), | 315 gfx::Point(0, 0)).c_str(), |
| 246 kForceDPMS, kUngrab, NULL), | 316 kForceDPMS, kUngrab, NULL), |
| 247 log_->GetActionsAndClear()); | 317 log_->GetActionsAndClear()); |
| 248 } | 318 } |
| 249 | 319 |
| 250 CallbackResult PopCallbackResult() { | |
| 251 CallbackResult result = callback_result_; | |
| 252 callback_result_ = CALLBACK_NOT_CALLED; | |
| 253 return result; | |
| 254 } | |
| 255 | |
| 256 CallbackResult PopDisplayControlResult() { | 320 CallbackResult PopDisplayControlResult() { |
| 257 CallbackResult result = display_control_result_; | 321 CallbackResult result = display_control_result_; |
| 258 display_control_result_ = CALLBACK_NOT_CALLED; | 322 display_control_result_ = CALLBACK_NOT_CALLED; |
| 259 return result; | 323 return result; |
| 260 } | 324 } |
| 261 | 325 |
| 262 base::MessageLoop message_loop_; | 326 base::MessageLoop message_loop_; |
| 263 TestStateController state_controller_; | 327 TestStateController state_controller_; |
| 264 TestMirroringController mirroring_controller_; | 328 TestMirroringController mirroring_controller_; |
| 265 DisplayConfigurator configurator_; | 329 DisplayConfigurator configurator_; |
| 266 TestObserver observer_; | 330 TestObserver observer_; |
| 267 std::unique_ptr<ActionLogger> log_; | 331 std::unique_ptr<ActionLogger> log_; |
| 268 TestNativeDisplayDelegate* native_display_delegate_; // not owned | 332 TestNativeDisplayDelegate* native_display_delegate_; // not owned |
| 269 DisplayConfigurator::TestApi test_api_; | 333 DisplayConfigurator::TestApi test_api_; |
| 270 | 334 ConfigurationWaiter config_waiter_; |
| 271 bool enable_content_protection_status_; | 335 bool enable_content_protection_status_; |
| 272 int enable_content_protection_call_count_; | 336 int enable_content_protection_call_count_; |
| 273 DisplayConfigurator::QueryProtectionResponse | 337 DisplayConfigurator::QueryProtectionResponse |
| 274 query_content_protection_response_; | 338 query_content_protection_response_; |
| 275 int query_content_protection_call_count_; | 339 int query_content_protection_call_count_; |
| 276 | 340 |
| 277 TestDisplaySnapshot outputs_[3]; | 341 TestDisplaySnapshot outputs_[3]; |
| 278 | 342 |
| 279 CallbackResult callback_result_; | |
| 280 CallbackResult display_control_result_; | 343 CallbackResult display_control_result_; |
| 281 | 344 |
| 282 private: | 345 private: |
| 283 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); | 346 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); |
| 284 }; | 347 }; |
| 285 | 348 |
| 286 } // namespace | 349 } // namespace |
| 287 | 350 |
| 288 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { | 351 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { |
| 289 std::vector<const DisplayMode*> modes; | 352 std::vector<const DisplayMode*> modes; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 725 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 663 kUngrab, | 726 kUngrab, |
| 664 NULL), | 727 NULL), |
| 665 log_->GetActionsAndClear()); | 728 log_->GetActionsAndClear()); |
| 666 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 729 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 667 EXPECT_EQ(1, observer_.num_changes()); | 730 EXPECT_EQ(1, observer_.num_changes()); |
| 668 | 731 |
| 669 // Turning off the internal display should switch the external display to | 732 // Turning off the internal display should switch the external display to |
| 670 // its native mode. | 733 // its native mode. |
| 671 observer_.Reset(); | 734 observer_.Reset(); |
| 735 config_waiter_.Reset(); |
| 672 configurator_.SetDisplayPower( | 736 configurator_.SetDisplayPower( |
| 673 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 737 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 674 DisplayConfigurator::kSetDisplayPowerNoFlags, | 738 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 675 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 739 config_waiter_.on_configuration_callback()); |
| 676 base::Unretained(this))); | 740 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 677 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 741 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 678 EXPECT_EQ( | 742 EXPECT_EQ( |
| 679 JoinActions( | 743 JoinActions( |
| 680 kGrab, | 744 kGrab, |
| 681 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 745 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 682 .c_str(), | 746 .c_str(), |
| 683 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 747 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 684 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 748 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 685 kForceDPMS, | 749 kForceDPMS, |
| 686 kUngrab, | 750 kUngrab, |
| 687 NULL), | 751 NULL), |
| 688 log_->GetActionsAndClear()); | 752 log_->GetActionsAndClear()); |
| 689 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 753 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 690 EXPECT_EQ(1, observer_.num_changes()); | 754 EXPECT_EQ(1, observer_.num_changes()); |
| 691 | 755 |
| 692 // When all displays are turned off, the framebuffer should switch back | 756 // When all displays are turned off, the framebuffer should switch back |
| 693 // to the mirrored size. | 757 // to the mirrored size. |
| 694 observer_.Reset(); | 758 observer_.Reset(); |
| 695 configurator_.SetDisplayPower( | 759 config_waiter_.Reset(); |
| 696 chromeos::DISPLAY_POWER_ALL_OFF, | 760 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 697 DisplayConfigurator::kSetDisplayPowerNoFlags, | 761 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 698 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 762 config_waiter_.on_configuration_callback()); |
| 699 base::Unretained(this))); | 763 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 700 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 764 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 701 EXPECT_EQ( | 765 EXPECT_EQ( |
| 702 JoinActions(kGrab, | 766 JoinActions(kGrab, |
| 703 GetFramebufferAction( | 767 GetFramebufferAction( |
| 704 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), | 768 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), |
| 705 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 769 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 706 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 770 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
| 707 kUngrab, | 771 kUngrab, |
| 708 NULL), | 772 NULL), |
| 709 log_->GetActionsAndClear()); | 773 log_->GetActionsAndClear()); |
| 710 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 774 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 711 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 775 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 712 EXPECT_EQ(1, observer_.num_changes()); | 776 EXPECT_EQ(1, observer_.num_changes()); |
| 713 | 777 |
| 714 // Turn all displays on and check that mirroring is still used. | 778 // Turn all displays on and check that mirroring is still used. |
| 715 observer_.Reset(); | 779 observer_.Reset(); |
| 716 configurator_.SetDisplayPower( | 780 config_waiter_.Reset(); |
| 717 chromeos::DISPLAY_POWER_ALL_ON, | 781 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 718 DisplayConfigurator::kSetDisplayPowerNoFlags, | 782 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 719 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 783 config_waiter_.on_configuration_callback()); |
| 720 base::Unretained(this))); | 784 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 721 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 785 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 722 EXPECT_EQ( | 786 EXPECT_EQ( |
| 723 JoinActions( | 787 JoinActions( |
| 724 kGrab, | 788 kGrab, |
| 725 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 789 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 726 .c_str(), | 790 .c_str(), |
| 727 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 791 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 728 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 792 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 729 kForceDPMS, | 793 kForceDPMS, |
| 730 kUngrab, | 794 kUngrab, |
| 731 NULL), | 795 NULL), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 NULL), | 827 NULL), |
| 764 log_->GetActionsAndClear()); | 828 log_->GetActionsAndClear()); |
| 765 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 829 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 766 configurator_.display_state()); | 830 configurator_.display_state()); |
| 767 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 831 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 768 EXPECT_EQ(1, observer_.num_changes()); | 832 EXPECT_EQ(1, observer_.num_changes()); |
| 769 | 833 |
| 770 // Turning off the internal display should switch the external display to | 834 // Turning off the internal display should switch the external display to |
| 771 // its native mode. | 835 // its native mode. |
| 772 observer_.Reset(); | 836 observer_.Reset(); |
| 837 config_waiter_.Reset(); |
| 773 configurator_.SetDisplayPower( | 838 configurator_.SetDisplayPower( |
| 774 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 839 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 775 DisplayConfigurator::kSetDisplayPowerNoFlags, | 840 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 776 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 841 config_waiter_.on_configuration_callback()); |
| 777 base::Unretained(this))); | 842 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 778 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 843 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 779 EXPECT_EQ( | 844 EXPECT_EQ( |
| 780 JoinActions( | 845 JoinActions( |
| 781 kGrab, | 846 kGrab, |
| 782 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 847 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 783 .c_str(), | 848 .c_str(), |
| 784 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 849 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 785 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 850 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 786 kForceDPMS, | 851 kForceDPMS, |
| 787 kUngrab, | 852 kUngrab, |
| 788 NULL), | 853 NULL), |
| 789 log_->GetActionsAndClear()); | 854 log_->GetActionsAndClear()); |
| 790 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); | 855 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 791 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 856 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 792 EXPECT_EQ(1, observer_.num_changes()); | 857 EXPECT_EQ(1, observer_.num_changes()); |
| 793 | 858 |
| 794 // When all displays are turned off, the framebuffer should switch back | 859 // When all displays are turned off, the framebuffer should switch back |
| 795 // to the extended + software mirroring. | 860 // to the extended + software mirroring. |
| 796 observer_.Reset(); | 861 observer_.Reset(); |
| 797 configurator_.SetDisplayPower( | 862 config_waiter_.Reset(); |
| 798 chromeos::DISPLAY_POWER_ALL_OFF, | 863 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 799 DisplayConfigurator::kSetDisplayPowerNoFlags, | 864 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 800 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 865 config_waiter_.on_configuration_callback()); |
| 801 base::Unretained(this))); | 866 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 802 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 867 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 803 EXPECT_EQ( | 868 EXPECT_EQ( |
| 804 JoinActions( | 869 JoinActions( |
| 805 kGrab, | 870 kGrab, |
| 806 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 871 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 807 &outputs_[0], | 872 &outputs_[0], |
| 808 &outputs_[1]).c_str(), | 873 &outputs_[1]).c_str(), |
| 809 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 874 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 810 GetCrtcAction(outputs_[1], | 875 GetCrtcAction(outputs_[1], |
| 811 NULL, | 876 NULL, |
| 812 gfx::Point(0, | 877 gfx::Point(0, |
| 813 small_mode_.size().height() + | 878 small_mode_.size().height() + |
| 814 DisplayConfigurator::kVerticalGap)) | 879 DisplayConfigurator::kVerticalGap)) |
| 815 .c_str(), | 880 .c_str(), |
| 816 kUngrab, | 881 kUngrab, |
| 817 NULL), | 882 NULL), |
| 818 log_->GetActionsAndClear()); | 883 log_->GetActionsAndClear()); |
| 819 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 884 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 820 configurator_.display_state()); | 885 configurator_.display_state()); |
| 821 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 886 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 822 EXPECT_EQ(1, observer_.num_changes()); | 887 EXPECT_EQ(1, observer_.num_changes()); |
| 823 | 888 |
| 824 // Turn all displays on and check that mirroring is still used. | 889 // Turn all displays on and check that mirroring is still used. |
| 825 observer_.Reset(); | 890 observer_.Reset(); |
| 826 configurator_.SetDisplayPower( | 891 config_waiter_.Reset(); |
| 827 chromeos::DISPLAY_POWER_ALL_ON, | 892 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 828 DisplayConfigurator::kSetDisplayPowerNoFlags, | 893 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 829 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 894 config_waiter_.on_configuration_callback()); |
| 830 base::Unretained(this))); | 895 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 831 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 896 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 832 EXPECT_EQ( | 897 EXPECT_EQ( |
| 833 JoinActions( | 898 JoinActions( |
| 834 kGrab, | 899 kGrab, |
| 835 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 900 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 836 &outputs_[0], | 901 &outputs_[0], |
| 837 &outputs_[1]).c_str(), | 902 &outputs_[1]).c_str(), |
| 838 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 903 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 839 GetCrtcAction(outputs_[1], | 904 GetCrtcAction(outputs_[1], |
| 840 &big_mode_, | 905 &big_mode_, |
| 841 gfx::Point(0, | 906 gfx::Point(0, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 853 } | 918 } |
| 854 | 919 |
| 855 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { | 920 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { |
| 856 InitWithSingleOutput(); | 921 InitWithSingleOutput(); |
| 857 | 922 |
| 858 // No preparation is needed before suspending when the display is already | 923 // No preparation is needed before suspending when the display is already |
| 859 // on. The configurator should still reprobe on resume in case a display | 924 // on. The configurator should still reprobe on resume in case a display |
| 860 // was connected while suspended. | 925 // was connected while suspended. |
| 861 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); | 926 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 862 DCHECK(!framebuffer_size.IsEmpty()); | 927 DCHECK(!framebuffer_size.IsEmpty()); |
| 863 configurator_.SuspendDisplays(base::Bind( | 928 config_waiter_.Reset(); |
| 864 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 929 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 865 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 930 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 931 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 866 EXPECT_EQ(framebuffer_size.ToString(), | 932 EXPECT_EQ(framebuffer_size.ToString(), |
| 867 configurator_.framebuffer_size().ToString()); | 933 configurator_.framebuffer_size().ToString()); |
| 868 EXPECT_EQ( | 934 EXPECT_EQ( |
| 869 JoinActions( | 935 JoinActions( |
| 870 kGrab, | 936 kGrab, |
| 871 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 937 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 872 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 938 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 873 kUngrab, | 939 kUngrab, |
| 874 kSync, | 940 kSync, |
| 875 NULL), | 941 NULL), |
| 876 log_->GetActionsAndClear()); | 942 log_->GetActionsAndClear()); |
| 877 configurator_.ResumeDisplays(); | 943 |
| 944 // No resume delay in single display mode. |
| 945 config_waiter_.Reset(); |
| 946 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 947 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 948 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 878 EXPECT_EQ( | 949 EXPECT_EQ( |
| 879 JoinActions( | 950 JoinActions( |
| 880 kGrab, | 951 kGrab, |
| 881 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 952 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 882 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 953 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 883 kForceDPMS, | 954 kForceDPMS, |
| 884 kUngrab, | 955 kUngrab, |
| 885 NULL), | 956 NULL), |
| 886 log_->GetActionsAndClear()); | 957 log_->GetActionsAndClear()); |
| 887 | 958 |
| 888 // Now turn the display off before suspending and check that the | 959 // Now turn the display off before suspending and check that the |
| 889 // configurator turns it back on and syncs with the server. | 960 // configurator turns it back on and syncs with the server. |
| 890 configurator_.SetDisplayPower( | 961 config_waiter_.Reset(); |
| 891 chromeos::DISPLAY_POWER_ALL_OFF, | 962 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 892 DisplayConfigurator::kSetDisplayPowerNoFlags, | 963 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 893 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 964 config_waiter_.on_configuration_callback()); |
| 894 base::Unretained(this))); | 965 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 895 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 966 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 896 EXPECT_EQ( | 967 EXPECT_EQ( |
| 897 JoinActions( | 968 JoinActions( |
| 898 kGrab, | 969 kGrab, |
| 899 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 970 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 900 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 971 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 901 kUngrab, | 972 kUngrab, |
| 902 NULL), | 973 NULL), |
| 903 log_->GetActionsAndClear()); | 974 log_->GetActionsAndClear()); |
| 904 | 975 |
| 905 configurator_.SuspendDisplays(base::Bind( | 976 config_waiter_.Reset(); |
| 906 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 977 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 907 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 978 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 979 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 908 EXPECT_EQ(kSync, log_->GetActionsAndClear()); | 980 EXPECT_EQ(kSync, log_->GetActionsAndClear()); |
| 909 | 981 |
| 910 configurator_.ResumeDisplays(); | 982 config_waiter_.Reset(); |
| 983 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 984 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 985 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 911 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 986 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 912 | 987 |
| 913 configurator_.SetDisplayPower( | 988 config_waiter_.Reset(); |
| 914 chromeos::DISPLAY_POWER_ALL_ON, | 989 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 915 DisplayConfigurator::kSetDisplayPowerNoFlags, | 990 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 916 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 991 config_waiter_.on_configuration_callback()); |
| 917 base::Unretained(this))); | 992 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 993 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 918 EXPECT_EQ( | 994 EXPECT_EQ( |
| 919 JoinActions( | 995 JoinActions( |
| 920 kGrab, | 996 kGrab, |
| 921 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 997 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 922 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 998 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 923 kForceDPMS, | 999 kForceDPMS, |
| 924 kUngrab, | 1000 kUngrab, |
| 925 NULL), | 1001 NULL), |
| 926 log_->GetActionsAndClear()); | 1002 log_->GetActionsAndClear()); |
| 927 | 1003 |
| 928 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1004 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 929 UpdateOutputs(2, true); | 1005 UpdateOutputs(2, true); |
| 930 EXPECT_EQ( | 1006 EXPECT_EQ( |
| 931 JoinActions( | 1007 JoinActions( |
| 932 kGrab, | 1008 kGrab, |
| 933 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1009 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 934 .c_str(), | 1010 .c_str(), |
| 935 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1011 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 936 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1012 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 937 kUngrab, | 1013 kUngrab, |
| 938 NULL), | 1014 NULL), |
| 939 log_->GetActionsAndClear()); | 1015 log_->GetActionsAndClear()); |
| 940 | 1016 |
| 941 configurator_.SetDisplayPower( | 1017 config_waiter_.Reset(); |
| 942 chromeos::DISPLAY_POWER_ALL_OFF, | 1018 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 943 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1019 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 944 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1020 config_waiter_.on_configuration_callback()); |
| 945 base::Unretained(this))); | 1021 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 946 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1022 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1023 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 947 EXPECT_EQ( | 1024 EXPECT_EQ( |
| 948 JoinActions( | 1025 JoinActions( |
| 949 kGrab, | 1026 kGrab, |
| 950 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1027 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 951 .c_str(), | 1028 .c_str(), |
| 952 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1029 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 953 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 1030 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
| 954 kUngrab, | 1031 kUngrab, |
| 955 NULL), | 1032 NULL), |
| 956 log_->GetActionsAndClear()); | 1033 log_->GetActionsAndClear()); |
| 957 | 1034 |
| 958 configurator_.SuspendDisplays(base::Bind( | 1035 // No delay in suspend. |
| 959 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1036 config_waiter_.Reset(); |
| 960 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1037 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 1038 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1039 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1040 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF, |
| 1041 configurator_.current_power_state()); |
| 1042 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 961 EXPECT_EQ(kSync, log_->GetActionsAndClear()); | 1043 EXPECT_EQ(kSync, log_->GetActionsAndClear()); |
| 962 | 1044 |
| 963 // If a display is disconnected while suspended, the configurator should | 1045 // If a display is disconnected while suspended, the configurator should |
| 964 // pick up the change and only turn on the internal display. | 1046 // pick up the change and only turn on the internal display. The should be |
| 1047 // a longer configuration delay when we set the displays back to on. |
| 965 UpdateOutputs(1, false); | 1048 UpdateOutputs(1, false); |
| 966 configurator_.ResumeDisplays(); | 1049 config_waiter_.Reset(); |
| 1050 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 1051 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1052 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 967 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1053 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 968 | 1054 |
| 969 configurator_.SetDisplayPower( | 1055 config_waiter_.Reset(); |
| 970 chromeos::DISPLAY_POWER_ALL_ON, | 1056 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 971 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1057 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 972 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1058 config_waiter_.on_configuration_callback()); |
| 973 base::Unretained(this))); | 1059 EXPECT_GE(config_waiter_.Wait(), kMinLongDelayMs); |
| 1060 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 974 EXPECT_EQ( | 1061 EXPECT_EQ( |
| 975 JoinActions( | 1062 JoinActions( |
| 976 kGrab, | 1063 kGrab, |
| 977 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1064 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 978 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1065 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 979 kForceDPMS, | 1066 kForceDPMS, |
| 980 kUngrab, | 1067 kUngrab, |
| 981 NULL), | 1068 NULL), |
| 982 log_->GetActionsAndClear()); | 1069 log_->GetActionsAndClear()); |
| 983 } | 1070 } |
| 984 | 1071 |
| 985 TEST_F(DisplayConfiguratorTest, Headless) { | 1072 TEST_F(DisplayConfiguratorTest, Headless) { |
| 986 UpdateOutputs(0, false); | 1073 UpdateOutputs(0, false); |
| 987 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1074 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 988 Init(false); | 1075 Init(false); |
| 989 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1076 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 990 configurator_.ForceInitialConfigure(0); | 1077 configurator_.ForceInitialConfigure(0); |
| 991 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, NULL), | 1078 EXPECT_EQ(JoinActions(kInitXRandR, kGrab, kForceDPMS, kUngrab, NULL), |
| 992 log_->GetActionsAndClear()); | 1079 log_->GetActionsAndClear()); |
| 993 | 1080 |
| 994 // Not much should happen when the display power state is changed while | 1081 // Not much should happen when the display power state is changed while |
| 995 // no displays are connected. | 1082 // no displays are connected. |
| 996 configurator_.SetDisplayPower( | 1083 config_waiter_.Reset(); |
| 997 chromeos::DISPLAY_POWER_ALL_OFF, | 1084 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 998 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1085 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 999 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1086 config_waiter_.on_configuration_callback()); |
| 1000 base::Unretained(this))); | 1087 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1001 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1088 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1002 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 1089 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 1003 configurator_.SetDisplayPower( | 1090 config_waiter_.Reset(); |
| 1004 chromeos::DISPLAY_POWER_ALL_ON, | 1091 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1005 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1092 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1006 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1093 config_waiter_.on_configuration_callback()); |
| 1007 base::Unretained(this))); | 1094 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1008 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1095 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1009 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), | 1096 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), |
| 1010 log_->GetActionsAndClear()); | 1097 log_->GetActionsAndClear()); |
| 1011 | 1098 |
| 1012 // Connect an external display and check that it's configured correctly. | 1099 // Connect an external display and check that it's configured correctly. |
| 1013 std::vector<std::unique_ptr<const DisplayMode>> modes; | 1100 std::vector<std::unique_ptr<const DisplayMode>> modes; |
| 1014 for (const std::unique_ptr<const DisplayMode>& mode : outputs_[1].modes()) { | 1101 for (const std::unique_ptr<const DisplayMode>& mode : outputs_[1].modes()) { |
| 1015 modes.push_back(mode->Clone()); | 1102 modes.push_back(mode->Clone()); |
| 1016 if (mode.get() == outputs_[1].current_mode()) | 1103 if (mode.get() == outputs_[1].current_mode()) |
| 1017 outputs_[0].set_current_mode(modes.back().get()); | 1104 outputs_[0].set_current_mode(modes.back().get()); |
| 1018 if (mode.get() == outputs_[1].native_mode()) | 1105 if (mode.get() == outputs_[1].native_mode()) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 log_->GetActionsAndClear()); | 1329 log_->GetActionsAndClear()); |
| 1243 } | 1330 } |
| 1244 | 1331 |
| 1245 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { | 1332 TEST_F(DisplayConfiguratorTest, DoNotConfigureWithSuspendedDisplays) { |
| 1246 InitWithSingleOutput(); | 1333 InitWithSingleOutput(); |
| 1247 | 1334 |
| 1248 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() | 1335 // The DisplayConfigurator may occasionally receive OnConfigurationChanged() |
| 1249 // after the displays have been suspended. This event should be ignored since | 1336 // after the displays have been suspended. This event should be ignored since |
| 1250 // the DisplayConfigurator will force a probe and reconfiguration of displays | 1337 // the DisplayConfigurator will force a probe and reconfiguration of displays |
| 1251 // at resume time. | 1338 // at resume time. |
| 1252 configurator_.SuspendDisplays(base::Bind( | 1339 config_waiter_.Reset(); |
| 1253 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1340 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 1254 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1341 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1342 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1255 EXPECT_EQ( | 1343 EXPECT_EQ( |
| 1256 JoinActions( | 1344 JoinActions( |
| 1257 kGrab, | 1345 kGrab, |
| 1258 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1346 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1259 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1347 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1260 kUngrab, | 1348 kUngrab, |
| 1261 kSync, | 1349 kSync, |
| 1262 NULL), | 1350 NULL), |
| 1263 log_->GetActionsAndClear()); | 1351 log_->GetActionsAndClear()); |
| 1264 | 1352 |
| 1265 // The configuration timer should not be started when the displays | 1353 // The configuration timer should not be started when the displays |
| 1266 // are suspended. | 1354 // are suspended. |
| 1267 configurator_.OnConfigurationChanged(); | 1355 configurator_.OnConfigurationChanged(); |
| 1268 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1356 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
| 1269 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1357 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1270 | 1358 |
| 1271 // Calls to SetDisplayPower should do nothing if the power state doesn't | 1359 // Calls to SetDisplayPower should do nothing if the power state doesn't |
| 1272 // change. | 1360 // change. |
| 1273 configurator_.SetDisplayPower( | 1361 config_waiter_.Reset(); |
| 1274 chromeos::DISPLAY_POWER_ALL_OFF, | 1362 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 1275 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1363 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1276 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1364 config_waiter_.on_configuration_callback()); |
| 1277 base::Unretained(this))); | 1365 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1278 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1366 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1279 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1367 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1280 configurator_.SetDisplayPower( | 1368 config_waiter_.Reset(); |
| 1281 chromeos::DISPLAY_POWER_ALL_ON, | 1369 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1282 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1370 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1283 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1371 config_waiter_.on_configuration_callback()); |
| 1284 base::Unretained(this))); | 1372 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1285 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1373 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1286 EXPECT_EQ( | 1374 EXPECT_EQ( |
| 1287 JoinActions( | 1375 JoinActions( |
| 1288 kGrab, | 1376 kGrab, |
| 1289 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1377 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1290 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1378 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1291 kForceDPMS, | 1379 kForceDPMS, |
| 1292 kUngrab, | 1380 kUngrab, |
| 1293 NULL), | 1381 NULL), |
| 1294 log_->GetActionsAndClear()); | 1382 log_->GetActionsAndClear()); |
| 1295 | 1383 |
| 1296 UpdateOutputs(2, false); | 1384 UpdateOutputs(2, false); |
| 1297 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1385 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1298 EXPECT_EQ( | 1386 EXPECT_EQ( |
| 1299 JoinActions( | 1387 JoinActions( |
| 1300 kGrab, | 1388 kGrab, |
| 1301 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1389 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1302 .c_str(), | 1390 .c_str(), |
| 1303 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1391 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1304 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1392 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1305 kUngrab, | 1393 kUngrab, |
| 1306 NULL), | 1394 NULL), |
| 1307 log_->GetActionsAndClear()); | 1395 log_->GetActionsAndClear()); |
| 1308 | 1396 |
| 1309 // The DisplayConfigurator should do nothing at resume time if there is no | 1397 // The DisplayConfigurator should do nothing at resume time if there is no |
| 1310 // state change. | 1398 // state change. |
| 1399 config_waiter_.Reset(); |
| 1311 UpdateOutputs(1, false); | 1400 UpdateOutputs(1, false); |
| 1312 configurator_.ResumeDisplays(); | 1401 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 1402 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1403 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1313 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1404 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1314 | 1405 |
| 1315 // If a configuration task is pending when the displays are suspended, that | 1406 // If a configuration task is pending when the displays are suspended, that |
| 1316 // task should not run either and the timer should be stopped. The displays | 1407 // task should not run either and the timer should be stopped. The displays |
| 1317 // should be turned off by suspend. | 1408 // should be turned off by suspend. |
| 1318 configurator_.OnConfigurationChanged(); | 1409 configurator_.OnConfigurationChanged(); |
| 1319 configurator_.SuspendDisplays(base::Bind( | 1410 config_waiter_.Reset(); |
| 1320 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1411 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 1321 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1412 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1413 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1322 EXPECT_EQ( | 1414 EXPECT_EQ( |
| 1323 JoinActions( | 1415 JoinActions( |
| 1324 kGrab, | 1416 kGrab, |
| 1325 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1417 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1326 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1418 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1327 kUngrab, | 1419 kUngrab, |
| 1328 kSync, | 1420 kSync, |
| 1329 NULL), | 1421 NULL), |
| 1330 log_->GetActionsAndClear()); | 1422 log_->GetActionsAndClear()); |
| 1331 | 1423 |
| 1332 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); | 1424 EXPECT_FALSE(test_api_.TriggerConfigureTimeout()); |
| 1333 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1425 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1334 | 1426 |
| 1335 configurator_.ResumeDisplays(); | 1427 config_waiter_.Reset(); |
| 1428 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 1429 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1430 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1336 EXPECT_EQ( | 1431 EXPECT_EQ( |
| 1337 JoinActions( | 1432 JoinActions( |
| 1338 kGrab, | 1433 kGrab, |
| 1339 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 1434 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 1340 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1435 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1341 kForceDPMS, | 1436 kForceDPMS, |
| 1342 kUngrab, | 1437 kUngrab, |
| 1343 NULL), | 1438 NULL), |
| 1344 log_->GetActionsAndClear()); | 1439 log_->GetActionsAndClear()); |
| 1345 } | 1440 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1638 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1544 Init(false); | 1639 Init(false); |
| 1545 configurator_.ForceInitialConfigure(0); | 1640 configurator_.ForceInitialConfigure(0); |
| 1546 log_->GetActionsAndClear(); | 1641 log_->GetActionsAndClear(); |
| 1547 observer_.Reset(); | 1642 observer_.Reset(); |
| 1548 | 1643 |
| 1549 // Turn off the internal display, simulating docked mode. | 1644 // Turn off the internal display, simulating docked mode. |
| 1550 configurator_.SetDisplayPower( | 1645 configurator_.SetDisplayPower( |
| 1551 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1646 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1552 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1647 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1553 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1648 config_waiter_.on_configuration_callback()); |
| 1554 base::Unretained(this))); | 1649 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1555 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1650 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1556 EXPECT_EQ(1, observer_.num_changes()); | 1651 EXPECT_EQ(1, observer_.num_changes()); |
| 1557 EXPECT_EQ(0, observer_.num_failures()); | 1652 EXPECT_EQ(0, observer_.num_failures()); |
| 1558 log_->GetActionsAndClear(); | 1653 log_->GetActionsAndClear(); |
| 1559 | 1654 |
| 1560 // Make all subsequent configuration requests fail and try to turn the | 1655 // Make all subsequent configuration requests fail and try to turn the |
| 1561 // internal display back on. | 1656 // internal display back on. |
| 1562 native_display_delegate_->set_max_configurable_pixels(1); | 1657 native_display_delegate_->set_max_configurable_pixels(1); |
| 1563 configurator_.SetDisplayPower( | 1658 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1564 chromeos::DISPLAY_POWER_ALL_ON, | 1659 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1565 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1660 config_waiter_.on_configuration_callback()); |
| 1566 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1661 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1567 base::Unretained(this))); | 1662 EXPECT_EQ(CALLBACK_FAILURE, config_waiter_.callback_result()); |
| 1568 EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult()); | |
| 1569 EXPECT_EQ(1, observer_.num_changes()); | 1663 EXPECT_EQ(1, observer_.num_changes()); |
| 1570 EXPECT_EQ(1, observer_.num_failures()); | 1664 EXPECT_EQ(1, observer_.num_failures()); |
| 1571 log_->GetActionsAndClear(); | 1665 log_->GetActionsAndClear(); |
| 1572 | 1666 |
| 1573 // Simulate the external display getting disconnected and check that the | 1667 // Simulate the external display getting disconnected and check that the |
| 1574 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather | 1668 // internal display is turned on (i.e. DISPLAY_POWER_ALL_ON is used) rather |
| 1575 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. | 1669 // than the earlier DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON state. |
| 1576 native_display_delegate_->set_max_configurable_pixels(0); | 1670 native_display_delegate_->set_max_configurable_pixels(0); |
| 1577 UpdateOutputs(1, true); | 1671 UpdateOutputs(1, true); |
| 1578 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), | 1672 EXPECT_EQ(JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1591 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1685 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 1592 Init(false); | 1686 Init(false); |
| 1593 configurator_.ForceInitialConfigure(0); | 1687 configurator_.ForceInitialConfigure(0); |
| 1594 log_->GetActionsAndClear(); | 1688 log_->GetActionsAndClear(); |
| 1595 observer_.Reset(); | 1689 observer_.Reset(); |
| 1596 | 1690 |
| 1597 // Turn off the internal display, simulating docked mode. | 1691 // Turn off the internal display, simulating docked mode. |
| 1598 configurator_.SetDisplayPower( | 1692 configurator_.SetDisplayPower( |
| 1599 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 1693 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 1600 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1694 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1601 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1695 config_waiter_.on_configuration_callback()); |
| 1602 base::Unretained(this))); | 1696 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1603 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1697 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1604 EXPECT_EQ(1, observer_.num_changes()); | 1698 EXPECT_EQ(1, observer_.num_changes()); |
| 1605 EXPECT_EQ(0, observer_.num_failures()); | 1699 EXPECT_EQ(0, observer_.num_failures()); |
| 1606 EXPECT_EQ( | 1700 EXPECT_EQ( |
| 1607 JoinActions( | 1701 JoinActions( |
| 1608 kGrab, | 1702 kGrab, |
| 1609 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) | 1703 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1610 .c_str(), | 1704 .c_str(), |
| 1611 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1705 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1612 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), | 1706 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 1613 kForceDPMS, | 1707 kForceDPMS, |
| 1614 kUngrab, | 1708 kUngrab, |
| 1615 NULL), | 1709 NULL), |
| 1616 log_->GetActionsAndClear()); | 1710 log_->GetActionsAndClear()); |
| 1617 | 1711 |
| 1618 // Suspend and resume the system. Resuming should restore the previous power | 1712 // Suspend and resume the system. Resuming should restore the previous power |
| 1619 // state and force a probe. Suspend should turn off the displays since an | 1713 // state and force a probe. Suspend should turn off the displays since an |
| 1620 // external monitor is connected. | 1714 // external monitor is connected. |
| 1621 configurator_.SuspendDisplays(base::Bind( | 1715 config_waiter_.Reset(); |
| 1622 &DisplayConfiguratorTest::OnConfiguredCallback, base::Unretained(this))); | 1716 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 1623 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1717 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1718 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1624 EXPECT_EQ(2, observer_.num_changes()); | 1719 EXPECT_EQ(2, observer_.num_changes()); |
| 1625 EXPECT_EQ( | 1720 EXPECT_EQ( |
| 1626 JoinActions( | 1721 JoinActions( |
| 1627 kGrab, | 1722 kGrab, |
| 1628 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1723 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 1629 &outputs_[1]).c_str(), | 1724 &outputs_[1]).c_str(), |
| 1630 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), | 1725 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), |
| 1631 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), | 1726 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), |
| 1632 kUngrab, | 1727 kUngrab, |
| 1633 kSync, | 1728 kSync, |
| 1634 NULL), | 1729 NULL), |
| 1635 log_->GetActionsAndClear()); | 1730 log_->GetActionsAndClear()); |
| 1636 | 1731 |
| 1637 // Before the task runs, exit docked mode. | 1732 // Before the task runs, exit docked mode. |
| 1638 configurator_.SetDisplayPower( | 1733 config_waiter_.Reset(); |
| 1639 chromeos::DISPLAY_POWER_ALL_ON, | 1734 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1640 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1735 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1641 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1736 config_waiter_.on_configuration_callback()); |
| 1642 base::Unretained(this))); | 1737 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1643 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1738 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1644 EXPECT_EQ(3, observer_.num_changes()); | 1739 EXPECT_EQ(3, observer_.num_changes()); |
| 1645 EXPECT_EQ(0, observer_.num_failures()); | 1740 EXPECT_EQ(0, observer_.num_failures()); |
| 1646 EXPECT_EQ( | 1741 EXPECT_EQ( |
| 1647 JoinActions( | 1742 JoinActions( |
| 1648 kGrab, | 1743 kGrab, |
| 1649 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) | 1744 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) |
| 1650 .c_str(), | 1745 .c_str(), |
| 1651 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1746 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1652 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1747 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1653 kForceDPMS, | 1748 kForceDPMS, |
| 1654 kUngrab, | 1749 kUngrab, |
| 1655 NULL), | 1750 NULL), |
| 1656 log_->GetActionsAndClear()); | 1751 log_->GetActionsAndClear()); |
| 1657 | 1752 |
| 1658 // Check that the display states are not changed after resuming. | 1753 // Check that the display states are not changed after resuming. |
| 1659 configurator_.ResumeDisplays(); | 1754 config_waiter_.Reset(); |
| 1755 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 1756 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1757 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1758 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 1759 configurator_.current_power_state()); |
| 1660 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 1760 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 1661 } | 1761 } |
| 1662 | 1762 |
| 1663 TEST_F(DisplayConfiguratorTest, ExternalControl) { | 1763 TEST_F(DisplayConfiguratorTest, ExternalControl) { |
| 1664 InitWithSingleOutput(); | 1764 InitWithSingleOutput(); |
| 1665 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1765 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 1666 configurator_.RelinquishControl( | 1766 configurator_.RelinquishControl( |
| 1667 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, | 1767 base::Bind(&DisplayConfiguratorTest::OnDisplayControlUpdated, |
| 1668 base::Unretained(this))); | 1768 base::Unretained(this))); |
| 1669 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); | 1769 EXPECT_EQ(CALLBACK_SUCCESS, PopDisplayControlResult()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1689 SetDisplayPowerWhilePendingConfigurationTaskRunning) { | 1789 SetDisplayPowerWhilePendingConfigurationTaskRunning) { |
| 1690 // Start out with two displays in extended mode. | 1790 // Start out with two displays in extended mode. |
| 1691 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1791 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1692 Init(false); | 1792 Init(false); |
| 1693 configurator_.ForceInitialConfigure(0); | 1793 configurator_.ForceInitialConfigure(0); |
| 1694 log_->GetActionsAndClear(); | 1794 log_->GetActionsAndClear(); |
| 1695 observer_.Reset(); | 1795 observer_.Reset(); |
| 1696 | 1796 |
| 1697 native_display_delegate_->set_run_async(true); | 1797 native_display_delegate_->set_run_async(true); |
| 1698 | 1798 |
| 1699 configurator_.SetDisplayPower( | 1799 config_waiter_.Reset(); |
| 1700 chromeos::DISPLAY_POWER_ALL_OFF, | 1800 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 1701 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1801 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1702 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1802 config_waiter_.on_configuration_callback()); |
| 1703 base::Unretained(this))); | |
| 1704 | 1803 |
| 1705 configurator_.SetDisplayPower( | 1804 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1706 chromeos::DISPLAY_POWER_ALL_ON, | 1805 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1707 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1806 config_waiter_.on_configuration_callback()); |
| 1708 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | |
| 1709 base::Unretained(this))); | |
| 1710 | 1807 |
| 1711 EXPECT_EQ(CALLBACK_NOT_CALLED, PopCallbackResult()); | 1808 EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result()); |
| 1712 base::RunLoop().RunUntilIdle(); | 1809 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1713 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1810 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1714 EXPECT_EQ(1, observer_.num_changes()); | 1811 EXPECT_EQ(1, observer_.num_changes()); |
| 1715 EXPECT_EQ(0, observer_.num_failures()); | 1812 EXPECT_EQ(0, observer_.num_failures()); |
| 1716 | 1813 |
| 1717 const int kDualHeight = small_mode_.size().height() + | 1814 const int kDualHeight = small_mode_.size().height() + |
| 1718 DisplayConfigurator::kVerticalGap + | 1815 DisplayConfigurator::kVerticalGap + |
| 1719 big_mode_.size().height(); | 1816 big_mode_.size().height(); |
| 1720 EXPECT_EQ( | 1817 EXPECT_EQ( |
| 1721 JoinActions( | 1818 JoinActions( |
| 1722 kGrab, | 1819 kGrab, |
| 1723 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1820 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1724 &outputs_[0], &outputs_[1]) | 1821 &outputs_[0], &outputs_[1]) |
| 1725 .c_str(), | 1822 .c_str(), |
| 1726 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), | 1823 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1727 GetCrtcAction(outputs_[1], nullptr, | 1824 GetCrtcAction(outputs_[1], nullptr, |
| 1728 gfx::Point(0, small_mode_.size().height() + | 1825 gfx::Point(0, small_mode_.size().height() + |
| 1729 DisplayConfigurator::kVerticalGap)) | 1826 DisplayConfigurator::kVerticalGap)) |
| 1730 .c_str(), | 1827 .c_str(), |
| 1731 kUngrab, NULL), | 1828 kUngrab, NULL), |
| 1732 log_->GetActionsAndClear()); | 1829 log_->GetActionsAndClear()); |
| 1733 | 1830 |
| 1831 config_waiter_.Reset(); |
| 1734 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 1832 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 1735 base::RunLoop().RunUntilIdle(); | 1833 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1736 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | 1834 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1737 EXPECT_EQ(2, observer_.num_changes()); | 1835 EXPECT_EQ(2, observer_.num_changes()); |
| 1738 EXPECT_EQ(0, observer_.num_failures()); | 1836 EXPECT_EQ(0, observer_.num_failures()); |
| 1739 | 1837 |
| 1740 EXPECT_EQ( | 1838 EXPECT_EQ( |
| 1741 JoinActions( | 1839 JoinActions( |
| 1742 kGrab, | 1840 kGrab, |
| 1743 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1841 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1744 &outputs_[0], &outputs_[1]) | 1842 &outputs_[0], &outputs_[1]) |
| 1745 .c_str(), | 1843 .c_str(), |
| 1746 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1844 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1757 // Start out with two displays in extended mode. | 1855 // Start out with two displays in extended mode. |
| 1758 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 1856 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 1759 Init(false); | 1857 Init(false); |
| 1760 configurator_.ForceInitialConfigure(0); | 1858 configurator_.ForceInitialConfigure(0); |
| 1761 log_->GetActionsAndClear(); | 1859 log_->GetActionsAndClear(); |
| 1762 observer_.Reset(); | 1860 observer_.Reset(); |
| 1763 | 1861 |
| 1764 // Fail display configuration. | 1862 // Fail display configuration. |
| 1765 native_display_delegate_->set_max_configurable_pixels(-1); | 1863 native_display_delegate_->set_max_configurable_pixels(-1); |
| 1766 | 1864 |
| 1767 configurator_.SetDisplayPower( | 1865 config_waiter_.Reset(); |
| 1768 chromeos::DISPLAY_POWER_ALL_OFF, | 1866 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 1769 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1867 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1770 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1868 config_waiter_.on_configuration_callback()); |
| 1771 base::Unretained(this))); | 1869 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1772 | 1870 EXPECT_EQ(CALLBACK_FAILURE, config_waiter_.callback_result()); |
| 1773 EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult()); | |
| 1774 EXPECT_EQ(0, observer_.num_changes()); | 1871 EXPECT_EQ(0, observer_.num_changes()); |
| 1775 EXPECT_EQ(1, observer_.num_failures()); | 1872 EXPECT_EQ(1, observer_.num_failures()); |
| 1776 | 1873 |
| 1777 const int kDualHeight = small_mode_.size().height() + | 1874 const int kDualHeight = small_mode_.size().height() + |
| 1778 DisplayConfigurator::kVerticalGap + | 1875 DisplayConfigurator::kVerticalGap + |
| 1779 big_mode_.size().height(); | 1876 big_mode_.size().height(); |
| 1780 | 1877 |
| 1781 EXPECT_EQ( | 1878 EXPECT_EQ( |
| 1782 JoinActions( | 1879 JoinActions( |
| 1783 kGrab, | 1880 kGrab, |
| 1784 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1881 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1785 &outputs_[0], &outputs_[1]) | 1882 &outputs_[0], &outputs_[1]) |
| 1786 .c_str(), | 1883 .c_str(), |
| 1787 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), | 1884 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1788 GetCrtcAction(outputs_[1], nullptr, | 1885 GetCrtcAction(outputs_[1], nullptr, |
| 1789 gfx::Point(0, small_mode_.size().height() + | 1886 gfx::Point(0, small_mode_.size().height() + |
| 1790 DisplayConfigurator::kVerticalGap)) | 1887 DisplayConfigurator::kVerticalGap)) |
| 1791 .c_str(), | 1888 .c_str(), |
| 1792 kUngrab, NULL), | 1889 kUngrab, NULL), |
| 1793 log_->GetActionsAndClear()); | 1890 log_->GetActionsAndClear()); |
| 1794 | 1891 |
| 1795 // This configuration should trigger a display configuration since the | 1892 // This configuration should trigger a display configuration since the |
| 1796 // previous configuration failed. | 1893 // previous configuration failed. |
| 1797 configurator_.SetDisplayPower( | 1894 config_waiter_.Reset(); |
| 1798 chromeos::DISPLAY_POWER_ALL_ON, | 1895 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1799 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1896 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1800 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1897 config_waiter_.on_configuration_callback()); |
| 1801 base::Unretained(this))); | 1898 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1802 | 1899 |
| 1803 EXPECT_EQ(0, observer_.num_changes()); | 1900 EXPECT_EQ(0, observer_.num_changes()); |
| 1804 EXPECT_EQ(2, observer_.num_failures()); | 1901 EXPECT_EQ(2, observer_.num_failures()); |
| 1805 EXPECT_EQ( | 1902 EXPECT_EQ( |
| 1806 JoinActions( | 1903 JoinActions( |
| 1807 kGrab, | 1904 kGrab, |
| 1808 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), | 1905 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), |
| 1809 &outputs_[0], &outputs_[1]) | 1906 &outputs_[0], &outputs_[1]) |
| 1810 .c_str(), | 1907 .c_str(), |
| 1811 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1908 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 GetCrtcAction( | 1974 GetCrtcAction( |
| 1878 outputs_[2], &small_mode_, | 1975 outputs_[2], &small_mode_, |
| 1879 gfx::Point(0, small_mode_.size().height() + | 1976 gfx::Point(0, small_mode_.size().height() + |
| 1880 big_mode_.size().height() + | 1977 big_mode_.size().height() + |
| 1881 2 * DisplayConfigurator::kVerticalGap)) | 1978 2 * DisplayConfigurator::kVerticalGap)) |
| 1882 .c_str(), | 1979 .c_str(), |
| 1883 kUngrab, NULL), | 1980 kUngrab, NULL), |
| 1884 log_->GetActionsAndClear()); | 1981 log_->GetActionsAndClear()); |
| 1885 | 1982 |
| 1886 // Verify that turning the power off works. | 1983 // Verify that turning the power off works. |
| 1887 configurator_.SetDisplayPower( | 1984 config_waiter_.Reset(); |
| 1888 chromeos::DISPLAY_POWER_ALL_OFF, | 1985 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, |
| 1889 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1986 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1890 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 1987 config_waiter_.on_configuration_callback()); |
| 1891 base::Unretained(this))); | 1988 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1892 | 1989 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1893 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | |
| 1894 EXPECT_EQ( | 1990 EXPECT_EQ( |
| 1895 JoinActions( | 1991 JoinActions( |
| 1896 kGrab, GetFramebufferAction( | 1992 kGrab, GetFramebufferAction( |
| 1897 gfx::Size(big_mode_.size().width(), kTripleHeight), | 1993 gfx::Size(big_mode_.size().width(), kTripleHeight), |
| 1898 &outputs_[0], &outputs_[1]) | 1994 &outputs_[0], &outputs_[1]) |
| 1899 .c_str(), | 1995 .c_str(), |
| 1900 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), | 1996 GetCrtcAction(outputs_[0], nullptr, gfx::Point(0, 0)).c_str(), |
| 1901 GetCrtcAction(outputs_[1], nullptr, | 1997 GetCrtcAction(outputs_[1], nullptr, |
| 1902 gfx::Point(0, small_mode_.size().height() + | 1998 gfx::Point(0, small_mode_.size().height() + |
| 1903 DisplayConfigurator::kVerticalGap)) | 1999 DisplayConfigurator::kVerticalGap)) |
| 1904 .c_str(), | 2000 .c_str(), |
| 1905 GetCrtcAction( | 2001 GetCrtcAction( |
| 1906 outputs_[2], nullptr, | 2002 outputs_[2], nullptr, |
| 1907 gfx::Point(0, small_mode_.size().height() + | 2003 gfx::Point(0, small_mode_.size().height() + |
| 1908 big_mode_.size().height() + | 2004 big_mode_.size().height() + |
| 1909 2 * DisplayConfigurator::kVerticalGap)) | 2005 2 * DisplayConfigurator::kVerticalGap)) |
| 1910 .c_str(), | 2006 .c_str(), |
| 1911 kUngrab, NULL), | 2007 kUngrab, NULL), |
| 1912 log_->GetActionsAndClear()); | 2008 log_->GetActionsAndClear()); |
| 1913 | 2009 |
| 1914 configurator_.SetDisplayPower( | 2010 config_waiter_.Reset(); |
| 1915 chromeos::DISPLAY_POWER_ALL_ON, | 2011 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1916 DisplayConfigurator::kSetDisplayPowerNoFlags, | 2012 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1917 base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback, | 2013 config_waiter_.on_configuration_callback()); |
| 1918 base::Unretained(this))); | 2014 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 1919 | 2015 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1920 EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult()); | |
| 1921 EXPECT_EQ( | 2016 EXPECT_EQ( |
| 1922 JoinActions( | 2017 JoinActions( |
| 1923 kGrab, GetFramebufferAction( | 2018 kGrab, GetFramebufferAction( |
| 1924 gfx::Size(big_mode_.size().width(), kTripleHeight), | 2019 gfx::Size(big_mode_.size().width(), kTripleHeight), |
| 1925 &outputs_[0], &outputs_[1]) | 2020 &outputs_[0], &outputs_[1]) |
| 1926 .c_str(), | 2021 .c_str(), |
| 1927 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 2022 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1928 GetCrtcAction(outputs_[1], &big_mode_, | 2023 GetCrtcAction(outputs_[1], &big_mode_, |
| 1929 gfx::Point(0, small_mode_.size().height() + | 2024 gfx::Point(0, small_mode_.size().height() + |
| 1930 DisplayConfigurator::kVerticalGap)) | 2025 DisplayConfigurator::kVerticalGap)) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1950 .c_str(), | 2045 .c_str(), |
| 1951 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 2046 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 1952 GetCrtcAction(outputs_[1], &big_mode_, | 2047 GetCrtcAction(outputs_[1], &big_mode_, |
| 1953 gfx::Point(0, small_mode_.size().height() + | 2048 gfx::Point(0, small_mode_.size().height() + |
| 1954 DisplayConfigurator::kVerticalGap)) | 2049 DisplayConfigurator::kVerticalGap)) |
| 1955 .c_str(), | 2050 .c_str(), |
| 1956 kUngrab, NULL), | 2051 kUngrab, NULL), |
| 1957 log_->GetActionsAndClear()); | 2052 log_->GetActionsAndClear()); |
| 1958 } | 2053 } |
| 1959 | 2054 |
| 2055 // Tests the suspend and resume behavior when in dual or multi display modes. |
| 2056 TEST_F(DisplayConfiguratorTest, SuspendResumeWithMultipleDisplays) { |
| 2057 InitWithSingleOutput(); |
| 2058 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 2059 observer_.Reset(); |
| 2060 UpdateOutputs(2, true); |
| 2061 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 2062 configurator_.display_state()); |
| 2063 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 2064 EXPECT_EQ(1, observer_.num_changes()); |
| 2065 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2066 configurator_.current_power_state()); |
| 2067 |
| 2068 // Suspending displays should result in an immediate configuration without |
| 2069 // delays, even in dual display mode. |
| 2070 config_waiter_.Reset(); |
| 2071 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 2072 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 2073 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 2074 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF, |
| 2075 configurator_.current_power_state()); |
| 2076 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 2077 configurator_.display_state()); |
| 2078 |
| 2079 // Resuming from suspend with dual displays, should be done after a delay, and |
| 2080 // after the configuration we should still expect to be in a dual display |
| 2081 // mode. |
| 2082 config_waiter_.Reset(); |
| 2083 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 2084 EXPECT_GE(test_api_.GetConfigureDelay(), kMinLongDelayMs); |
| 2085 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 2086 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 2087 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2088 configurator_.current_power_state()); |
| 2089 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 2090 configurator_.display_state()); |
| 2091 |
| 2092 // Suspend displays and disconnect one of them while in suspend. |
| 2093 config_waiter_.Reset(); |
| 2094 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 2095 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 2096 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 2097 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 2098 configurator_.display_state()); |
| 2099 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF, |
| 2100 configurator_.current_power_state()); |
| 2101 UpdateOutputs(1, false); |
| 2102 |
| 2103 // Now resume, and expect that we'll still have a long delay since we were in |
| 2104 // dual mode before suspend. The configurator should pick up the change and |
| 2105 // detect that we are in single display mode now. |
| 2106 config_waiter_.Reset(); |
| 2107 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 2108 EXPECT_GE(config_waiter_.Wait(), kMinLongDelayMs); |
| 2109 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 2110 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2111 configurator_.current_power_state()); |
| 2112 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| 2113 |
| 2114 // Verify that the above is the exact same behavior for 3+ displays. |
| 2115 UpdateOutputs(3, true); |
| 2116 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 2117 configurator_.display_state()); |
| 2118 // Suspend. |
| 2119 config_waiter_.Reset(); |
| 2120 configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); |
| 2121 EXPECT_LT(config_waiter_.Wait(), kMaxShortDelayMs); |
| 2122 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 2123 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 2124 configurator_.display_state()); |
| 2125 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF, |
| 2126 configurator_.current_power_state()); |
| 2127 |
| 2128 // Resume and expect the correct delay. |
| 2129 config_waiter_.Reset(); |
| 2130 configurator_.ResumeDisplays(config_waiter_.on_configuration_callback()); |
| 2131 EXPECT_GE(config_waiter_.Wait(), kMinLongDelayMs); |
| 2132 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 2133 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2134 configurator_.current_power_state()); |
| 2135 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 2136 configurator_.display_state()); |
| 2137 } |
| 2138 |
| 1960 } // namespace test | 2139 } // namespace test |
| 1961 } // namespace ui | 2140 } // namespace ui |
| OLD | NEW |