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

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

Issue 2613493002: Fix namespace for src/ui/display/. (Closed)
Patch Set: Rebase. Created 3 years, 11 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
« no previous file with comments | « ash/display/projecting_observer_chromeos.cc ('k') | ash/display/shutdown_observer_chromeos.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/projecting_observer_chromeos.h" 5 #include "ash/display/projecting_observer_chromeos.h"
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "chromeos/dbus/fake_power_manager_client.h" 8 #include "chromeos/dbus/fake_power_manager_client.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/display/fake_display_snapshot.h" 10 #include "ui/display/fake_display_snapshot.h"
11 11
12 namespace ash { 12 namespace ash {
13 namespace { 13 namespace {
14 14
15 std::unique_ptr<ui::DisplaySnapshot> CreateInternalSnapshot() { 15 std::unique_ptr<display::DisplaySnapshot> CreateInternalSnapshot() {
16 return display::FakeDisplaySnapshot::Builder() 16 return display::FakeDisplaySnapshot::Builder()
17 .SetId(123) 17 .SetId(123)
18 .SetNativeMode(gfx::Size(1024, 768)) 18 .SetNativeMode(gfx::Size(1024, 768))
19 .SetType(ui::DISPLAY_CONNECTION_TYPE_INTERNAL) 19 .SetType(display::DISPLAY_CONNECTION_TYPE_INTERNAL)
20 .Build(); 20 .Build();
21 } 21 }
22 22
23 std::unique_ptr<ui::DisplaySnapshot> CreateVGASnapshot() { 23 std::unique_ptr<display::DisplaySnapshot> CreateVGASnapshot() {
24 return display::FakeDisplaySnapshot::Builder() 24 return display::FakeDisplaySnapshot::Builder()
25 .SetId(456) 25 .SetId(456)
26 .SetNativeMode(gfx::Size(1024, 768)) 26 .SetNativeMode(gfx::Size(1024, 768))
27 .SetType(ui::DISPLAY_CONNECTION_TYPE_VGA) 27 .SetType(display::DISPLAY_CONNECTION_TYPE_VGA)
28 .Build(); 28 .Build();
29 } 29 }
30 30
31 class ProjectingObserverTest : public testing::Test { 31 class ProjectingObserverTest : public testing::Test {
32 public: 32 public:
33 ProjectingObserverTest() : observer_(&fake_power_client_) {} 33 ProjectingObserverTest() : observer_(&fake_power_client_) {}
34 34
35 ~ProjectingObserverTest() override {} 35 ~ProjectingObserverTest() override {}
36 36
37 protected: 37 protected:
38 chromeos::FakePowerManagerClient fake_power_client_; 38 chromeos::FakePowerManagerClient fake_power_client_;
39 ProjectingObserver observer_; 39 ProjectingObserver observer_;
40 40
41 private: 41 private:
42 DISALLOW_COPY_AND_ASSIGN(ProjectingObserverTest); 42 DISALLOW_COPY_AND_ASSIGN(ProjectingObserverTest);
43 }; 43 };
44 44
45 } // namespace 45 } // namespace
46 46
47 TEST_F(ProjectingObserverTest, CheckNoDisplay) { 47 TEST_F(ProjectingObserverTest, CheckNoDisplay) {
48 ScopedVector<ui::DisplaySnapshot> displays; 48 ScopedVector<display::DisplaySnapshot> displays;
49 observer_.OnDisplayModeChanged(displays.get()); 49 observer_.OnDisplayModeChanged(displays.get());
50 50
51 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls()); 51 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls());
52 EXPECT_FALSE(fake_power_client_.is_projecting()); 52 EXPECT_FALSE(fake_power_client_.is_projecting());
53 } 53 }
54 54
55 TEST_F(ProjectingObserverTest, CheckWithoutInternalDisplay) { 55 TEST_F(ProjectingObserverTest, CheckWithoutInternalDisplay) {
56 ScopedVector<ui::DisplaySnapshot> displays; 56 ScopedVector<display::DisplaySnapshot> displays;
57 displays.push_back(CreateVGASnapshot()); 57 displays.push_back(CreateVGASnapshot());
58 observer_.OnDisplayModeChanged(displays.get()); 58 observer_.OnDisplayModeChanged(displays.get());
59 59
60 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls()); 60 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls());
61 EXPECT_FALSE(fake_power_client_.is_projecting()); 61 EXPECT_FALSE(fake_power_client_.is_projecting());
62 } 62 }
63 63
64 TEST_F(ProjectingObserverTest, CheckWithInternalDisplay) { 64 TEST_F(ProjectingObserverTest, CheckWithInternalDisplay) {
65 ScopedVector<ui::DisplaySnapshot> displays; 65 ScopedVector<display::DisplaySnapshot> displays;
66 displays.push_back(CreateInternalSnapshot()); 66 displays.push_back(CreateInternalSnapshot());
67 observer_.OnDisplayModeChanged(displays.get()); 67 observer_.OnDisplayModeChanged(displays.get());
68 68
69 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls()); 69 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls());
70 EXPECT_FALSE(fake_power_client_.is_projecting()); 70 EXPECT_FALSE(fake_power_client_.is_projecting());
71 } 71 }
72 72
73 TEST_F(ProjectingObserverTest, CheckWithTwoVGADisplays) { 73 TEST_F(ProjectingObserverTest, CheckWithTwoVGADisplays) {
74 ScopedVector<ui::DisplaySnapshot> displays; 74 ScopedVector<display::DisplaySnapshot> displays;
75 displays.push_back(CreateVGASnapshot()); 75 displays.push_back(CreateVGASnapshot());
76 displays.push_back(CreateVGASnapshot()); 76 displays.push_back(CreateVGASnapshot());
77 observer_.OnDisplayModeChanged(displays.get()); 77 observer_.OnDisplayModeChanged(displays.get());
78 78
79 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls()); 79 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls());
80 // We need at least 1 internal display to set projecting to on. 80 // We need at least 1 internal display to set projecting to on.
81 EXPECT_FALSE(fake_power_client_.is_projecting()); 81 EXPECT_FALSE(fake_power_client_.is_projecting());
82 } 82 }
83 83
84 TEST_F(ProjectingObserverTest, CheckWithInternalAndVGADisplays) { 84 TEST_F(ProjectingObserverTest, CheckWithInternalAndVGADisplays) {
85 ScopedVector<ui::DisplaySnapshot> displays; 85 ScopedVector<display::DisplaySnapshot> displays;
86 displays.push_back(CreateInternalSnapshot()); 86 displays.push_back(CreateInternalSnapshot());
87 displays.push_back(CreateVGASnapshot()); 87 displays.push_back(CreateVGASnapshot());
88 observer_.OnDisplayModeChanged(displays.get()); 88 observer_.OnDisplayModeChanged(displays.get());
89 89
90 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls()); 90 EXPECT_EQ(1, fake_power_client_.num_set_is_projecting_calls());
91 EXPECT_TRUE(fake_power_client_.is_projecting()); 91 EXPECT_TRUE(fake_power_client_.is_projecting());
92 } 92 }
93 93
94 TEST_F(ProjectingObserverTest, CheckWithVGADisplayAndOneCastingSession) { 94 TEST_F(ProjectingObserverTest, CheckWithVGADisplayAndOneCastingSession) {
95 ScopedVector<ui::DisplaySnapshot> displays; 95 ScopedVector<display::DisplaySnapshot> displays;
96 displays.push_back(CreateVGASnapshot()); 96 displays.push_back(CreateVGASnapshot());
97 observer_.OnDisplayModeChanged(displays.get()); 97 observer_.OnDisplayModeChanged(displays.get());
98 98
99 observer_.OnCastingSessionStartedOrStopped(true); 99 observer_.OnCastingSessionStartedOrStopped(true);
100 100
101 EXPECT_EQ(2, fake_power_client_.num_set_is_projecting_calls()); 101 EXPECT_EQ(2, fake_power_client_.num_set_is_projecting_calls());
102 // Need at least one internal display to set projecting state to |true|. 102 // Need at least one internal display to set projecting state to |true|.
103 EXPECT_FALSE(fake_power_client_.is_projecting()); 103 EXPECT_FALSE(fake_power_client_.is_projecting());
104 } 104 }
105 105
106 TEST_F(ProjectingObserverTest, CheckWithInternalDisplayAndOneCastingSession) { 106 TEST_F(ProjectingObserverTest, CheckWithInternalDisplayAndOneCastingSession) {
107 ScopedVector<ui::DisplaySnapshot> displays; 107 ScopedVector<display::DisplaySnapshot> displays;
108 displays.push_back(CreateInternalSnapshot()); 108 displays.push_back(CreateInternalSnapshot());
109 observer_.OnDisplayModeChanged(displays.get()); 109 observer_.OnDisplayModeChanged(displays.get());
110 110
111 observer_.OnCastingSessionStartedOrStopped(true); 111 observer_.OnCastingSessionStartedOrStopped(true);
112 112
113 EXPECT_EQ(2, fake_power_client_.num_set_is_projecting_calls()); 113 EXPECT_EQ(2, fake_power_client_.num_set_is_projecting_calls());
114 EXPECT_TRUE(fake_power_client_.is_projecting()); 114 EXPECT_TRUE(fake_power_client_.is_projecting());
115 } 115 }
116 116
117 TEST_F(ProjectingObserverTest, CheckProjectingAfterClosingACastingSession) { 117 TEST_F(ProjectingObserverTest, CheckProjectingAfterClosingACastingSession) {
118 ScopedVector<ui::DisplaySnapshot> displays; 118 ScopedVector<display::DisplaySnapshot> displays;
119 displays.push_back(CreateInternalSnapshot()); 119 displays.push_back(CreateInternalSnapshot());
120 observer_.OnDisplayModeChanged(displays.get()); 120 observer_.OnDisplayModeChanged(displays.get());
121 121
122 observer_.OnCastingSessionStartedOrStopped(true); 122 observer_.OnCastingSessionStartedOrStopped(true);
123 observer_.OnCastingSessionStartedOrStopped(true); 123 observer_.OnCastingSessionStartedOrStopped(true);
124 124
125 EXPECT_EQ(3, fake_power_client_.num_set_is_projecting_calls()); 125 EXPECT_EQ(3, fake_power_client_.num_set_is_projecting_calls());
126 EXPECT_TRUE(fake_power_client_.is_projecting()); 126 EXPECT_TRUE(fake_power_client_.is_projecting());
127 127
128 observer_.OnCastingSessionStartedOrStopped(false); 128 observer_.OnCastingSessionStartedOrStopped(false);
129 129
130 EXPECT_EQ(4, fake_power_client_.num_set_is_projecting_calls()); 130 EXPECT_EQ(4, fake_power_client_.num_set_is_projecting_calls());
131 EXPECT_TRUE(fake_power_client_.is_projecting()); 131 EXPECT_TRUE(fake_power_client_.is_projecting());
132 } 132 }
133 133
134 TEST_F(ProjectingObserverTest, 134 TEST_F(ProjectingObserverTest,
135 CheckStopProjectingAfterClosingAllCastingSessions) { 135 CheckStopProjectingAfterClosingAllCastingSessions) {
136 ScopedVector<ui::DisplaySnapshot> displays; 136 ScopedVector<display::DisplaySnapshot> displays;
137 displays.push_back(CreateInternalSnapshot()); 137 displays.push_back(CreateInternalSnapshot());
138 observer_.OnDisplayModeChanged(displays.get()); 138 observer_.OnDisplayModeChanged(displays.get());
139 139
140 observer_.OnCastingSessionStartedOrStopped(true); 140 observer_.OnCastingSessionStartedOrStopped(true);
141 observer_.OnCastingSessionStartedOrStopped(false); 141 observer_.OnCastingSessionStartedOrStopped(false);
142 142
143 EXPECT_EQ(3, fake_power_client_.num_set_is_projecting_calls()); 143 EXPECT_EQ(3, fake_power_client_.num_set_is_projecting_calls());
144 EXPECT_FALSE(fake_power_client_.is_projecting()); 144 EXPECT_FALSE(fake_power_client_.is_projecting());
145 } 145 }
146 146
147 TEST_F(ProjectingObserverTest, 147 TEST_F(ProjectingObserverTest,
148 CheckStopProjectingAfterDisconnectingSecondOutput) { 148 CheckStopProjectingAfterDisconnectingSecondOutput) {
149 ScopedVector<ui::DisplaySnapshot> displays; 149 ScopedVector<display::DisplaySnapshot> displays;
150 displays.push_back(CreateInternalSnapshot()); 150 displays.push_back(CreateInternalSnapshot());
151 displays.push_back(CreateVGASnapshot()); 151 displays.push_back(CreateVGASnapshot());
152 observer_.OnDisplayModeChanged(displays.get()); 152 observer_.OnDisplayModeChanged(displays.get());
153 153
154 // Remove VGA output. 154 // Remove VGA output.
155 displays.erase(displays.begin() + 1); 155 displays.erase(displays.begin() + 1);
156 observer_.OnDisplayModeChanged(displays.get()); 156 observer_.OnDisplayModeChanged(displays.get());
157 157
158 EXPECT_EQ(2, fake_power_client_.num_set_is_projecting_calls()); 158 EXPECT_EQ(2, fake_power_client_.num_set_is_projecting_calls());
159 EXPECT_FALSE(fake_power_client_.is_projecting()); 159 EXPECT_FALSE(fake_power_client_.is_projecting());
160 } 160 }
161 161
162 } // namespace ash 162 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/projecting_observer_chromeos.cc ('k') | ash/display/shutdown_observer_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698