1 // Copyright 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.
5 #include "ash/display/display_error_observer_chromeos.h"
8 #include "ash/test/ash_test_base.h"
9 #include "grit/ash_strings.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"
14 #include "ui/views/widget/widget.h"
18 class DisplayErrorObserverTest
: public test::AshTestBase
{
20 DisplayErrorObserverTest() {
23 virtual ~DisplayErrorObserverTest() {
26 virtual void SetUp() OVERRIDE
{
27 test::AshTestBase::SetUp();
28 observer_
.reset(new DisplayErrorObserver());
32 DisplayErrorObserver
* observer() { return observer_
.get(); }
34 base::string16
GetMessageContents() {
35 return observer_
->GetTitleOfDisplayErrorNotificationForTest();
39 scoped_ptr
<DisplayErrorObserver
> observer_
;
41 DISALLOW_COPY_AND_ASSIGN(DisplayErrorObserverTest
);
44 TEST_F(DisplayErrorObserverTest
, Normal
) {
45 if (!SupportsMultipleDisplays())
48 UpdateDisplay("200x200,300x300");
49 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
50 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING
),
51 GetMessageContents());
54 TEST_F(DisplayErrorObserverTest
, CallTwice
) {
55 if (!SupportsMultipleDisplays())
58 UpdateDisplay("200x200,300x300");
59 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
60 base::string16 message
= GetMessageContents();
61 EXPECT_FALSE(message
.empty());
63 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
64 base::string16 message2
= GetMessageContents();
65 EXPECT_FALSE(message2
.empty());
66 EXPECT_EQ(message
, message2
);
69 TEST_F(DisplayErrorObserverTest
, CallWithDifferentState
) {
70 if (!SupportsMultipleDisplays())
73 UpdateDisplay("200x200,300x300");
74 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
75 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING
),
76 GetMessageContents());
78 observer()->OnDisplayModeChangeFailed(
79 ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED
);
80 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING
),
81 GetMessageContents());