Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ash / display / display_error_observer_chromeos_unittest.cc
blob96871fef51be3d3800c1cee54b77b1c3c9a0b3f9
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"
7 #include "ash/shell.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"
16 namespace ash {
18 class DisplayErrorObserverTest : public test::AshTestBase {
19 protected:
20 DisplayErrorObserverTest() {
23 ~DisplayErrorObserverTest() override {}
25 void SetUp() override {
26 test::AshTestBase::SetUp();
27 observer_.reset(new DisplayErrorObserver());
30 protected:
31 DisplayErrorObserver* observer() { return observer_.get(); }
33 base::string16 GetMessageContents() {
34 return observer_->GetTitleOfDisplayErrorNotificationForTest();
37 private:
38 scoped_ptr<DisplayErrorObserver> observer_;
40 DISALLOW_COPY_AND_ASSIGN(DisplayErrorObserverTest);
43 TEST_F(DisplayErrorObserverTest, Normal) {
44 if (!SupportsMultipleDisplays())
45 return;
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())
57 return;
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())
76 return;
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());
92 } // namespace ash