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

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

Issue 192483007: Move chromeos/display/* to ui/display/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include display.gyp into ChromeOS builds only Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/projecting_observer_chromeos.cc ('k') | ash/shell.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 "chromeos/dbus/fake_dbus_thread_manager.h" 7 #include "chromeos/dbus/fake_dbus_thread_manager.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 10
11 namespace ash { 11 namespace ash {
12 12
13 namespace internal { 13 namespace internal {
14 14
15 namespace { 15 namespace {
16 16
17 chromeos::OutputConfigurator::OutputSnapshot CreateInternalSnapshot() { 17 ui::OutputConfigurator::OutputSnapshot CreateInternalSnapshot() {
18 chromeos::OutputConfigurator::OutputSnapshot output; 18 ui::OutputConfigurator::OutputSnapshot output;
19 output.type = ui::OUTPUT_TYPE_INTERNAL; 19 output.type = ui::OUTPUT_TYPE_INTERNAL;
20 return output; 20 return output;
21 } 21 }
22 22
23 chromeos::OutputConfigurator::OutputSnapshot CreateVGASnapshot() { 23 ui::OutputConfigurator::OutputSnapshot CreateVGASnapshot() {
24 chromeos::OutputConfigurator::OutputSnapshot output; 24 ui::OutputConfigurator::OutputSnapshot output;
25 output.type = ui::OUTPUT_TYPE_VGA; 25 output.type = ui::OUTPUT_TYPE_VGA;
26 return output; 26 return output;
27 } 27 }
28 28
29 class ProjectingObserverTest : public testing::Test { 29 class ProjectingObserverTest : public testing::Test {
30 public: 30 public:
31 ProjectingObserverTest() : observer_(new ProjectingObserver()) { 31 ProjectingObserverTest() : observer_(new ProjectingObserver()) {
32 chromeos::FakeDBusThreadManager* dbus_manager = 32 chromeos::FakeDBusThreadManager* dbus_manager =
33 new chromeos::FakeDBusThreadManager(); 33 new chromeos::FakeDBusThreadManager();
34 fake_power_client_ = new chromeos::FakePowerManagerClient(); 34 fake_power_client_ = new chromeos::FakePowerManagerClient();
(...skipping 12 matching lines...) Expand all
47 protected: 47 protected:
48 scoped_ptr<ProjectingObserver> observer_; 48 scoped_ptr<ProjectingObserver> observer_;
49 chromeos::FakePowerManagerClient* fake_power_client_; // Not owned. 49 chromeos::FakePowerManagerClient* fake_power_client_; // Not owned.
50 50
51 DISALLOW_COPY_AND_ASSIGN(ProjectingObserverTest); 51 DISALLOW_COPY_AND_ASSIGN(ProjectingObserverTest);
52 }; 52 };
53 53
54 } // namespace 54 } // namespace
55 55
56 TEST_F(ProjectingObserverTest, CheckNoDisplay) { 56 TEST_F(ProjectingObserverTest, CheckNoDisplay) {
57 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 57 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
58 observer_->OnDisplayModeChanged(outputs); 58 observer_->OnDisplayModeChanged(outputs);
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, CheckWithoutInternalDisplay) { 64 TEST_F(ProjectingObserverTest, CheckWithoutInternalDisplay) {
65 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 65 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
66 outputs.push_back(CreateVGASnapshot()); 66 outputs.push_back(CreateVGASnapshot());
67 observer_->OnDisplayModeChanged(outputs); 67 observer_->OnDisplayModeChanged(outputs);
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, CheckWithInternalDisplay) { 73 TEST_F(ProjectingObserverTest, CheckWithInternalDisplay) {
74 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 74 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
75 outputs.push_back(CreateInternalSnapshot()); 75 outputs.push_back(CreateInternalSnapshot());
76 observer_->OnDisplayModeChanged(outputs); 76 observer_->OnDisplayModeChanged(outputs);
77 77
78 EXPECT_EQ(1, fake_power_client_->num_set_is_projecting_calls()); 78 EXPECT_EQ(1, fake_power_client_->num_set_is_projecting_calls());
79 EXPECT_FALSE(fake_power_client_->is_projecting()); 79 EXPECT_FALSE(fake_power_client_->is_projecting());
80 } 80 }
81 81
82 TEST_F(ProjectingObserverTest, CheckWithTwoVGADisplays) { 82 TEST_F(ProjectingObserverTest, CheckWithTwoVGADisplays) {
83 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 83 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
84 outputs.push_back(CreateVGASnapshot()); 84 outputs.push_back(CreateVGASnapshot());
85 outputs.push_back(CreateVGASnapshot()); 85 outputs.push_back(CreateVGASnapshot());
86 observer_->OnDisplayModeChanged(outputs); 86 observer_->OnDisplayModeChanged(outputs);
87 87
88 EXPECT_EQ(1, fake_power_client_->num_set_is_projecting_calls()); 88 EXPECT_EQ(1, fake_power_client_->num_set_is_projecting_calls());
89 // We need at least 1 internal display to set projecting to on. 89 // We need at least 1 internal display to set projecting to on.
90 EXPECT_FALSE(fake_power_client_->is_projecting()); 90 EXPECT_FALSE(fake_power_client_->is_projecting());
91 } 91 }
92 92
93 TEST_F(ProjectingObserverTest, CheckWithInternalAndVGADisplays) { 93 TEST_F(ProjectingObserverTest, CheckWithInternalAndVGADisplays) {
94 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 94 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
95 outputs.push_back(CreateInternalSnapshot()); 95 outputs.push_back(CreateInternalSnapshot());
96 outputs.push_back(CreateVGASnapshot()); 96 outputs.push_back(CreateVGASnapshot());
97 observer_->OnDisplayModeChanged(outputs); 97 observer_->OnDisplayModeChanged(outputs);
98 98
99 EXPECT_EQ(1, fake_power_client_->num_set_is_projecting_calls()); 99 EXPECT_EQ(1, fake_power_client_->num_set_is_projecting_calls());
100 EXPECT_TRUE(fake_power_client_->is_projecting()); 100 EXPECT_TRUE(fake_power_client_->is_projecting());
101 } 101 }
102 102
103 TEST_F(ProjectingObserverTest, CheckWithVGADisplayAndOneCastingSession) { 103 TEST_F(ProjectingObserverTest, CheckWithVGADisplayAndOneCastingSession) {
104 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 104 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
105 outputs.push_back(CreateVGASnapshot()); 105 outputs.push_back(CreateVGASnapshot());
106 observer_->OnDisplayModeChanged(outputs); 106 observer_->OnDisplayModeChanged(outputs);
107 107
108 observer_->OnCastingSessionStartedOrStopped(true); 108 observer_->OnCastingSessionStartedOrStopped(true);
109 109
110 EXPECT_EQ(2, fake_power_client_->num_set_is_projecting_calls()); 110 EXPECT_EQ(2, fake_power_client_->num_set_is_projecting_calls());
111 // Need at least one internal display to set projecting state to |true|. 111 // Need at least one internal display to set projecting state to |true|.
112 EXPECT_FALSE(fake_power_client_->is_projecting()); 112 EXPECT_FALSE(fake_power_client_->is_projecting());
113 } 113 }
114 114
115 TEST_F(ProjectingObserverTest, CheckWithInternalDisplayAndOneCastingSession) { 115 TEST_F(ProjectingObserverTest, CheckWithInternalDisplayAndOneCastingSession) {
116 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 116 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
117 outputs.push_back(CreateInternalSnapshot()); 117 outputs.push_back(CreateInternalSnapshot());
118 observer_->OnDisplayModeChanged(outputs); 118 observer_->OnDisplayModeChanged(outputs);
119 119
120 observer_->OnCastingSessionStartedOrStopped(true); 120 observer_->OnCastingSessionStartedOrStopped(true);
121 121
122 EXPECT_EQ(2, fake_power_client_->num_set_is_projecting_calls()); 122 EXPECT_EQ(2, fake_power_client_->num_set_is_projecting_calls());
123 EXPECT_TRUE(fake_power_client_->is_projecting()); 123 EXPECT_TRUE(fake_power_client_->is_projecting());
124 } 124 }
125 125
126 TEST_F(ProjectingObserverTest, CheckProjectingAfterClosingACastingSession) { 126 TEST_F(ProjectingObserverTest, CheckProjectingAfterClosingACastingSession) {
127 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 127 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
128 outputs.push_back(CreateInternalSnapshot()); 128 outputs.push_back(CreateInternalSnapshot());
129 observer_->OnDisplayModeChanged(outputs); 129 observer_->OnDisplayModeChanged(outputs);
130 130
131 observer_->OnCastingSessionStartedOrStopped(true); 131 observer_->OnCastingSessionStartedOrStopped(true);
132 observer_->OnCastingSessionStartedOrStopped(true); 132 observer_->OnCastingSessionStartedOrStopped(true);
133 133
134 EXPECT_EQ(3, fake_power_client_->num_set_is_projecting_calls()); 134 EXPECT_EQ(3, fake_power_client_->num_set_is_projecting_calls());
135 EXPECT_TRUE(fake_power_client_->is_projecting()); 135 EXPECT_TRUE(fake_power_client_->is_projecting());
136 136
137 observer_->OnCastingSessionStartedOrStopped(false); 137 observer_->OnCastingSessionStartedOrStopped(false);
138 138
139 EXPECT_EQ(4, fake_power_client_->num_set_is_projecting_calls()); 139 EXPECT_EQ(4, fake_power_client_->num_set_is_projecting_calls());
140 EXPECT_TRUE(fake_power_client_->is_projecting()); 140 EXPECT_TRUE(fake_power_client_->is_projecting());
141 } 141 }
142 142
143 TEST_F(ProjectingObserverTest, 143 TEST_F(ProjectingObserverTest,
144 CheckStopProjectingAfterClosingAllCastingSessions) { 144 CheckStopProjectingAfterClosingAllCastingSessions) {
145 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 145 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
146 outputs.push_back(CreateInternalSnapshot()); 146 outputs.push_back(CreateInternalSnapshot());
147 observer_->OnDisplayModeChanged(outputs); 147 observer_->OnDisplayModeChanged(outputs);
148 148
149 observer_->OnCastingSessionStartedOrStopped(true); 149 observer_->OnCastingSessionStartedOrStopped(true);
150 observer_->OnCastingSessionStartedOrStopped(false); 150 observer_->OnCastingSessionStartedOrStopped(false);
151 151
152 EXPECT_EQ(3, fake_power_client_->num_set_is_projecting_calls()); 152 EXPECT_EQ(3, fake_power_client_->num_set_is_projecting_calls());
153 EXPECT_FALSE(fake_power_client_->is_projecting()); 153 EXPECT_FALSE(fake_power_client_->is_projecting());
154 } 154 }
155 155
156 TEST_F(ProjectingObserverTest, 156 TEST_F(ProjectingObserverTest,
157 CheckStopProjectingAfterDisconnectingSecondOutput) { 157 CheckStopProjectingAfterDisconnectingSecondOutput) {
158 std::vector<chromeos::OutputConfigurator::OutputSnapshot> outputs; 158 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs;
159 outputs.push_back(CreateInternalSnapshot()); 159 outputs.push_back(CreateInternalSnapshot());
160 outputs.push_back(CreateVGASnapshot()); 160 outputs.push_back(CreateVGASnapshot());
161 observer_->OnDisplayModeChanged(outputs); 161 observer_->OnDisplayModeChanged(outputs);
162 162
163 // Remove VGA output. 163 // Remove VGA output.
164 outputs.erase(outputs.begin() + 1); 164 outputs.erase(outputs.begin() + 1);
165 observer_->OnDisplayModeChanged(outputs); 165 observer_->OnDisplayModeChanged(outputs);
166 166
167 EXPECT_EQ(2, fake_power_client_->num_set_is_projecting_calls()); 167 EXPECT_EQ(2, fake_power_client_->num_set_is_projecting_calls());
168 EXPECT_FALSE(fake_power_client_->is_projecting()); 168 EXPECT_FALSE(fake_power_client_->is_projecting());
169 } 169 }
170 170
171 } // namespace internal 171 } // namespace internal
172 172
173 } // namespace ash 173 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/projecting_observer_chromeos.cc ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698