OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/display/display_error_dialog.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ui/aura/window.h" |
| 10 #include "ui/views/widget/widget.h" |
| 11 |
| 12 namespace ash { |
| 13 namespace internal { |
| 14 |
| 15 typedef test::AshTestBase DisplayErrorDialogTest; |
| 16 |
| 17 // The test cases in this file usually check if the showing dialog doesn't |
| 18 // cause any crashes, and the code doesn't cause any memory leaks. |
| 19 TEST_F(DisplayErrorDialogTest, Normal) { |
| 20 UpdateDisplay("200x200,300x300"); |
| 21 DisplayErrorDialog::ShowDialog(); |
| 22 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); |
| 23 EXPECT_TRUE(dialog); |
| 24 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
| 25 EXPECT_EQ(Shell::GetAllRootWindows()[1], |
| 26 dialog->GetWidget()->GetNativeView()->GetRootWindow()); |
| 27 } |
| 28 |
| 29 TEST_F(DisplayErrorDialogTest, CallTwice) { |
| 30 UpdateDisplay("200x200,300x300"); |
| 31 DisplayErrorDialog::ShowDialog(); |
| 32 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); |
| 33 EXPECT_TRUE(dialog); |
| 34 DisplayErrorDialog::ShowDialog(); |
| 35 EXPECT_EQ(dialog, DisplayErrorDialog::GetInstanceForTest()); |
| 36 } |
| 37 |
| 38 TEST_F(DisplayErrorDialogTest, SingleDisplay) { |
| 39 UpdateDisplay("200x200"); |
| 40 DisplayErrorDialog::ShowDialog(); |
| 41 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); |
| 42 EXPECT_TRUE(dialog); |
| 43 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
| 44 EXPECT_EQ(Shell::GetInstance()->GetPrimaryRootWindow(), |
| 45 dialog->GetWidget()->GetNativeView()->GetRootWindow()); |
| 46 } |
| 47 |
| 48 TEST_F(DisplayErrorDialogTest, DisplayDisconnected) { |
| 49 UpdateDisplay("200x200,300x300"); |
| 50 DisplayErrorDialog::ShowDialog(); |
| 51 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); |
| 52 EXPECT_TRUE(dialog); |
| 53 |
| 54 UpdateDisplay("200x200"); |
| 55 // Disconnection will close the dialog but we have to run all pending tasks |
| 56 // to make the effect of the close. |
| 57 RunAllPendingInMessageLoop(); |
| 58 EXPECT_FALSE(DisplayErrorDialog::GetInstanceForTest()); |
| 59 } |
| 60 |
| 61 } // namespace internal |
| 62 } // namespace ash |
OLD | NEW |