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

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
« no previous file with comments | « 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..e4d21d503a58ccc295a46e41c7d03d43f0bd1a03
--- /dev/null
+++ b/ash/display/display_error_dialog_unittest.cc
@@ -0,0 +1,62 @@
+// 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/shell.h"
+#include "ash/test/ash_test_base.h"
+#include "ui/aura/window.h"
+#include "ui/views/widget/widget.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());
+ EXPECT_EQ(Shell::GetAllRootWindows()[1],
+ dialog->GetWidget()->GetNativeView()->GetRootWindow());
+}
+
+TEST_F(DisplayErrorDialogTest, CallTwice) {
+ UpdateDisplay("200x200,300x300");
+ DisplayErrorDialog::ShowDialog();
+ DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ EXPECT_TRUE(dialog);
+ DisplayErrorDialog::ShowDialog();
+ EXPECT_EQ(dialog, DisplayErrorDialog::GetInstanceForTest());
+}
+
+TEST_F(DisplayErrorDialogTest, SingleDisplay) {
+ UpdateDisplay("200x200");
+ DisplayErrorDialog::ShowDialog();
+ DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ EXPECT_TRUE(dialog);
+ EXPECT_TRUE(dialog->GetWidget()->IsVisible());
+ EXPECT_EQ(Shell::GetInstance()->GetPrimaryRootWindow(),
+ dialog->GetWidget()->GetNativeView()->GetRootWindow());
+}
+
+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
« no previous file with comments | « ash/display/display_error_dialog.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698