Chromium Code Reviews| 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/display/display_controller.h" | |
| 8 #include "ash/screen_ash.h" | |
| 9 #include "ash/shell.h" | |
| 10 #include "ash/test/ash_test_base.h" | |
| 11 #include "ui/aura/window.h" | |
| 12 #include "ui/views/widget/widget.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 namespace internal { | |
| 16 namespace { | |
| 17 | |
| 18 aura::RootWindow* GetSecondaryRootWindow() { | |
| 19 DisplayController* display_controller = | |
| 20 Shell::GetInstance()->display_controller(); | |
| 21 return display_controller->GetRootWindowForDisplayId( | |
| 22 ScreenAsh::GetSecondaryDisplay().id()); | |
|
oshima
2013/02/06 00:41:08
you can use ash::Shell::GetAllRootWindows()[1]
Jun Mukai
2013/02/06 00:43:59
Done.
| |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 27 typedef test::AshTestBase DisplayErrorDialogTest; | |
| 28 | |
| 29 // The test cases in this file usually check if the showing dialog doesn't | |
| 30 // cause any crashes, and the code doesn't cause any memory leaks. | |
| 31 TEST_F(DisplayErrorDialogTest, Normal) { | |
| 32 UpdateDisplay("200x200,300x300"); | |
| 33 DisplayErrorDialog::ShowDialog(); | |
| 34 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); | |
| 35 EXPECT_TRUE(dialog); | |
| 36 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | |
| 37 EXPECT_EQ(GetSecondaryRootWindow(), | |
| 38 dialog->GetWidget()->GetNativeView()->GetRootWindow()); | |
| 39 } | |
| 40 | |
| 41 TEST_F(DisplayErrorDialogTest, CallTwice) { | |
| 42 UpdateDisplay("200x200,300x300"); | |
| 43 DisplayErrorDialog::ShowDialog(); | |
| 44 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); | |
| 45 EXPECT_TRUE(dialog); | |
| 46 DisplayErrorDialog::ShowDialog(); | |
| 47 EXPECT_EQ(dialog, DisplayErrorDialog::GetInstanceForTest()); | |
| 48 } | |
| 49 | |
| 50 TEST_F(DisplayErrorDialogTest, SingleDisplay) { | |
| 51 UpdateDisplay("200x200"); | |
| 52 DisplayErrorDialog::ShowDialog(); | |
| 53 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); | |
| 54 EXPECT_TRUE(dialog); | |
| 55 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | |
| 56 EXPECT_EQ(Shell::GetInstance()->GetPrimaryRootWindow(), | |
| 57 dialog->GetWidget()->GetNativeView()->GetRootWindow()); | |
| 58 } | |
| 59 | |
| 60 TEST_F(DisplayErrorDialogTest, DisplayDisconnected) { | |
| 61 UpdateDisplay("200x200,300x300"); | |
| 62 DisplayErrorDialog::ShowDialog(); | |
| 63 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); | |
| 64 EXPECT_TRUE(dialog); | |
| 65 | |
| 66 UpdateDisplay("200x200"); | |
| 67 // Disconnection will close the dialog but we have to run all pending tasks | |
| 68 // to make the effect of the close. | |
| 69 RunAllPendingInMessageLoop(); | |
| 70 EXPECT_FALSE(DisplayErrorDialog::GetInstanceForTest()); | |
| 71 } | |
| 72 | |
| 73 } // namespace internal | |
| 74 } // namespace ash | |
| OLD | NEW |