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 ~DisplayErrorObserverTest() override
{}
25 void SetUp() override
{
26 test::AshTestBase::SetUp();
27 observer_
.reset(new DisplayErrorObserver());
31 DisplayErrorObserver
* observer() { return observer_
.get(); }
33 base::string16
GetMessageContents() {
34 return observer_
->GetTitleOfDisplayErrorNotificationForTest();
38 scoped_ptr
<DisplayErrorObserver
> observer_
;
40 DISALLOW_COPY_AND_ASSIGN(DisplayErrorObserverTest
);
43 TEST_F(DisplayErrorObserverTest
, Normal
) {
44 if (!SupportsMultipleDisplays())
47 UpdateDisplay("200x200,300x300");
48 observer()->OnDisplayModeChangeFailed(
49 ui::DisplayConfigurator::DisplayStateList(),
50 ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
51 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING
),
52 GetMessageContents());
55 TEST_F(DisplayErrorObserverTest
, CallTwice
) {
56 if (!SupportsMultipleDisplays())
59 UpdateDisplay("200x200,300x300");
60 observer()->OnDisplayModeChangeFailed(
61 ui::DisplayConfigurator::DisplayStateList(),
62 ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
63 base::string16 message
= GetMessageContents();
64 EXPECT_FALSE(message
.empty());
66 observer()->OnDisplayModeChangeFailed(
67 ui::DisplayConfigurator::DisplayStateList(),
68 ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
69 base::string16 message2
= GetMessageContents();
70 EXPECT_FALSE(message2
.empty());
71 EXPECT_EQ(message
, message2
);
74 TEST_F(DisplayErrorObserverTest
, CallWithDifferentState
) {
75 if (!SupportsMultipleDisplays())
78 UpdateDisplay("200x200,300x300");
79 observer()->OnDisplayModeChangeFailed(
80 ui::DisplayConfigurator::DisplayStateList(),
81 ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR
);
82 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING
),
83 GetMessageContents());
85 observer()->OnDisplayModeChangeFailed(
86 ui::DisplayConfigurator::DisplayStateList(),
87 ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED
);
88 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING
),
89 GetMessageContents());