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

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

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_session_manager.cc ('k') | remoting/protocol/pepper_session.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop_proxy.h" 6 #include "base/message_loop_proxy.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "net/socket/socket.h" 8 #include "net/socket/socket.h"
9 #include "net/socket/stream_socket.h" 9 #include "net/socket/stream_socket.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 ACTION_P(QuitThreadOnCounter, counter) { 58 ACTION_P(QuitThreadOnCounter, counter) {
59 (*counter)--; 59 (*counter)--;
60 EXPECT_GE(*counter, 0); 60 EXPECT_GE(*counter, 0);
61 if (*counter == 0) 61 if (*counter == 0)
62 QuitCurrentThread(); 62 QuitCurrentThread();
63 } 63 }
64 64
65 class MockSessionManagerListener : public SessionManager::Listener { 65 class MockSessionManagerListener : public SessionManager::Listener {
66 public: 66 public:
67 MOCK_METHOD0(OnSessionManagerInitialized, void()); 67 MOCK_METHOD0(OnSessionManagerReady, void());
68 MOCK_METHOD2(OnIncomingSession, 68 MOCK_METHOD2(OnIncomingSession,
69 void(Session*, 69 void(Session*,
70 SessionManager::IncomingSessionResponse*)); 70 SessionManager::IncomingSessionResponse*));
71 }; 71 };
72 72
73 class MockSessionCallback { 73 class MockSessionCallback {
74 public: 74 public:
75 MOCK_METHOD1(OnStateChange, void(Session::State)); 75 MOCK_METHOD1(OnStateChange, void(Session::State));
76 }; 76 };
77 77
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 client_session_.reset(); 120 client_session_.reset();
121 } 121 }
122 122
123 void CreateSessionManagers(int auth_round_trips, 123 void CreateSessionManagers(int auth_round_trips,
124 FakeAuthenticator::Action auth_action) { 124 FakeAuthenticator::Action auth_action) {
125 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); 125 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid));
126 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); 126 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid));
127 FakeSignalStrategy::Connect(host_signal_strategy_.get(), 127 FakeSignalStrategy::Connect(host_signal_strategy_.get(),
128 client_signal_strategy_.get()); 128 client_signal_strategy_.get());
129 129
130 EXPECT_CALL(host_server_listener_, OnSessionManagerInitialized()) 130 EXPECT_CALL(host_server_listener_, OnSessionManagerReady())
131 .Times(1); 131 .Times(1);
132 host_server_.reset(new JingleSessionManager( 132 host_server_.reset(new JingleSessionManager(
133 base::MessageLoopProxy::current())); 133 base::MessageLoopProxy::current()));
134 host_server_->Init( 134 host_server_->Init(
135 kHostJid, host_signal_strategy_.get(), &host_server_listener_, false); 135 host_signal_strategy_.get(), &host_server_listener_, false);
136 136
137 host_server_->set_authenticator_factory( 137 host_server_->set_authenticator_factory(
138 new FakeHostAuthenticatorFactory(auth_round_trips, auth_action, true)); 138 new FakeHostAuthenticatorFactory(auth_round_trips, auth_action, true));
139 139
140 EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized()) 140 EXPECT_CALL(client_server_listener_, OnSessionManagerReady())
141 .Times(1); 141 .Times(1);
142 client_server_.reset(new JingleSessionManager( 142 client_server_.reset(new JingleSessionManager(
143 base::MessageLoopProxy::current())); 143 base::MessageLoopProxy::current()));
144 client_server_->Init( 144 client_server_->Init(
145 kClientJid, client_signal_strategy_.get(), 145 client_signal_strategy_.get(), &client_server_listener_, false);
146 &client_server_listener_, false);
147 } 146 }
148 147
149 void CloseSessionManager() { 148 void CloseSessionManager() {
150 if (host_server_.get()) { 149 if (host_server_.get()) {
151 host_server_->Close(); 150 host_server_->Close();
152 host_server_.reset(); 151 host_server_.reset();
153 } 152 }
154 if (client_server_.get()) { 153 if (client_server_.get()) {
155 client_server_->Close(); 154 client_server_->Close();
156 client_server_.reset(); 155 client_server_.reset();
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 436
438 DatagramConnectionTester tester( 437 DatagramConnectionTester tester(
439 client_socket, host_socket, kMessageSize, kMessages, kUdpWriteDelayMs); 438 client_socket, host_socket, kMessageSize, kMessages, kUdpWriteDelayMs);
440 tester.Start(); 439 tester.Start();
441 message_loop_.Run(); 440 message_loop_.Run();
442 tester.CheckResults(); 441 tester.CheckResults();
443 } 442 }
444 443
445 } // namespace protocol 444 } // namespace protocol
446 } // namespace remoting 445 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session_manager.cc ('k') | remoting/protocol/pepper_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698