| 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/manager/chromeos/display_configurator.h" | 5 #include "ui/display/manager/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/display/fake_display_snapshot.h" | 16 #include "ui/display/fake_display_snapshot.h" |
| 17 #include "ui/display/manager/chromeos/test/action_logger_util.h" | 17 #include "ui/display/manager/chromeos/test/action_logger_util.h" |
| 18 #include "ui/display/manager/chromeos/test/test_native_display_delegate.h" | 18 #include "ui/display/manager/chromeos/test/test_native_display_delegate.h" |
| 19 #include "ui/display/util/display_util.h" | 19 #include "ui/display/util/display_util.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace display { |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 int64_t kDisplayIds[3] = {123, 456, 789}; | 26 int64_t kDisplayIds[3] = {123, 456, 789}; |
| 27 | 27 |
| 28 std::unique_ptr<ui::DisplayMode> MakeDisplayMode(int width, | 28 std::unique_ptr<DisplayMode> MakeDisplayMode(int width, |
| 29 int height, | 29 int height, |
| 30 bool is_interlaced, | 30 bool is_interlaced, |
| 31 float refresh_rate) { | 31 float refresh_rate) { |
| 32 return base::MakeUnique<ui::DisplayMode>(gfx::Size(width, height), | 32 return base::MakeUnique<DisplayMode>(gfx::Size(width, height), is_interlaced, |
| 33 is_interlaced, refresh_rate); | 33 refresh_rate); |
| 34 } | 34 } |
| 35 | 35 |
| 36 enum CallbackResult { | 36 enum CallbackResult { |
| 37 CALLBACK_FAILURE, | 37 CALLBACK_FAILURE, |
| 38 CALLBACK_SUCCESS, | 38 CALLBACK_SUCCESS, |
| 39 CALLBACK_NOT_CALLED, | 39 CALLBACK_NOT_CALLED, |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 // Expected immediate configurations should be done without any delays. | 42 // Expected immediate configurations should be done without any delays. |
| 43 constexpr base::TimeDelta kNoDelay = base::TimeDelta::FromMilliseconds(0); | 43 constexpr base::TimeDelta kNoDelay = base::TimeDelta::FromMilliseconds(0); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 void SetUp() override { | 214 void SetUp() override { |
| 215 log_.reset(new ActionLogger()); | 215 log_.reset(new ActionLogger()); |
| 216 | 216 |
| 217 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); | 217 native_display_delegate_ = new TestNativeDisplayDelegate(log_.get()); |
| 218 configurator_.SetDelegateForTesting( | 218 configurator_.SetDelegateForTesting( |
| 219 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); | 219 std::unique_ptr<NativeDisplayDelegate>(native_display_delegate_)); |
| 220 | 220 |
| 221 configurator_.set_state_controller(&state_controller_); | 221 configurator_.set_state_controller(&state_controller_); |
| 222 configurator_.set_mirroring_controller(&mirroring_controller_); | 222 configurator_.set_mirroring_controller(&mirroring_controller_); |
| 223 | 223 |
| 224 outputs_[0] = display::FakeDisplaySnapshot::Builder() | 224 outputs_[0] = FakeDisplaySnapshot::Builder() |
| 225 .SetId(kDisplayIds[0]) | 225 .SetId(kDisplayIds[0]) |
| 226 .SetNativeMode(small_mode_.Clone()) | 226 .SetNativeMode(small_mode_.Clone()) |
| 227 .SetCurrentMode(small_mode_.Clone()) | 227 .SetCurrentMode(small_mode_.Clone()) |
| 228 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) | 228 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 229 .SetIsAspectPerservingScaling(true) | 229 .SetIsAspectPerservingScaling(true) |
| 230 .Build(); | 230 .Build(); |
| 231 | 231 |
| 232 outputs_[1] = display::FakeDisplaySnapshot::Builder() | 232 outputs_[1] = FakeDisplaySnapshot::Builder() |
| 233 .SetId(kDisplayIds[1]) | 233 .SetId(kDisplayIds[1]) |
| 234 .SetNativeMode(big_mode_.Clone()) | 234 .SetNativeMode(big_mode_.Clone()) |
| 235 .SetCurrentMode(big_mode_.Clone()) | 235 .SetCurrentMode(big_mode_.Clone()) |
| 236 .AddMode(small_mode_.Clone()) | 236 .AddMode(small_mode_.Clone()) |
| 237 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) | 237 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 238 .SetIsAspectPerservingScaling(true) | 238 .SetIsAspectPerservingScaling(true) |
| 239 .Build(); | 239 .Build(); |
| 240 | 240 |
| 241 outputs_[2] = display::FakeDisplaySnapshot::Builder() | 241 outputs_[2] = FakeDisplaySnapshot::Builder() |
| 242 .SetId(kDisplayIds[2]) | 242 .SetId(kDisplayIds[2]) |
| 243 .SetNativeMode(small_mode_.Clone()) | 243 .SetNativeMode(small_mode_.Clone()) |
| 244 .SetCurrentMode(small_mode_.Clone()) | 244 .SetCurrentMode(small_mode_.Clone()) |
| 245 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) | 245 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 246 .SetIsAspectPerservingScaling(true) | 246 .SetIsAspectPerservingScaling(true) |
| 247 .Build(); | 247 .Build(); |
| 248 | 248 |
| 249 UpdateOutputs(2, false); | 249 UpdateOutputs(2, false); |
| 250 } | 250 } |
| 251 | 251 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 CallbackResult display_control_result_; | 335 CallbackResult display_control_result_; |
| 336 | 336 |
| 337 private: | 337 private: |
| 338 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); | 338 DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 } // namespace | 341 } // namespace |
| 342 | 342 |
| 343 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { | 343 TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { |
| 344 std::unique_ptr<ui::DisplaySnapshot> output = | 344 std::unique_ptr<DisplaySnapshot> output = |
| 345 display::FakeDisplaySnapshot::Builder() | 345 FakeDisplaySnapshot::Builder() |
| 346 .SetId(kDisplayIds[0]) | 346 .SetId(kDisplayIds[0]) |
| 347 .AddMode(MakeDisplayMode(1920, 1200, false, 60.0)) | 347 .AddMode(MakeDisplayMode(1920, 1200, false, 60.0)) |
| 348 .SetNativeMode(MakeDisplayMode(1920, 1200, false, 50.0)) | 348 .SetNativeMode(MakeDisplayMode(1920, 1200, false, 50.0)) |
| 349 // Different rates. | 349 // Different rates. |
| 350 .AddMode(MakeDisplayMode(1920, 1080, false, 30.0)) | 350 .AddMode(MakeDisplayMode(1920, 1080, false, 30.0)) |
| 351 .AddMode(MakeDisplayMode(1920, 1080, false, 50.0)) | 351 .AddMode(MakeDisplayMode(1920, 1080, false, 50.0)) |
| 352 .AddMode(MakeDisplayMode(1920, 1080, false, 40.0)) | 352 .AddMode(MakeDisplayMode(1920, 1080, false, 40.0)) |
| 353 .AddMode(MakeDisplayMode(1920, 1080, false, 0.0)) | 353 .AddMode(MakeDisplayMode(1920, 1080, false, 0.0)) |
| 354 // Interlaced vs non-interlaced. | 354 // Interlaced vs non-interlaced. |
| 355 .AddMode(MakeDisplayMode(1280, 720, true, 60.0)) | 355 .AddMode(MakeDisplayMode(1280, 720, true, 60.0)) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 411 |
| 412 observer_.Reset(); | 412 observer_.Reset(); |
| 413 const DisplayConfigurator::DisplayStateList& cached = | 413 const DisplayConfigurator::DisplayStateList& cached = |
| 414 configurator_.cached_displays(); | 414 configurator_.cached_displays(); |
| 415 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); | 415 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); |
| 416 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 416 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 417 | 417 |
| 418 // Add virtual display. | 418 // Add virtual display. |
| 419 int64_t virtual_display_id = | 419 int64_t virtual_display_id = |
| 420 configurator_.AddVirtualDisplay(big_mode_.size()); | 420 configurator_.AddVirtualDisplay(big_mode_.size()); |
| 421 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 1), virtual_display_id); | 421 EXPECT_EQ(GenerateDisplayID(0x8000, 0x0, 1), virtual_display_id); |
| 422 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 422 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 423 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 423 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 424 configurator_.display_state()); | 424 configurator_.display_state()); |
| 425 | 425 |
| 426 // Virtual should not trigger addition of added crtc but does change FB | 426 // Virtual should not trigger addition of added crtc but does change FB |
| 427 // height. | 427 // height. |
| 428 const int kVirtualHeight = small_mode_.size().height() + | 428 const int kVirtualHeight = small_mode_.size().height() + |
| 429 DisplayConfigurator::kVerticalGap + | 429 DisplayConfigurator::kVerticalGap + |
| 430 big_mode_.size().height(); | 430 big_mode_.size().height(); |
| 431 EXPECT_EQ( | 431 EXPECT_EQ( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 observer_.Reset(); | 466 observer_.Reset(); |
| 467 const DisplayConfigurator::DisplayStateList& cached = | 467 const DisplayConfigurator::DisplayStateList& cached = |
| 468 configurator_.cached_displays(); | 468 configurator_.cached_displays(); |
| 469 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); | 469 ASSERT_EQ(static_cast<size_t>(1u), cached.size()); |
| 470 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 470 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 471 | 471 |
| 472 // Add 1st virtual display. | 472 // Add 1st virtual display. |
| 473 int64_t virtual_display_id_1 = | 473 int64_t virtual_display_id_1 = |
| 474 configurator_.AddVirtualDisplay(big_mode_.size()); | 474 configurator_.AddVirtualDisplay(big_mode_.size()); |
| 475 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 1), virtual_display_id_1); | 475 EXPECT_EQ(GenerateDisplayID(0x8000, 0x0, 1), virtual_display_id_1); |
| 476 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 476 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 477 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 477 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 478 configurator_.display_state()); | 478 configurator_.display_state()); |
| 479 | 479 |
| 480 // Virtual should not trigger addition of added crtc but does change FB | 480 // Virtual should not trigger addition of added crtc but does change FB |
| 481 // height. | 481 // height. |
| 482 const int kSingleVirtualHeight = small_mode_.size().height() + | 482 const int kSingleVirtualHeight = small_mode_.size().height() + |
| 483 DisplayConfigurator::kVerticalGap + | 483 DisplayConfigurator::kVerticalGap + |
| 484 big_mode_.size().height(); | 484 big_mode_.size().height(); |
| 485 EXPECT_EQ( | 485 EXPECT_EQ( |
| 486 JoinActions( | 486 JoinActions( |
| 487 kGrab, GetFramebufferAction( | 487 kGrab, GetFramebufferAction( |
| 488 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), | 488 gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), |
| 489 outputs_[0].get(), nullptr) | 489 outputs_[0].get(), nullptr) |
| 490 .c_str(), | 490 .c_str(), |
| 491 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 491 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 492 kUngrab, nullptr), | 492 kUngrab, nullptr), |
| 493 log_->GetActionsAndClear()); | 493 log_->GetActionsAndClear()); |
| 494 EXPECT_EQ(1, observer_.num_changes()); | 494 EXPECT_EQ(1, observer_.num_changes()); |
| 495 ASSERT_EQ(static_cast<size_t>(2), cached.size()); | 495 ASSERT_EQ(static_cast<size_t>(2), cached.size()); |
| 496 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); | 496 EXPECT_EQ(small_mode_.size(), cached[0]->current_mode()->size()); |
| 497 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); | 497 EXPECT_EQ(big_mode_.size(), cached[1]->current_mode()->size()); |
| 498 EXPECT_EQ(virtual_display_id_1, cached[1]->display_id()); | 498 EXPECT_EQ(virtual_display_id_1, cached[1]->display_id()); |
| 499 | 499 |
| 500 // Add 2nd virtual display | 500 // Add 2nd virtual display |
| 501 int64_t virtual_display_id_2 = | 501 int64_t virtual_display_id_2 = |
| 502 configurator_.AddVirtualDisplay(big_mode_.size()); | 502 configurator_.AddVirtualDisplay(big_mode_.size()); |
| 503 EXPECT_EQ(display::GenerateDisplayID(0x8000, 0x0, 2), virtual_display_id_2); | 503 EXPECT_EQ(GenerateDisplayID(0x8000, 0x0, 2), virtual_display_id_2); |
| 504 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 504 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 505 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, | 505 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 506 configurator_.display_state()); | 506 configurator_.display_state()); |
| 507 | 507 |
| 508 const int kDualVirtualHeight = | 508 const int kDualVirtualHeight = |
| 509 small_mode_.size().height() + | 509 small_mode_.size().height() + |
| 510 (DisplayConfigurator::kVerticalGap + big_mode_.size().height()) * 2; | 510 (DisplayConfigurator::kVerticalGap + big_mode_.size().height()) * 2; |
| 511 EXPECT_EQ( | 511 EXPECT_EQ( |
| 512 JoinActions( | 512 JoinActions( |
| 513 kGrab, GetFramebufferAction( | 513 kGrab, GetFramebufferAction( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 kGrab, | 611 kGrab, |
| 612 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) | 612 GetFramebufferAction(small_mode_.size(), outputs_[0].get(), nullptr) |
| 613 .c_str(), | 613 .c_str(), |
| 614 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 614 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 615 kUngrab, nullptr), | 615 kUngrab, nullptr), |
| 616 log_->GetActionsAndClear()); | 616 log_->GetActionsAndClear()); |
| 617 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 617 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 618 EXPECT_EQ(1, observer_.num_changes()); | 618 EXPECT_EQ(1, observer_.num_changes()); |
| 619 | 619 |
| 620 // Get rid of shared modes to force software mirroring. | 620 // Get rid of shared modes to force software mirroring. |
| 621 outputs_[1] = display::FakeDisplaySnapshot::Builder() | 621 outputs_[1] = FakeDisplaySnapshot::Builder() |
| 622 .SetId(kDisplayIds[1]) | 622 .SetId(kDisplayIds[1]) |
| 623 .SetNativeMode(big_mode_.Clone()) | 623 .SetNativeMode(big_mode_.Clone()) |
| 624 .SetCurrentMode(big_mode_.Clone()) | 624 .SetCurrentMode(big_mode_.Clone()) |
| 625 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) | 625 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 626 .SetIsAspectPerservingScaling(true) | 626 .SetIsAspectPerservingScaling(true) |
| 627 .Build(); | 627 .Build(); |
| 628 | 628 |
| 629 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 629 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 630 UpdateOutputs(2, true); | 630 UpdateOutputs(2, true); |
| 631 EXPECT_EQ( | 631 EXPECT_EQ( |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 .c_str(), | 764 .c_str(), |
| 765 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 765 GetCrtcAction(*outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 766 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), | 766 GetCrtcAction(*outputs_[1], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 767 kForceDPMS, kUngrab, nullptr), | 767 kForceDPMS, kUngrab, nullptr), |
| 768 log_->GetActionsAndClear()); | 768 log_->GetActionsAndClear()); |
| 769 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); | 769 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); |
| 770 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 770 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 771 EXPECT_EQ(1, observer_.num_changes()); | 771 EXPECT_EQ(1, observer_.num_changes()); |
| 772 | 772 |
| 773 // Get rid of shared modes to force software mirroring. | 773 // Get rid of shared modes to force software mirroring. |
| 774 outputs_[1] = display::FakeDisplaySnapshot::Builder() | 774 outputs_[1] = FakeDisplaySnapshot::Builder() |
| 775 .SetId(kDisplayIds[1]) | 775 .SetId(kDisplayIds[1]) |
| 776 .SetNativeMode(big_mode_.Clone()) | 776 .SetNativeMode(big_mode_.Clone()) |
| 777 .SetCurrentMode(big_mode_.Clone()) | 777 .SetCurrentMode(big_mode_.Clone()) |
| 778 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) | 778 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 779 .SetIsAspectPerservingScaling(true) | 779 .SetIsAspectPerservingScaling(true) |
| 780 .Build(); | 780 .Build(); |
| 781 | 781 |
| 782 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 782 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 783 observer_.Reset(); | 783 observer_.Reset(); |
| 784 UpdateOutputs(2, true); | 784 UpdateOutputs(2, true); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 config_waiter_.Reset(); | 1046 config_waiter_.Reset(); |
| 1047 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, | 1047 configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, |
| 1048 DisplayConfigurator::kSetDisplayPowerNoFlags, | 1048 DisplayConfigurator::kSetDisplayPowerNoFlags, |
| 1049 config_waiter_.on_configuration_callback()); | 1049 config_waiter_.on_configuration_callback()); |
| 1050 EXPECT_EQ(kNoDelay, config_waiter_.Wait()); | 1050 EXPECT_EQ(kNoDelay, config_waiter_.Wait()); |
| 1051 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); | 1051 EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); |
| 1052 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, nullptr), | 1052 EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, nullptr), |
| 1053 log_->GetActionsAndClear()); | 1053 log_->GetActionsAndClear()); |
| 1054 | 1054 |
| 1055 // Connect an external display and check that it's configured correctly. | 1055 // Connect an external display and check that it's configured correctly. |
| 1056 outputs_[0] = display::FakeDisplaySnapshot::Builder() | 1056 outputs_[0] = FakeDisplaySnapshot::Builder() |
| 1057 .SetId(kDisplayIds[0]) | 1057 .SetId(kDisplayIds[0]) |
| 1058 .SetNativeMode(big_mode_.Clone()) | 1058 .SetNativeMode(big_mode_.Clone()) |
| 1059 .SetCurrentMode(big_mode_.Clone()) | 1059 .SetCurrentMode(big_mode_.Clone()) |
| 1060 .AddMode(small_mode_.Clone()) | 1060 .AddMode(small_mode_.Clone()) |
| 1061 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) | 1061 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 1062 .SetIsAspectPerservingScaling(true) | 1062 .SetIsAspectPerservingScaling(true) |
| 1063 .Build(); | 1063 .Build(); |
| 1064 | 1064 |
| 1065 UpdateOutputs(1, true); | 1065 UpdateOutputs(1, true); |
| 1066 EXPECT_EQ( | 1066 EXPECT_EQ( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); | 1161 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| 1162 UpdateOutputs(2, true); | 1162 UpdateOutputs(2, true); |
| 1163 ASSERT_EQ(static_cast<size_t>(2), cached.size()); | 1163 ASSERT_EQ(static_cast<size_t>(2), cached.size()); |
| 1164 EXPECT_EQ(outputs_[0]->current_mode(), cached[0]->current_mode()); | 1164 EXPECT_EQ(outputs_[0]->current_mode(), cached[0]->current_mode()); |
| 1165 EXPECT_EQ(outputs_[1]->current_mode(), cached[1]->current_mode()); | 1165 EXPECT_EQ(outputs_[1]->current_mode(), cached[1]->current_mode()); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 TEST_F(DisplayConfiguratorTest, PanelFitting) { | 1168 TEST_F(DisplayConfiguratorTest, PanelFitting) { |
| 1169 // Configure the internal display to support only the big mode and the | 1169 // Configure the internal display to support only the big mode and the |
| 1170 // external display to support only the small mode. | 1170 // external display to support only the small mode. |
| 1171 outputs_[0] = display::FakeDisplaySnapshot::Builder() | 1171 outputs_[0] = FakeDisplaySnapshot::Builder() |
| 1172 .SetId(kDisplayIds[0]) | 1172 .SetId(kDisplayIds[0]) |
| 1173 .SetNativeMode(big_mode_.Clone()) | 1173 .SetNativeMode(big_mode_.Clone()) |
| 1174 .SetCurrentMode(big_mode_.Clone()) | 1174 .SetCurrentMode(big_mode_.Clone()) |
| 1175 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) | 1175 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 1176 .SetIsAspectPerservingScaling(true) | 1176 .SetIsAspectPerservingScaling(true) |
| 1177 .Build(); | 1177 .Build(); |
| 1178 | 1178 |
| 1179 outputs_[1] = display::FakeDisplaySnapshot::Builder() | 1179 outputs_[1] = FakeDisplaySnapshot::Builder() |
| 1180 .SetId(kDisplayIds[1]) | 1180 .SetId(kDisplayIds[1]) |
| 1181 .SetNativeMode(small_mode_.Clone()) | 1181 .SetNativeMode(small_mode_.Clone()) |
| 1182 .SetCurrentMode(small_mode_.Clone()) | 1182 .SetCurrentMode(small_mode_.Clone()) |
| 1183 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) | 1183 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 1184 .SetIsAspectPerservingScaling(true) | 1184 .SetIsAspectPerservingScaling(true) |
| 1185 .Build(); | 1185 .Build(); |
| 1186 | 1186 |
| 1187 // The small mode should be added to the internal output when requesting | 1187 // The small mode should be added to the internal output when requesting |
| 1188 // mirrored mode. | 1188 // mirrored mode. |
| 1189 UpdateOutputs(2, false); | 1189 UpdateOutputs(2, false); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 std::vector<std::unique_ptr<const DisplayMode>> modes; | 1501 std::vector<std::unique_ptr<const DisplayMode>> modes; |
| 1502 // The first mode is the mode we are requesting DisplayConfigurator to choose. | 1502 // The first mode is the mode we are requesting DisplayConfigurator to choose. |
| 1503 // The test will be setup so that this mode will fail and it will have to | 1503 // The test will be setup so that this mode will fail and it will have to |
| 1504 // choose the next best option. | 1504 // choose the next best option. |
| 1505 modes.push_back(MakeDisplayMode(2560, 1600, false, 60.0)); | 1505 modes.push_back(MakeDisplayMode(2560, 1600, false, 60.0)); |
| 1506 modes.push_back(MakeDisplayMode(1024, 768, false, 60.0)); | 1506 modes.push_back(MakeDisplayMode(1024, 768, false, 60.0)); |
| 1507 modes.push_back(MakeDisplayMode(1280, 720, false, 60.0)); | 1507 modes.push_back(MakeDisplayMode(1280, 720, false, 60.0)); |
| 1508 modes.push_back(MakeDisplayMode(1920, 1080, false, 60.0)); | 1508 modes.push_back(MakeDisplayMode(1920, 1080, false, 60.0)); |
| 1509 modes.push_back(MakeDisplayMode(1920, 1080, false, 40.0)); | 1509 modes.push_back(MakeDisplayMode(1920, 1080, false, 40.0)); |
| 1510 | 1510 |
| 1511 outputs_[0] = display::FakeDisplaySnapshot::Builder() | 1511 outputs_[0] = FakeDisplaySnapshot::Builder() |
| 1512 .SetId(kDisplayIds[0]) | 1512 .SetId(kDisplayIds[0]) |
| 1513 .SetNativeMode(modes[0]->Clone()) | 1513 .SetNativeMode(modes[0]->Clone()) |
| 1514 .SetCurrentMode(modes[0]->Clone()) | 1514 .SetCurrentMode(modes[0]->Clone()) |
| 1515 .AddMode(modes[1]->Clone()) | 1515 .AddMode(modes[1]->Clone()) |
| 1516 .AddMode(modes[2]->Clone()) | 1516 .AddMode(modes[2]->Clone()) |
| 1517 .AddMode(modes[3]->Clone()) | 1517 .AddMode(modes[3]->Clone()) |
| 1518 .AddMode(modes[4]->Clone()) | 1518 .AddMode(modes[4]->Clone()) |
| 1519 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) | 1519 .SetType(DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 1520 .SetIsAspectPerservingScaling(true) | 1520 .SetIsAspectPerservingScaling(true) |
| 1521 .Build(); | 1521 .Build(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1532 JoinActions( | 1532 JoinActions( |
| 1533 kGrab, | 1533 kGrab, |
| 1534 GetFramebufferAction(big_mode_.size(), outputs_[0].get(), nullptr) | 1534 GetFramebufferAction(big_mode_.size(), outputs_[0].get(), nullptr) |
| 1535 .c_str(), | 1535 .c_str(), |
| 1536 GetCrtcAction(*outputs_[0], modes[0].get(), gfx::Point(0, 0)).c_str(), | 1536 GetCrtcAction(*outputs_[0], modes[0].get(), gfx::Point(0, 0)).c_str(), |
| 1537 GetCrtcAction(*outputs_[0], modes[3].get(), gfx::Point(0, 0)).c_str(), | 1537 GetCrtcAction(*outputs_[0], modes[3].get(), gfx::Point(0, 0)).c_str(), |
| 1538 GetCrtcAction(*outputs_[0], modes[2].get(), gfx::Point(0, 0)).c_str(), | 1538 GetCrtcAction(*outputs_[0], modes[2].get(), gfx::Point(0, 0)).c_str(), |
| 1539 kUngrab, nullptr), | 1539 kUngrab, nullptr), |
| 1540 log_->GetActionsAndClear()); | 1540 log_->GetActionsAndClear()); |
| 1541 | 1541 |
| 1542 outputs_[1] = display::FakeDisplaySnapshot::Builder() | 1542 outputs_[1] = FakeDisplaySnapshot::Builder() |
| 1543 .SetId(kDisplayIds[1]) | 1543 .SetId(kDisplayIds[1]) |
| 1544 .SetNativeMode(modes[0]->Clone()) | 1544 .SetNativeMode(modes[0]->Clone()) |
| 1545 .SetCurrentMode(modes[0]->Clone()) | 1545 .SetCurrentMode(modes[0]->Clone()) |
| 1546 .AddMode(modes[1]->Clone()) | 1546 .AddMode(modes[1]->Clone()) |
| 1547 .AddMode(modes[2]->Clone()) | 1547 .AddMode(modes[2]->Clone()) |
| 1548 .AddMode(modes[3]->Clone()) | 1548 .AddMode(modes[3]->Clone()) |
| 1549 .AddMode(modes[4]->Clone()) | 1549 .AddMode(modes[4]->Clone()) |
| 1550 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) | 1550 .SetType(DISPLAY_CONNECTION_TYPE_HDMI) |
| 1551 .SetIsAspectPerservingScaling(true) | 1551 .SetIsAspectPerservingScaling(true) |
| 1552 .Build(); | 1552 .Build(); |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 config_waiter_.Reset(); | 2171 config_waiter_.Reset(); |
| 2172 configurator_.ResumeDisplays(); | 2172 configurator_.ResumeDisplays(); |
| 2173 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); | 2173 EXPECT_EQ(kLongDelay, config_waiter_.Wait()); |
| 2174 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, | 2174 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 2175 configurator_.current_power_state()); | 2175 configurator_.current_power_state()); |
| 2176 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, | 2176 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| 2177 configurator_.display_state()); | 2177 configurator_.display_state()); |
| 2178 } | 2178 } |
| 2179 | 2179 |
| 2180 } // namespace test | 2180 } // namespace test |
| 2181 } // namespace ui | 2181 } // namespace display |
| OLD | NEW |