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

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

Issue 7796026: Pass SessionConfig by reference instead of pointer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 3 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/host/chromoting_host.cc ('k') | remoting/protocol/connection_to_host.h » ('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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "remoting/host/capturer_fake.h" 9 #include "remoting/host/capturer_fake.h"
10 #include "remoting/host/chromoting_host.h" 10 #include "remoting/host/chromoting_host.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 access_verifier, false); 105 access_verifier, false);
106 credentials_.set_type(protocol::PASSWORD); 106 credentials_.set_type(protocol::PASSWORD);
107 credentials_.set_username("user"); 107 credentials_.set_username("user");
108 credentials_.set_credential("password"); 108 credentials_.set_credential("password");
109 connection_ = new MockConnectionToClient( 109 connection_ = new MockConnectionToClient(
110 &handler_, &host_stub_, event_executor_); 110 &handler_, &host_stub_, event_executor_);
111 connection2_ = new MockConnectionToClient( 111 connection2_ = new MockConnectionToClient(
112 &handler_, &host_stub2_, &event_executor2_); 112 &handler_, &host_stub2_, &event_executor2_);
113 session_.reset(new MockSession()); 113 session_.reset(new MockSession());
114 session2_.reset(new MockSession()); 114 session2_.reset(new MockSession());
115 session_config_.reset(SessionConfig::CreateDefault()); 115 session_config_ = SessionConfig::GetDefault();
116 session_config2_.reset(SessionConfig::CreateDefault()); 116 session_jid_ = "user@domain/rest-of-jid";
117 session_config2_ = SessionConfig::GetDefault();
117 118
118 ON_CALL(video_stub_, ProcessVideoPacket(_, _)) 119 ON_CALL(video_stub_, ProcessVideoPacket(_, _))
119 .WillByDefault( 120 .WillByDefault(
120 DoAll(DeleteArg<0>(), DeleteArg<1>())); 121 DoAll(DeleteArg<0>(), DeleteArg<1>()));
121 ON_CALL(video_stub2_, ProcessVideoPacket(_, _)) 122 ON_CALL(video_stub2_, ProcessVideoPacket(_, _))
122 .WillByDefault( 123 .WillByDefault(
123 DoAll(DeleteArg<0>(), DeleteArg<1>())); 124 DoAll(DeleteArg<0>(), DeleteArg<1>()));
124 ON_CALL(*connection_.get(), video_stub()) 125 ON_CALL(*connection_.get(), video_stub())
125 .WillByDefault(Return(&video_stub_)); 126 .WillByDefault(Return(&video_stub_));
126 ON_CALL(*connection_.get(), client_stub()) 127 ON_CALL(*connection_.get(), client_stub())
127 .WillByDefault(Return(&client_stub_)); 128 .WillByDefault(Return(&client_stub_));
128 ON_CALL(*connection_.get(), session()) 129 ON_CALL(*connection_.get(), session())
129 .WillByDefault(Return(session_.get())); 130 .WillByDefault(Return(session_.get()));
130 ON_CALL(*connection2_.get(), video_stub()) 131 ON_CALL(*connection2_.get(), video_stub())
131 .WillByDefault(Return(&video_stub2_)); 132 .WillByDefault(Return(&video_stub2_));
132 ON_CALL(*connection2_.get(), client_stub()) 133 ON_CALL(*connection2_.get(), client_stub())
133 .WillByDefault(Return(&client_stub2_)); 134 .WillByDefault(Return(&client_stub2_));
134 ON_CALL(*connection2_.get(), session()) 135 ON_CALL(*connection2_.get(), session())
135 .WillByDefault(Return(session2_.get())); 136 .WillByDefault(Return(session2_.get()));
136 ON_CALL(*session_.get(), config()) 137 ON_CALL(*session_.get(), config())
137 .WillByDefault(Return(session_config_.get())); 138 .WillByDefault(ReturnRef(session_config_));
139 ON_CALL(*session_, jid())
140 .WillByDefault(ReturnRef(session_jid_));
138 ON_CALL(*session2_.get(), config()) 141 ON_CALL(*session2_.get(), config())
139 .WillByDefault(Return(session_config2_.get())); 142 .WillByDefault(ReturnRef(session_config2_));
140 EXPECT_CALL(*connection_.get(), video_stub()) 143 EXPECT_CALL(*connection_.get(), video_stub())
141 .Times(AnyNumber()); 144 .Times(AnyNumber());
142 EXPECT_CALL(*connection_.get(), client_stub()) 145 EXPECT_CALL(*connection_.get(), client_stub())
143 .Times(AnyNumber()); 146 .Times(AnyNumber());
144 EXPECT_CALL(*connection_.get(), session()) 147 EXPECT_CALL(*connection_.get(), session())
145 .Times(AnyNumber()); 148 .Times(AnyNumber());
146 EXPECT_CALL(*connection2_.get(), video_stub()) 149 EXPECT_CALL(*connection2_.get(), video_stub())
147 .Times(AnyNumber()); 150 .Times(AnyNumber());
148 EXPECT_CALL(*connection2_.get(), client_stub()) 151 EXPECT_CALL(*connection2_.get(), client_stub())
149 .Times(AnyNumber()); 152 .Times(AnyNumber());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 protected: 212 protected:
210 MessageLoop message_loop_; 213 MessageLoop message_loop_;
211 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 214 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
212 MockConnectionToClientEventHandler handler_; 215 MockConnectionToClientEventHandler handler_;
213 scoped_ptr<DesktopEnvironment> desktop_environment_; 216 scoped_ptr<DesktopEnvironment> desktop_environment_;
214 scoped_refptr<ChromotingHost> host_; 217 scoped_refptr<ChromotingHost> host_;
215 scoped_refptr<InMemoryHostConfig> config_; 218 scoped_refptr<InMemoryHostConfig> config_;
216 MockChromotingHostContext context_; 219 MockChromotingHostContext context_;
217 protocol::LocalLoginCredentials credentials_; 220 protocol::LocalLoginCredentials credentials_;
218 scoped_refptr<MockConnectionToClient> connection_; 221 scoped_refptr<MockConnectionToClient> connection_;
222 std::string session_jid_;
219 scoped_ptr<MockSession> session_; 223 scoped_ptr<MockSession> session_;
220 scoped_ptr<SessionConfig> session_config_; 224 SessionConfig session_config_;
221 MockVideoStub video_stub_; 225 MockVideoStub video_stub_;
222 MockClientStub client_stub_; 226 MockClientStub client_stub_;
223 MockHostStub host_stub_; 227 MockHostStub host_stub_;
224 scoped_refptr<MockConnectionToClient> connection2_; 228 scoped_refptr<MockConnectionToClient> connection2_;
225 scoped_ptr<MockSession> session2_; 229 scoped_ptr<MockSession> session2_;
226 scoped_ptr<SessionConfig> session_config2_; 230 SessionConfig session_config2_;
227 MockVideoStub video_stub2_; 231 MockVideoStub video_stub2_;
228 MockClientStub client_stub2_; 232 MockClientStub client_stub2_;
229 MockHostStub host_stub2_; 233 MockHostStub host_stub2_;
230 MockEventExecutor event_executor2_; 234 MockEventExecutor event_executor2_;
231 235
232 // Owned by |host_|. 236 // Owned by |host_|.
233 MockEventExecutor* event_executor_; 237 MockEventExecutor* event_executor_;
234 MockCurtain* curtain_; 238 MockCurtain* curtain_;
235 MockDisconnectWindow* disconnect_window_; 239 MockDisconnectWindow* disconnect_window_;
236 MockContinueWindow* continue_window_; 240 MockContinueWindow* continue_window_;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 TEST_F(ChromotingHostTest, CurtainModeIT2Me) { 458 TEST_F(ChromotingHostTest, CurtainModeIT2Me) {
455 host_->Start(); 459 host_->Start();
456 host_->set_it2me(true); 460 host_->set_it2me(true);
457 461
458 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) 462 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
459 .WillOnce(RunDoneTask()); 463 .WillOnce(RunDoneTask());
460 464
461 // When the video packet is received we first shutdown ChromotingHost 465 // When the video packet is received we first shutdown ChromotingHost
462 // then execute the done task. 466 // then execute the done task.
463 bool curtain_activated = false; 467 bool curtain_activated = false;
464 std::string mockJid("user@domain/rest-of-jid");
465 { 468 {
466 Sequence s1, s2; 469 Sequence s1, s2;
467 // Can't just expect Times(0) because if it fails then the host will 470 // Can't just expect Times(0) because if it fails then the host will
468 // not be shut down and the message loop will never exit. 471 // not be shut down and the message loop will never exit.
469 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) 472 EXPECT_CALL(*curtain_, EnableCurtainMode(_))
470 .Times(AnyNumber()) 473 .Times(AnyNumber())
471 .WillRepeatedly(SetBool(&curtain_activated)); 474 .WillRepeatedly(SetBool(&curtain_activated));
472 EXPECT_CALL(*session_, jid())
473 .Times(1)
474 .InSequence(s1)
475 .WillOnce(ReturnRef(mockJid));
476 EXPECT_CALL(*disconnect_window_, Show(_, "user@domain")) 475 EXPECT_CALL(*disconnect_window_, Show(_, "user@domain"))
477 .Times(1) 476 .Times(1)
478 .InSequence(s1); 477 .InSequence(s1);
479 EXPECT_CALL(*local_input_monitor_, Start(_)) 478 EXPECT_CALL(*local_input_monitor_, Start(_))
480 .Times(1) 479 .Times(1)
481 .InSequence(s2); 480 .InSequence(s2);
482 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 481 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
483 .InSequence(s1, s2) 482 .InSequence(s1, s2)
484 .WillOnce(DoAll( 483 .WillOnce(DoAll(
485 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 484 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
486 RunDoneTask())) 485 RunDoneTask()))
487 .RetiresOnSaturation(); 486 .RetiresOnSaturation();
488 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 487 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
489 .Times(AnyNumber()) 488 .Times(AnyNumber())
490 .InSequence(s1, s2); 489 .InSequence(s1, s2);
491 EXPECT_CALL(*connection_.get(), Disconnect()) 490 EXPECT_CALL(*connection_.get(), Disconnect())
492 .InSequence(s1, s2) 491 .InSequence(s1, s2)
493 .RetiresOnSaturation(); 492 .RetiresOnSaturation();
494 } 493 }
495 SimulateClientConnection(0, true); 494 SimulateClientConnection(0, true);
496 message_loop_.Run(); 495 message_loop_.Run();
497 host_->set_it2me(false); 496 host_->set_it2me(false);
498 EXPECT_THAT(curtain_activated, false); 497 EXPECT_THAT(curtain_activated, false);
499 } 498 }
500 } // namespace remoting 499 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698