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

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

Issue 2615113005: [Chromoting] Use HostExperimentSessionPlugin in host (Closed)
Patch Set: Created 3 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
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/host/client_session.h" 5 #include "remoting/host/client_session.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "remoting/base/auto_thread_task_runner.h" 20 #include "remoting/base/auto_thread_task_runner.h"
20 #include "remoting/base/constants.h" 21 #include "remoting/base/constants.h"
21 #include "remoting/codec/video_encoder_verbatim.h" 22 #include "remoting/codec/video_encoder_verbatim.h"
22 #include "remoting/host/desktop_environment.h" 23 #include "remoting/host/desktop_environment.h"
23 #include "remoting/host/fake_desktop_environment.h" 24 #include "remoting/host/fake_desktop_environment.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 } // namespace 96 } // namespace
96 97
97 class ClientSessionTest : public testing::Test { 98 class ClientSessionTest : public testing::Test {
98 public: 99 public:
99 ClientSessionTest() : client_jid_("user@domain/rest-of-jid") {} 100 ClientSessionTest() : client_jid_("user@domain/rest-of-jid") {}
100 101
101 void SetUp() override; 102 void SetUp() override;
102 void TearDown() override; 103 void TearDown() override;
103 104
105 protected:
106 // Creates the client session from a MockSession instance.
107 void CreateClientSession(std::unique_ptr<protocol::MockSession> session);
108
104 // Creates the client session. 109 // Creates the client session.
105 void CreateClientSession(); 110 void CreateClientSession();
106 111
107 protected:
108 // Notifies the client session that the client connection has been 112 // Notifies the client session that the client connection has been
109 // authenticated and channels have been connected. This effectively enables 113 // authenticated and channels have been connected. This effectively enables
110 // the input pipe line and starts video capturing. 114 // the input pipe line and starts video capturing.
111 void ConnectClientSession(); 115 void ConnectClientSession();
112 116
113 // Fakes video size notification from the VideoStream. 117 // Fakes video size notification from the VideoStream.
114 void NotifyVideoSize(); 118 void NotifyVideoSize();
115 119
116 // Creates expectations to send an extension message and to disconnect
117 // afterwards.
118 void SetSendMessageAndDisconnectExpectation(const std::string& message_type);
119
120 // Message loop that will process all ClientSession tasks. 120 // Message loop that will process all ClientSession tasks.
121 base::MessageLoop message_loop_; 121 base::MessageLoop message_loop_;
122 122
123 // AutoThreadTaskRunner on which |client_session_| will be run. 123 // AutoThreadTaskRunner on which |client_session_| will be run.
124 scoped_refptr<AutoThreadTaskRunner> task_runner_; 124 scoped_refptr<AutoThreadTaskRunner> task_runner_;
125 125
126 // Used to run |message_loop_| after each test, until no objects remain that 126 // Used to run |message_loop_| after each test, until no objects remain that
127 // require it. 127 // require it.
128 base::RunLoop run_loop_; 128 base::RunLoop run_loop_;
129 129
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 client_session_.reset(); 166 client_session_.reset();
167 desktop_environment_factory_.reset(); 167 desktop_environment_factory_.reset();
168 } 168 }
169 169
170 // Clear out |task_runner_| reference so the loop can quit, and run it until 170 // Clear out |task_runner_| reference so the loop can quit, and run it until
171 // it does. 171 // it does.
172 task_runner_ = nullptr; 172 task_runner_ = nullptr;
173 run_loop_.Run(); 173 run_loop_.Run();
174 } 174 }
175 175
176 void ClientSessionTest::CreateClientSession() { 176 void ClientSessionTest::CreateClientSession(
177 std::unique_ptr<protocol::MockSession> session) {
178 DCHECK(session);
177 // Mock protocol::Session APIs called directly by ClientSession. 179 // Mock protocol::Session APIs called directly by ClientSession.
178 std::unique_ptr<protocol::MockSession> session(new MockSession());
179 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(*session_config_)); 180 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(*session_config_));
180 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); 181 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_));
181 182
182 // Mock protocol::ConnectionToClient APIs called directly by ClientSession. 183 // Mock protocol::ConnectionToClient APIs called directly by ClientSession.
183 // HostStub is not touched by ClientSession, so we can safely pass nullptr. 184 // HostStub is not touched by ClientSession, so we can safely pass nullptr.
184 std::unique_ptr<protocol::FakeConnectionToClient> connection( 185 std::unique_ptr<protocol::FakeConnectionToClient> connection(
185 new protocol::FakeConnectionToClient(std::move(session))); 186 new protocol::FakeConnectionToClient(std::move(session)));
186 connection->set_client_stub(&client_stub_); 187 connection->set_client_stub(&client_stub_);
187 connection_ = connection.get(); 188 connection_ = connection.get();
188 189
189 client_session_.reset( 190 client_session_.reset(
190 new ClientSession(&session_event_handler_, std::move(connection), 191 new ClientSession(&session_event_handler_, std::move(connection),
191 desktop_environment_factory_.get(), 192 desktop_environment_factory_.get(),
192 DesktopEnvironmentOptions::CreateDefault(), 193 DesktopEnvironmentOptions::CreateDefault(),
193 base::TimeDelta(), nullptr, extensions_)); 194 base::TimeDelta(), nullptr, extensions_));
194 } 195 }
195 196
197 void ClientSessionTest::CreateClientSession() {
198 CreateClientSession(base::MakeUnique<protocol::MockSession>());
199 }
200
196 void ClientSessionTest::ConnectClientSession() { 201 void ClientSessionTest::ConnectClientSession() {
197 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 202 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
198 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 203 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
199 204
200 // Stubs should be set only after connection is authenticated. 205 // Stubs should be set only after connection is authenticated.
201 EXPECT_FALSE(connection_->clipboard_stub()); 206 EXPECT_FALSE(connection_->clipboard_stub());
202 EXPECT_FALSE(connection_->input_stub()); 207 EXPECT_FALSE(connection_->input_stub());
203 208
204 client_session_->OnConnectionAuthenticated(); 209 client_session_->OnConnectionAuthenticated();
205 210
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 EXPECT_TRUE(extension1.has_handled_message()); 429 EXPECT_TRUE(extension1.has_handled_message());
425 430
426 // ext2 was instantiated but not sent a message, and wrapped video encoder. 431 // ext2 was instantiated but not sent a message, and wrapped video encoder.
427 EXPECT_TRUE(extension2.was_instantiated()); 432 EXPECT_TRUE(extension2.was_instantiated());
428 EXPECT_FALSE(extension2.has_handled_message()); 433 EXPECT_FALSE(extension2.has_handled_message());
429 434
430 // ext3 was sent a message but not instantiated. 435 // ext3 was sent a message but not instantiated.
431 EXPECT_FALSE(extension3.was_instantiated()); 436 EXPECT_FALSE(extension3.was_instantiated());
432 } 437 }
433 438
439 #if defined(OS_WIN)
440 TEST_F(ClientSessionTest, ForwardHostSessionOptions) {
441 std::unique_ptr<protocol::MockSession> session(new protocol::MockSession());
Sergey Ulanov 2017/01/07 01:23:09 nit: This line may would be more readable if writt
Hzj_jie 2017/01/08 23:48:48 Done.
442 std::unique_ptr<buzz::XmlElement> configuration(new buzz::XmlElement(
443 buzz::QName(kChromotingXmlNamespace, "host-configuration")));
444 configuration->SetBodyText("Allow-DirectX-Capturer:");
445 session->SetAttachment(0, std::move(configuration));
446 CreateClientSession(std::move(session));
447 ConnectClientSession();
448 ASSERT_TRUE(desktop_environment_factory_->last_desktop_environment()
449 ->options().desktop_capture_options()->allow_directx_capturer());
Sergey Ulanov 2017/01/07 01:23:09 'git cl format' please
Hzj_jie 2017/01/08 23:48:48 Done.
450 }
451 #endif
452
434 } // namespace remoting 453 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698