summaryrefslogtreecommitdiff
path: root/chromium/ash/display/resolution_notification_controller_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ash/display/resolution_notification_controller_unittest.cc')
-rw-r--r--chromium/ash/display/resolution_notification_controller_unittest.cc53
1 files changed, 28 insertions, 25 deletions
diff --git a/chromium/ash/display/resolution_notification_controller_unittest.cc b/chromium/ash/display/resolution_notification_controller_unittest.cc
index 036cce0d85c..3a479f98fd3 100644
--- a/chromium/ash/display/resolution_notification_controller_unittest.cc
+++ b/chromium/ash/display/resolution_notification_controller_unittest.cc
@@ -43,18 +43,16 @@ class ResolutionNotificationControllerTest : public ash::test::AshTestBase {
// OnConfigurationChanged event won't be emitted in the test environment,
// so invoke UpdateDisplay() to emit that event explicitly.
- std::vector<DisplayInfo> info_list;
+ std::string display_spec;
for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
+ if (i > 0)
+ display_spec.append(",");
int64 id = display_manager->GetDisplayAt(i).id();
- DisplayInfo info = display_manager->GetDisplayInfo(id);
- if (display.id() == id) {
- gfx::Rect bounds = info.bounds_in_pixel();
- bounds.set_size(new_resolution);
- info.SetBounds(bounds);
- }
- info_list.push_back(info);
+ gfx::Size size = (display.id() == id) ?
+ new_resolution : display_manager->GetDisplayInfo(id).size_in_pixel();
+ display_spec.append(size.ToString());
}
- display_manager->OnNativeDisplaysChanged(info_list);
+ UpdateDisplay(display_spec);
RunAllPendingInMessageLoop();
}
@@ -106,7 +104,7 @@ TEST_F(ResolutionNotificationControllerTest, Basic) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200");
+ UpdateDisplay("100x100,150x150");
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -123,20 +121,21 @@ TEST_F(ResolutionNotificationControllerTest, Basic) {
display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
EXPECT_EQ("200x200", resolution.ToString());
- // Click the revert button, which reverts to the best resolution.
+ // Click the revert button, which reverts the resolution.
ClickOnNotificationButton(0);
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- EXPECT_FALSE(
+ EXPECT_TRUE(
display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_EQ("150x150", resolution.ToString());
}
TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200");
+ UpdateDisplay("100x100,150x150");
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -170,7 +169,7 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("100x100");
const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay();
SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
@@ -187,7 +186,7 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
EXPECT_EQ("200x200", resolution.ToString());
// In that case the second button is revert.
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("100x100");
SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
@@ -195,8 +194,9 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
ClickOnNotificationButton(1);
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(1, accept_count());
- EXPECT_FALSE(display_manager->GetSelectedResolutionForDisplayId(
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
display.id(), &resolution));
+ EXPECT_EQ("100x100", resolution.ToString());
}
TEST_F(ResolutionNotificationControllerTest, Close) {
@@ -232,7 +232,7 @@ TEST_F(ResolutionNotificationControllerTest, Timeout) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("100x100");
const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay();
SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
@@ -247,38 +247,39 @@ TEST_F(ResolutionNotificationControllerTest, Timeout) {
gfx::Size resolution;
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
- EXPECT_FALSE(display_manager->GetSelectedResolutionForDisplayId(
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
display.id(), &resolution));
+ EXPECT_EQ("100x100", resolution.ToString());
}
TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,200x200#250x250|200x200|100x100");
+ UpdateDisplay("100x100,150x150");
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
SetDisplayResolutionAndNotify(
- ScreenAsh::GetSecondaryDisplay(), gfx::Size(100, 100));
+ ScreenAsh::GetSecondaryDisplay(), gfx::Size(200, 200));
ASSERT_TRUE(IsNotificationVisible());
// Disconnects the secondary display and verifies it doesn't cause crashes.
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("100x100");
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
gfx::Size resolution;
EXPECT_TRUE(
display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
- EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ("150x150", resolution.ToString());
}
TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200");
+ UpdateDisplay("100x100,150x150");
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -296,8 +297,9 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
// visible.
SetDisplayResolutionAndNotify(
ScreenAsh::GetSecondaryDisplay(), gfx::Size(250, 250));
- EXPECT_FALSE(
+ EXPECT_TRUE(
display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_EQ("250x250", resolution.ToString());
// Then, click the revert button. Although |old_resolution| for the second
// SetDisplayResolutionAndNotify is 200x200, it should revert to the original
@@ -306,8 +308,9 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- EXPECT_FALSE(
+ EXPECT_TRUE(
display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_EQ("150x150", resolution.ToString());
}
} // namespace internal