| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/display/chromeos/test/action_logger_util.h" | 9 #include "ui/display/chromeos/test/action_logger_util.h" |
| 10 #include "ui/display/chromeos/test/test_display_snapshot.h" | 10 #include "ui/display/chromeos/test/test_display_snapshot.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 MultipleDisplayState GetDisplayState() const override { | 46 MultipleDisplayState GetDisplayState() const override { |
| 47 return display_state_; | 47 return display_state_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 chromeos::DisplayPowerState GetPowerState() const override { | 50 chromeos::DisplayPowerState GetPowerState() const override { |
| 51 return power_state_; | 51 return power_state_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 std::vector<DisplayConfigurator::DisplayState> ParseDisplays( | 54 bool GetDisplayLayout(const std::vector<DisplaySnapshot*>& displays, |
| 55 const std::vector<DisplaySnapshot*>& displays) const override { | 55 MultipleDisplayState new_display_state, |
| 56 std::vector<DisplayConfigurator::DisplayState> parsed_displays; | 56 chromeos::DisplayPowerState new_power_state, |
| 57 std::vector<DisplayConfigureRequest>* requests, |
| 58 gfx::Size* framebuffer_size) const override { |
| 59 gfx::Point origin; |
| 57 for (DisplaySnapshot* display : displays) { | 60 for (DisplaySnapshot* display : displays) { |
| 58 DisplayConfigurator::DisplayState state; | 61 const DisplayMode* mode = display->native_mode(); |
| 59 state.display = display; | |
| 60 state.selected_mode = display->native_mode(); | |
| 61 if (should_mirror_) | |
| 62 state.mirror_mode = FindMirrorMode(displays); | |
| 63 | |
| 64 parsed_displays.push_back(state); | |
| 65 } | |
| 66 | |
| 67 return parsed_displays; | |
| 68 } | |
| 69 | |
| 70 bool GetDisplayLayout( | |
| 71 const std::vector<DisplayConfigurator::DisplayState>& displays, | |
| 72 MultipleDisplayState new_display_state, | |
| 73 chromeos::DisplayPowerState new_power_state, | |
| 74 std::vector<DisplayConfigureRequest>* requests, | |
| 75 gfx::Size* framebuffer_size) const override { | |
| 76 gfx::Point origin; | |
| 77 for (const DisplayConfigurator::DisplayState& state : displays) { | |
| 78 const DisplayMode* mode = state.selected_mode; | |
| 79 if (new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) | 62 if (new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) |
| 80 mode = state.mirror_mode; | 63 mode = should_mirror_ ? FindMirrorMode(displays) : nullptr; |
| 81 | 64 |
| 82 if (!mode) | 65 if (!mode) |
| 83 return false; | 66 return false; |
| 84 | 67 |
| 85 if (new_power_state == chromeos::DISPLAY_POWER_ALL_ON) { | 68 if (new_power_state == chromeos::DISPLAY_POWER_ALL_ON) { |
| 86 requests->push_back( | 69 requests->push_back(DisplayConfigureRequest(display, mode, origin)); |
| 87 DisplayConfigureRequest(state.display, mode, origin)); | |
| 88 } else { | 70 } else { |
| 89 requests->push_back( | 71 requests->push_back(DisplayConfigureRequest(display, nullptr, origin)); |
| 90 DisplayConfigureRequest(state.display, nullptr, origin)); | |
| 91 } | 72 } |
| 92 | 73 |
| 93 if (new_display_state != MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) { | 74 if (new_display_state != MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) { |
| 94 origin.Offset(0, state.selected_mode->size().height()); | 75 origin.Offset(0, mode->size().height()); |
| 95 framebuffer_size->SetToMax(gfx::Size(mode->size().width(), origin.y())); | 76 framebuffer_size->SetToMax(gfx::Size(mode->size().width(), origin.y())); |
| 96 } else { | 77 } else { |
| 97 *framebuffer_size = mode->size(); | 78 *framebuffer_size = mode->size(); |
| 98 } | 79 } |
| 99 } | 80 } |
| 100 | 81 |
| 101 return true; | 82 return true; |
| 102 } | 83 } |
| 103 | 84 |
| 104 private: | 85 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 ~UpdateDisplayConfigurationTaskTest() override {} | 129 ~UpdateDisplayConfigurationTaskTest() override {} |
| 149 | 130 |
| 150 void UpdateDisplays(size_t count) { | 131 void UpdateDisplays(size_t count) { |
| 151 std::vector<DisplaySnapshot*> displays; | 132 std::vector<DisplaySnapshot*> displays; |
| 152 for (size_t i = 0; i < count; ++i) | 133 for (size_t i = 0; i < count; ++i) |
| 153 displays.push_back(&displays_[i]); | 134 displays.push_back(&displays_[i]); |
| 154 | 135 |
| 155 delegate_.set_outputs(displays); | 136 delegate_.set_outputs(displays); |
| 156 } | 137 } |
| 157 | 138 |
| 158 void ResponseCallback( | 139 void ResponseCallback(bool success, |
| 159 bool success, | 140 const std::vector<DisplaySnapshot*>& displays, |
| 160 const std::vector<DisplayConfigurator::DisplayState>& displays, | 141 const gfx::Size& framebuffer_size, |
| 161 const gfx::Size& framebuffer_size, | 142 MultipleDisplayState new_display_state, |
| 162 MultipleDisplayState new_display_state, | 143 chromeos::DisplayPowerState new_power_state) { |
| 163 chromeos::DisplayPowerState new_power_state) { | |
| 164 configured_ = true; | 144 configured_ = true; |
| 165 configuration_status_ = success; | 145 configuration_status_ = success; |
| 166 display_states_ = displays; | 146 display_states_ = displays; |
| 167 display_state_ = new_display_state; | 147 display_state_ = new_display_state; |
| 168 power_state_ = new_power_state; | 148 power_state_ = new_power_state; |
| 169 | 149 |
| 170 if (success) { | 150 if (success) { |
| 171 layout_manager_.set_display_state(display_state_); | 151 layout_manager_.set_display_state(display_state_); |
| 172 layout_manager_.set_power_state(power_state_); | 152 layout_manager_.set_power_state(power_state_); |
| 173 } | 153 } |
| 174 } | 154 } |
| 175 | 155 |
| 176 protected: | 156 protected: |
| 177 ActionLogger log_; | 157 ActionLogger log_; |
| 178 TestNativeDisplayDelegate delegate_; | 158 TestNativeDisplayDelegate delegate_; |
| 179 TestDisplayLayoutManager layout_manager_; | 159 TestDisplayLayoutManager layout_manager_; |
| 180 | 160 |
| 181 const DisplayMode small_mode_; | 161 const DisplayMode small_mode_; |
| 182 const DisplayMode big_mode_; | 162 const DisplayMode big_mode_; |
| 183 | 163 |
| 184 TestDisplaySnapshot displays_[2]; | 164 TestDisplaySnapshot displays_[2]; |
| 185 | 165 |
| 186 bool configured_; | 166 bool configured_; |
| 187 bool configuration_status_; | 167 bool configuration_status_; |
| 188 std::vector<DisplayConfigurator::DisplayState> display_states_; | 168 std::vector<DisplaySnapshot*> display_states_; |
| 189 MultipleDisplayState display_state_; | 169 MultipleDisplayState display_state_; |
| 190 chromeos::DisplayPowerState power_state_; | 170 chromeos::DisplayPowerState power_state_; |
| 191 | 171 |
| 192 private: | 172 private: |
| 193 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTaskTest); | 173 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTaskTest); |
| 194 }; | 174 }; |
| 195 | 175 |
| 196 } // namespace | 176 } // namespace |
| 197 | 177 |
| 198 TEST_F(UpdateDisplayConfigurationTaskTest, HeadlessConfiguration) { | 178 TEST_F(UpdateDisplayConfigurationTaskTest, HeadlessConfiguration) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 EXPECT_EQ( | 357 EXPECT_EQ( |
| 378 JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), &displays_[0], | 358 JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), &displays_[0], |
| 379 nullptr).c_str(), | 359 nullptr).c_str(), |
| 380 GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(), | 360 GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(), |
| 381 kUngrab, NULL), | 361 kUngrab, NULL), |
| 382 log_.GetActionsAndClear()); | 362 log_.GetActionsAndClear()); |
| 383 } | 363 } |
| 384 | 364 |
| 385 } // namespace test | 365 } // namespace test |
| 386 } // namespace ui | 366 } // namespace ui |
| OLD | NEW |