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

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

Issue 1460593005: Make protocol::ConnectionToClient an abstract interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 (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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "remoting/base/auto_thread_task_runner.h" 8 #include "remoting/base/auto_thread_task_runner.h"
9 #include "remoting/host/audio_capturer.h" 9 #include "remoting/host/audio_capturer.h"
10 #include "remoting/host/chromoting_host.h" 10 #include "remoting/host/chromoting_host.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 session_unowned_jid2_ = "user4@doman/rest-of-jid"; 111 session_unowned_jid2_ = "user4@doman/rest-of-jid";
112 112
113 EXPECT_CALL(*session1_, jid()) 113 EXPECT_CALL(*session1_, jid())
114 .WillRepeatedly(ReturnRef(session_jid1_)); 114 .WillRepeatedly(ReturnRef(session_jid1_));
115 EXPECT_CALL(*session2_, jid()) 115 EXPECT_CALL(*session2_, jid())
116 .WillRepeatedly(ReturnRef(session_jid2_)); 116 .WillRepeatedly(ReturnRef(session_jid2_));
117 EXPECT_CALL(*session_unowned1_, jid()) 117 EXPECT_CALL(*session_unowned1_, jid())
118 .WillRepeatedly(ReturnRef(session_unowned_jid1_)); 118 .WillRepeatedly(ReturnRef(session_unowned_jid1_));
119 EXPECT_CALL(*session_unowned2_, jid()) 119 EXPECT_CALL(*session_unowned2_, jid())
120 .WillRepeatedly(ReturnRef(session_unowned_jid2_)); 120 .WillRepeatedly(ReturnRef(session_unowned_jid2_));
121 EXPECT_CALL(*session1_, SetEventHandler(_))
122 .Times(AnyNumber());
123 EXPECT_CALL(*session2_, SetEventHandler(_))
124 .Times(AnyNumber());
125 EXPECT_CALL(*session_unowned1_, SetEventHandler(_)) 121 EXPECT_CALL(*session_unowned1_, SetEventHandler(_))
126 .Times(AnyNumber()) 122 .Times(AnyNumber())
127 .WillRepeatedly(SaveArg<0>(&session_unowned1_event_handler_)); 123 .WillRepeatedly(SaveArg<0>(&session_unowned1_event_handler_));
128 EXPECT_CALL(*session_unowned2_, SetEventHandler(_)) 124 EXPECT_CALL(*session_unowned2_, SetEventHandler(_))
129 .Times(AnyNumber()) 125 .Times(AnyNumber())
130 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_)); 126 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_));
131 EXPECT_CALL(*session1_, config()) 127 EXPECT_CALL(*session1_, config())
132 .WillRepeatedly(ReturnRef(*session_config1_)); 128 .WillRepeatedly(ReturnRef(*session_config1_));
133 EXPECT_CALL(*session2_, config()) 129 EXPECT_CALL(*session2_, config())
134 .WillRepeatedly(ReturnRef(*session_config2_)); 130 .WillRepeatedly(ReturnRef(*session_config2_));
135 131
136 owned_connection1_.reset(new MockConnectionToClient(session1_, 132 owned_connection1_.reset(
137 &host_stub1_)); 133 new MockConnectionToClient(make_scoped_ptr(session1_), &host_stub1_));
138 connection1_ = owned_connection1_.get(); 134 connection1_ = owned_connection1_.get();
139 owned_connection2_.reset(new MockConnectionToClient(session2_, 135 owned_connection2_.reset(
140 &host_stub2_)); 136 new MockConnectionToClient(make_scoped_ptr(session2_), &host_stub2_));
141 connection2_ = owned_connection2_.get(); 137 connection2_ = owned_connection2_.get();
142 138
143 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _)) 139 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _))
144 .WillByDefault(DeleteArg<0>()); 140 .WillByDefault(DeleteArg<0>());
145 ON_CALL(video_stub2_, ProcessVideoPacketPtr(_, _)) 141 ON_CALL(video_stub2_, ProcessVideoPacketPtr(_, _))
146 .WillByDefault(DeleteArg<0>()); 142 .WillByDefault(DeleteArg<0>());
147 ON_CALL(*connection1_, video_stub()) 143 ON_CALL(*connection1_, video_stub())
148 .WillByDefault(Return(&video_stub1_)); 144 .WillByDefault(Return(&video_stub1_));
149 ON_CALL(*connection1_, client_stub()) 145 ON_CALL(*connection1_, client_stub())
150 .WillByDefault(Return(&client_stub1_)); 146 .WillByDefault(Return(&client_stub1_));
151 ON_CALL(*connection1_, session())
152 .WillByDefault(Return(session1_));
153 ON_CALL(*connection2_, video_stub()) 147 ON_CALL(*connection2_, video_stub())
154 .WillByDefault(Return(&video_stub2_)); 148 .WillByDefault(Return(&video_stub2_));
155 ON_CALL(*connection2_, client_stub()) 149 ON_CALL(*connection2_, client_stub())
156 .WillByDefault(Return(&client_stub2_)); 150 .WillByDefault(Return(&client_stub2_));
157 ON_CALL(*connection2_, session())
158 .WillByDefault(Return(session2_));
159 EXPECT_CALL(*connection1_, video_stub()) 151 EXPECT_CALL(*connection1_, video_stub())
160 .Times(AnyNumber()); 152 .Times(AnyNumber());
161 EXPECT_CALL(*connection1_, client_stub()) 153 EXPECT_CALL(*connection1_, client_stub())
162 .Times(AnyNumber()); 154 .Times(AnyNumber());
163 EXPECT_CALL(*connection1_, session())
164 .Times(AnyNumber());
165 EXPECT_CALL(*connection2_, video_stub()) 155 EXPECT_CALL(*connection2_, video_stub())
166 .Times(AnyNumber()); 156 .Times(AnyNumber());
167 EXPECT_CALL(*connection2_, client_stub()) 157 EXPECT_CALL(*connection2_, client_stub())
168 .Times(AnyNumber()); 158 .Times(AnyNumber());
169 EXPECT_CALL(*connection2_, session())
170 .Times(AnyNumber());
171 } 159 }
172 160
173 // Helper method to pretend a client is connected to ChromotingHost. 161 // Helper method to pretend a client is connected to ChromotingHost.
174 void SimulateClientConnection(int connection_index, bool authenticate, 162 void SimulateClientConnection(int connection_index, bool authenticate,
175 bool reject) { 163 bool reject) {
176 scoped_ptr<protocol::ConnectionToClient> connection = 164 scoped_ptr<protocol::ConnectionToClient> connection =
177 ((connection_index == 0) ? owned_connection1_ : owned_connection2_) 165 ((connection_index == 0) ? owned_connection1_ : owned_connection2_)
178 .Pass(); 166 .Pass();
179 protocol::ConnectionToClient* connection_ptr = connection.get(); 167 protocol::ConnectionToClient* connection_ptr = connection.get();
180 scoped_ptr<ClientSession> client(new ClientSession( 168 scoped_ptr<ClientSession> client(new ClientSession(
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 ExpectClientDisconnected(0, true, video_packet_sent, 658 ExpectClientDisconnected(0, true, video_packet_sent,
671 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 659 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
672 EXPECT_CALL(host_status_observer_, OnShutdown()); 660 EXPECT_CALL(host_status_observer_, OnShutdown());
673 661
674 host_->Start(xmpp_login_); 662 host_->Start(xmpp_login_);
675 SimulateClientConnection(0, true, false); 663 SimulateClientConnection(0, true, false);
676 message_loop_.Run(); 664 message_loop_.Run();
677 } 665 }
678 666
679 } // namespace remoting 667 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698