Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: ash/display/resolution_notification_controller_unittest.cc

Issue 138903025: Read compositor VSync information from platform, when possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 041e3518 Cleaned up. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/display/resolution_notification_controller_unittest.cc
diff --git a/ash/display/resolution_notification_controller_unittest.cc b/ash/display/resolution_notification_controller_unittest.cc
index afbc4a755eb9b71925aa58be6aeb86758dd66e09..c06bd6b8410916d39aa127827b4d3b7f7cc88112 100644
--- a/ash/display/resolution_notification_controller_unittest.cc
+++ b/ash/display/resolution_notification_controller_unittest.cc
@@ -157,7 +157,7 @@ TEST_F(ResolutionNotificationControllerTest, Basic) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200");
+ UpdateDisplay("300x300#300x300%57|200x200%58,250x250#250x250%59|200x200%60");
int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -172,24 +172,28 @@ TEST_F(ResolutionNotificationControllerTest, Basic) {
EXPECT_EQ(ExpectedNotificationMessage(id2, gfx::Size(200, 200)),
GetNotificationMessage());
gfx::Size resolution;
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ float refresh_rate = 0.0f;
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(60.0, refresh_rate);
// Click the revert button, which reverts to the best resolution.
ClickOnNotificationButton(0);
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- EXPECT_FALSE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
+ EXPECT_EQ("250x250", resolution.ToString());
+ EXPECT_EQ(59.0, refresh_rate);
}
TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200");
+ UpdateDisplay("300x300#300x300%57|200x200%58,250x250#250x250%59|200x200%60");
int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -202,18 +206,21 @@ TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) {
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
gfx::Size resolution;
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ float refresh_rate = 0.0f;
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(60.0, refresh_rate);
// Click the revert button, which reverts the resolution.
ClickOnNotification();
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(1, accept_count());
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(60.0, refresh_rate);
}
TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
@@ -223,7 +230,7 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("300x300#300x300%59|200x200%60");
const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay();
SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
@@ -235,12 +242,14 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(1, accept_count());
gfx::Size resolution;
+ float refresh_rate = 0.0f;
EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
- display.id(), &resolution));
+ display.id(), &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(60.0f, refresh_rate);
// In that case the second button is revert.
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("300x300#300x300%59|200x200%60");
SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
EXPECT_TRUE(IsNotificationVisible());
@@ -248,15 +257,17 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
ClickOnNotificationButton(1);
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(1, accept_count());
- EXPECT_FALSE(display_manager->GetSelectedResolutionForDisplayId(
- display.id(), &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ display.id(), &resolution, &refresh_rate));
+ EXPECT_EQ("300x300", resolution.ToString());
+ EXPECT_EQ(59.0f, refresh_rate);
}
TEST_F(ResolutionNotificationControllerTest, Close) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("100x100,150x150#150x150|200x200");
+ UpdateDisplay("100x100,150x150#150x150%59|200x200%60");
int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -269,9 +280,11 @@ TEST_F(ResolutionNotificationControllerTest, Close) {
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
gfx::Size resolution;
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ float refresh_rate = 0.0f;
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(60.0f, refresh_rate);
// Close the notification (imitates clicking [x] button). Also verifies if
// this does not cause a crash. See crbug.com/271784
@@ -285,7 +298,7 @@ TEST_F(ResolutionNotificationControllerTest, Timeout) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("300x300#300x300%59|200x200%60");
const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay();
SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
@@ -298,17 +311,21 @@ TEST_F(ResolutionNotificationControllerTest, Timeout) {
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
gfx::Size resolution;
+ float refresh_rate = 0.0f;
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
- EXPECT_FALSE(display_manager->GetSelectedResolutionForDisplayId(
- display.id(), &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ display.id(), &resolution, &refresh_rate));
+ EXPECT_EQ("300x300", resolution.ToString());
+ EXPECT_EQ(59.0f, refresh_rate);
}
TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,200x200#250x250|200x200|100x100");
+ UpdateDisplay("300x300#300x300%56|200x200%57,"
+ "200x200#250x250%58|200x200%59|100x100%60");
int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -317,21 +334,24 @@ TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) {
ASSERT_TRUE(IsNotificationVisible());
// Disconnects the secondary display and verifies it doesn't cause crashes.
- UpdateDisplay("300x300#300x300|200x200");
+ UpdateDisplay("300x300#300x300%56|200x200%57");
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
gfx::Size resolution;
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ float refresh_rate = 0.0f;
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(59.0f, refresh_rate);
}
TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200");
+ UpdateDisplay("300x300#300x300%56|200x200%57,"
+ "250x250#250x250%58|200x200%59");
int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -341,33 +361,40 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) {
EXPECT_TRUE(IsNotificationVisible());
EXPECT_FALSE(controller()->DoesNotificationTimeout());
gfx::Size resolution;
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ float refresh_rate = 0.0f;
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(59.0f, refresh_rate);
// Invokes SetDisplayResolutionAndNotify during the previous notification is
// visible.
SetDisplayResolutionAndNotify(
ScreenUtil::GetSecondaryDisplay(), gfx::Size(250, 250));
- EXPECT_FALSE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
+ EXPECT_EQ("250x250", resolution.ToString());
+ EXPECT_EQ(58.0f, refresh_rate);
// Then, click the revert button. Although |old_resolution| for the second
// SetDisplayResolutionAndNotify is 200x200, it should revert to the original
- // size 150x150.
+ // size 250x250.
ClickOnNotificationButton(0);
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- EXPECT_FALSE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
+ EXPECT_EQ("250x250", resolution.ToString());
+ EXPECT_EQ(58.0f, refresh_rate);
}
TEST_F(ResolutionNotificationControllerTest, Fallback) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("300x300#300x300|200x200,250x250#250x250|220x220|200x200");
+ UpdateDisplay("300x300#300x300%56|200x200%57,"
+ "250x250#250x250%58|220x220%59|200x200%60");
int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
@@ -386,17 +413,21 @@ TEST_F(ResolutionNotificationControllerTest, Fallback) {
id2, gfx::Size(220, 220), gfx::Size(200, 200)),
GetNotificationMessage());
gfx::Size resolution;
- EXPECT_TRUE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ float refresh_rate = 0.0f;
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
EXPECT_EQ("200x200", resolution.ToString());
+ EXPECT_EQ(60.0f, refresh_rate);
// Click the revert button, which reverts to the best resolution.
ClickOnNotificationButton(0);
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsNotificationVisible());
EXPECT_EQ(0, accept_count());
- EXPECT_FALSE(
- display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId(
+ id2, &resolution, &refresh_rate));
+ EXPECT_EQ("250x250", resolution.ToString());
+ EXPECT_EQ(58.0f, refresh_rate);
}
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698