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

Side by Side Diff: ash/display/display_error_dialog_unittest.cc

Issue 12212171: Provides more types of errors for output status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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') | ash/display/output_configurator_animation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/display/display_error_dialog.h" 5 #include "ash/display/display_error_dialog.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "grit/ash_strings.h"
9 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/views/controls/label.h"
13 #include "ui/views/view.h"
10 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
11 15
12 namespace ash { 16 namespace ash {
13 namespace internal { 17 namespace internal {
18 namespace {
14 19
15 typedef test::AshTestBase DisplayErrorDialogTest; 20 class DisplayErrorDialogTest : public test::AshTestBase {
21 protected:
22 DisplayErrorDialogTest() {
23 }
24
25 virtual ~DisplayErrorDialogTest() {
26 }
27
28 virtual void SetUp() OVERRIDE {
29 test::AshTestBase::SetUp();
30 observer_.reset(new DisplayErrorObserver());
31 }
32
33 virtual void TearDown() OVERRIDE {
34 if (observer_->dialog()) {
35 views::Widget* widget =
36 const_cast<DisplayErrorDialog*>(observer_->dialog())->GetWidget();
37 widget->CloseNow();
38 }
39 observer_.reset();
40 test::AshTestBase::TearDown();
41 }
42
43 DisplayErrorObserver* observer() { return observer_.get(); }
44
45 const string16& GetMessageContents(const DisplayErrorDialog* dialog) {
46 const views::Label* label = static_cast<const views::Label*>(
47 static_cast<const views::View*>(dialog)->child_at(0));
48 return label->text();
49 }
50
51 private:
52 scoped_ptr<DisplayErrorObserver> observer_;
53
54 DISALLOW_COPY_AND_ASSIGN(DisplayErrorDialogTest);
55 };
56
57 }
16 58
17 // The test cases in this file usually check if the showing dialog doesn't 59 // 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. 60 // cause any crashes, and the code doesn't cause any memory leaks.
19 TEST_F(DisplayErrorDialogTest, Normal) { 61 TEST_F(DisplayErrorDialogTest, Normal) {
20 UpdateDisplay("200x200,300x300"); 62 UpdateDisplay("200x200,300x300");
21 DisplayErrorDialog::ShowDialog(); 63 DisplayErrorDialog* dialog =
22 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); 64 DisplayErrorDialog::ShowDialog(chromeos::STATE_DUAL_MIRROR);
23 EXPECT_TRUE(dialog); 65 EXPECT_TRUE(dialog);
24 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 66 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
67 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING),
68 GetMessageContents(dialog));
25 EXPECT_EQ(Shell::GetAllRootWindows()[1], 69 EXPECT_EQ(Shell::GetAllRootWindows()[1],
26 dialog->GetWidget()->GetNativeView()->GetRootWindow()); 70 dialog->GetWidget()->GetNativeView()->GetRootWindow());
27 } 71 }
28 72
29 TEST_F(DisplayErrorDialogTest, CallTwice) { 73 TEST_F(DisplayErrorDialogTest, CallTwice) {
30 UpdateDisplay("200x200,300x300"); 74 UpdateDisplay("200x200,300x300");
31 DisplayErrorDialog::ShowDialog(); 75 observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
32 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); 76 const DisplayErrorDialog* dialog = observer()->dialog();
33 EXPECT_TRUE(dialog); 77 EXPECT_TRUE(dialog);
34 DisplayErrorDialog::ShowDialog(); 78
35 EXPECT_EQ(dialog, DisplayErrorDialog::GetInstanceForTest()); 79 observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
80 EXPECT_EQ(dialog, observer()->dialog());
81 }
82
83 TEST_F(DisplayErrorDialogTest, CallWithDifferentState) {
84 UpdateDisplay("200x200,300x300");
85 observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
86 const DisplayErrorDialog* dialog = observer()->dialog();
87 EXPECT_TRUE(dialog);
88 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING),
89 GetMessageContents(dialog));
90
91 observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_EXTENDED);
92 EXPECT_EQ(dialog, observer()->dialog());
93 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_EXTENDED),
94 GetMessageContents(dialog));
36 } 95 }
37 96
38 TEST_F(DisplayErrorDialogTest, SingleDisplay) { 97 TEST_F(DisplayErrorDialogTest, SingleDisplay) {
39 UpdateDisplay("200x200"); 98 UpdateDisplay("200x200");
40 DisplayErrorDialog::ShowDialog(); 99 DisplayErrorDialog* dialog =
41 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); 100 DisplayErrorDialog::ShowDialog(chromeos::STATE_DUAL_MIRROR);
42 EXPECT_TRUE(dialog); 101 EXPECT_TRUE(dialog);
43 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); 102 EXPECT_TRUE(dialog->GetWidget()->IsVisible());
44 EXPECT_EQ(Shell::GetInstance()->GetPrimaryRootWindow(), 103 EXPECT_EQ(Shell::GetInstance()->GetPrimaryRootWindow(),
45 dialog->GetWidget()->GetNativeView()->GetRootWindow()); 104 dialog->GetWidget()->GetNativeView()->GetRootWindow());
46 } 105 }
47 106
48 TEST_F(DisplayErrorDialogTest, DisplayDisconnected) { 107 TEST_F(DisplayErrorDialogTest, DisplayDisconnected) {
49 UpdateDisplay("200x200,300x300"); 108 UpdateDisplay("200x200,300x300");
50 DisplayErrorDialog::ShowDialog(); 109 observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
51 DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest(); 110 EXPECT_TRUE(observer()->dialog());
52 EXPECT_TRUE(dialog);
53 111
54 UpdateDisplay("200x200"); 112 UpdateDisplay("200x200");
55 // Disconnection will close the dialog but we have to run all pending tasks 113 // Disconnection will close the dialog but we have to run all pending tasks
56 // to make the effect of the close. 114 // to make the effect of the close.
57 RunAllPendingInMessageLoop(); 115 RunAllPendingInMessageLoop();
58 EXPECT_FALSE(DisplayErrorDialog::GetInstanceForTest()); 116 EXPECT_FALSE(observer()->dialog());
59 } 117 }
60 118
61 } // namespace internal 119 } // namespace internal
62 } // namespace ash 120 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_error_dialog.cc ('k') | ash/display/output_configurator_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698