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

Unified Diff: ash/display/display_error_dialog_unittest.cc

Issue 12209026: Fix the crash of DisplayErrorDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« ash/display/display_error_dialog.cc ('K') | « ash/display/display_error_dialog.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_error_dialog_unittest.cc
diff --git a/ash/display/display_error_dialog_unittest.cc b/ash/display/display_error_dialog_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4592c86db518bdfd885641a4cf4c26a3e700dc99
--- /dev/null
+++ b/ash/display/display_error_dialog_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/display/display_error_dialog.h"
+
+#include "ash/test/ash_test_base.h"
+
+namespace ash {
+namespace internal {
+
+typedef test::AshTestBase DisplayErrorDialogTest;
+
+// The test cases in this file usually check if the showing dialog doesn't
+// cause any crashes, and the code doesn't cause any memory leaks.
+TEST_F(DisplayErrorDialogTest, Normal) {
+ UpdateDisplay("200x200,300x300");
+ DisplayErrorDialog::ShowDialog();
+ DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ EXPECT_TRUE(dialog);
+ EXPECT_TRUE(dialog->GetWidget()->IsVisible());
James Cook 2013/02/05 23:59:52 Does this need to manually close the widget at the
oshima 2013/02/06 00:17:28 If the widget's ownership is NATIVE_WIDGET_OWNS_WI
+}
+
+TEST_F(DisplayErrorDialogTest, CallTwice) {
+ UpdateDisplay("200x200,300x300");
+ DisplayErrorDialog::ShowDialog();
+ DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ EXPECT_TRUE(dialog);
+ DisplayErrorDialog::ShowDialog();
+ EXPECT_EQ(dialog, DisplayErrorDialog::GetInstanceForTest());
oshima 2013/02/06 00:17:28 can you test if the dialog is on the right root wi
Jun Mukai 2013/02/06 00:37:18 Done.
+}
+
+TEST_F(DisplayErrorDialogTest, SingleDisplay) {
+ UpdateDisplay("200x200");
+ DisplayErrorDialog::ShowDialog();
+ DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ EXPECT_TRUE(dialog);
+ EXPECT_TRUE(dialog->GetWidget()->IsVisible());
+}
+
+TEST_F(DisplayErrorDialogTest, DisplayDisconnected) {
+ UpdateDisplay("200x200,300x300");
+ DisplayErrorDialog::ShowDialog();
+ DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ EXPECT_TRUE(dialog);
+
+ UpdateDisplay("200x200");
+ // Disconnection will close the dialog but we have to run all pending tasks
+ // to make the effect of the close.
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(DisplayErrorDialog::GetInstanceForTest());
+}
+
+} // namespace internal
+} // namespace ash
« ash/display/display_error_dialog.cc ('K') | « ash/display/display_error_dialog.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698