| 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 "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/display/chromeos/test/action_logger_util.h" | 10 #include "ui/display/chromeos/test/action_logger_util.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 GetCrtcAction(outputs_[1], | 378 GetCrtcAction(outputs_[1], |
| 379 &big_mode_, | 379 &big_mode_, |
| 380 gfx::Point(0, | 380 gfx::Point(0, |
| 381 small_mode_.size().height() + | 381 small_mode_.size().height() + |
| 382 DisplayConfigurator::kVerticalGap)) | 382 DisplayConfigurator::kVerticalGap)) |
| 383 .c_str(), | 383 .c_str(), |
| 384 kUngrab, | 384 kUngrab, |
| 385 NULL), | 385 NULL), |
| 386 log_->GetActionsAndClear()); | 386 log_->GetActionsAndClear()); |
| 387 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 387 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 388 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 389 DCHECK(!framebuffer_size.IsEmpty()); |
| 388 | 390 |
| 389 observer_.Reset(); | 391 observer_.Reset(); |
| 390 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 392 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 391 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); | 393 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 392 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 394 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 393 configurator_.display_state()); | 395 configurator_.display_state()); |
| 394 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 396 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 397 EXPECT_EQ(framebuffer_size.ToString(), |
| 398 configurator_.framebuffer_size().ToString()); |
| 399 |
| 395 EXPECT_EQ(1, observer_.num_changes()); | 400 EXPECT_EQ(1, observer_.num_changes()); |
| 396 | 401 |
| 397 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. | 402 // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. |
| 398 observer_.Reset(); | 403 observer_.Reset(); |
| 399 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); | 404 configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); |
| 400 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); | 405 EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); |
| 401 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); | 406 EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 402 EXPECT_EQ(1, observer_.num_changes()); | 407 EXPECT_EQ(1, observer_.num_changes()); |
| 403 | 408 |
| 404 // Set back to software mirror mode. | 409 // Set back to software mirror mode. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); | 630 EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled()); |
| 626 EXPECT_EQ(1, observer_.num_changes()); | 631 EXPECT_EQ(1, observer_.num_changes()); |
| 627 } | 632 } |
| 628 | 633 |
| 629 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { | 634 TEST_F(DisplayConfiguratorTest, SuspendAndResume) { |
| 630 InitWithSingleOutput(); | 635 InitWithSingleOutput(); |
| 631 | 636 |
| 632 // No preparation is needed before suspending when the display is already | 637 // No preparation is needed before suspending when the display is already |
| 633 // on. The configurator should still reprobe on resume in case a display | 638 // on. The configurator should still reprobe on resume in case a display |
| 634 // was connected while suspended. | 639 // was connected while suspended. |
| 640 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 641 DCHECK(!framebuffer_size.IsEmpty()); |
| 635 configurator_.SuspendDisplays(); | 642 configurator_.SuspendDisplays(); |
| 643 EXPECT_EQ(framebuffer_size.ToString(), |
| 644 configurator_.framebuffer_size().ToString()); |
| 636 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 645 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 637 configurator_.ResumeDisplays(); | 646 configurator_.ResumeDisplays(); |
| 638 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 647 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 639 EXPECT_EQ( | 648 EXPECT_EQ( |
| 640 JoinActions( | 649 JoinActions( |
| 641 kGrab, | 650 kGrab, |
| 642 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), | 651 GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| 643 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), | 652 GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| 644 kForceDPMS, | 653 kForceDPMS, |
| 645 kUngrab, | 654 kUngrab, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 | 781 |
| 773 UpdateOutputs(1, true); | 782 UpdateOutputs(1, true); |
| 774 EXPECT_EQ( | 783 EXPECT_EQ( |
| 775 JoinActions( | 784 JoinActions( |
| 776 kGrab, | 785 kGrab, |
| 777 GetFramebufferAction(big_mode_.size(), &outputs_[0], NULL).c_str(), | 786 GetFramebufferAction(big_mode_.size(), &outputs_[0], NULL).c_str(), |
| 778 GetCrtcAction(outputs_[0], &big_mode_, gfx::Point(0, 0)).c_str(), | 787 GetCrtcAction(outputs_[0], &big_mode_, gfx::Point(0, 0)).c_str(), |
| 779 kUngrab, | 788 kUngrab, |
| 780 NULL), | 789 NULL), |
| 781 log_->GetActionsAndClear()); | 790 log_->GetActionsAndClear()); |
| 791 const gfx::Size framebuffer_size = configurator_.framebuffer_size(); |
| 792 DCHECK(!framebuffer_size.IsEmpty()); |
| 793 |
| 794 UpdateOutputs(0, true); |
| 795 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); |
| 796 EXPECT_EQ(framebuffer_size.ToString(), |
| 797 configurator_.framebuffer_size().ToString()); |
| 782 } | 798 } |
| 783 | 799 |
| 784 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { | 800 TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { |
| 785 UpdateOutputs(2, false); | 801 UpdateOutputs(2, false); |
| 786 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 802 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 787 configurator_.Init(false); | 803 configurator_.Init(false); |
| 788 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); | 804 EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); |
| 789 | 805 |
| 790 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); | 806 state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); |
| 791 configurator_.ForceInitialConfigure(0); | 807 configurator_.ForceInitialConfigure(0); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 GetFramebufferAction(small_mode_.size(), &outputs_[0], | 1358 GetFramebufferAction(small_mode_.size(), &outputs_[0], |
| 1343 nullptr).c_str(), | 1359 nullptr).c_str(), |
| 1344 GetCrtcAction(outputs_[0], &small_mode_, | 1360 GetCrtcAction(outputs_[0], &small_mode_, |
| 1345 gfx::Point(0, 0)).c_str(), | 1361 gfx::Point(0, 0)).c_str(), |
| 1346 kUngrab, NULL), | 1362 kUngrab, NULL), |
| 1347 log_->GetActionsAndClear()); | 1363 log_->GetActionsAndClear()); |
| 1348 } | 1364 } |
| 1349 | 1365 |
| 1350 } // namespace test | 1366 } // namespace test |
| 1351 } // namespace ui | 1367 } // namespace ui |
| OLD | NEW |