Chromium Code Reviews| Index: ui/display/chromeos/display_configurator_unittest.cc |
| diff --git a/ui/display/chromeos/display_configurator_unittest.cc b/ui/display/chromeos/display_configurator_unittest.cc |
| index bd5f7e9d8cead04bf485626034edbe751b54953d..6b03d74cb6f58f7425fb1f11a13cdf89cd1a0edc 100644 |
| --- a/ui/display/chromeos/display_configurator_unittest.cc |
| +++ b/ui/display/chromeos/display_configurator_unittest.cc |
| @@ -337,6 +337,157 @@ TEST_F(DisplayConfiguratorTest, FindDisplayModeMatchingSize) { |
| output, gfx::Size(1440, 900))); |
| } |
| +TEST_F(DisplayConfiguratorTest, EnableVirtualDisplay) { |
| + InitWithSingleOutput(); |
| + |
| + observer_.Reset(); |
| + const DisplayConfigurator::DisplayStateList* cached = |
| + &configurator_.cached_displays(); |
|
oshima
2015/11/24 22:19:27
const ... & cached =
(I understand this is used i
robert.bradford
2015/11/26 16:29:40
Done. And I addressed the other user of this.
|
| + ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
|
oshima
2015/11/24 22:19:27
1u
robert.bradford
2015/11/26 16:29:40
Done. And some similar ones too.
|
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + |
| + // Add virtual display. |
| + int64_t virtual_display_id = |
| + configurator_.AddVirtualDisplay(big_mode_.size()); |
| + EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| + configurator_.display_state()); |
| + |
| + // Virtual should not trigger addition of added crtc but does change FB |
| + // height. |
| + const int kVirtualHeight = small_mode_.size().height() + |
| + DisplayConfigurator::kVerticalGap + |
| + big_mode_.size().height(); |
| + EXPECT_EQ( |
| + JoinActions( |
| + kGrab, GetFramebufferAction( |
| + gfx::Size(big_mode_.size().width(), kVirtualHeight), |
| + &outputs_[0], NULL) |
|
oshima
2015/11/24 22:19:27
nullptr. same for other files
robert.bradford
2015/11/26 16:29:40
Done.
|
| + .c_str(), |
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| + kUngrab, NULL), |
| + log_->GetActionsAndClear()); |
| + EXPECT_EQ(1, observer_.num_changes()); |
| + ASSERT_EQ(static_cast<size_t>(2), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); |
| + EXPECT_EQ(virtual_display_id, (*cached)[1]->display_id()); |
| + |
| + // Remove virtual display. |
| + observer_.Reset(); |
| + EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id)); |
| + EXPECT_EQ( |
| + JoinActions( |
| + kGrab, |
| + GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| + kUngrab, NULL), |
| + log_->GetActionsAndClear()); |
| + EXPECT_EQ(1, observer_.num_changes()); |
| + ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| +} |
| + |
| +TEST_F(DisplayConfiguratorTest, EnableTwoVirtualDisplays) { |
| + InitWithSingleOutput(); |
| + |
| + observer_.Reset(); |
| + const DisplayConfigurator::DisplayStateList* cached = |
| + &configurator_.cached_displays(); |
| + ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + |
| + // Add 1st virtual display. |
| + int64_t virtual_display_id_1 = |
| + configurator_.AddVirtualDisplay(big_mode_.size()); |
| + EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| + configurator_.display_state()); |
| + |
| + // Virtual should not trigger addition of added crtc but does change FB |
| + // height. |
| + const int kSingleVirtualHeight = small_mode_.size().height() + |
| + DisplayConfigurator::kVerticalGap + |
| + big_mode_.size().height(); |
| + EXPECT_EQ( |
| + JoinActions( |
| + kGrab, GetFramebufferAction( |
| + gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), |
| + &outputs_[0], NULL) |
| + .c_str(), |
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| + kUngrab, NULL), |
| + log_->GetActionsAndClear()); |
| + EXPECT_EQ(1, observer_.num_changes()); |
| + ASSERT_EQ(static_cast<size_t>(2), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); |
| + EXPECT_EQ(virtual_display_id_1, (*cached)[1]->display_id()); |
| + |
| + // Add 2nd virtual display |
| + int64_t virtual_display_id_2 = |
| + configurator_.AddVirtualDisplay(big_mode_.size()); |
| + EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled()); |
| + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, |
| + configurator_.display_state()); |
| + |
| + const int kDualVirtualHeight = |
| + small_mode_.size().height() + |
| + (DisplayConfigurator::kVerticalGap + big_mode_.size().height()) * 2; |
| + EXPECT_EQ( |
| + JoinActions( |
| + kGrab, GetFramebufferAction( |
| + gfx::Size(big_mode_.size().width(), kDualVirtualHeight), |
| + &outputs_[0], NULL) |
| + .c_str(), |
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| + kUngrab, NULL), |
| + log_->GetActionsAndClear()); |
| + EXPECT_EQ(2, observer_.num_changes()); |
| + ASSERT_EQ(static_cast<size_t>(3), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); |
| + EXPECT_EQ(big_mode_.size(), (*cached)[2]->current_mode()->size()); |
| + EXPECT_EQ(virtual_display_id_1, (*cached)[1]->display_id()); |
| + EXPECT_EQ(virtual_display_id_2, (*cached)[2]->display_id()); |
| + |
| + // Remove 1st virtual display. |
| + observer_.Reset(); |
| + EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_1)); |
| + EXPECT_EQ( |
| + JoinActions( |
| + kGrab, GetFramebufferAction( |
| + gfx::Size(big_mode_.size().width(), kSingleVirtualHeight), |
| + &outputs_[0], NULL) |
| + .c_str(), |
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| + kUngrab, NULL), |
| + log_->GetActionsAndClear()); |
| + EXPECT_EQ(1, observer_.num_changes()); |
| + ASSERT_EQ(static_cast<size_t>(2), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + EXPECT_EQ(big_mode_.size(), (*cached)[1]->current_mode()->size()); |
| + EXPECT_EQ(virtual_display_id_2, (*cached)[1]->display_id()); |
| + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, |
| + configurator_.display_state()); |
| + |
| + // Remove 2nd virtual display. |
| + observer_.Reset(); |
| + EXPECT_TRUE(configurator_.RemoveVirtualDisplay(virtual_display_id_2)); |
| + EXPECT_EQ( |
| + JoinActions( |
| + kGrab, |
| + GetFramebufferAction(small_mode_.size(), &outputs_[0], NULL).c_str(), |
| + GetCrtcAction(outputs_[0], &small_mode_, gfx::Point(0, 0)).c_str(), |
| + kUngrab, NULL), |
| + log_->GetActionsAndClear()); |
| + EXPECT_EQ(1, observer_.num_changes()); |
| + ASSERT_EQ(static_cast<size_t>(1), cached->size()); |
| + EXPECT_EQ(small_mode_.size(), (*cached)[0]->current_mode()->size()); |
| + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); |
| +} |
| + |
| TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { |
| InitWithSingleOutput(); |
| @@ -914,7 +1065,6 @@ TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { |
| // |cached_displays_| even if an invalid state is requested. |
| state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); |
| UpdateOutputs(2, true); |
| - cached = &configurator_.cached_displays(); |
| ASSERT_EQ(static_cast<size_t>(2), cached->size()); |
| EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0]->current_mode()); |
| EXPECT_EQ(outputs_[1].current_mode(), (*cached)[1]->current_mode()); |