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

Side by Side 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: fix 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/display/display_error_dialog.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« 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