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

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

Issue 226183004: Renamed OutputConfigurator to DisplayConfigurator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/chromeos/output_configurator.h" 5 #include "ui/display/chromeos/display_configurator.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <cstdarg> 10 #include <cstdarg>
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 "framebuffer(width=%d,height=%d,display1=%s,display2=%s)", 78 "framebuffer(width=%d,height=%d,display1=%s,display2=%s)",
79 size.width(), 79 size.width(),
80 size.height(), 80 size.height(),
81 out1 ? DisplaySnapshotToString(*out1).c_str() : "NULL", 81 out1 ? DisplaySnapshotToString(*out1).c_str() : "NULL",
82 out2 ? DisplaySnapshotToString(*out2).c_str() : "NULL"); 82 out2 ? DisplaySnapshotToString(*out2).c_str() : "NULL");
83 } 83 }
84 84
85 // Returns a string describing a TestNativeDisplayDelegate::ConfigureCTM() call. 85 // Returns a string describing a TestNativeDisplayDelegate::ConfigureCTM() call.
86 std::string GetCTMAction( 86 std::string GetCTMAction(
87 int device_id, 87 int device_id,
88 const OutputConfigurator::CoordinateTransformation& ctm) { 88 const DisplayConfigurator::CoordinateTransformation& ctm) {
89 return base::StringPrintf("ctm(id=%d,transform=(%f,%f,%f,%f))", 89 return base::StringPrintf("ctm(id=%d,transform=(%f,%f,%f,%f))",
90 device_id, 90 device_id,
91 ctm.x_scale, 91 ctm.x_scale,
92 ctm.x_offset, 92 ctm.x_offset,
93 ctm.y_scale, 93 ctm.y_scale,
94 ctm.y_offset); 94 ctm.y_offset);
95 } 95 }
96 96
97 // Returns a string describing a TestNativeDisplayDelegate::SetHDCPState() call. 97 // Returns a string describing a TestNativeDisplayDelegate::SetHDCPState() call.
98 std::string GetSetHDCPStateAction(const DisplaySnapshot& output, 98 std::string GetSetHDCPStateAction(const DisplaySnapshot& output,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 actions_.clear(); 138 actions_.clear();
139 return actions; 139 return actions;
140 } 140 }
141 141
142 private: 142 private:
143 std::string actions_; 143 std::string actions_;
144 144
145 DISALLOW_COPY_AND_ASSIGN(ActionLogger); 145 DISALLOW_COPY_AND_ASSIGN(ActionLogger);
146 }; 146 };
147 147
148 class TestTouchscreenDelegate : public OutputConfigurator::TouchscreenDelegate { 148 class TestTouchscreenDelegate
149 : public DisplayConfigurator::TouchscreenDelegate {
149 public: 150 public:
150 // Ownership of |log| remains with the caller. 151 // Ownership of |log| remains with the caller.
151 explicit TestTouchscreenDelegate(ActionLogger* log) 152 explicit TestTouchscreenDelegate(ActionLogger* log)
152 : log_(log), 153 : log_(log),
153 configure_touchscreens_(false) {} 154 configure_touchscreens_(false) {}
154 virtual ~TestTouchscreenDelegate() {} 155 virtual ~TestTouchscreenDelegate() {}
155 156
156 const OutputConfigurator::CoordinateTransformation& GetCTM( 157 const DisplayConfigurator::CoordinateTransformation& GetCTM(
157 int touch_device_id) { 158 int touch_device_id) {
158 return ctms_[touch_device_id]; 159 return ctms_[touch_device_id];
159 } 160 }
160 161
161 void set_configure_touchscreens(bool state) { 162 void set_configure_touchscreens(bool state) {
162 configure_touchscreens_ = state; 163 configure_touchscreens_ = state;
163 } 164 }
164 165
165 // OutputConfigurator::TouchscreenDelegate implementation: 166 // DisplayConfigurator::TouchscreenDelegate implementation:
166 virtual void AssociateTouchscreens( 167 virtual void AssociateTouchscreens(
167 OutputConfigurator::DisplayStateList* outputs) OVERRIDE { 168 DisplayConfigurator::DisplayStateList* outputs) OVERRIDE {
168 if (configure_touchscreens_) { 169 if (configure_touchscreens_) {
169 for (size_t i = 0; i < outputs->size(); ++i) 170 for (size_t i = 0; i < outputs->size(); ++i)
170 (*outputs)[i].touch_device_id = i + 1; 171 (*outputs)[i].touch_device_id = i + 1;
171 } 172 }
172 } 173 }
173 virtual void ConfigureCTM( 174 virtual void ConfigureCTM(
174 int touch_device_id, 175 int touch_device_id,
175 const OutputConfigurator::CoordinateTransformation& ctm) OVERRIDE { 176 const DisplayConfigurator::CoordinateTransformation& ctm) OVERRIDE {
176 log_->AppendAction(GetCTMAction(touch_device_id, ctm)); 177 log_->AppendAction(GetCTMAction(touch_device_id, ctm));
177 ctms_[touch_device_id] = ctm; 178 ctms_[touch_device_id] = ctm;
178 } 179 }
179 180
180 private: 181 private:
181 ActionLogger* log_; // Not owned. 182 ActionLogger* log_; // Not owned.
182 183
183 bool configure_touchscreens_; 184 bool configure_touchscreens_;
184 185
185 // Most-recently-configured transformation matrices, keyed by touch device ID. 186 // Most-recently-configured transformation matrices, keyed by touch device ID.
186 std::map<int, OutputConfigurator::CoordinateTransformation> ctms_; 187 std::map<int, DisplayConfigurator::CoordinateTransformation> ctms_;
187 188
188 DISALLOW_COPY_AND_ASSIGN(TestTouchscreenDelegate); 189 DISALLOW_COPY_AND_ASSIGN(TestTouchscreenDelegate);
189 }; 190 };
190 191
191 class TestNativeDisplayDelegate : public NativeDisplayDelegate { 192 class TestNativeDisplayDelegate : public NativeDisplayDelegate {
192 public: 193 public:
193 // Ownership of |log| remains with the caller. 194 // Ownership of |log| remains with the caller.
194 explicit TestNativeDisplayDelegate(ActionLogger* log) 195 explicit TestNativeDisplayDelegate(ActionLogger* log)
195 : max_configurable_pixels_(0), 196 : max_configurable_pixels_(0),
196 hdcp_state_(HDCP_STATE_UNDESIRED), 197 hdcp_state_(HDCP_STATE_UNDESIRED),
197 log_(log) {} 198 log_(log) {}
198 virtual ~TestNativeDisplayDelegate() {} 199 virtual ~TestNativeDisplayDelegate() {}
199 200
200 const std::vector<DisplaySnapshot*>& outputs() const { return outputs_; } 201 const std::vector<DisplaySnapshot*>& outputs() const { return outputs_; }
201 void set_outputs(const std::vector<DisplaySnapshot*>& outputs) { 202 void set_outputs(const std::vector<DisplaySnapshot*>& outputs) {
202 outputs_ = outputs; 203 outputs_ = outputs;
203 } 204 }
204 205
205 void set_max_configurable_pixels(int pixels) { 206 void set_max_configurable_pixels(int pixels) {
206 max_configurable_pixels_ = pixels; 207 max_configurable_pixels_ = pixels;
207 } 208 }
208 209
209 void set_hdcp_state(HDCPState state) { hdcp_state_ = state; } 210 void set_hdcp_state(HDCPState state) { hdcp_state_ = state; }
210 211
211 // OutputConfigurator::Delegate overrides: 212 // DisplayConfigurator::Delegate overrides:
212 virtual void Initialize() OVERRIDE { log_->AppendAction(kInitXRandR); } 213 virtual void Initialize() OVERRIDE { log_->AppendAction(kInitXRandR); }
213 virtual void GrabServer() OVERRIDE { log_->AppendAction(kGrab); } 214 virtual void GrabServer() OVERRIDE { log_->AppendAction(kGrab); }
214 virtual void UngrabServer() OVERRIDE { log_->AppendAction(kUngrab); } 215 virtual void UngrabServer() OVERRIDE { log_->AppendAction(kUngrab); }
215 virtual void SyncWithServer() OVERRIDE { log_->AppendAction(kSync); } 216 virtual void SyncWithServer() OVERRIDE { log_->AppendAction(kSync); }
216 virtual void SetBackgroundColor(uint32_t color_argb) OVERRIDE { 217 virtual void SetBackgroundColor(uint32_t color_argb) OVERRIDE {
217 log_->AppendAction(GetBackgroundAction(color_argb)); 218 log_->AppendAction(GetBackgroundAction(color_argb));
218 } 219 }
219 virtual void ForceDPMSOn() OVERRIDE { log_->AppendAction(kForceDPMS); } 220 virtual void ForceDPMSOn() OVERRIDE { log_->AppendAction(kForceDPMS); }
220 virtual std::vector<DisplaySnapshot*> GetOutputs() OVERRIDE { 221 virtual std::vector<DisplaySnapshot*> GetOutputs() OVERRIDE {
221 return outputs_; 222 return outputs_;
(...skipping 27 matching lines...) Expand all
249 return true; 250 return true;
250 } 251 }
251 252
252 virtual bool SetHDCPState(const DisplaySnapshot& output, 253 virtual bool SetHDCPState(const DisplaySnapshot& output,
253 HDCPState state) OVERRIDE { 254 HDCPState state) OVERRIDE {
254 log_->AppendAction(GetSetHDCPStateAction(output, state)); 255 log_->AppendAction(GetSetHDCPStateAction(output, state));
255 return true; 256 return true;
256 } 257 }
257 258
258 virtual std::vector<ui::ColorCalibrationProfile> 259 virtual std::vector<ui::ColorCalibrationProfile>
259 GetAvailableColorCalibrationProfiles( 260 GetAvailableColorCalibrationProfiles(const DisplaySnapshot& output) OVERRIDE {
260 const DisplaySnapshot& output) OVERRIDE {
261 return std::vector<ui::ColorCalibrationProfile>(); 261 return std::vector<ui::ColorCalibrationProfile>();
262 } 262 }
263 263
264 virtual bool SetColorCalibrationProfile( 264 virtual bool SetColorCalibrationProfile(
265 const DisplaySnapshot& output, 265 const DisplaySnapshot& output,
266 ui::ColorCalibrationProfile new_profile) OVERRIDE { 266 ui::ColorCalibrationProfile new_profile) OVERRIDE {
267 return false; 267 return false;
268 } 268 }
269 269
270 virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE {} 270 virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE {}
(...skipping 13 matching lines...) Expand all
284 int max_configurable_pixels_; 284 int max_configurable_pixels_;
285 285
286 // Result value of GetHDCPState(). 286 // Result value of GetHDCPState().
287 HDCPState hdcp_state_; 287 HDCPState hdcp_state_;
288 288
289 ActionLogger* log_; // Not owned. 289 ActionLogger* log_; // Not owned.
290 290
291 DISALLOW_COPY_AND_ASSIGN(TestNativeDisplayDelegate); 291 DISALLOW_COPY_AND_ASSIGN(TestNativeDisplayDelegate);
292 }; 292 };
293 293
294 class TestObserver : public OutputConfigurator::Observer { 294 class TestObserver : public DisplayConfigurator::Observer {
295 public: 295 public:
296 explicit TestObserver(OutputConfigurator* configurator) 296 explicit TestObserver(DisplayConfigurator* configurator)
297 : configurator_(configurator) { 297 : configurator_(configurator) {
298 Reset(); 298 Reset();
299 configurator_->AddObserver(this); 299 configurator_->AddObserver(this);
300 } 300 }
301 virtual ~TestObserver() { configurator_->RemoveObserver(this); } 301 virtual ~TestObserver() { configurator_->RemoveObserver(this); }
302 302
303 int num_changes() const { return num_changes_; } 303 int num_changes() const { return num_changes_; }
304 int num_failures() const { return num_failures_; } 304 int num_failures() const { return num_failures_; }
305 const OutputConfigurator::DisplayStateList& latest_outputs() const { 305 const DisplayConfigurator::DisplayStateList& latest_outputs() const {
306 return latest_outputs_; 306 return latest_outputs_;
307 } 307 }
308 OutputState latest_failed_state() const { return latest_failed_state_; } 308 OutputState latest_failed_state() const { return latest_failed_state_; }
309 309
310 void Reset() { 310 void Reset() {
311 num_changes_ = 0; 311 num_changes_ = 0;
312 num_failures_ = 0; 312 num_failures_ = 0;
313 latest_outputs_.clear(); 313 latest_outputs_.clear();
314 latest_failed_state_ = OUTPUT_STATE_INVALID; 314 latest_failed_state_ = OUTPUT_STATE_INVALID;
315 } 315 }
316 316
317 // OutputConfigurator::Observer overrides: 317 // DisplayConfigurator::Observer overrides:
318 virtual void OnDisplayModeChanged( 318 virtual void OnDisplayModeChanged(
319 const OutputConfigurator::DisplayStateList& outputs) OVERRIDE { 319 const DisplayConfigurator::DisplayStateList& outputs) OVERRIDE {
320 num_changes_++; 320 num_changes_++;
321 latest_outputs_ = outputs; 321 latest_outputs_ = outputs;
322 } 322 }
323 323
324 virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) 324 virtual void OnDisplayModeChangeFailed(OutputState failed_new_state)
325 OVERRIDE { 325 OVERRIDE {
326 num_failures_++; 326 num_failures_++;
327 latest_failed_state_ = failed_new_state; 327 latest_failed_state_ = failed_new_state;
328 } 328 }
329 329
330 private: 330 private:
331 OutputConfigurator* configurator_; // Not owned. 331 DisplayConfigurator* configurator_; // Not owned.
332 332
333 // Number of times that OnDisplayMode*() has been called. 333 // Number of times that OnDisplayMode*() has been called.
334 int num_changes_; 334 int num_changes_;
335 int num_failures_; 335 int num_failures_;
336 336
337 // Parameters most recently passed to OnDisplayMode*(). 337 // Parameters most recently passed to OnDisplayMode*().
338 OutputConfigurator::DisplayStateList latest_outputs_; 338 DisplayConfigurator::DisplayStateList latest_outputs_;
339 OutputState latest_failed_state_; 339 OutputState latest_failed_state_;
340 340
341 DISALLOW_COPY_AND_ASSIGN(TestObserver); 341 DISALLOW_COPY_AND_ASSIGN(TestObserver);
342 }; 342 };
343 343
344 class TestStateController : public OutputConfigurator::StateController { 344 class TestStateController : public DisplayConfigurator::StateController {
345 public: 345 public:
346 TestStateController() : state_(OUTPUT_STATE_DUAL_EXTENDED) {} 346 TestStateController() : state_(OUTPUT_STATE_DUAL_EXTENDED) {}
347 virtual ~TestStateController() {} 347 virtual ~TestStateController() {}
348 348
349 void set_state(OutputState state) { state_ = state; } 349 void set_state(OutputState state) { state_ = state; }
350 350
351 // OutputConfigurator::StateController overrides: 351 // DisplayConfigurator::StateController overrides:
352 virtual OutputState GetStateForDisplayIds( 352 virtual OutputState GetStateForDisplayIds(
353 const std::vector<int64_t>& outputs) const OVERRIDE { 353 const std::vector<int64_t>& outputs) const OVERRIDE {
354 return state_; 354 return state_;
355 } 355 }
356 virtual bool GetResolutionForDisplayId(int64_t display_id, 356 virtual bool GetResolutionForDisplayId(int64_t display_id,
357 gfx::Size* size) const OVERRIDE { 357 gfx::Size* size) const OVERRIDE {
358 return false; 358 return false;
359 } 359 }
360 360
361 private: 361 private:
362 OutputState state_; 362 OutputState state_;
363 363
364 DISALLOW_COPY_AND_ASSIGN(TestStateController); 364 DISALLOW_COPY_AND_ASSIGN(TestStateController);
365 }; 365 };
366 366
367 class TestMirroringController 367 class TestMirroringController
368 : public OutputConfigurator::SoftwareMirroringController { 368 : public DisplayConfigurator::SoftwareMirroringController {
369 public: 369 public:
370 TestMirroringController() : software_mirroring_enabled_(false) {} 370 TestMirroringController() : software_mirroring_enabled_(false) {}
371 virtual ~TestMirroringController() {} 371 virtual ~TestMirroringController() {}
372 372
373 virtual void SetSoftwareMirroring(bool enabled) OVERRIDE { 373 virtual void SetSoftwareMirroring(bool enabled) OVERRIDE {
374 software_mirroring_enabled_ = enabled; 374 software_mirroring_enabled_ = enabled;
375 } 375 }
376 376
377 bool software_mirroring_enabled() const { 377 bool software_mirroring_enabled() const {
378 return software_mirroring_enabled_; 378 return software_mirroring_enabled_;
379 } 379 }
380 380
381 private: 381 private:
382 bool software_mirroring_enabled_; 382 bool software_mirroring_enabled_;
383 383
384 DISALLOW_COPY_AND_ASSIGN(TestMirroringController); 384 DISALLOW_COPY_AND_ASSIGN(TestMirroringController);
385 }; 385 };
386 386
387 class OutputConfiguratorTest : public testing::Test { 387 class DisplayConfiguratorTest : public testing::Test {
388 public: 388 public:
389 OutputConfiguratorTest() 389 DisplayConfiguratorTest()
390 : small_mode_(gfx::Size(1366, 768), false, 60.0f), 390 : small_mode_(gfx::Size(1366, 768), false, 60.0f),
391 big_mode_(gfx::Size(2560, 1600), false, 60.0f), 391 big_mode_(gfx::Size(2560, 1600), false, 60.0f),
392 observer_(&configurator_), 392 observer_(&configurator_),
393 test_api_(&configurator_) {} 393 test_api_(&configurator_) {}
394 virtual ~OutputConfiguratorTest() {} 394 virtual ~DisplayConfiguratorTest() {}
395 395
396 virtual void SetUp() OVERRIDE { 396 virtual void SetUp() OVERRIDE {
397 log_.reset(new ActionLogger()); 397 log_.reset(new ActionLogger());
398 398
399 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); 399 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get());
400 configurator_.SetNativeDisplayDelegateForTesting( 400 configurator_.SetNativeDisplayDelegateForTesting(
401 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_)); 401 scoped_ptr<NativeDisplayDelegate>(native_display_delegate_));
402 402
403 touchscreen_delegate_ = new TestTouchscreenDelegate(log_.get()); 403 touchscreen_delegate_ = new TestTouchscreenDelegate(log_.get());
404 configurator_.SetTouchscreenDelegateForTesting( 404 configurator_.SetTouchscreenDelegateForTesting(
405 scoped_ptr<OutputConfigurator::TouchscreenDelegate>( 405 scoped_ptr<DisplayConfigurator::TouchscreenDelegate>(
406 touchscreen_delegate_)); 406 touchscreen_delegate_));
407 407
408 configurator_.set_state_controller(&state_controller_); 408 configurator_.set_state_controller(&state_controller_);
409 configurator_.set_mirroring_controller(&mirroring_controller_); 409 configurator_.set_mirroring_controller(&mirroring_controller_);
410 410
411 std::vector<const DisplayMode*> modes; 411 std::vector<const DisplayMode*> modes;
412 modes.push_back(&small_mode_); 412 modes.push_back(&small_mode_);
413 413
414 TestDisplaySnapshot* o = &outputs_[0]; 414 TestDisplaySnapshot* o = &outputs_[0];
415 o->set_current_mode(&small_mode_); 415 o->set_current_mode(&small_mode_);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 472 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
473 kForceDPMS, 473 kForceDPMS,
474 kUngrab, 474 kUngrab,
475 NULL), 475 NULL),
476 log_->GetActionsAndClear()); 476 log_->GetActionsAndClear());
477 } 477 }
478 478
479 base::MessageLoop message_loop_; 479 base::MessageLoop message_loop_;
480 TestStateController state_controller_; 480 TestStateController state_controller_;
481 TestMirroringController mirroring_controller_; 481 TestMirroringController mirroring_controller_;
482 OutputConfigurator configurator_; 482 DisplayConfigurator configurator_;
483 TestObserver observer_; 483 TestObserver observer_;
484 scoped_ptr<ActionLogger> log_; 484 scoped_ptr<ActionLogger> log_;
485 TestNativeDisplayDelegate* native_display_delegate_; // not owned 485 TestNativeDisplayDelegate* native_display_delegate_; // not owned
486 TestTouchscreenDelegate* touchscreen_delegate_; // not owned 486 TestTouchscreenDelegate* touchscreen_delegate_; // not owned
487 OutputConfigurator::TestApi test_api_; 487 DisplayConfigurator::TestApi test_api_;
488 488
489 TestDisplaySnapshot outputs_[2]; 489 TestDisplaySnapshot outputs_[2];
490 490
491 private: 491 private:
492 DISALLOW_COPY_AND_ASSIGN(OutputConfiguratorTest); 492 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest);
493 }; 493 };
494 494
495 } // namespace 495 } // namespace
496 496
497 TEST_F(OutputConfiguratorTest, FindDisplayModeMatchingSize) { 497 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) {
498 ScopedVector<const DisplayMode> modes; 498 ScopedVector<const DisplayMode> modes;
499 499
500 // Fields are width, height, interlaced, refresh rate. 500 // Fields are width, height, interlaced, refresh rate.
501 modes.push_back(new DisplayMode(gfx::Size(1920, 1200), false, 60.0)); 501 modes.push_back(new DisplayMode(gfx::Size(1920, 1200), false, 60.0));
502 // Different rates. 502 // Different rates.
503 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 30.0)); 503 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 30.0));
504 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 50.0)); 504 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 50.0));
505 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); 505 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0));
506 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 0.0)); 506 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 0.0));
507 // Interlaced vs non-interlaced. 507 // Interlaced vs non-interlaced.
508 modes.push_back(new DisplayMode(gfx::Size(1280, 720), true, 60.0)); 508 modes.push_back(new DisplayMode(gfx::Size(1280, 720), true, 60.0));
509 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 40.0)); 509 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 40.0));
510 // Interlaced only. 510 // Interlaced only.
511 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 0.0)); 511 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 0.0));
512 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 40.0)); 512 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 40.0));
513 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 60.0)); 513 modes.push_back(new DisplayMode(gfx::Size(1024, 768), true, 60.0));
514 // Mixed. 514 // Mixed.
515 modes.push_back(new DisplayMode(gfx::Size(1024, 600), true, 60.0)); 515 modes.push_back(new DisplayMode(gfx::Size(1024, 600), true, 60.0));
516 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 40.0)); 516 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 40.0));
517 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 50.0)); 517 modes.push_back(new DisplayMode(gfx::Size(1024, 600), false, 50.0));
518 // Just one interlaced mode. 518 // Just one interlaced mode.
519 modes.push_back(new DisplayMode(gfx::Size(640, 480), true, 60.0)); 519 modes.push_back(new DisplayMode(gfx::Size(640, 480), true, 60.0));
520 // Refresh rate not available. 520 // Refresh rate not available.
521 modes.push_back(new DisplayMode(gfx::Size(320, 200), false, 0.0)); 521 modes.push_back(new DisplayMode(gfx::Size(320, 200), false, 0.0));
522 522
523 TestDisplaySnapshot output; 523 TestDisplaySnapshot output;
524 output.set_modes(modes.get()); 524 output.set_modes(modes.get());
525 525
526 EXPECT_EQ(modes[0], 526 EXPECT_EQ(modes[0],
527 OutputConfigurator::FindDisplayModeMatchingSize( 527 DisplayConfigurator::FindDisplayModeMatchingSize(
528 output, gfx::Size(1920, 1200))); 528 output, gfx::Size(1920, 1200)));
529 529
530 // Should pick highest refresh rate. 530 // Should pick highest refresh rate.
531 EXPECT_EQ(modes[2], 531 EXPECT_EQ(modes[2],
532 OutputConfigurator::FindDisplayModeMatchingSize( 532 DisplayConfigurator::FindDisplayModeMatchingSize(
533 output, gfx::Size(1920, 1080))); 533 output, gfx::Size(1920, 1080)));
534 534
535 // Should pick non-interlaced mode. 535 // Should pick non-interlaced mode.
536 EXPECT_EQ(modes[6], 536 EXPECT_EQ(modes[6],
537 OutputConfigurator::FindDisplayModeMatchingSize( 537 DisplayConfigurator::FindDisplayModeMatchingSize(
538 output, gfx::Size(1280, 720))); 538 output, gfx::Size(1280, 720)));
539 539
540 // Interlaced only. Should pick one with the highest refresh rate in 540 // Interlaced only. Should pick one with the highest refresh rate in
541 // interlaced mode. 541 // interlaced mode.
542 EXPECT_EQ(modes[9], 542 EXPECT_EQ(modes[9],
543 OutputConfigurator::FindDisplayModeMatchingSize( 543 DisplayConfigurator::FindDisplayModeMatchingSize(
544 output, gfx::Size(1024, 768))); 544 output, gfx::Size(1024, 768)));
545 545
546 // Mixed: Should pick one with the highest refresh rate in 546 // Mixed: Should pick one with the highest refresh rate in
547 // interlaced mode. 547 // interlaced mode.
548 EXPECT_EQ(modes[12], 548 EXPECT_EQ(modes[12],
549 OutputConfigurator::FindDisplayModeMatchingSize( 549 DisplayConfigurator::FindDisplayModeMatchingSize(
550 output, gfx::Size(1024, 600))); 550 output, gfx::Size(1024, 600)));
551 551
552 // Just one interlaced mode. 552 // Just one interlaced mode.
553 EXPECT_EQ(modes[13], 553 EXPECT_EQ(modes[13],
554 OutputConfigurator::FindDisplayModeMatchingSize( 554 DisplayConfigurator::FindDisplayModeMatchingSize(
555 output, gfx::Size(640, 480))); 555 output, gfx::Size(640, 480)));
556 556
557 // Refresh rate not available. 557 // Refresh rate not available.
558 EXPECT_EQ(modes[14], 558 EXPECT_EQ(modes[14],
559 OutputConfigurator::FindDisplayModeMatchingSize( 559 DisplayConfigurator::FindDisplayModeMatchingSize(
560 output, gfx::Size(320, 200))); 560 output, gfx::Size(320, 200)));
561 561
562 // No mode found. 562 // No mode found.
563 EXPECT_EQ(NULL, 563 EXPECT_EQ(NULL,
564 OutputConfigurator::FindDisplayModeMatchingSize( 564 DisplayConfigurator::FindDisplayModeMatchingSize(
565 output, gfx::Size(1440, 900))); 565 output, gfx::Size(1440, 900)));
566 } 566 }
567 567
568 TEST_F(OutputConfiguratorTest, ConnectSecondOutput) { 568 TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
569 InitWithSingleOutput(); 569 InitWithSingleOutput();
570 570
571 // Connect a second output and check that the configurator enters 571 // Connect a second output and check that the configurator enters
572 // extended mode. 572 // extended mode.
573 observer_.Reset(); 573 observer_.Reset();
574 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); 574 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED);
575 UpdateOutputs(2, true); 575 UpdateOutputs(2, true);
576 const int kDualHeight = small_mode_.size().height() + 576 const int kDualHeight = small_mode_.size().height() +
577 OutputConfigurator::kVerticalGap + 577 DisplayConfigurator::kVerticalGap +
578 big_mode_.size().height(); 578 big_mode_.size().height();
579 EXPECT_EQ( 579 EXPECT_EQ(
580 JoinActions( 580 JoinActions(
581 kGrab, 581 kGrab,
582 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 582 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
583 &outputs_[0], 583 &outputs_[0],
584 &outputs_[1]).c_str(), 584 &outputs_[1]).c_str(),
585 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 585 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
586 GetCrtcAction(outputs_[1], 586 GetCrtcAction(outputs_[1],
587 &big_mode_, 587 &big_mode_,
588 gfx::Point(0, 588 gfx::Point(0,
589 small_mode_.size().height() + 589 small_mode_.size().height() +
590 OutputConfigurator::kVerticalGap)) 590 DisplayConfigurator::kVerticalGap))
591 .c_str(), 591 .c_str(),
592 kUngrab, 592 kUngrab,
593 NULL), 593 NULL),
594 log_->GetActionsAndClear()); 594 log_->GetActionsAndClear());
595 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 595 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
596 EXPECT_EQ(1, observer_.num_changes()); 596 EXPECT_EQ(1, observer_.num_changes());
597 597
598 observer_.Reset(); 598 observer_.Reset();
599 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); 599 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR));
600 EXPECT_EQ( 600 EXPECT_EQ(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 JoinActions( 632 JoinActions(
633 kGrab, 633 kGrab,
634 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 634 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
635 &outputs_[0], 635 &outputs_[0],
636 &outputs_[1]).c_str(), 636 &outputs_[1]).c_str(),
637 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 637 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
638 GetCrtcAction(outputs_[1], 638 GetCrtcAction(outputs_[1],
639 &big_mode_, 639 &big_mode_,
640 gfx::Point(0, 640 gfx::Point(0,
641 small_mode_.size().height() + 641 small_mode_.size().height() +
642 OutputConfigurator::kVerticalGap)) 642 DisplayConfigurator::kVerticalGap))
643 .c_str(), 643 .c_str(),
644 kUngrab, 644 kUngrab,
645 NULL), 645 NULL),
646 log_->GetActionsAndClear()); 646 log_->GetActionsAndClear());
647 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 647 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
648 648
649 observer_.Reset(); 649 observer_.Reset();
650 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); 650 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR));
651 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); 651 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear());
652 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); 652 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state());
(...skipping 23 matching lines...) Expand all
676 kGrab, 676 kGrab,
677 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), 677 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
678 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 678 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
679 kUngrab, 679 kUngrab,
680 NULL), 680 NULL),
681 log_->GetActionsAndClear()); 681 log_->GetActionsAndClear());
682 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 682 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
683 EXPECT_EQ(1, observer_.num_changes()); 683 EXPECT_EQ(1, observer_.num_changes());
684 } 684 }
685 685
686 TEST_F(OutputConfiguratorTest, SetDisplayPower) { 686 TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
687 InitWithSingleOutput(); 687 InitWithSingleOutput();
688 688
689 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); 689 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR);
690 observer_.Reset(); 690 observer_.Reset();
691 UpdateOutputs(2, true); 691 UpdateOutputs(2, true);
692 EXPECT_EQ( 692 EXPECT_EQ(
693 JoinActions( 693 JoinActions(
694 kGrab, 694 kGrab,
695 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) 695 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1])
696 .c_str(), 696 .c_str(),
697 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 697 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
698 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 698 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
699 kUngrab, 699 kUngrab,
700 NULL), 700 NULL),
701 log_->GetActionsAndClear()); 701 log_->GetActionsAndClear());
702 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 702 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
703 EXPECT_EQ(1, observer_.num_changes()); 703 EXPECT_EQ(1, observer_.num_changes());
704 704
705 // Turning off the internal display should switch the external display to 705 // Turning off the internal display should switch the external display to
706 // its native mode. 706 // its native mode.
707 observer_.Reset(); 707 observer_.Reset();
708 configurator_.SetDisplayPower( 708 configurator_.SetDisplayPower(
709 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 709 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
710 OutputConfigurator::kSetDisplayPowerNoFlags); 710 DisplayConfigurator::kSetDisplayPowerNoFlags);
711 EXPECT_EQ( 711 EXPECT_EQ(
712 JoinActions( 712 JoinActions(
713 kGrab, 713 kGrab,
714 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) 714 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1])
715 .c_str(), 715 .c_str(),
716 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 716 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
717 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), 717 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(),
718 kForceDPMS, 718 kForceDPMS,
719 kUngrab, 719 kUngrab,
720 NULL), 720 NULL),
721 log_->GetActionsAndClear()); 721 log_->GetActionsAndClear());
722 EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state()); 722 EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state());
723 EXPECT_EQ(1, observer_.num_changes()); 723 EXPECT_EQ(1, observer_.num_changes());
724 724
725 // When all displays are turned off, the framebuffer should switch back 725 // When all displays are turned off, the framebuffer should switch back
726 // to the mirrored size. 726 // to the mirrored size.
727 observer_.Reset(); 727 observer_.Reset();
728 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, 728 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
729 OutputConfigurator::kSetDisplayPowerNoFlags); 729 DisplayConfigurator::kSetDisplayPowerNoFlags);
730 EXPECT_EQ( 730 EXPECT_EQ(
731 JoinActions(kGrab, 731 JoinActions(kGrab,
732 GetFramebufferAction( 732 GetFramebufferAction(
733 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), 733 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(),
734 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 734 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
735 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), 735 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(),
736 kUngrab, 736 kUngrab,
737 NULL), 737 NULL),
738 log_->GetActionsAndClear()); 738 log_->GetActionsAndClear());
739 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); 739 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state());
740 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 740 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
741 EXPECT_EQ(1, observer_.num_changes()); 741 EXPECT_EQ(1, observer_.num_changes());
742 742
743 // Turn all displays on and check that mirroring is still used. 743 // Turn all displays on and check that mirroring is still used.
744 observer_.Reset(); 744 observer_.Reset();
745 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, 745 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
746 OutputConfigurator::kSetDisplayPowerNoFlags); 746 DisplayConfigurator::kSetDisplayPowerNoFlags);
747 EXPECT_EQ( 747 EXPECT_EQ(
748 JoinActions( 748 JoinActions(
749 kGrab, 749 kGrab,
750 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) 750 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1])
751 .c_str(), 751 .c_str(),
752 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 752 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
753 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 753 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
754 kForceDPMS, 754 kForceDPMS,
755 kUngrab, 755 kUngrab,
756 NULL), 756 NULL),
757 log_->GetActionsAndClear()); 757 log_->GetActionsAndClear());
758 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); 758 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state());
759 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 759 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
760 EXPECT_EQ(1, observer_.num_changes()); 760 EXPECT_EQ(1, observer_.num_changes());
761 761
762 // Get rid of shared modes to force software mirroring. 762 // Get rid of shared modes to force software mirroring.
763 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &big_mode_)); 763 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &big_mode_));
764 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); 764 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR);
765 observer_.Reset(); 765 observer_.Reset();
766 UpdateOutputs(2, true); 766 UpdateOutputs(2, true);
767 const int kDualHeight = small_mode_.size().height() + 767 const int kDualHeight = small_mode_.size().height() +
768 OutputConfigurator::kVerticalGap + 768 DisplayConfigurator::kVerticalGap +
769 big_mode_.size().height(); 769 big_mode_.size().height();
770 EXPECT_EQ( 770 EXPECT_EQ(
771 JoinActions( 771 JoinActions(
772 kGrab, 772 kGrab,
773 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 773 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
774 &outputs_[0], 774 &outputs_[0],
775 &outputs_[1]).c_str(), 775 &outputs_[1]).c_str(),
776 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 776 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
777 GetCrtcAction(outputs_[1], 777 GetCrtcAction(outputs_[1],
778 &big_mode_, 778 &big_mode_,
779 gfx::Point(0, 779 gfx::Point(0,
780 small_mode_.size().height() + 780 small_mode_.size().height() +
781 OutputConfigurator::kVerticalGap)) 781 DisplayConfigurator::kVerticalGap))
782 .c_str(), 782 .c_str(),
783 kUngrab, 783 kUngrab,
784 NULL), 784 NULL),
785 log_->GetActionsAndClear()); 785 log_->GetActionsAndClear());
786 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); 786 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state());
787 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); 787 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
788 EXPECT_EQ(1, observer_.num_changes()); 788 EXPECT_EQ(1, observer_.num_changes());
789 789
790 // Turning off the internal display should switch the external display to 790 // Turning off the internal display should switch the external display to
791 // its native mode. 791 // its native mode.
792 observer_.Reset(); 792 observer_.Reset();
793 configurator_.SetDisplayPower( 793 configurator_.SetDisplayPower(
794 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 794 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
795 OutputConfigurator::kSetDisplayPowerNoFlags); 795 DisplayConfigurator::kSetDisplayPowerNoFlags);
796 EXPECT_EQ( 796 EXPECT_EQ(
797 JoinActions( 797 JoinActions(
798 kGrab, 798 kGrab,
799 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1]) 799 GetFramebufferAction(big_mode_.size(), &outputs_[0], &outputs_[1])
800 .c_str(), 800 .c_str(),
801 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 801 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
802 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(), 802 GetCrtcAction(outputs_[1], &big_mode_, gfx::Point(0, 0)).c_str(),
803 kForceDPMS, 803 kForceDPMS,
804 kUngrab, 804 kUngrab,
805 NULL), 805 NULL),
806 log_->GetActionsAndClear()); 806 log_->GetActionsAndClear());
807 EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state()); 807 EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state());
808 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); 808 EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
809 EXPECT_EQ(1, observer_.num_changes()); 809 EXPECT_EQ(1, observer_.num_changes());
810 810
811 // When all displays are turned off, the framebuffer should switch back 811 // When all displays are turned off, the framebuffer should switch back
812 // to the extended + software mirroring. 812 // to the extended + software mirroring.
813 observer_.Reset(); 813 observer_.Reset();
814 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, 814 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
815 OutputConfigurator::kSetDisplayPowerNoFlags); 815 DisplayConfigurator::kSetDisplayPowerNoFlags);
816 EXPECT_EQ( 816 EXPECT_EQ(
817 JoinActions( 817 JoinActions(
818 kGrab, 818 kGrab,
819 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 819 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
820 &outputs_[0], 820 &outputs_[0],
821 &outputs_[1]).c_str(), 821 &outputs_[1]).c_str(),
822 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 822 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
823 GetCrtcAction(outputs_[1], 823 GetCrtcAction(outputs_[1],
824 NULL, 824 NULL,
825 gfx::Point(0, 825 gfx::Point(0,
826 small_mode_.size().height() + 826 small_mode_.size().height() +
827 OutputConfigurator::kVerticalGap)) 827 DisplayConfigurator::kVerticalGap))
828 .c_str(), 828 .c_str(),
829 kUngrab, 829 kUngrab,
830 NULL), 830 NULL),
831 log_->GetActionsAndClear()); 831 log_->GetActionsAndClear());
832 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); 832 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state());
833 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); 833 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
834 EXPECT_EQ(1, observer_.num_changes()); 834 EXPECT_EQ(1, observer_.num_changes());
835 835
836 // Turn all displays on and check that mirroring is still used. 836 // Turn all displays on and check that mirroring is still used.
837 observer_.Reset(); 837 observer_.Reset();
838 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, 838 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
839 OutputConfigurator::kSetDisplayPowerNoFlags); 839 DisplayConfigurator::kSetDisplayPowerNoFlags);
840 EXPECT_EQ( 840 EXPECT_EQ(
841 JoinActions( 841 JoinActions(
842 kGrab, 842 kGrab,
843 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight), 843 GetFramebufferAction(gfx::Size(big_mode_.size().width(), kDualHeight),
844 &outputs_[0], 844 &outputs_[0],
845 &outputs_[1]).c_str(), 845 &outputs_[1]).c_str(),
846 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 846 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
847 GetCrtcAction(outputs_[1], 847 GetCrtcAction(outputs_[1],
848 &big_mode_, 848 &big_mode_,
849 gfx::Point(0, 849 gfx::Point(0,
850 small_mode_.size().height() + 850 small_mode_.size().height() +
851 OutputConfigurator::kVerticalGap)) 851 DisplayConfigurator::kVerticalGap))
852 .c_str(), 852 .c_str(),
853 kForceDPMS, 853 kForceDPMS,
854 kUngrab, 854 kUngrab,
855 NULL), 855 NULL),
856 log_->GetActionsAndClear()); 856 log_->GetActionsAndClear());
857 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); 857 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state());
858 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); 858 EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
859 EXPECT_EQ(1, observer_.num_changes()); 859 EXPECT_EQ(1, observer_.num_changes());
860 } 860 }
861 861
862 TEST_F(OutputConfiguratorTest, SuspendAndResume) { 862 TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
863 InitWithSingleOutput(); 863 InitWithSingleOutput();
864 864
865 // No preparation is needed before suspending when the display is already 865 // No preparation is needed before suspending when the display is already
866 // on. The configurator should still reprobe on resume in case a display 866 // on. The configurator should still reprobe on resume in case a display
867 // was connected while suspended. 867 // was connected while suspended.
868 configurator_.SuspendDisplays(); 868 configurator_.SuspendDisplays();
869 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 869 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
870 configurator_.ResumeDisplays(); 870 configurator_.ResumeDisplays();
871 EXPECT_EQ( 871 EXPECT_EQ(
872 JoinActions( 872 JoinActions(
873 kGrab, 873 kGrab,
874 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), 874 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
875 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 875 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
876 kForceDPMS, 876 kForceDPMS,
877 kUngrab, 877 kUngrab,
878 NULL), 878 NULL),
879 log_->GetActionsAndClear()); 879 log_->GetActionsAndClear());
880 880
881 // Now turn the display off before suspending and check that the 881 // Now turn the display off before suspending and check that the
882 // configurator turns it back on and syncs with the server. 882 // configurator turns it back on and syncs with the server.
883 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, 883 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
884 OutputConfigurator::kSetDisplayPowerNoFlags); 884 DisplayConfigurator::kSetDisplayPowerNoFlags);
885 EXPECT_EQ( 885 EXPECT_EQ(
886 JoinActions( 886 JoinActions(
887 kGrab, 887 kGrab,
888 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), 888 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
889 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 889 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
890 kUngrab, 890 kUngrab,
891 NULL), 891 NULL),
892 log_->GetActionsAndClear()); 892 log_->GetActionsAndClear());
893 893
894 configurator_.SuspendDisplays(); 894 configurator_.SuspendDisplays();
(...skipping 28 matching lines...) Expand all
923 kGrab, 923 kGrab,
924 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) 924 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1])
925 .c_str(), 925 .c_str(),
926 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 926 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
927 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 927 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
928 kUngrab, 928 kUngrab,
929 NULL), 929 NULL),
930 log_->GetActionsAndClear()); 930 log_->GetActionsAndClear());
931 931
932 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, 932 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
933 OutputConfigurator::kSetDisplayPowerNoFlags); 933 DisplayConfigurator::kSetDisplayPowerNoFlags);
934 EXPECT_EQ( 934 EXPECT_EQ(
935 JoinActions(kGrab, 935 JoinActions(kGrab,
936 GetFramebufferAction( 936 GetFramebufferAction(
937 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(), 937 small_mode_.size(), &outputs_[0], &outputs_[1]).c_str(),
938 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 938 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
939 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(), 939 GetCrtcAction(outputs_[1], NULL, gfx::Point(0, 0)).c_str(),
940 kUngrab, 940 kUngrab,
941 NULL), 941 NULL),
942 log_->GetActionsAndClear()); 942 log_->GetActionsAndClear());
943 943
944 configurator_.SuspendDisplays(); 944 configurator_.SuspendDisplays();
945 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL), 945 EXPECT_EQ(JoinActions(kGrab, kUngrab, kSync, NULL),
946 log_->GetActionsAndClear()); 946 log_->GetActionsAndClear());
947 947
948 // If a display is disconnected while suspended, the configurator should 948 // If a display is disconnected while suspended, the configurator should
949 // pick up the change. 949 // pick up the change.
950 UpdateOutputs(1, false); 950 UpdateOutputs(1, false);
951 configurator_.ResumeDisplays(); 951 configurator_.ResumeDisplays();
952 EXPECT_EQ( 952 EXPECT_EQ(
953 JoinActions( 953 JoinActions(
954 kGrab, 954 kGrab,
955 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), 955 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(),
956 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(), 956 GetCrtcAction(outputs_[0], NULL, gfx::Point(0, 0)).c_str(),
957 kUngrab, 957 kUngrab,
958 NULL), 958 NULL),
959 log_->GetActionsAndClear()); 959 log_->GetActionsAndClear());
960 } 960 }
961 961
962 TEST_F(OutputConfiguratorTest, Headless) { 962 TEST_F(DisplayConfiguratorTest, Headless) {
963 UpdateOutputs(0, false); 963 UpdateOutputs(0, false);
964 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 964 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
965 configurator_.Init(false); 965 configurator_.Init(false);
966 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 966 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
967 configurator_.ForceInitialConfigure(0); 967 configurator_.ForceInitialConfigure(0);
968 EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, NULL), 968 EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, NULL),
969 log_->GetActionsAndClear()); 969 log_->GetActionsAndClear());
970 970
971 // Not much should happen when the display power state is changed while 971 // Not much should happen when the display power state is changed while
972 // no displays are connected. 972 // no displays are connected.
973 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, 973 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF,
974 OutputConfigurator::kSetDisplayPowerNoFlags); 974 DisplayConfigurator::kSetDisplayPowerNoFlags);
975 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); 975 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear());
976 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, 976 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
977 OutputConfigurator::kSetDisplayPowerNoFlags); 977 DisplayConfigurator::kSetDisplayPowerNoFlags);
978 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), 978 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL),
979 log_->GetActionsAndClear()); 979 log_->GetActionsAndClear());
980 980
981 // Connect an external display and check that it's configured correctly. 981 // Connect an external display and check that it's configured correctly.
982 outputs_[0].set_current_mode(outputs_[1].current_mode()); 982 outputs_[0].set_current_mode(outputs_[1].current_mode());
983 outputs_[0].set_native_mode(outputs_[1].native_mode()); 983 outputs_[0].set_native_mode(outputs_[1].native_mode());
984 outputs_[0].set_modes(outputs_[1].modes()); 984 outputs_[0].set_modes(outputs_[1].modes());
985 outputs_[0].set_type(outputs_[1].type()); 985 outputs_[0].set_type(outputs_[1].type());
986 986
987 UpdateOutputs(1, true); 987 UpdateOutputs(1, true);
988 EXPECT_EQ( 988 EXPECT_EQ(
989 JoinActions( 989 JoinActions(
990 kGrab, 990 kGrab,
991 GetFramebufferAction(big_mode_.size(), &outputs_[0], NULL).c_str(), 991 GetFramebufferAction(big_mode_.size(), &outputs_[0], NULL).c_str(),
992 GetCrtcAction(outputs_[0], &big_mode_, gfx::Point(0, 0)).c_str(), 992 GetCrtcAction(outputs_[0], &big_mode_, gfx::Point(0, 0)).c_str(),
993 kUngrab, 993 kUngrab,
994 NULL), 994 NULL),
995 log_->GetActionsAndClear()); 995 log_->GetActionsAndClear());
996 } 996 }
997 997
998 TEST_F(OutputConfiguratorTest, StartWithTwoOutputs) { 998 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) {
999 UpdateOutputs(2, false); 999 UpdateOutputs(2, false);
1000 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1000 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1001 configurator_.Init(false); 1001 configurator_.Init(false);
1002 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1002 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1003 1003
1004 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); 1004 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR);
1005 configurator_.ForceInitialConfigure(0); 1005 configurator_.ForceInitialConfigure(0);
1006 EXPECT_EQ( 1006 EXPECT_EQ(
1007 JoinActions( 1007 JoinActions(
1008 kGrab, 1008 kGrab,
1009 kInitXRandR, 1009 kInitXRandR,
1010 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1]) 1010 GetFramebufferAction(small_mode_.size(), &outputs_[0], &outputs_[1])
1011 .c_str(), 1011 .c_str(),
1012 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), 1012 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(),
1013 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), 1013 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(),
1014 kForceDPMS, 1014 kForceDPMS,
1015 kUngrab, 1015 kUngrab,
1016 NULL), 1016 NULL),
1017 log_->GetActionsAndClear()); 1017 log_->GetActionsAndClear());
1018 } 1018 }
1019 1019
1020 TEST_F(OutputConfiguratorTest, InvalidOutputStates) { 1020 TEST_F(DisplayConfiguratorTest, InvalidOutputStates) {
1021 UpdateOutputs(0, false); 1021 UpdateOutputs(0, false);
1022 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1022 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1023 configurator_.Init(false); 1023 configurator_.Init(false);
1024 configurator_.ForceInitialConfigure(0); 1024 configurator_.ForceInitialConfigure(0);
1025 observer_.Reset(); 1025 observer_.Reset();
1026 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); 1026 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS));
1027 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); 1027 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE));
1028 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); 1028 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR));
1029 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); 1029 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED));
1030 EXPECT_EQ(1, observer_.num_changes()); 1030 EXPECT_EQ(1, observer_.num_changes());
(...skipping 12 matching lines...) Expand all
1043 UpdateOutputs(2, true); 1043 UpdateOutputs(2, true);
1044 observer_.Reset(); 1044 observer_.Reset();
1045 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); 1045 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS));
1046 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); 1046 EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE));
1047 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); 1047 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR));
1048 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); 1048 EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED));
1049 EXPECT_EQ(2, observer_.num_changes()); 1049 EXPECT_EQ(2, observer_.num_changes());
1050 EXPECT_EQ(2, observer_.num_failures()); 1050 EXPECT_EQ(2, observer_.num_failures());
1051 } 1051 }
1052 1052
1053 TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithoutId) { 1053 TEST_F(DisplayConfiguratorTest, GetOutputStateForDisplaysWithoutId) {
1054 outputs_[0].set_has_proper_display_id(false); 1054 outputs_[0].set_has_proper_display_id(false);
1055 UpdateOutputs(2, false); 1055 UpdateOutputs(2, false);
1056 configurator_.Init(false); 1056 configurator_.Init(false);
1057 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); 1057 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR);
1058 configurator_.ForceInitialConfigure(0); 1058 configurator_.ForceInitialConfigure(0);
1059 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); 1059 EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state());
1060 } 1060 }
1061 1061
1062 TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithId) { 1062 TEST_F(DisplayConfiguratorTest, GetOutputStateForDisplaysWithId) {
1063 outputs_[0].set_has_proper_display_id(true); 1063 outputs_[0].set_has_proper_display_id(true);
1064 UpdateOutputs(2, false); 1064 UpdateOutputs(2, false);
1065 configurator_.Init(false); 1065 configurator_.Init(false);
1066 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); 1066 state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR);
1067 configurator_.ForceInitialConfigure(0); 1067 configurator_.ForceInitialConfigure(0);
1068 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); 1068 EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state());
1069 } 1069 }
1070 1070
1071 TEST_F(OutputConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { 1071 TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) {
1072 InitWithSingleOutput(); 1072 InitWithSingleOutput();
1073 const OutputConfigurator::DisplayStateList* cached = 1073 const DisplayConfigurator::DisplayStateList* cached =
1074 &configurator_.cached_outputs(); 1074 &configurator_.cached_outputs();
1075 ASSERT_EQ(static_cast<size_t>(1), cached->size()); 1075 ASSERT_EQ(static_cast<size_t>(1), cached->size());
1076 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode()); 1076 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode());
1077 1077
1078 // After connecting a second output, check that it shows up in 1078 // After connecting a second output, check that it shows up in
1079 // |cached_outputs_| even if an invalid state is requested. 1079 // |cached_outputs_| even if an invalid state is requested.
1080 state_controller_.set_state(OUTPUT_STATE_SINGLE); 1080 state_controller_.set_state(OUTPUT_STATE_SINGLE);
1081 UpdateOutputs(2, true); 1081 UpdateOutputs(2, true);
1082 cached = &configurator_.cached_outputs(); 1082 cached = &configurator_.cached_outputs();
1083 ASSERT_EQ(static_cast<size_t>(2), cached->size()); 1083 ASSERT_EQ(static_cast<size_t>(2), cached->size());
1084 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode()); 1084 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode());
1085 EXPECT_EQ(outputs_[1].current_mode(), (*cached)[1].display->current_mode()); 1085 EXPECT_EQ(outputs_[1].current_mode(), (*cached)[1].display->current_mode());
1086 } 1086 }
1087 1087
1088 TEST_F(OutputConfiguratorTest, PanelFitting) { 1088 TEST_F(DisplayConfiguratorTest, PanelFitting) {
1089 // Configure the internal display to support only the big mode and the 1089 // Configure the internal display to support only the big mode and the
1090 // external display to support only the small mode. 1090 // external display to support only the small mode.
1091 outputs_[0].set_current_mode(&big_mode_); 1091 outputs_[0].set_current_mode(&big_mode_);
1092 outputs_[0].set_native_mode(&big_mode_); 1092 outputs_[0].set_native_mode(&big_mode_);
1093 outputs_[0].set_modes(std::vector<const DisplayMode*>(1, &big_mode_)); 1093 outputs_[0].set_modes(std::vector<const DisplayMode*>(1, &big_mode_));
1094 1094
1095 outputs_[1].set_current_mode(&small_mode_); 1095 outputs_[1].set_current_mode(&small_mode_);
1096 outputs_[1].set_native_mode(&small_mode_); 1096 outputs_[1].set_native_mode(&small_mode_);
1097 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &small_mode_)); 1097 outputs_[1].set_modes(std::vector<const DisplayMode*>(1, &small_mode_));
1098 1098
(...skipping 23 matching lines...) Expand all
1122 ASSERT_EQ(static_cast<size_t>(2), observer_.latest_outputs().size()); 1122 ASSERT_EQ(static_cast<size_t>(2), observer_.latest_outputs().size());
1123 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[0].mirror_mode); 1123 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[0].mirror_mode);
1124 EXPECT_EQ(&small_mode_, 1124 EXPECT_EQ(&small_mode_,
1125 observer_.latest_outputs()[0].display->current_mode()); 1125 observer_.latest_outputs()[0].display->current_mode());
1126 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[1].mirror_mode); 1126 EXPECT_EQ(&small_mode_, observer_.latest_outputs()[1].mirror_mode);
1127 EXPECT_EQ(&small_mode_, 1127 EXPECT_EQ(&small_mode_,
1128 observer_.latest_outputs()[1].display->current_mode()); 1128 observer_.latest_outputs()[1].display->current_mode());
1129 1129
1130 // Also check that the newly-added small mode is present in the internal 1130 // Also check that the newly-added small mode is present in the internal
1131 // snapshot that was passed to the observer (http://crbug.com/289159). 1131 // snapshot that was passed to the observer (http://crbug.com/289159).
1132 const OutputConfigurator::DisplayState& state = observer_.latest_outputs()[0]; 1132 const DisplayConfigurator::DisplayState& state =
1133 observer_.latest_outputs()[0];
1133 ASSERT_NE(state.display->modes().end(), 1134 ASSERT_NE(state.display->modes().end(),
1134 std::find(state.display->modes().begin(), 1135 std::find(state.display->modes().begin(),
1135 state.display->modes().end(), 1136 state.display->modes().end(),
1136 &small_mode_)); 1137 &small_mode_));
1137 } 1138 }
1138 1139
1139 TEST_F(OutputConfiguratorTest, OutputProtection) { 1140 TEST_F(DisplayConfiguratorTest, OutputProtection) {
1140 configurator_.Init(false); 1141 configurator_.Init(false);
1141 configurator_.ForceInitialConfigure(0); 1142 configurator_.ForceInitialConfigure(0);
1142 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); 1143 EXPECT_NE(kNoActions, log_->GetActionsAndClear());
1143 1144
1144 OutputConfigurator::OutputProtectionClientId id = 1145 DisplayConfigurator::OutputProtectionClientId id =
1145 configurator_.RegisterOutputProtectionClient(); 1146 configurator_.RegisterOutputProtectionClient();
1146 EXPECT_NE(0u, id); 1147 EXPECT_NE(0u, id);
1147 1148
1148 // One output. 1149 // One output.
1149 UpdateOutputs(1, true); 1150 UpdateOutputs(1, true);
1150 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); 1151 EXPECT_NE(kNoActions, log_->GetActionsAndClear());
1151 uint32_t link_mask = 0; 1152 uint32_t link_mask = 0;
1152 uint32_t protection_mask = 0; 1153 uint32_t protection_mask = 0;
1153 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( 1154 EXPECT_TRUE(configurator_.QueryOutputProtectionStatus(
1154 id, outputs_[0].display_id(), &link_mask, &protection_mask)); 1155 id, outputs_[0].display_id(), &link_mask, &protection_mask));
(...skipping 25 matching lines...) Expand all
1180 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_PROTECTION_METHOD_HDCP), 1181 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_PROTECTION_METHOD_HDCP),
1181 protection_mask); 1182 protection_mask);
1182 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); 1183 EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
1183 1184
1184 // Protections should be disabled after unregister. 1185 // Protections should be disabled after unregister.
1185 configurator_.UnregisterOutputProtectionClient(id); 1186 configurator_.UnregisterOutputProtectionClient(id);
1186 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED), 1187 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED),
1187 log_->GetActionsAndClear()); 1188 log_->GetActionsAndClear());
1188 } 1189 }
1189 1190
1190 TEST_F(OutputConfiguratorTest, OutputProtectionTwoClients) { 1191 TEST_F(DisplayConfiguratorTest, OutputProtectionTwoClients) {
1191 OutputConfigurator::OutputProtectionClientId client1 = 1192 DisplayConfigurator::OutputProtectionClientId client1 =
1192 configurator_.RegisterOutputProtectionClient(); 1193 configurator_.RegisterOutputProtectionClient();
1193 OutputConfigurator::OutputProtectionClientId client2 = 1194 DisplayConfigurator::OutputProtectionClientId client2 =
1194 configurator_.RegisterOutputProtectionClient(); 1195 configurator_.RegisterOutputProtectionClient();
1195 EXPECT_NE(client1, client2); 1196 EXPECT_NE(client1, client2);
1196 1197
1197 configurator_.Init(false); 1198 configurator_.Init(false);
1198 configurator_.ForceInitialConfigure(0); 1199 configurator_.ForceInitialConfigure(0);
1199 UpdateOutputs(2, true); 1200 UpdateOutputs(2, true);
1200 EXPECT_NE(kNoActions, log_->GetActionsAndClear()); 1201 EXPECT_NE(kNoActions, log_->GetActionsAndClear());
1201 1202
1202 // Clients never know state enableness for methods that they didn't request. 1203 // Clients never know state enableness for methods that they didn't request.
1203 EXPECT_TRUE(configurator_.EnableOutputProtection( 1204 EXPECT_TRUE(configurator_.EnableOutputProtection(
(...skipping 14 matching lines...) Expand all
1218 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_HDMI), link_mask); 1219 EXPECT_EQ(static_cast<uint32_t>(OUTPUT_TYPE_HDMI), link_mask);
1219 EXPECT_EQ(OUTPUT_PROTECTION_METHOD_NONE, protection_mask); 1220 EXPECT_EQ(OUTPUT_PROTECTION_METHOD_NONE, protection_mask);
1220 1221
1221 // Protections will be disabled only if no more clients request them. 1222 // Protections will be disabled only if no more clients request them.
1222 EXPECT_TRUE(configurator_.EnableOutputProtection( 1223 EXPECT_TRUE(configurator_.EnableOutputProtection(
1223 client2, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_NONE)); 1224 client2, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_NONE));
1224 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), 1225 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(),
1225 log_->GetActionsAndClear()); 1226 log_->GetActionsAndClear());
1226 EXPECT_TRUE(configurator_.EnableOutputProtection( 1227 EXPECT_TRUE(configurator_.EnableOutputProtection(
1227 client1, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_NONE)); 1228 client1, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_NONE));
1228 EXPECT_EQ( 1229 EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(),
1229 GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(), 1230 log_->GetActionsAndClear());
1230 log_->GetActionsAndClear());
1231 } 1231 }
1232 1232
1233 TEST_F(OutputConfiguratorTest, CTMForMultiScreens) { 1233 TEST_F(DisplayConfiguratorTest, CTMForMultiScreens) {
1234 touchscreen_delegate_->set_configure_touchscreens(true); 1234 touchscreen_delegate_->set_configure_touchscreens(true);
1235 UpdateOutputs(2, false); 1235 UpdateOutputs(2, false);
1236 configurator_.Init(false); 1236 configurator_.Init(false);
1237 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); 1237 state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED);
1238 configurator_.ForceInitialConfigure(0); 1238 configurator_.ForceInitialConfigure(0);
1239 1239
1240 const int kDualHeight = small_mode_.size().height() + 1240 const int kDualHeight = small_mode_.size().height() +
1241 OutputConfigurator::kVerticalGap + 1241 DisplayConfigurator::kVerticalGap +
1242 big_mode_.size().height(); 1242 big_mode_.size().height();
1243 const int kDualWidth = big_mode_.size().width(); 1243 const int kDualWidth = big_mode_.size().width();
1244 1244
1245 OutputConfigurator::CoordinateTransformation ctm1 = 1245 DisplayConfigurator::CoordinateTransformation ctm1 =
1246 touchscreen_delegate_->GetCTM(1); 1246 touchscreen_delegate_->GetCTM(1);
1247 OutputConfigurator::CoordinateTransformation ctm2 = 1247 DisplayConfigurator::CoordinateTransformation ctm2 =
1248 touchscreen_delegate_->GetCTM(2); 1248 touchscreen_delegate_->GetCTM(2);
1249 1249
1250 EXPECT_EQ(small_mode_.size().height() - 1, 1250 EXPECT_EQ(small_mode_.size().height() - 1,
1251 round((kDualHeight - 1) * ctm1.y_scale)); 1251 round((kDualHeight - 1) * ctm1.y_scale));
1252 EXPECT_EQ(0, round((kDualHeight - 1) * ctm1.y_offset)); 1252 EXPECT_EQ(0, round((kDualHeight - 1) * ctm1.y_offset));
1253 1253
1254 EXPECT_EQ(big_mode_.size().height() - 1, 1254 EXPECT_EQ(big_mode_.size().height() - 1,
1255 round((kDualHeight - 1) * ctm2.y_scale)); 1255 round((kDualHeight - 1) * ctm2.y_scale));
1256 EXPECT_EQ(small_mode_.size().height() + OutputConfigurator::kVerticalGap, 1256 EXPECT_EQ(small_mode_.size().height() + DisplayConfigurator::kVerticalGap,
1257 round((kDualHeight - 1) * ctm2.y_offset)); 1257 round((kDualHeight - 1) * ctm2.y_offset));
1258 1258
1259 EXPECT_EQ(small_mode_.size().width() - 1, 1259 EXPECT_EQ(small_mode_.size().width() - 1,
1260 round((kDualWidth - 1) * ctm1.x_scale)); 1260 round((kDualWidth - 1) * ctm1.x_scale));
1261 EXPECT_EQ(0, round((kDualWidth - 1) * ctm1.x_offset)); 1261 EXPECT_EQ(0, round((kDualWidth - 1) * ctm1.x_offset));
1262 1262
1263 EXPECT_EQ(big_mode_.size().width() - 1, 1263 EXPECT_EQ(big_mode_.size().width() - 1,
1264 round((kDualWidth - 1) * ctm2.x_scale)); 1264 round((kDualWidth - 1) * ctm2.x_scale));
1265 EXPECT_EQ(0, round((kDualWidth - 1) * ctm2.x_offset)); 1265 EXPECT_EQ(0, round((kDualWidth - 1) * ctm2.x_offset));
1266 } 1266 }
1267 1267
1268 TEST_F(OutputConfiguratorTest, HandleConfigureCrtcFailure) { 1268 TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) {
1269 InitWithSingleOutput(); 1269 InitWithSingleOutput();
1270 1270
1271 ScopedVector<const DisplayMode> modes; 1271 ScopedVector<const DisplayMode> modes;
1272 // The first mode is the mode we are requesting OutputConfigurator to choose. 1272 // The first mode is the mode we are requesting DisplayConfigurator to choose.
1273 // The test will be setup so that this mode will fail and it will have to 1273 // The test will be setup so that this mode will fail and it will have to
1274 // choose the next best option. 1274 // choose the next best option.
1275 modes.push_back(new DisplayMode(gfx::Size(2560, 1600), false, 60.0)); 1275 modes.push_back(new DisplayMode(gfx::Size(2560, 1600), false, 60.0));
1276 modes.push_back(new DisplayMode(gfx::Size(1024, 768), false, 60.0)); 1276 modes.push_back(new DisplayMode(gfx::Size(1024, 768), false, 60.0));
1277 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0)); 1277 modes.push_back(new DisplayMode(gfx::Size(1280, 720), false, 60.0));
1278 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 60.0)); 1278 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 60.0));
1279 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0)); 1279 modes.push_back(new DisplayMode(gfx::Size(1920, 1080), false, 40.0));
1280 1280
1281 for (unsigned int i = 0; i < arraysize(outputs_); i++) { 1281 for (unsigned int i = 0; i < arraysize(outputs_); i++) {
1282 outputs_[i].set_modes(modes.get()); 1282 outputs_[i].set_modes(modes.get());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 // Then attempt to configure crtc1 with the first mode. 1324 // Then attempt to configure crtc1 with the first mode.
1325 GetCrtcAction(outputs_[1], modes[0], gfx::Point(0, 0)).c_str(), 1325 GetCrtcAction(outputs_[1], modes[0], gfx::Point(0, 0)).c_str(),
1326 GetCrtcAction(outputs_[1], modes[3], gfx::Point(0, 0)).c_str(), 1326 GetCrtcAction(outputs_[1], modes[3], gfx::Point(0, 0)).c_str(),
1327 // Since it was requested to go into mirror mode 1327 // Since it was requested to go into mirror mode
1328 // and the configured modes were different, it 1328 // and the configured modes were different, it
1329 // should now try and setup a valid configurable 1329 // should now try and setup a valid configurable
1330 // extended mode. 1330 // extended mode.
1331 GetFramebufferAction( 1331 GetFramebufferAction(
1332 gfx::Size(modes[0]->size().width(), 1332 gfx::Size(modes[0]->size().width(),
1333 modes[0]->size().height() + modes[0]->size().height() + 1333 modes[0]->size().height() + modes[0]->size().height() +
1334 OutputConfigurator::kVerticalGap), 1334 DisplayConfigurator::kVerticalGap),
1335 &outputs_[0], 1335 &outputs_[0],
1336 &outputs_[1]).c_str(), 1336 &outputs_[1]).c_str(),
1337 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(), 1337 GetCrtcAction(outputs_[0], modes[0], gfx::Point(0, 0)).c_str(),
1338 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(), 1338 GetCrtcAction(outputs_[0], modes[3], gfx::Point(0, 0)).c_str(),
1339 GetCrtcAction(outputs_[1], 1339 GetCrtcAction(outputs_[1],
1340 modes[0], 1340 modes[0],
1341 gfx::Point(0, 1341 gfx::Point(0,
1342 modes[0]->size().height() + 1342 modes[0]->size().height() +
1343 OutputConfigurator::kVerticalGap)) 1343 DisplayConfigurator::kVerticalGap))
1344 .c_str(), 1344 .c_str(),
1345 GetCrtcAction(outputs_[1], 1345 GetCrtcAction(outputs_[1],
1346 modes[3], 1346 modes[3],
1347 gfx::Point(0, 1347 gfx::Point(0,
1348 modes[0]->size().height() + 1348 modes[0]->size().height() +
1349 OutputConfigurator::kVerticalGap)) 1349 DisplayConfigurator::kVerticalGap))
1350 .c_str(), 1350 .c_str(),
1351 kUngrab, 1351 kUngrab,
1352 NULL), 1352 NULL),
1353 log_->GetActionsAndClear()); 1353 log_->GetActionsAndClear());
1354 } 1354 }
1355 1355
1356 } // namespace ui 1356 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/display_configurator.cc ('k') | ui/display/chromeos/native_display_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698