Chromium Code Reviews| 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..98a0ad03541fbfcade07c63cedcd1b43328a5b32 |
| --- /dev/null |
| +++ b/ash/display/display_error_dialog_unittest.cc |
| @@ -0,0 +1,74 @@ |
| +// 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/display/display_controller.h" |
| +#include "ash/screen_ash.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 { |
| +namespace { |
| + |
| +aura::RootWindow* GetSecondaryRootWindow() { |
| + DisplayController* display_controller = |
| + Shell::GetInstance()->display_controller(); |
| + return display_controller->GetRootWindowForDisplayId( |
| + 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.
|
| +} |
| + |
| +} // namespace |
| + |
| +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(GetSecondaryRootWindow(), |
| + 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 |