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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 std::vector<const DisplayMode*> modes; | 352 std::vector<const DisplayMode*> modes; |
353 modes.push_back(&small_mode_); | 353 modes.push_back(&small_mode_); |
354 | 354 |
355 TestDisplaySnapshot* o = &outputs_[0]; | 355 TestDisplaySnapshot* o = &outputs_[0]; |
356 o->set_current_mode(&small_mode_); | 356 o->set_current_mode(&small_mode_); |
357 o->set_native_mode(&small_mode_); | 357 o->set_native_mode(&small_mode_); |
358 o->set_modes(modes); | 358 o->set_modes(modes); |
359 o->set_type(DISPLAY_CONNECTION_TYPE_INTERNAL); | 359 o->set_type(DISPLAY_CONNECTION_TYPE_INTERNAL); |
360 o->set_is_aspect_preserving_scaling(true); | 360 o->set_is_aspect_preserving_scaling(true); |
361 o->set_display_id(123); | 361 o->set_display_id(123); |
362 o->set_has_proper_display_id(true); | |
363 | 362 |
364 o = &outputs_[1]; | 363 o = &outputs_[1]; |
365 o->set_current_mode(&big_mode_); | 364 o->set_current_mode(&big_mode_); |
366 o->set_native_mode(&big_mode_); | 365 o->set_native_mode(&big_mode_); |
367 modes.push_back(&big_mode_); | 366 modes.push_back(&big_mode_); |
368 o->set_modes(modes); | 367 o->set_modes(modes); |
369 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); | 368 o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); |
370 o->set_is_aspect_preserving_scaling(true); | 369 o->set_is_aspect_preserving_scaling(true); |
371 o->set_display_id(456); | 370 o->set_display_id(456); |
372 o->set_has_proper_display_id(true); | |
373 | 371 |
374 UpdateOutputs(2, false); | 372 UpdateOutputs(2, false); |
375 } | 373 } |
376 | 374 |
377 // Predefined modes that can be used by outputs. | 375 // Predefined modes that can be used by outputs. |
378 const DisplayMode small_mode_; | 376 const DisplayMode small_mode_; |
379 const DisplayMode big_mode_; | 377 const DisplayMode big_mode_; |
380 | 378 |
381 protected: | 379 protected: |
382 // Configures |native_display_delegate_| to return the first |num_outputs| | 380 // Configures |native_display_delegate_| to return the first |num_outputs| |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 observer_.Reset(); | 995 observer_.Reset(); |
998 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); | 996 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); |
999 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); | 997 EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); |
1000 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); | 998 EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); |
1001 EXPECT_TRUE( | 999 EXPECT_TRUE( |
1002 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); | 1000 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); |
1003 EXPECT_EQ(2, observer_.num_changes()); | 1001 EXPECT_EQ(2, observer_.num_changes()); |
1004 EXPECT_EQ(2, observer_.num_failures()); | 1002 EXPECT_EQ(2, observer_.num_failures()); |
1005 } | 1003 } |
1006 | 1004 |
1007 TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForDisplaysWithoutId) { | 1005 TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForMirroredDisplays) { |
1008 outputs_[0].set_has_proper_display_id(false); | |
1009 UpdateOutputs(2, false); | 1006 UpdateOutputs(2, false); |
1010 configurator_.Init(false); | 1007 configurator_.Init(false); |
1011 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 1008 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
1012 configurator_.ForceInitialConfigure(0); | |
1013 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | |
1014 configurator_.display_state()); | |
1015 } | |
1016 | |
1017 TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForDisplaysWithId) { | |
1018 outputs_[0].set_has_proper_display_id(true); | |
1019 UpdateOutputs(2, false); | |
1020 configurator_.Init(false); | |
1021 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | |
1022 configurator_.ForceInitialConfigure(0); | 1009 configurator_.ForceInitialConfigure(0); |
1023 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 1010 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
1024 } | 1011 } |
1025 | 1012 |
1026 TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { | 1013 TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { |
1027 InitWithSingleOutput(); | 1014 InitWithSingleOutput(); |
1028 const DisplayConfigurator::DisplayStateList* cached = | 1015 const DisplayConfigurator::DisplayStateList* cached = |
1029 &configurator_.cached_displays(); | 1016 &configurator_.cached_displays(); |
1030 ASSERT_EQ(static_cast<size_t>(1), cached->size()); | 1017 ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
1031 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode()); | 1018 EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode()); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 .c_str(), | 1382 .c_str(), |
1396 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 1383 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
1397 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 1384 GetCrtcAction(outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
1398 kForceDPMS, | 1385 kForceDPMS, |
1399 kUngrab, | 1386 kUngrab, |
1400 NULL), | 1387 NULL), |
1401 log_->GetActionsAndClear()); | 1388 log_->GetActionsAndClear()); |
1402 } | 1389 } |
1403 | 1390 |
1404 } // namespace ui | 1391 } // namespace ui |
OLD | NEW |