OLD | NEW |
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> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
130 // HostExtensions to pass when creating the ClientSession. Caller retains | 130 // HostExtensions to pass when creating the ClientSession. Caller retains |
131 // ownership of the HostExtensions themselves. | 131 // ownership of the HostExtensions themselves. |
132 std::vector<HostExtension*> extensions_; | 132 std::vector<HostExtension*> extensions_; |
133 | 133 |
134 // ClientSession instance under test. | 134 // ClientSession instance under test. |
135 scoped_ptr<ClientSession> client_session_; | 135 std::unique_ptr<ClientSession> client_session_; |
136 | 136 |
137 // ClientSession::EventHandler mock for use in tests. | 137 // ClientSession::EventHandler mock for use in tests. |
138 MockClientSessionEventHandler session_event_handler_; | 138 MockClientSessionEventHandler session_event_handler_; |
139 | 139 |
140 // Storage for values to be returned by the protocol::Session mock. | 140 // Storage for values to be returned by the protocol::Session mock. |
141 scoped_ptr<SessionConfig> session_config_; | 141 std::unique_ptr<SessionConfig> session_config_; |
142 const std::string client_jid_; | 142 const std::string client_jid_; |
143 | 143 |
144 // Stubs returned to |client_session_| components by |connection_|. | 144 // Stubs returned to |client_session_| components by |connection_|. |
145 MockClientStub client_stub_; | 145 MockClientStub client_stub_; |
146 | 146 |
147 // ClientSession owns |connection_| but tests need it to inject fake events. | 147 // ClientSession owns |connection_| but tests need it to inject fake events. |
148 protocol::FakeConnectionToClient* connection_; | 148 protocol::FakeConnectionToClient* connection_; |
149 | 149 |
150 scoped_ptr<FakeDesktopEnvironmentFactory> desktop_environment_factory_; | 150 std::unique_ptr<FakeDesktopEnvironmentFactory> desktop_environment_factory_; |
151 }; | 151 }; |
152 | 152 |
153 void ClientSessionTest::SetUp() { | 153 void ClientSessionTest::SetUp() { |
154 // Arrange to run |message_loop_| until no components depend on it. | 154 // Arrange to run |message_loop_| until no components depend on it. |
155 task_runner_ = new AutoThreadTaskRunner( | 155 task_runner_ = new AutoThreadTaskRunner( |
156 message_loop_.task_runner(), run_loop_.QuitClosure()); | 156 message_loop_.task_runner(), run_loop_.QuitClosure()); |
157 | 157 |
158 desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory()); | 158 desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory()); |
159 session_config_ = SessionConfig::ForTest(); | 159 session_config_ = SessionConfig::ForTest(); |
160 } | 160 } |
161 | 161 |
162 void ClientSessionTest::TearDown() { | 162 void ClientSessionTest::TearDown() { |
163 if (client_session_) { | 163 if (client_session_) { |
164 client_session_->DisconnectSession(protocol::OK); | 164 client_session_->DisconnectSession(protocol::OK); |
165 client_session_.reset(); | 165 client_session_.reset(); |
166 desktop_environment_factory_.reset(); | 166 desktop_environment_factory_.reset(); |
167 } | 167 } |
168 | 168 |
169 // Clear out |task_runner_| reference so the loop can quit, and run it until | 169 // Clear out |task_runner_| reference so the loop can quit, and run it until |
170 // it does. | 170 // it does. |
171 task_runner_ = nullptr; | 171 task_runner_ = nullptr; |
172 run_loop_.Run(); | 172 run_loop_.Run(); |
173 } | 173 } |
174 | 174 |
175 void ClientSessionTest::CreateClientSession() { | 175 void ClientSessionTest::CreateClientSession() { |
176 // Mock protocol::Session APIs called directly by ClientSession. | 176 // Mock protocol::Session APIs called directly by ClientSession. |
177 scoped_ptr<protocol::MockSession> session(new MockSession()); | 177 std::unique_ptr<protocol::MockSession> session(new MockSession()); |
178 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(*session_config_)); | 178 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(*session_config_)); |
179 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); | 179 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); |
180 | 180 |
181 // Mock protocol::ConnectionToClient APIs called directly by ClientSession. | 181 // Mock protocol::ConnectionToClient APIs called directly by ClientSession. |
182 // HostStub is not touched by ClientSession, so we can safely pass nullptr. | 182 // HostStub is not touched by ClientSession, so we can safely pass nullptr. |
183 scoped_ptr<protocol::FakeConnectionToClient> connection( | 183 std::unique_ptr<protocol::FakeConnectionToClient> connection( |
184 new protocol::FakeConnectionToClient(std::move(session))); | 184 new protocol::FakeConnectionToClient(std::move(session))); |
185 connection->set_client_stub(&client_stub_); | 185 connection->set_client_stub(&client_stub_); |
186 connection_ = connection.get(); | 186 connection_ = connection.get(); |
187 | 187 |
188 client_session_.reset(new ClientSession( | 188 client_session_.reset(new ClientSession( |
189 &session_event_handler_, | 189 &session_event_handler_, |
190 task_runner_, // Audio thread. | 190 task_runner_, // Audio thread. |
191 std::move(connection), desktop_environment_factory_.get(), | 191 std::move(connection), desktop_environment_factory_.get(), |
192 base::TimeDelta(), nullptr, extensions_)); | 192 base::TimeDelta(), nullptr, extensions_)); |
193 } | 193 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 422 |
423 // ext2 was instantiated but not sent a message, and wrapped video encoder. | 423 // ext2 was instantiated but not sent a message, and wrapped video encoder. |
424 EXPECT_TRUE(extension2.was_instantiated()); | 424 EXPECT_TRUE(extension2.was_instantiated()); |
425 EXPECT_FALSE(extension2.has_handled_message()); | 425 EXPECT_FALSE(extension2.has_handled_message()); |
426 | 426 |
427 // ext3 was sent a message but not instantiated. | 427 // ext3 was sent a message but not instantiated. |
428 EXPECT_FALSE(extension3.was_instantiated()); | 428 EXPECT_FALSE(extension3.was_instantiated()); |
429 } | 429 } |
430 | 430 |
431 } // namespace remoting | 431 } // namespace remoting |
OLD | NEW |