| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 130 // HostExtensions to pass when creating the ClientSession. Caller retains | 130 // HostExtensions to pass when creating the ClientSession. |
| 131 // ownership of the HostExtensions themselves. | 131 std::vector<std::unique_ptr<HostExtension>> extensions_; |
| 132 std::vector<HostExtension*> extensions_; | |
| 133 | 132 |
| 134 // ClientSession instance under test. | 133 // ClientSession instance under test. |
| 135 std::unique_ptr<ClientSession> client_session_; | 134 std::unique_ptr<ClientSession> client_session_; |
| 136 | 135 |
| 137 // ClientSession::EventHandler mock for use in tests. | 136 // ClientSession::EventHandler mock for use in tests. |
| 138 MockClientSessionEventHandler session_event_handler_; | 137 MockClientSessionEventHandler session_event_handler_; |
| 139 | 138 |
| 140 // Storage for values to be returned by the protocol::Session mock. | 139 // Storage for values to be returned by the protocol::Session mock. |
| 141 std::unique_ptr<SessionConfig> session_config_; | 140 std::unique_ptr<SessionConfig> session_config_; |
| 142 const std::string client_jid_; | 141 const std::string client_jid_; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 } | 377 } |
| 379 | 378 |
| 380 // Verifies that clients can have extensions registered, resulting in the | 379 // Verifies that clients can have extensions registered, resulting in the |
| 381 // correct capabilities being reported, and messages delivered correctly. | 380 // correct capabilities being reported, and messages delivered correctly. |
| 382 // The extension system is tested more extensively in the | 381 // The extension system is tested more extensively in the |
| 383 // HostExtensionSessionManager unit-tests. | 382 // HostExtensionSessionManager unit-tests. |
| 384 TEST_F(ClientSessionTest, Extensions) { | 383 TEST_F(ClientSessionTest, Extensions) { |
| 385 // Configure fake extensions for testing. | 384 // Configure fake extensions for testing. |
| 386 FakeExtension extension1("ext1", "cap1"); | 385 extensions_.push_back(base::MakeUnique<FakeExtension>("ext1", "cap1")); |
| 387 extensions_.push_back(&extension1); | 386 extensions_.push_back(base::MakeUnique<FakeExtension>("ext2", std::string())); |
| 388 FakeExtension extension2("ext2", ""); | 387 extensions_.push_back(base::MakeUnique<FakeExtension>("ext3", "cap3")); |
| 389 extensions_.push_back(&extension2); | 388 FakeExtension* extension1 = static_cast<FakeExtension*>(extensions_[0].get()); |
| 390 FakeExtension extension3("ext3", "cap3"); | 389 FakeExtension* extension2 = static_cast<FakeExtension*>(extensions_[1].get()); |
| 391 extensions_.push_back(&extension3); | 390 FakeExtension* extension3 = static_cast<FakeExtension*>(extensions_[2].get()); |
| 392 | 391 |
| 393 // Verify that the ClientSession reports the correct capabilities. | 392 // Verify that the ClientSession reports the correct capabilities. |
| 394 EXPECT_CALL(client_stub_, SetCapabilities(EqCapabilities("cap1 cap3"))); | 393 EXPECT_CALL(client_stub_, SetCapabilities(EqCapabilities("cap1 cap3"))); |
| 395 | 394 |
| 396 CreateClientSession(); | 395 CreateClientSession(); |
| 397 ConnectClientSession(); | 396 ConnectClientSession(); |
| 398 | 397 |
| 399 testing::Mock::VerifyAndClearExpectations(&client_stub_); | 398 testing::Mock::VerifyAndClearExpectations(&client_stub_); |
| 400 | 399 |
| 401 // Mimic the client reporting an overlapping set of capabilities. | 400 // Mimic the client reporting an overlapping set of capabilities. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 413 message3.set_data("data"); | 412 message3.set_data("data"); |
| 414 client_session_->DeliverClientMessage(message3); | 413 client_session_->DeliverClientMessage(message3); |
| 415 protocol::ExtensionMessage message4; | 414 protocol::ExtensionMessage message4; |
| 416 message4.set_type("ext4"); | 415 message4.set_type("ext4"); |
| 417 message4.set_data("data"); | 416 message4.set_data("data"); |
| 418 client_session_->DeliverClientMessage(message4); | 417 client_session_->DeliverClientMessage(message4); |
| 419 | 418 |
| 420 base::RunLoop().RunUntilIdle(); | 419 base::RunLoop().RunUntilIdle(); |
| 421 | 420 |
| 422 // ext1 was instantiated and sent a message, and did not wrap anything. | 421 // ext1 was instantiated and sent a message, and did not wrap anything. |
| 423 EXPECT_TRUE(extension1.was_instantiated()); | 422 EXPECT_TRUE(extension1->was_instantiated()); |
| 424 EXPECT_TRUE(extension1.has_handled_message()); | 423 EXPECT_TRUE(extension1->has_handled_message()); |
| 425 | 424 |
| 426 // ext2 was instantiated but not sent a message, and wrapped video encoder. | 425 // ext2 was instantiated but not sent a message, and wrapped video encoder. |
| 427 EXPECT_TRUE(extension2.was_instantiated()); | 426 EXPECT_TRUE(extension2->was_instantiated()); |
| 428 EXPECT_FALSE(extension2.has_handled_message()); | 427 EXPECT_FALSE(extension2->has_handled_message()); |
| 429 | 428 |
| 430 // ext3 was sent a message but not instantiated. | 429 // ext3 was sent a message but not instantiated. |
| 431 EXPECT_FALSE(extension3.was_instantiated()); | 430 EXPECT_FALSE(extension3->was_instantiated()); |
| 432 } | 431 } |
| 433 | 432 |
| 434 } // namespace remoting | 433 } // namespace remoting |
| OLD | NEW |