| 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/update_display_configuration_task.h" | 5 #include "ui/display/chromeos/update_display_configuration_task.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/display/chromeos/display_layout_manager.h" | 17 #include "ui/display/chromeos/display_layout_manager.h" |
| 16 #include "ui/display/chromeos/test/action_logger_util.h" | 18 #include "ui/display/chromeos/test/action_logger_util.h" |
| 17 #include "ui/display/chromeos/test/test_display_snapshot.h" | 19 #include "ui/display/chromeos/test/test_display_snapshot.h" |
| 18 #include "ui/display/chromeos/test/test_native_display_delegate.h" | 20 #include "ui/display/chromeos/test/test_native_display_delegate.h" |
| 19 | 21 |
| 20 namespace ui { | 22 namespace ui { |
| 21 namespace test { | 23 namespace test { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 | 50 |
| 49 void set_should_mirror(bool should_mirror) { should_mirror_ = should_mirror; } | 51 void set_should_mirror(bool should_mirror) { should_mirror_ = should_mirror; } |
| 50 | 52 |
| 51 void set_display_state(MultipleDisplayState state) { display_state_ = state; } | 53 void set_display_state(MultipleDisplayState state) { display_state_ = state; } |
| 52 | 54 |
| 53 void set_power_state(chromeos::DisplayPowerState state) { | 55 void set_power_state(chromeos::DisplayPowerState state) { |
| 54 power_state_ = state; | 56 power_state_ = state; |
| 55 } | 57 } |
| 56 | 58 |
| 57 void set_software_mirroring_controller( | 59 void set_software_mirroring_controller( |
| 58 scoped_ptr<DisplayConfigurator::SoftwareMirroringController> | 60 std::unique_ptr<DisplayConfigurator::SoftwareMirroringController> |
| 59 software_mirroring_controller) { | 61 software_mirroring_controller) { |
| 60 software_mirroring_controller_ = std::move(software_mirroring_controller); | 62 software_mirroring_controller_ = std::move(software_mirroring_controller); |
| 61 } | 63 } |
| 62 | 64 |
| 63 // DisplayConfigurator::DisplayLayoutManager: | 65 // DisplayConfigurator::DisplayLayoutManager: |
| 64 DisplayConfigurator::SoftwareMirroringController* | 66 DisplayConfigurator::SoftwareMirroringController* |
| 65 GetSoftwareMirroringController() const override { | 67 GetSoftwareMirroringController() const override { |
| 66 return software_mirroring_controller_.get(); | 68 return software_mirroring_controller_.get(); |
| 67 } | 69 } |
| 68 | 70 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 131 |
| 130 return mode; | 132 return mode; |
| 131 } | 133 } |
| 132 | 134 |
| 133 bool should_mirror_; | 135 bool should_mirror_; |
| 134 | 136 |
| 135 MultipleDisplayState display_state_; | 137 MultipleDisplayState display_state_; |
| 136 | 138 |
| 137 chromeos::DisplayPowerState power_state_; | 139 chromeos::DisplayPowerState power_state_; |
| 138 | 140 |
| 139 scoped_ptr<DisplayConfigurator::SoftwareMirroringController> | 141 std::unique_ptr<DisplayConfigurator::SoftwareMirroringController> |
| 140 software_mirroring_controller_; | 142 software_mirroring_controller_; |
| 141 | 143 |
| 142 DISALLOW_COPY_AND_ASSIGN(TestDisplayLayoutManager); | 144 DISALLOW_COPY_AND_ASSIGN(TestDisplayLayoutManager); |
| 143 }; | 145 }; |
| 144 | 146 |
| 145 class UpdateDisplayConfigurationTaskTest : public testing::Test { | 147 class UpdateDisplayConfigurationTaskTest : public testing::Test { |
| 146 public: | 148 public: |
| 147 UpdateDisplayConfigurationTaskTest() | 149 UpdateDisplayConfigurationTaskTest() |
| 148 : delegate_(&log_), | 150 : delegate_(&log_), |
| 149 small_mode_(gfx::Size(1366, 768), false, 60.0f), | 151 small_mode_(gfx::Size(1366, 768), false, 60.0f), |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), &displays_[0], | 399 JoinActions(kGrab, GetFramebufferAction(small_mode_.size(), &displays_[0], |
| 398 nullptr).c_str(), | 400 nullptr).c_str(), |
| 399 GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(), | 401 GetCrtcAction(displays_[0], nullptr, gfx::Point()).c_str(), |
| 400 kUngrab, NULL), | 402 kUngrab, NULL), |
| 401 log_.GetActionsAndClear()); | 403 log_.GetActionsAndClear()); |
| 402 } | 404 } |
| 403 | 405 |
| 404 TEST_F(UpdateDisplayConfigurationTaskTest, NoopSoftwareMirrorConfiguration) { | 406 TEST_F(UpdateDisplayConfigurationTaskTest, NoopSoftwareMirrorConfiguration) { |
| 405 layout_manager_.set_should_mirror(false); | 407 layout_manager_.set_should_mirror(false); |
| 406 layout_manager_.set_software_mirroring_controller( | 408 layout_manager_.set_software_mirroring_controller( |
| 407 make_scoped_ptr(new TestSoftwareMirroringController())); | 409 base::WrapUnique(new TestSoftwareMirroringController())); |
| 408 UpdateDisplays(2); | 410 UpdateDisplays(2); |
| 409 | 411 |
| 410 { | 412 { |
| 411 UpdateDisplayConfigurationTask task( | 413 UpdateDisplayConfigurationTask task( |
| 412 &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 414 &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 413 chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, | 415 chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |
| 414 base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, | 416 base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |
| 415 base::Unretained(this))); | 417 base::Unretained(this))); |
| 416 task.Run(); | 418 task.Run(); |
| 417 } | 419 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 431 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, display_state_); | 433 EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, display_state_); |
| 432 EXPECT_TRUE(layout_manager_.GetSoftwareMirroringController() | 434 EXPECT_TRUE(layout_manager_.GetSoftwareMirroringController() |
| 433 ->SoftwareMirroringEnabled()); | 435 ->SoftwareMirroringEnabled()); |
| 434 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_.GetActionsAndClear()); | 436 EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_.GetActionsAndClear()); |
| 435 } | 437 } |
| 436 | 438 |
| 437 TEST_F(UpdateDisplayConfigurationTaskTest, | 439 TEST_F(UpdateDisplayConfigurationTaskTest, |
| 438 ForceConfigurationWhileGoingToSoftwareMirror) { | 440 ForceConfigurationWhileGoingToSoftwareMirror) { |
| 439 layout_manager_.set_should_mirror(false); | 441 layout_manager_.set_should_mirror(false); |
| 440 layout_manager_.set_software_mirroring_controller( | 442 layout_manager_.set_software_mirroring_controller( |
| 441 make_scoped_ptr(new TestSoftwareMirroringController())); | 443 base::WrapUnique(new TestSoftwareMirroringController())); |
| 442 UpdateDisplays(2); | 444 UpdateDisplays(2); |
| 443 | 445 |
| 444 { | 446 { |
| 445 UpdateDisplayConfigurationTask task( | 447 UpdateDisplayConfigurationTask task( |
| 446 &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, | 448 &delegate_, &layout_manager_, MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| 447 chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, | 449 chromeos::DISPLAY_POWER_ALL_ON, 0, 0, false, |
| 448 base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, | 450 base::Bind(&UpdateDisplayConfigurationTaskTest::ResponseCallback, |
| 449 base::Unretained(this))); | 451 base::Unretained(this))); |
| 450 task.Run(); | 452 task.Run(); |
| 451 } | 453 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 473 &displays_[0], &displays_[1]).c_str(), | 475 &displays_[0], &displays_[1]).c_str(), |
| 474 GetCrtcAction(displays_[0], &small_mode_, gfx::Point()).c_str(), | 476 GetCrtcAction(displays_[0], &small_mode_, gfx::Point()).c_str(), |
| 475 GetCrtcAction(displays_[1], &big_mode_, | 477 GetCrtcAction(displays_[1], &big_mode_, |
| 476 gfx::Point(0, small_mode_.size().height())).c_str(), | 478 gfx::Point(0, small_mode_.size().height())).c_str(), |
| 477 kUngrab, NULL), | 479 kUngrab, NULL), |
| 478 log_.GetActionsAndClear()); | 480 log_.GetActionsAndClear()); |
| 479 } | 481 } |
| 480 | 482 |
| 481 } // namespace test | 483 } // namespace test |
| 482 } // namespace ui | 484 } // namespace ui |
| OLD | NEW |