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

Unified Diff: ash/display/resolution_notification_controller_unittest.cc

Issue 22960004: Fix the crash bug of close button for the resolution change notification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the new test Created 7 years, 4 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
« no previous file with comments | « ash/display/resolution_notification_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1ae175061ead50b23c839306fb293ba8dd495289..036cce0d85c9690ba2229aea4643e5cf218d81d2 100644
--- a/ash/display/resolution_notification_controller_unittest.cc
+++ b/ash/display/resolution_notification_controller_unittest.cc
@@ -68,6 +68,11 @@ class ResolutionNotificationControllerTest : public ash::test::AshTestBase {
ResolutionNotificationController::kNotificationId, index);
}
+ void CloseNotification() {
+ message_center::MessageCenter::Get()->RemoveNotification(
+ ResolutionNotificationController::kNotificationId, true /* by_user */);
+ }
+
bool IsNotificationVisible() {
return message_center::MessageCenter::Get()->HasNotification(
ResolutionNotificationController::kNotificationId);
@@ -194,6 +199,35 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
display.id(), &resolution));
}
+TEST_F(ResolutionNotificationControllerTest, Close) {
+ if (!SupportsMultipleDisplays())
+ return;
+
+ UpdateDisplay("100x100,150x150#150x150|200x200");
+ int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
+ ash::internal::DisplayManager* display_manager =
+ ash::Shell::GetInstance()->display_manager();
+ ASSERT_EQ(0, accept_count());
+ EXPECT_FALSE(IsNotificationVisible());
+
+ // Changes the resolution and apply the result.
+ SetDisplayResolutionAndNotify(
+ ScreenAsh::GetSecondaryDisplay(), gfx::Size(200, 200));
+ EXPECT_TRUE(IsNotificationVisible());
+ EXPECT_FALSE(controller()->DoesNotificationTimeout());
+ gfx::Size resolution;
+ EXPECT_TRUE(
+ display_manager->GetSelectedResolutionForDisplayId(id2, &resolution));
+ EXPECT_EQ("200x200", resolution.ToString());
+
+ // Close the notification (imitates clicking [x] button). Also verifies if
+ // this does not cause a crash. See crbug.com/271784
+ CloseNotification();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(IsNotificationVisible());
+ EXPECT_EQ(1, accept_count());
+}
+
TEST_F(ResolutionNotificationControllerTest, Timeout) {
if (!SupportsMultipleDisplays())
return;
« no previous file with comments | « ash/display/resolution_notification_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698