Android: Get rid of extra dup()s on launching child processes
[chromium-blink-merge.git] / ash / display / display_error_observer_chromeos_unittest.cc
blobb0b3810ee41641ea0e7529a90e971e6d0d79e4e0
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(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
49 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING),
50 GetMessageContents());
53 TEST_F(DisplayErrorObserverTest, CallTwice) {
54 if (!SupportsMultipleDisplays())
55 return;
57 UpdateDisplay("200x200,300x300");
58 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
59 base::string16 message = GetMessageContents();
60 EXPECT_FALSE(message.empty());
62 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
63 base::string16 message2 = GetMessageContents();
64 EXPECT_FALSE(message2.empty());
65 EXPECT_EQ(message, message2);
68 TEST_F(DisplayErrorObserverTest, CallWithDifferentState) {
69 if (!SupportsMultipleDisplays())
70 return;
72 UpdateDisplay("200x200,300x300");
73 observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
74 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING),
75 GetMessageContents());
77 observer()->OnDisplayModeChangeFailed(
78 ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED);
79 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING),
80 GetMessageContents());
83 } // namespace ash