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

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

Issue 2082363002: Remove calls to deprecated MessageLoop methods in remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing include Created 4 years, 6 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 "remoting/host/fake_host_status_monitor.h" 9 #include "remoting/host/fake_host_status_monitor.h"
9 #include "remoting/signaling/mock_signal_strategy.h" 10 #include "remoting/signaling/mock_signal_strategy.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gmock_mutant.h" 12 #include "testing/gmock_mutant.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
14 15
15 using buzz::XmlElement; 16 using buzz::XmlElement;
16 using buzz::QName; 17 using buzz::QName;
17 using testing::_; 18 using testing::_;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 .RetiresOnSaturation(); 156 .RetiresOnSaturation();
156 } 157 }
157 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 158 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
158 protocol::TransportRoute route; 159 protocol::TransportRoute route;
159 route.type = protocol::TransportRoute::DIRECT; 160 route.type = protocol::TransportRoute::DIRECT;
160 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route); 161 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route);
161 host_status_logger_->OnClientAuthenticated(kClientJid1); 162 host_status_logger_->OnClientAuthenticated(kClientJid1);
162 host_status_logger_->OnClientConnected(kClientJid1); 163 host_status_logger_->OnClientConnected(kClientJid1);
163 host_status_logger_->SetSignalingStateForTest( 164 host_status_logger_->SetSignalingStateForTest(
164 SignalStrategy::DISCONNECTED); 165 SignalStrategy::DISCONNECTED);
165 message_loop_.Run(); 166 base::RunLoop().Run();
166 } 167 }
167 168
168 TEST_F(HostStatusLoggerTest, SendLater) { 169 TEST_F(HostStatusLoggerTest, SendLater) {
169 protocol::TransportRoute route; 170 protocol::TransportRoute route;
170 route.type = protocol::TransportRoute::DIRECT; 171 route.type = protocol::TransportRoute::DIRECT;
171 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route); 172 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route);
172 host_status_logger_->OnClientAuthenticated(kClientJid1); 173 host_status_logger_->OnClientAuthenticated(kClientJid1);
173 host_status_logger_->OnClientConnected(kClientJid1); 174 host_status_logger_->OnClientConnected(kClientJid1);
174 { 175 {
175 InSequence s; 176 InSequence s;
176 EXPECT_CALL(signal_strategy_, GetLocalJid()) 177 EXPECT_CALL(signal_strategy_, GetLocalJid())
177 .WillRepeatedly(Return(kHostJid)); 178 .WillRepeatedly(Return(kHostJid));
178 EXPECT_CALL(signal_strategy_, AddListener(_)); 179 EXPECT_CALL(signal_strategy_, AddListener(_));
179 EXPECT_CALL(signal_strategy_, GetNextId()); 180 EXPECT_CALL(signal_strategy_, GetNextId());
180 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) 181 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct")))
181 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 182 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
182 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 183 EXPECT_CALL(signal_strategy_, RemoveListener(_))
183 .WillOnce(QuitMainMessageLoop(&message_loop_)) 184 .WillOnce(QuitMainMessageLoop(&message_loop_))
184 .RetiresOnSaturation(); 185 .RetiresOnSaturation();
185 } 186 }
186 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 187 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
187 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 188 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
188 message_loop_.Run(); 189 base::RunLoop().Run();
189 } 190 }
190 191
191 TEST_F(HostStatusLoggerTest, SendTwoEntriesLater) { 192 TEST_F(HostStatusLoggerTest, SendTwoEntriesLater) {
192 protocol::TransportRoute route1; 193 protocol::TransportRoute route1;
193 route1.type = protocol::TransportRoute::DIRECT; 194 route1.type = protocol::TransportRoute::DIRECT;
194 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1); 195 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1);
195 host_status_logger_->OnClientAuthenticated(kClientJid1); 196 host_status_logger_->OnClientAuthenticated(kClientJid1);
196 host_status_logger_->OnClientConnected(kClientJid1); 197 host_status_logger_->OnClientConnected(kClientJid1);
197 protocol::TransportRoute route2; 198 protocol::TransportRoute route2;
198 route2.type = protocol::TransportRoute::STUN; 199 route2.type = protocol::TransportRoute::STUN;
199 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2); 200 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2);
200 host_status_logger_->OnClientAuthenticated(kClientJid2); 201 host_status_logger_->OnClientAuthenticated(kClientJid2);
201 host_status_logger_->OnClientConnected(kClientJid2); 202 host_status_logger_->OnClientConnected(kClientJid2);
202 { 203 {
203 InSequence s; 204 InSequence s;
204 EXPECT_CALL(signal_strategy_, GetLocalJid()) 205 EXPECT_CALL(signal_strategy_, GetLocalJid())
205 .WillRepeatedly(Return(kHostJid)); 206 .WillRepeatedly(Return(kHostJid));
206 EXPECT_CALL(signal_strategy_, AddListener(_)); 207 EXPECT_CALL(signal_strategy_, AddListener(_));
207 EXPECT_CALL(signal_strategy_, GetNextId()); 208 EXPECT_CALL(signal_strategy_, GetNextId());
208 EXPECT_CALL(signal_strategy_, 209 EXPECT_CALL(signal_strategy_,
209 SendStanzaPtr(IsTwoClientsConnected("direct", "stun"))) 210 SendStanzaPtr(IsTwoClientsConnected("direct", "stun")))
210 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 211 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
211 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 212 EXPECT_CALL(signal_strategy_, RemoveListener(_))
212 .WillOnce(QuitMainMessageLoop(&message_loop_)) 213 .WillOnce(QuitMainMessageLoop(&message_loop_))
213 .RetiresOnSaturation(); 214 .RetiresOnSaturation();
214 } 215 }
215 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 216 host_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
216 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 217 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
217 message_loop_.Run(); 218 base::RunLoop().Run();
218 } 219 }
219 220
220 TEST_F(HostStatusLoggerTest, HandleRouteChangeInUnusualOrder) { 221 TEST_F(HostStatusLoggerTest, HandleRouteChangeInUnusualOrder) {
221 { 222 {
222 InSequence s; 223 InSequence s;
223 EXPECT_CALL(signal_strategy_, GetLocalJid()) 224 EXPECT_CALL(signal_strategy_, GetLocalJid())
224 .WillRepeatedly(Return(kHostJid)); 225 .WillRepeatedly(Return(kHostJid));
225 EXPECT_CALL(signal_strategy_, AddListener(_)); 226 EXPECT_CALL(signal_strategy_, AddListener(_));
226 EXPECT_CALL(signal_strategy_, GetNextId()); 227 EXPECT_CALL(signal_strategy_, GetNextId());
227 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) 228 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct")))
(...skipping 14 matching lines...) Expand all
242 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1); 243 host_status_logger_->OnClientRouteChange(kClientJid1, "video", route1);
243 host_status_logger_->OnClientAuthenticated(kClientJid1); 244 host_status_logger_->OnClientAuthenticated(kClientJid1);
244 host_status_logger_->OnClientConnected(kClientJid1); 245 host_status_logger_->OnClientConnected(kClientJid1);
245 protocol::TransportRoute route2; 246 protocol::TransportRoute route2;
246 route2.type = protocol::TransportRoute::STUN; 247 route2.type = protocol::TransportRoute::STUN;
247 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2); 248 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2);
248 host_status_logger_->OnClientDisconnected(kClientJid1); 249 host_status_logger_->OnClientDisconnected(kClientJid1);
249 host_status_logger_->OnClientAuthenticated(kClientJid2); 250 host_status_logger_->OnClientAuthenticated(kClientJid2);
250 host_status_logger_->OnClientConnected(kClientJid2); 251 host_status_logger_->OnClientConnected(kClientJid2);
251 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 252 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
252 message_loop_.Run(); 253 base::RunLoop().Run();
253 } 254 }
254 255
255 } // namespace remoting 256 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_change_notification_listener_unittest.cc ('k') | remoting/host/resizing_host_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698