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 |