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

Side by Side Diff: remoting/host/host_status_logger_unittest.cc

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: h264_vt_encoder_unittest.cc Created 4 years, 5 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
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 "remoting/host/host_status_logger.h" 5 #include "remoting/host/host_status_logger.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "remoting/host/fake_host_status_monitor.h" 9 #include "remoting/host/fake_host_status_monitor.h"
10 #include "remoting/signaling/mock_signal_strategy.h" 10 #include "remoting/signaling/mock_signal_strategy.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gmock_mutant.h" 12 #include "testing/gmock_mutant.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
15 15
16 using buzz::XmlElement; 16 using buzz::XmlElement;
17 using buzz::QName; 17 using buzz::QName;
18 using testing::_; 18 using testing::_;
19 using testing::DeleteArg; 19 using testing::DeleteArg;
20 using testing::InSequence; 20 using testing::InSequence;
21 using testing::Return; 21 using testing::Return;
22 22
23 namespace remoting { 23 namespace remoting {
24 24
25 namespace { 25 namespace {
26 26
27 ACTION_P(QuitMainMessageLoop, message_loop) { 27 ACTION_P(QuitRunLoop, run_loop) {
28 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 28 run_loop->QuitWhenIdle();
29 } 29 }
30 30
31 const char kJabberClientNamespace[] = "jabber:client"; 31 const char kJabberClientNamespace[] = "jabber:client";
32 const char kChromotingNamespace[] = "google:remoting"; 32 const char kChromotingNamespace[] = "google:remoting";
33 const char kTestBotJid[] = "remotingunittest@bot.talk.google.com"; 33 const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
34 const char kClientJid1[] = "client@domain.com/1234"; 34 const char kClientJid1[] = "client@domain.com/1234";
35 const char kClientJid2[] = "client@domain.com/5678"; 35 const char kClientJid2[] = "client@domain.com/5678";
36 const char kHostJid[] = "host@domain.com/1234"; 36 const char kHostJid[] = "host@domain.com/1234";
37 37
38 bool IsLogEntryForConnection(XmlElement* node, const char* connection_type) { 38 bool IsLogEntryForConnection(XmlElement* node, const char* connection_type) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 protected: 138 protected:
139 base::MessageLoop message_loop_; 139 base::MessageLoop message_loop_;
140 MockSignalStrategy signal_strategy_; 140 MockSignalStrategy signal_strategy_;
141 std::unique_ptr<HostStatusLogger> host_status_logger_; 141 std::unique_ptr<HostStatusLogger> host_status_logger_;
142 FakeHostStatusMonitor host_status_monitor_; 142 FakeHostStatusMonitor host_status_monitor_;
143 }; 143 };
144 144
145 TEST_F(HostStatusLoggerTest, SendNow) { 145 TEST_F(HostStatusLoggerTest, SendNow) {
146 base::RunLoop run_loop;
146 { 147 {
147 InSequence s; 148 InSequence s;
148 EXPECT_CALL(signal_strategy_, GetLocalJid()) 149 EXPECT_CALL(signal_strategy_, GetLocalJid())
149 .WillRepeatedly(Return(kHostJid)); 150 .WillRepeatedly(Return(kHostJid));
150 EXPECT_CALL(signal_strategy_, AddListener(_)); 151 EXPECT_CALL(signal_strategy_, AddListener(_));
151 EXPECT_CALL(signal_strategy_, GetNextId()); 152 EXPECT_CALL(signal_strategy_, GetNextId());
152 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) 153 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct")))
153 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 154 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
154 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 155 EXPECT_CALL(signal_strategy_, RemoveListener(_))
155 .WillOnce(QuitMainMessageLoop(&message_loop_)) 156 .WillOnce(QuitRunLoop(&run_loop))
156 .RetiresOnSaturation(); 157 .RetiresOnSaturation();
157 } 158 }
158 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 159 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
159 protocol::TransportRoute route; 160 protocol::TransportRoute route;
160 route.type = protocol::TransportRoute::DIRECT; 161 route.type = protocol::TransportRoute::DIRECT;
161 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route); 162 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route);
162 host_status_logger_->OnClientAuthenticated(kClientJid1); 163 host_status_logger_->OnClientAuthenticated(kClientJid1);
163 host_status_logger_->OnClientConnected(kClientJid1); 164 host_status_logger_->OnClientConnected(kClientJid1);
164 host_status_logger_->SetSignalingStateForTest( 165 host_status_logger_->SetSignalingStateForTest(
165 SignalStrategy::DISCONNECTED); 166 SignalStrategy::DISCONNECTED);
166 base::RunLoop().Run(); 167 run_loop.Run();
167 } 168 }
168 169
169 TEST_F(HostStatusLoggerTest, SendLater) { 170 TEST_F(HostStatusLoggerTest, SendLater) {
171 base::RunLoop run_loop;
170 protocol::TransportRoute route; 172 protocol::TransportRoute route;
171 route.type = protocol::TransportRoute::DIRECT; 173 route.type = protocol::TransportRoute::DIRECT;
172 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route); 174 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route);
173 host_status_logger_->OnClientAuthenticated(kClientJid1); 175 host_status_logger_->OnClientAuthenticated(kClientJid1);
174 host_status_logger_->OnClientConnected(kClientJid1); 176 host_status_logger_->OnClientConnected(kClientJid1);
175 { 177 {
176 InSequence s; 178 InSequence s;
177 EXPECT_CALL(signal_strategy_, GetLocalJid()) 179 EXPECT_CALL(signal_strategy_, GetLocalJid())
178 .WillRepeatedly(Return(kHostJid)); 180 .WillRepeatedly(Return(kHostJid));
179 EXPECT_CALL(signal_strategy_, AddListener(_)); 181 EXPECT_CALL(signal_strategy_, AddListener(_));
180 EXPECT_CALL(signal_strategy_, GetNextId()); 182 EXPECT_CALL(signal_strategy_, GetNextId());
181 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) 183 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct")))
182 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 184 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
183 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 185 EXPECT_CALL(signal_strategy_, RemoveListener(_))
184 .WillOnce(QuitMainMessageLoop(&message_loop_)) 186 .WillOnce(QuitRunLoop(&run_loop))
185 .RetiresOnSaturation(); 187 .RetiresOnSaturation();
186 } 188 }
187 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 189 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
188 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 190 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
189 base::RunLoop().Run(); 191 run_loop.Run();
190 } 192 }
191 193
192 TEST_F(HostStatusLoggerTest, SendTwoEntriesLater) { 194 TEST_F(HostStatusLoggerTest, SendTwoEntriesLater) {
195 base::RunLoop run_loop;
193 protocol::TransportRoute route1; 196 protocol::TransportRoute route1;
194 route1.type = protocol::TransportRoute::DIRECT; 197 route1.type = protocol::TransportRoute::DIRECT;
195 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1); 198 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1);
196 host_status_logger_->OnClientAuthenticated(kClientJid1); 199 host_status_logger_->OnClientAuthenticated(kClientJid1);
197 host_status_logger_->OnClientConnected(kClientJid1); 200 host_status_logger_->OnClientConnected(kClientJid1);
198 protocol::TransportRoute route2; 201 protocol::TransportRoute route2;
199 route2.type = protocol::TransportRoute::STUN; 202 route2.type = protocol::TransportRoute::STUN;
200 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2); 203 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2);
201 host_status_logger_->OnClientAuthenticated(kClientJid2); 204 host_status_logger_->OnClientAuthenticated(kClientJid2);
202 host_status_logger_->OnClientConnected(kClientJid2); 205 host_status_logger_->OnClientConnected(kClientJid2);
203 { 206 {
204 InSequence s; 207 InSequence s;
205 EXPECT_CALL(signal_strategy_, GetLocalJid()) 208 EXPECT_CALL(signal_strategy_, GetLocalJid())
206 .WillRepeatedly(Return(kHostJid)); 209 .WillRepeatedly(Return(kHostJid));
207 EXPECT_CALL(signal_strategy_, AddListener(_)); 210 EXPECT_CALL(signal_strategy_, AddListener(_));
208 EXPECT_CALL(signal_strategy_, GetNextId()); 211 EXPECT_CALL(signal_strategy_, GetNextId());
209 EXPECT_CALL(signal_strategy_, 212 EXPECT_CALL(signal_strategy_,
210 SendStanzaPtr(IsTwoClientsConnected("direct", "stun"))) 213 SendStanzaPtr(IsTwoClientsConnected("direct", "stun")))
211 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 214 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
212 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 215 EXPECT_CALL(signal_strategy_, RemoveListener(_))
213 .WillOnce(QuitMainMessageLoop(&message_loop_)) 216 .WillOnce(QuitRunLoop(&run_loop))
214 .RetiresOnSaturation(); 217 .RetiresOnSaturation();
215 } 218 }
216 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 219 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
217 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 220 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
218 base::RunLoop().Run(); 221 run_loop.Run();
219 } 222 }
220 223
221 TEST_F(HostStatusLoggerTest, HandleRouteChangeInUnusualOrder) { 224 TEST_F(HostStatusLoggerTest, HandleRouteChangeInUnusualOrder) {
225 base::RunLoop run_loop;
222 { 226 {
223 InSequence s; 227 InSequence s;
224 EXPECT_CALL(signal_strategy_, GetLocalJid()) 228 EXPECT_CALL(signal_strategy_, GetLocalJid())
225 .WillRepeatedly(Return(kHostJid)); 229 .WillRepeatedly(Return(kHostJid));
226 EXPECT_CALL(signal_strategy_, AddListener(_)); 230 EXPECT_CALL(signal_strategy_, AddListener(_));
227 EXPECT_CALL(signal_strategy_, GetNextId()); 231 EXPECT_CALL(signal_strategy_, GetNextId());
228 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) 232 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct")))
229 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 233 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
230 EXPECT_CALL(signal_strategy_, GetNextId()); 234 EXPECT_CALL(signal_strategy_, GetNextId());
231 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientDisconnected())) 235 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientDisconnected()))
232 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 236 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
233 EXPECT_CALL(signal_strategy_, GetNextId()); 237 EXPECT_CALL(signal_strategy_, GetNextId());
234 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("stun"))) 238 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("stun")))
235 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 239 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
236 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 240 EXPECT_CALL(signal_strategy_, RemoveListener(_))
237 .WillOnce(QuitMainMessageLoop(&message_loop_)) 241 .WillOnce(QuitRunLoop(&run_loop))
238 .RetiresOnSaturation(); 242 .RetiresOnSaturation();
239 } 243 }
240 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 244 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
241 protocol::TransportRoute route1; 245 protocol::TransportRoute route1;
242 route1.type = protocol::TransportRoute::DIRECT; 246 route1.type = protocol::TransportRoute::DIRECT;
243 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1); 247 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1);
244 host_status_logger_->OnClientAuthenticated(kClientJid1); 248 host_status_logger_->OnClientAuthenticated(kClientJid1);
245 host_status_logger_->OnClientConnected(kClientJid1); 249 host_status_logger_->OnClientConnected(kClientJid1);
246 protocol::TransportRoute route2; 250 protocol::TransportRoute route2;
247 route2.type = protocol::TransportRoute::STUN; 251 route2.type = protocol::TransportRoute::STUN;
248 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2); 252 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2);
249 host_status_logger_->OnClientDisconnected(kClientJid1); 253 host_status_logger_->OnClientDisconnected(kClientJid1);
250 host_status_logger_->OnClientAuthenticated(kClientJid2); 254 host_status_logger_->OnClientAuthenticated(kClientJid2);
251 host_status_logger_->OnClientConnected(kClientJid2); 255 host_status_logger_->OnClientConnected(kClientJid2);
252 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 256 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
253 base::RunLoop().Run(); 257 run_loop.Run();
254 } 258 }
255 259
256 } // namespace remoting 260 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/client_status_logger_unittest.cc ('k') | services/shell/background/background_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698