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

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

Issue 1019623002: Remove DisplayState from the public interface for DisplayConfigurator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update ash_unittests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "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
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; 62 if (new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) {
60 state.selected_mode = display->native_mode(); 63 if (should_mirror_)
61 if (should_mirror_) 64 mode = FindMirrorMode(displays);
62 state.mirror_mode = FindMirrorMode(displays); 65 else
63 66 mode = nullptr;
oshima 2015/03/18 23:02:45 ternary operator?
dnicoara 2015/03/19 14:47:36 Done.
64 parsed_displays.push_back(state); 67 }
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)
80 mode = state.mirror_mode;
81 68
82 if (!mode) 69 if (!mode)
83 return false; 70 return false;
84 71
85 if (new_power_state == chromeos::DISPLAY_POWER_ALL_ON) { 72 if (new_power_state == chromeos::DISPLAY_POWER_ALL_ON) {
86 requests->push_back( 73 requests->push_back(DisplayConfigureRequest(display, mode, origin));
87 DisplayConfigureRequest(state.display, mode, origin));
88 } else { 74 } else {
89 requests->push_back( 75 requests->push_back(DisplayConfigureRequest(display, nullptr, origin));
90 DisplayConfigureRequest(state.display, nullptr, origin));
91 } 76 }
92 77
93 if (new_display_state != MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) { 78 if (new_display_state != MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) {
94 origin.Offset(0, state.selected_mode->size().height()); 79 origin.Offset(0, mode->size().height());
95 framebuffer_size->SetToMax(gfx::Size(mode->size().width(), origin.y())); 80 framebuffer_size->SetToMax(gfx::Size(mode->size().width(), origin.y()));
96 } else { 81 } else {
97 *framebuffer_size = mode->size(); 82 *framebuffer_size = mode->size();
98 } 83 }
99 } 84 }
100 85
101 return true; 86 return true;
102 } 87 }
103 88
104 private: 89 private:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ~UpdateDisplayConfigurationTaskTest() override {} 133 ~UpdateDisplayConfigurationTaskTest() override {}
149 134
150 void UpdateDisplays(size_t count) { 135 void UpdateDisplays(size_t count) {
151 std::vector<DisplaySnapshot*> displays; 136 std::vector<DisplaySnapshot*> displays;
152 for (size_t i = 0; i < count; ++i) 137 for (size_t i = 0; i < count; ++i)
153 displays.push_back(&displays_[i]); 138 displays.push_back(&displays_[i]);
154 139
155 delegate_.set_outputs(displays); 140 delegate_.set_outputs(displays);
156 } 141 }
157 142
158 void ResponseCallback( 143 void ResponseCallback(bool success,
159 bool success, 144 const std::vector<DisplaySnapshot*>& displays,
160 const std::vector<DisplayConfigurator::DisplayState>& displays, 145 const gfx::Size& framebuffer_size,
161 const gfx::Size& framebuffer_size, 146 MultipleDisplayState new_display_state,
162 MultipleDisplayState new_display_state, 147 chromeos::DisplayPowerState new_power_state) {
163 chromeos::DisplayPowerState new_power_state) {
164 configured_ = true; 148 configured_ = true;
165 configuration_status_ = success; 149 configuration_status_ = success;
166 display_states_ = displays; 150 display_states_ = displays;
167 display_state_ = new_display_state; 151 display_state_ = new_display_state;
168 power_state_ = new_power_state; 152 power_state_ = new_power_state;
169 153
170 if (success) { 154 if (success) {
171 layout_manager_.set_display_state(display_state_); 155 layout_manager_.set_display_state(display_state_);
172 layout_manager_.set_power_state(power_state_); 156 layout_manager_.set_power_state(power_state_);
173 } 157 }
174 } 158 }
175 159
176 protected: 160 protected:
177 ActionLogger log_; 161 ActionLogger log_;
178 TestNativeDisplayDelegate delegate_; 162 TestNativeDisplayDelegate delegate_;
179 TestDisplayLayoutManager layout_manager_; 163 TestDisplayLayoutManager layout_manager_;
180 164
181 const DisplayMode small_mode_; 165 const DisplayMode small_mode_;
182 const DisplayMode big_mode_; 166 const DisplayMode big_mode_;
183 167
184 TestDisplaySnapshot displays_[2]; 168 TestDisplaySnapshot displays_[2];
185 169
186 bool configured_; 170 bool configured_;
187 bool configuration_status_; 171 bool configuration_status_;
188 std::vector<DisplayConfigurator::DisplayState> display_states_; 172 std::vector<DisplaySnapshot*> display_states_;
189 MultipleDisplayState display_state_; 173 MultipleDisplayState display_state_;
190 chromeos::DisplayPowerState power_state_; 174 chromeos::DisplayPowerState power_state_;
191 175
192 private: 176 private:
193 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTaskTest); 177 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTaskTest);
194 }; 178 };
195 179
196 } // namespace 180 } // namespace
197 181
198 TEST_F(UpdateDisplayConfigurationTaskTest, HeadlessConfiguration) { 182 TEST_F(UpdateDisplayConfigurationTaskTest, HeadlessConfiguration) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 EXPECT_EQ( 361 EXPECT_EQ(
378 JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), &displays_[0], 362 JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), &displays_[0],
379 nullptr).c_str(), 363 nullptr).c_str(),
380 GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(), 364 GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(),
381 kUngrab, NULL), 365 kUngrab, NULL),
382 log_.GetActionsAndClear()); 366 log_.GetActionsAndClear());
383 } 367 }
384 368
385 } // namespace test 369 } // namespace test
386 } // namespace ui 370 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698