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

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

Issue 6724033: Remove authenticated_ fields from stubs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak. Created 9 years, 8 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
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/task.h" 6 #include "base/task.h"
6 #include "remoting/host/capturer_fake.h" 7 #include "remoting/host/capturer_fake.h"
7 #include "remoting/host/chromoting_host.h" 8 #include "remoting/host/chromoting_host.h"
8 #include "remoting/host/chromoting_host_context.h" 9 #include "remoting/host/chromoting_host_context.h"
9 #include "remoting/host/host_mock_objects.h" 10 #include "remoting/host/host_mock_objects.h"
10 #include "remoting/host/in_memory_host_config.h" 11 #include "remoting/host/in_memory_host_config.h"
12 #include "remoting/host/user_authenticator_fake.h"
11 #include "remoting/proto/video.pb.h" 13 #include "remoting/proto/video.pb.h"
12 #include "remoting/protocol/protocol_mock_objects.h" 14 #include "remoting/protocol/protocol_mock_objects.h"
13 #include "remoting/protocol/session_config.h" 15 #include "remoting/protocol/session_config.h"
14 #include "testing/gmock_mutant.h" 16 #include "testing/gmock_mutant.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 using ::remoting::protocol::LocalLoginCredentials; 20 using ::remoting::protocol::LocalLoginCredentials;
19 using ::remoting::protocol::MockClientStub; 21 using ::remoting::protocol::MockClientStub;
20 using ::remoting::protocol::MockConnectionToClient; 22 using ::remoting::protocol::MockConnectionToClient;
(...skipping 10 matching lines...) Expand all
31 using testing::DeleteArg; 33 using testing::DeleteArg;
32 using testing::DoAll; 34 using testing::DoAll;
33 using testing::InSequence; 35 using testing::InSequence;
34 using testing::InvokeWithoutArgs; 36 using testing::InvokeWithoutArgs;
35 using testing::Return; 37 using testing::Return;
36 38
37 namespace remoting { 39 namespace remoting {
38 40
39 namespace { 41 namespace {
40 42
43 UserAuthenticator* MakeUserAuthenticator() {
44 return new UserAuthenticatorFake();
45 }
46
41 void PostQuitTask(MessageLoop* message_loop) { 47 void PostQuitTask(MessageLoop* message_loop) {
42 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 48 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
43 } 49 }
44 50
45 // Run the task and delete it afterwards. This action is used to deal with 51 // Run the task and delete it afterwards. This action is used to deal with
46 // done callbacks. 52 // done callbacks.
47 ACTION(RunDoneTask) { 53 ACTION(RunDoneTask) {
48 arg1->Run(); 54 arg1->Run();
49 delete arg1; 55 delete arg1;
50 } 56 }
51 57
52 ACTION_P(QuitMainMessageLoop, message_loop) { 58 ACTION_P(QuitMainMessageLoop, message_loop) {
53 PostQuitTask(message_loop); 59 PostQuitTask(message_loop);
54 } 60 }
55 61
62 void DummyFunction() {}
63
56 } // namespace 64 } // namespace
57 65
58 class ChromotingHostTest : public testing::Test { 66 class ChromotingHostTest : public testing::Test {
59 public: 67 public:
60 ChromotingHostTest() { 68 ChromotingHostTest() {
61 } 69 }
62 70
63 virtual void SetUp() { 71 virtual void SetUp() {
64 config_ = new InMemoryHostConfig(); 72 config_ = new InMemoryHostConfig();
65 ON_CALL(context_, main_message_loop()) 73 ON_CALL(context_, main_message_loop())
(...skipping 10 matching lines...) Expand all
76 .Times(AnyNumber()); 84 .Times(AnyNumber());
77 85
78 Capturer* capturer = new CapturerFake(context_.main_message_loop()); 86 Capturer* capturer = new CapturerFake(context_.main_message_loop());
79 host_stub_ = new MockHostStub(); 87 host_stub_ = new MockHostStub();
80 host_stub2_ = new MockHostStub(); 88 host_stub2_ = new MockHostStub();
81 input_stub_ = new MockInputStub(); 89 input_stub_ = new MockInputStub();
82 input_stub2_ = new MockInputStub(); 90 input_stub2_ = new MockInputStub();
83 DesktopEnvironment* desktop = 91 DesktopEnvironment* desktop =
84 new DesktopEnvironment(capturer, input_stub_); 92 new DesktopEnvironment(capturer, input_stub_);
85 host_ = ChromotingHost::Create(&context_, config_, desktop); 93 host_ = ChromotingHost::Create(&context_, config_, desktop);
94 credentials_.set_type(protocol::PASSWORD);
95 credentials_.set_username("user");
96 credentials_.set_credential("password");
86 connection_ = new MockConnectionToClient( 97 connection_ = new MockConnectionToClient(
87 &message_loop_, &handler_, host_stub_, input_stub_); 98 &message_loop_, &handler_, host_stub_, input_stub_);
88 connection2_ = new MockConnectionToClient( 99 connection2_ = new MockConnectionToClient(
89 &message_loop_, &handler_, host_stub2_, input_stub2_); 100 &message_loop_, &handler_, host_stub2_, input_stub2_);
90 session_ = new MockSession(); 101 session_ = new MockSession();
91 session2_ = new MockSession(); 102 session2_ = new MockSession();
92 session_config_.reset(SessionConfig::CreateDefault()); 103 session_config_.reset(SessionConfig::CreateDefault());
93 session_config2_.reset(SessionConfig::CreateDefault()); 104 session_config2_.reset(SessionConfig::CreateDefault());
94 105
95 ON_CALL(video_stub_, ProcessVideoPacket(_, _)) 106 ON_CALL(video_stub_, ProcessVideoPacket(_, _))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 144
134 } 145 }
135 146
136 virtual void TearDown() { 147 virtual void TearDown() {
137 } 148 }
138 149
139 // Helper method to pretend a client is connected to ChromotingHost. 150 // Helper method to pretend a client is connected to ChromotingHost.
140 void SimulateClientConnection(int connection_index) { 151 void SimulateClientConnection(int connection_index) {
141 scoped_refptr<MockConnectionToClient> connection = 152 scoped_refptr<MockConnectionToClient> connection =
142 (connection_index == 0) ? connection_ : connection2_; 153 (connection_index == 0) ? connection_ : connection2_;
143 scoped_refptr<ClientSession> client = new ClientSession(host_.get(), 154 scoped_refptr<ClientSession> client = new ClientSession(
144 connection); 155 host_.get(),
156 base::Bind(MakeUserAuthenticator),
157 connection,
158 input_stub_);
145 connection->set_host_stub(client.get()); 159 connection->set_host_stub(client.get());
146 160
147 context_.network_message_loop()->PostTask( 161 context_.network_message_loop()->PostTask(
148 FROM_HERE, 162 FROM_HERE,
149 NewRunnableMethod(host_.get(), 163 NewRunnableMethod(host_.get(),
150 &ChromotingHost::AddClient, 164 &ChromotingHost::AddClient,
151 client)); 165 client));
152 context_.network_message_loop()->PostTask( 166 context_.network_message_loop()->PostTask(
153 FROM_HERE, 167 FROM_HERE,
154 NewRunnableMethod(host_.get(), 168 NewRunnableMethod(host_.get(),
155 &ChromotingHost::OnClientConnected, 169 &ChromotingHost::OnClientConnected,
156 connection)); 170 connection));
157 context_.network_message_loop()->PostTask( 171 context_.network_message_loop()->PostTask(
158 FROM_HERE, 172 FROM_HERE,
159 NewRunnableMethod(host_.get(), 173 NewRunnableMethod(client.get(),
160 &ChromotingHost::LocalLoginSucceeded, 174 &ClientSession::BeginSessionRequest,
161 connection)); 175 &credentials_,
176 NewRunnableFunction(&DummyFunction)));
162 } 177 }
163 178
164 // Helper method to remove a client connection from ChromotingHost. 179 // Helper method to remove a client connection from ChromotingHost.
165 void RemoveClientConnection() { 180 void RemoveClientConnection() {
166 context_.network_message_loop()->PostTask( 181 context_.network_message_loop()->PostTask(
167 FROM_HERE, 182 FROM_HERE,
168 NewRunnableMethod(host_.get(), 183 NewRunnableMethod(host_.get(),
169 &ChromotingHost::OnClientDisconnected, 184 &ChromotingHost::OnClientDisconnected,
170 connection_)); 185 connection_));
171 } 186 }
172 187
173 protected: 188 protected:
174 MessageLoop message_loop_; 189 MessageLoop message_loop_;
175 MockConnectionToClientEventHandler handler_; 190 MockConnectionToClientEventHandler handler_;
176 scoped_refptr<ChromotingHost> host_; 191 scoped_refptr<ChromotingHost> host_;
177 scoped_refptr<InMemoryHostConfig> config_; 192 scoped_refptr<InMemoryHostConfig> config_;
178 MockChromotingHostContext context_; 193 MockChromotingHostContext context_;
194 protocol::LocalLoginCredentials credentials_;
179 scoped_refptr<MockConnectionToClient> connection_; 195 scoped_refptr<MockConnectionToClient> connection_;
180 scoped_refptr<MockSession> session_; 196 scoped_refptr<MockSession> session_;
181 scoped_ptr<SessionConfig> session_config_; 197 scoped_ptr<SessionConfig> session_config_;
182 MockVideoStub video_stub_; 198 MockVideoStub video_stub_;
183 MockClientStub client_stub_; 199 MockClientStub client_stub_;
184 MockHostStub* host_stub_; 200 MockHostStub* host_stub_;
185 MockInputStub* input_stub_; 201 MockInputStub* input_stub_;
186 scoped_refptr<MockConnectionToClient> connection2_; 202 scoped_refptr<MockConnectionToClient> connection2_;
187 scoped_refptr<MockSession> session2_; 203 scoped_refptr<MockSession> session2_;
188 scoped_ptr<SessionConfig> session_config2_; 204 scoped_ptr<SessionConfig> session_config2_;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 EXPECT_CALL(*connection_.get(), Disconnect()) 323 EXPECT_CALL(*connection_.get(), Disconnect())
308 .RetiresOnSaturation(); 324 .RetiresOnSaturation();
309 EXPECT_CALL(*connection2_.get(), Disconnect()) 325 EXPECT_CALL(*connection2_.get(), Disconnect())
310 .RetiresOnSaturation(); 326 .RetiresOnSaturation();
311 327
312 SimulateClientConnection(0); 328 SimulateClientConnection(0);
313 message_loop_.Run(); 329 message_loop_.Run();
314 } 330 }
315 331
316 } // namespace remoting 332 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698