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

Side by Side Diff: remoting/protocol/jingle_session_unittest.cc

Issue 14314026: remoting: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/message_reader_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/protocol/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const char kHostJid[] = "host1@gmail.com/123"; 42 const char kHostJid[] = "host1@gmail.com/123";
43 const char kClientJid[] = "host2@gmail.com/321"; 43 const char kClientJid[] = "host2@gmail.com/321";
44 44
45 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay 45 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay
46 // between messages (about 1 second for 100 messages). 46 // between messages (about 1 second for 100 messages).
47 const int kMessageSize = 1024; 47 const int kMessageSize = 1024;
48 const int kMessages = 100; 48 const int kMessages = 100;
49 const char kChannelName[] = "test_channel"; 49 const char kChannelName[] = "test_channel";
50 50
51 void QuitCurrentThread() { 51 void QuitCurrentThread() {
52 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 52 base::MessageLoop::current()->PostTask(FROM_HERE,
53 base::MessageLoop::QuitClosure());
53 } 54 }
54 55
55 ACTION(QuitThread) { 56 ACTION(QuitThread) {
56 QuitCurrentThread(); 57 QuitCurrentThread();
57 } 58 }
58 59
59 ACTION_P(QuitThreadOnCounter, counter) { 60 ACTION_P(QuitThreadOnCounter, counter) {
60 --(*counter); 61 --(*counter);
61 EXPECT_GE(*counter, 0); 62 EXPECT_GE(*counter, 0);
62 if (*counter == 0) 63 if (*counter == 0)
(...skipping 18 matching lines...) Expand all
81 class MockStreamChannelCallback { 82 class MockStreamChannelCallback {
82 public: 83 public:
83 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket)); 84 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket));
84 }; 85 };
85 86
86 } // namespace 87 } // namespace
87 88
88 class JingleSessionTest : public testing::Test { 89 class JingleSessionTest : public testing::Test {
89 public: 90 public:
90 JingleSessionTest() { 91 JingleSessionTest() {
91 message_loop_.reset(new MessageLoopForIO()); 92 message_loop_.reset(new base::MessageLoopForIO());
92 } 93 }
93 94
94 // Helper method that handles OnIncomingSession(). 95 // Helper method that handles OnIncomingSession().
95 void SetHostSession(Session* session) { 96 void SetHostSession(Session* session) {
96 DCHECK(session); 97 DCHECK(session);
97 host_session_.reset(session); 98 host_session_.reset(session);
98 host_session_->SetEventHandler(&host_session_event_handler_); 99 host_session_->SetEventHandler(&host_session_event_handler_);
99 100
100 session->set_config(SessionConfig::ForTest()); 101 session->set_config(SessionConfig::ForTest());
101 } 102 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 void ExpectRouteChange(const std::string& channel_name) { 251 void ExpectRouteChange(const std::string& channel_name) {
251 EXPECT_CALL(host_session_event_handler_, 252 EXPECT_CALL(host_session_event_handler_,
252 OnSessionRouteChange(channel_name, _)) 253 OnSessionRouteChange(channel_name, _))
253 .Times(AtLeast(1)); 254 .Times(AtLeast(1));
254 EXPECT_CALL(client_session_event_handler_, 255 EXPECT_CALL(client_session_event_handler_,
255 OnSessionRouteChange(channel_name, _)) 256 OnSessionRouteChange(channel_name, _))
256 .Times(AtLeast(1)); 257 .Times(AtLeast(1));
257 } 258 }
258 259
259 scoped_ptr<MessageLoopForIO> message_loop_; 260 scoped_ptr<base::MessageLoopForIO> message_loop_;
260 261
261 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 262 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
262 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 263 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
263 264
264 scoped_ptr<JingleSessionManager> host_server_; 265 scoped_ptr<JingleSessionManager> host_server_;
265 MockSessionManagerListener host_server_listener_; 266 MockSessionManagerListener host_server_listener_;
266 scoped_ptr<JingleSessionManager> client_server_; 267 scoped_ptr<JingleSessionManager> client_server_;
267 MockSessionManagerListener client_server_listener_; 268 MockSessionManagerListener client_server_listener_;
268 269
269 scoped_ptr<Session> host_session_; 270 scoped_ptr<Session> host_session_;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 .Times(AtMost(1)); 427 .Times(AtMost(1));
427 ExpectRouteChange(kChannelName); 428 ExpectRouteChange(kChannelName);
428 429
429 message_loop_->Run(); 430 message_loop_->Run();
430 431
431 EXPECT_TRUE(!host_socket_.get()); 432 EXPECT_TRUE(!host_socket_.get());
432 } 433 }
433 434
434 } // namespace protocol 435 } // namespace protocol
435 } // namespace remoting 436 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/message_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698