summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2015-12-11 12:44:05 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-11 20:44:52 +0000
commit59cdfa9a030a84c4a79f0488324592a5b7c0614e (patch)
tree91fa387fd51efb9ccd987a41f606bf70d1acee60
parent24a953e9db68003b25262936d8ddf20bf251aeb3 (diff)
downloadchromium_src-59cdfa9a030a84c4a79f0488324592a5b7c0614e.zip
chromium_src-59cdfa9a030a84c4a79f0488324592a5b7c0614e.tar.gz
chromium_src-59cdfa9a030a84c4a79f0488324592a5b7c0614e.tar.bz2
Move IceTransport tests to ice_transport_unittest.cc
Previously IceTransport was tested as part of jingle_session_unittest.cc. This makes little sense because JingleSession can be used with transports other than IceTransport. Now the tests have been moved to ice_transport_unittest.cc. Review URL: https://codereview.chromium.org/1515823002 Cr-Commit-Position: refs/heads/master@{#364793}
-rw-r--r--remoting/protocol/BUILD.gn1
-rw-r--r--remoting/protocol/ice_transport_unittest.cc362
-rw-r--r--remoting/protocol/jingle_session_unittest.cc234
-rw-r--r--remoting/remoting_test.gypi1
4 files changed, 366 insertions, 232 deletions
diff --git a/remoting/protocol/BUILD.gn b/remoting/protocol/BUILD.gn
index 54224e8..fa66df1 100644
--- a/remoting/protocol/BUILD.gn
+++ b/remoting/protocol/BUILD.gn
@@ -100,6 +100,7 @@ source_set("unit_tests") {
"connection_tester.h",
"content_description_unittest.cc",
"ice_connection_to_client_unittest.cc",
+ "ice_transport_unittest.cc",
"input_event_tracker_unittest.cc",
"input_filter_unittest.cc",
"jingle_messages_unittest.cc",
diff --git a/remoting/protocol/ice_transport_unittest.cc b/remoting/protocol/ice_transport_unittest.cc
new file mode 100644
index 0000000..110a6d7
--- /dev/null
+++ b/remoting/protocol/ice_transport_unittest.cc
@@ -0,0 +1,362 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/ice_transport.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
+#include "base/thread_task_runner_handle.h"
+#include "jingle/glue/thread_wrapper.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "remoting/protocol/chromium_port_allocator.h"
+#include "remoting/protocol/connection_tester.h"
+#include "remoting/protocol/fake_authenticator.h"
+#include "remoting/protocol/p2p_stream_socket.h"
+#include "remoting/protocol/stream_channel_factory.h"
+#include "remoting/signaling/fake_signal_strategy.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
+
+using testing::_;
+
+namespace remoting {
+namespace protocol {
+
+namespace {
+
+// Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay
+// between messages (about 1 second for 100 messages).
+const int kMessageSize = 1024;
+const int kMessages = 100;
+const char kChannelName[] = "test_channel";
+
+ACTION_P(QuitRunLoop, run_loop) {
+ run_loop->Quit();
+}
+
+ACTION_P2(QuitRunLoopOnCounter, run_loop, counter) {
+ --(*counter);
+ EXPECT_GE(*counter, 0);
+ if (*counter == 0)
+ run_loop->Quit();
+}
+
+class MockChannelCreatedCallback {
+ public:
+ MOCK_METHOD1(OnDone, void(P2PStreamSocket* socket));
+};
+
+class TestTransportEventHandler : public Transport::EventHandler {
+ public:
+ typedef base::Callback<void(scoped_ptr<buzz::XmlElement> message)>
+ TransportInfoCallback;
+ typedef base::Callback<void(ErrorCode error)> ErrorCallback;
+
+ TestTransportEventHandler() {}
+ ~TestTransportEventHandler() {}
+
+ // Both callback must be set before the test handler is passed to a Transport
+ // object.
+ void set_transport_info_callback(const TransportInfoCallback& callback) {
+ transport_info_callback_ = callback;
+ }
+ void set_connected_callback(const base::Closure& callback) {
+ connected_callback_ = callback;
+ }
+ void set_error_callback(const ErrorCallback& callback) {
+ error_callback_ = callback;
+ }
+
+ // Transport::EventHandler interface.
+ void OnOutgoingTransportInfo(scoped_ptr<buzz::XmlElement> message) override {
+ transport_info_callback_.Run(message.Pass());
+ }
+ void OnTransportRouteChange(const std::string& channel_name,
+ const TransportRoute& route) override {}
+ void OnTransportConnected() override {
+ connected_callback_.Run();
+ }
+ void OnTransportError(ErrorCode error) override {
+ error_callback_.Run(error);
+ }
+
+ private:
+ TransportInfoCallback transport_info_callback_;
+ base::Closure connected_callback_;
+ ErrorCallback error_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestTransportEventHandler);
+};
+
+} // namespace
+
+class IceTransportTest : public testing::Test {
+ public:
+ IceTransportTest() {
+ jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
+ network_settings_ =
+ NetworkSettings(NetworkSettings::NAT_TRAVERSAL_OUTGOING);
+ }
+
+ void TearDown() override {
+ client_socket_.reset();
+ host_socket_.reset();
+ client_transport_.reset();
+ host_transport_.reset();
+ message_loop_.RunUntilIdle();
+ }
+
+ void ProcessTransportInfo(scoped_ptr<IceTransport>* target_transport,
+ scoped_ptr<buzz::XmlElement> transport_info) {
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE, base::Bind(&IceTransportTest::DeliverTransportInfo,
+ base::Unretained(this), target_transport,
+ base::Passed(&transport_info)),
+ transport_info_delay_);
+ }
+
+ void DeliverTransportInfo(scoped_ptr<IceTransport>* target_transport,
+ scoped_ptr<buzz::XmlElement> transport_info) {
+ ASSERT_TRUE(target_transport);
+ EXPECT_TRUE(
+ (*target_transport)->ProcessTransportInfo(transport_info.get()));
+ }
+
+ void InitializeConnection() {
+ port_allocator_ = ChromiumPortAllocator::Create(nullptr, network_settings_);
+
+ host_transport_.reset(new IceTransport(
+ port_allocator_.get(), network_settings_, TransportRole::SERVER));
+ host_transport_->GetCanStartClosure().Run();
+
+ if (!host_authenticator_) {
+ host_authenticator_.reset(new FakeAuthenticator(
+ FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, true));
+ }
+
+ client_transport_.reset(new IceTransport(
+ port_allocator_.get(), network_settings_, TransportRole::CLIENT));
+ client_transport_->GetCanStartClosure().Run();
+ if (!client_authenticator_) {
+ client_authenticator_.reset(new FakeAuthenticator(
+ FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, true));
+ }
+
+ // Connect signaling between the two IceTransport objects.
+ host_event_handler_.set_transport_info_callback(
+ base::Bind(&IceTransportTest::ProcessTransportInfo,
+ base::Unretained(this), &client_transport_));
+ client_event_handler_.set_transport_info_callback(
+ base::Bind(&IceTransportTest::ProcessTransportInfo,
+ base::Unretained(this), &host_transport_));
+
+ host_event_handler_.set_connected_callback(base::Bind(&base::DoNothing));
+ host_event_handler_.set_error_callback(base::Bind(
+ &IceTransportTest::OnTransportError, base::Unretained(this)));
+
+ client_event_handler_.set_connected_callback(base::Bind(&base::DoNothing));
+ client_event_handler_.set_error_callback(base::Bind(
+ &IceTransportTest::OnTransportError, base::Unretained(this)));
+
+ host_transport_->Start(&host_event_handler_, host_authenticator_.get());
+ client_transport_->Start(&client_event_handler_,
+ client_authenticator_.get());
+ }
+
+ void WaitUntilConnected() {
+ run_loop_.reset(new base::RunLoop());
+
+ int counter = 2;
+ EXPECT_CALL(client_channel_callback_, OnDone(_))
+ .WillOnce(QuitRunLoopOnCounter(run_loop_.get(), &counter));
+ EXPECT_CALL(host_channel_callback_, OnDone(_))
+ .WillOnce(QuitRunLoopOnCounter(run_loop_.get(), &counter));
+
+ run_loop_->Run();
+
+ EXPECT_TRUE(client_socket_.get());
+ EXPECT_TRUE(host_socket_.get());
+ }
+
+ void OnClientChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
+ client_socket_ = socket.Pass();
+ client_channel_callback_.OnDone(client_socket_.get());
+ }
+
+ void OnHostChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
+ host_socket_ = socket.Pass();
+ host_channel_callback_.OnDone(host_socket_.get());
+ }
+
+ void OnTransportError(ErrorCode error) {
+ error_ = error;
+ run_loop_->Quit();
+ }
+
+ protected:
+ base::MessageLoopForIO message_loop_;
+ scoped_ptr<base::RunLoop> run_loop_;
+
+ NetworkSettings network_settings_;
+
+ scoped_ptr<FakeSignalStrategy> signal_strategy_;
+
+ base::TimeDelta transport_info_delay_;
+
+ scoped_ptr<cricket::PortAllocator> port_allocator_;
+
+ // scoped_ptr<IceTransportFactory> host_transport_factory_;
+ scoped_ptr<IceTransport> host_transport_;
+ TestTransportEventHandler host_event_handler_;
+ scoped_ptr<FakeAuthenticator> host_authenticator_;
+
+ // scoped_ptr<IceTransportFactory> client_transport_factory_;
+ scoped_ptr<IceTransport> client_transport_;
+ TestTransportEventHandler client_event_handler_;
+ scoped_ptr<FakeAuthenticator> client_authenticator_;
+
+ MockChannelCreatedCallback client_channel_callback_;
+ MockChannelCreatedCallback host_channel_callback_;
+
+ scoped_ptr<P2PStreamSocket> client_socket_;
+ scoped_ptr<P2PStreamSocket> host_socket_;
+
+ ErrorCode error_ = OK;
+};
+
+TEST_F(IceTransportTest, DataStream) {
+ InitializeConnection();
+
+ client_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
+ base::Unretained(this)));
+ host_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated,
+ base::Unretained(this)));
+
+ WaitUntilConnected();
+
+ StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
+ kMessageSize, kMessages);
+ tester.Start();
+ message_loop_.Run();
+ tester.CheckResults();
+}
+
+TEST_F(IceTransportTest, MuxDataStream) {
+ InitializeConnection();
+
+ client_transport_->GetMultiplexedChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
+ base::Unretained(this)));
+ host_transport_->GetMultiplexedChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated,
+ base::Unretained(this)));
+
+ WaitUntilConnected();
+
+ StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
+ kMessageSize, kMessages);
+ tester.Start();
+ message_loop_.Run();
+ tester.CheckResults();
+}
+
+TEST_F(IceTransportTest, FailedChannelAuth) {
+ // Use host authenticator with one that rejects channel authentication.
+ host_authenticator_.reset(new FakeAuthenticator(
+ FakeAuthenticator::HOST, 0, FakeAuthenticator::REJECT_CHANNEL, true));
+
+ InitializeConnection();
+
+ client_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
+ base::Unretained(this)));
+ host_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated,
+ base::Unretained(this)));
+
+ run_loop_.reset(new base::RunLoop());
+
+ EXPECT_CALL(host_channel_callback_, OnDone(nullptr))
+ .WillOnce(QuitRunLoop(run_loop_.get()));
+
+ run_loop_->Run();
+
+ EXPECT_FALSE(host_socket_);
+
+ client_transport_->GetStreamChannelFactory()->CancelChannelCreation(
+ kChannelName);
+}
+
+// Verify that channels are never marked connected if connection cannot be
+// established.
+TEST_F(IceTransportTest, TestBrokenTransport) {
+ // Allow only incoming connections on both ends, which effectively renders
+ // transport unusable.
+ network_settings_ = NetworkSettings(NetworkSettings::NAT_TRAVERSAL_DISABLED);
+
+ InitializeConnection();
+
+ client_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
+ base::Unretained(this)));
+ host_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated,
+ base::Unretained(this)));
+
+ message_loop_.RunUntilIdle();
+
+ // Verify that neither of the two ends of the channel is connected.
+ EXPECT_FALSE(client_socket_);
+ EXPECT_FALSE(host_socket_);
+
+ client_transport_->GetStreamChannelFactory()->CancelChannelCreation(
+ kChannelName);
+ host_transport_->GetStreamChannelFactory()->CancelChannelCreation(
+ kChannelName);
+}
+
+TEST_F(IceTransportTest, TestCancelChannelCreation) {
+ InitializeConnection();
+
+ client_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
+ base::Unretained(this)));
+ client_transport_->GetStreamChannelFactory()->CancelChannelCreation(
+ kChannelName);
+
+ EXPECT_TRUE(!client_socket_.get());
+}
+
+// Verify that we can still connect even when there is a delay in signaling
+// messages delivery.
+TEST_F(IceTransportTest, TestDelayedSignaling) {
+ transport_info_delay_ = base::TimeDelta::FromMilliseconds(100);
+
+ InitializeConnection();
+
+ client_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
+ base::Unretained(this)));
+ host_transport_->GetStreamChannelFactory()->CreateChannel(
+ kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated,
+ base::Unretained(this)));
+
+ WaitUntilConnected();
+
+ StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
+ kMessageSize, kMessages);
+ tester.Start();
+ message_loop_.Run();
+ tester.CheckResults();
+}
+
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc
index ea6c13e..c1338951 100644
--- a/remoting/protocol/jingle_session_unittest.cc
+++ b/remoting/protocol/jingle_session_unittest.cc
@@ -22,8 +22,6 @@
#include "remoting/protocol/ice_transport_factory.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/network_settings.h"
-#include "remoting/protocol/p2p_stream_socket.h"
-#include "remoting/protocol/stream_channel_factory.h"
#include "remoting/signaling/fake_signal_strategy.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -49,28 +47,6 @@ namespace {
const char kHostJid[] = "host1@gmail.com/123";
const char kClientJid[] = "host2@gmail.com/321";
-// Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay
-// between messages (about 1 second for 100 messages).
-const int kMessageSize = 1024;
-const int kMessages = 100;
-const char kChannelName[] = "test_channel";
-
-void QuitCurrentThread() {
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
-}
-
-ACTION(QuitThread) {
- QuitCurrentThread();
-}
-
-ACTION_P(QuitThreadOnCounter, counter) {
- --(*counter);
- EXPECT_GE(*counter, 0);
- if (*counter == 0)
- QuitCurrentThread();
-}
-
class MockSessionManagerListener : public SessionManager::Listener {
public:
MOCK_METHOD2(OnIncomingSession,
@@ -85,11 +61,6 @@ class MockSessionEventHandler : public Session::EventHandler {
const TransportRoute& route));
};
-class MockChannelCreatedCallback {
- public:
- MOCK_METHOD1(OnDone, void(P2PStreamSocket* socket));
-};
-
} // namespace
class JingleSessionTest : public testing::Test {
@@ -112,16 +83,6 @@ class JingleSessionTest : public testing::Test {
host_session_.reset();
}
- void OnClientChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
- client_channel_callback_.OnDone(socket.get());
- client_socket_ = socket.Pass();
- }
-
- void OnHostChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
- host_channel_callback_.OnDone(socket.get());
- host_socket_ = socket.Pass();
- }
-
protected:
void TearDown() override {
CloseSessions();
@@ -130,9 +91,7 @@ class JingleSessionTest : public testing::Test {
}
void CloseSessions() {
- host_socket_.reset();
host_session_.reset();
- client_socket_.reset();
client_session_.reset();
}
@@ -248,26 +207,6 @@ class JingleSessionTest : public testing::Test {
base::RunLoop().RunUntilIdle();
}
- void CreateChannel() {
- client_session_->GetTransport()->GetStreamChannelFactory()->CreateChannel(
- kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
- base::Unretained(this)));
- host_session_->GetTransport()->GetStreamChannelFactory()->CreateChannel(
- kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
- base::Unretained(this)));
-
- int counter = 2;
- ExpectRouteChange(kChannelName);
- EXPECT_CALL(client_channel_callback_, OnDone(_))
- .WillOnce(QuitThreadOnCounter(&counter));
- EXPECT_CALL(host_channel_callback_, OnDone(_))
- .WillOnce(QuitThreadOnCounter(&counter));
- message_loop_->Run();
-
- EXPECT_TRUE(client_socket_.get());
- EXPECT_TRUE(host_socket_.get());
- }
-
void ExpectRouteChange(const std::string& channel_name) {
EXPECT_CALL(host_session_event_handler_,
OnSessionRouteChange(channel_name, _))
@@ -293,12 +232,6 @@ class JingleSessionTest : public testing::Test {
MockSessionEventHandler host_session_event_handler_;
scoped_ptr<Session> client_session_;
MockSessionEventHandler client_session_event_handler_;
-
- MockChannelCreatedCallback client_channel_callback_;
- MockChannelCreatedCallback host_channel_callback_;
-
- scoped_ptr<P2PStreamSocket> client_socket_;
- scoped_ptr<P2PStreamSocket> host_socket_;
};
@@ -366,21 +299,6 @@ TEST_F(JingleSessionTest, ConnectWithBadMultistepAuth) {
InitiateConnection(3, FakeAuthenticator::ACCEPT, true);
}
-// Verify that data can be sent over stream channel.
-TEST_F(JingleSessionTest, TestStreamChannel) {
- CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
- ASSERT_NO_FATAL_FAILURE(
- InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
-
- ASSERT_NO_FATAL_FAILURE(CreateChannel());
-
- StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
- kMessageSize, kMessages);
- tester.Start();
- message_loop_->Run();
- tester.CheckResults();
-}
-
// Verify that incompatible protocol configuration is handled properly.
TEST_F(JingleSessionTest, TestIncompatibleProtocol) {
CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
@@ -484,159 +402,11 @@ TEST_F(JingleSessionTest, DeleteSessionOnAuth) {
base::RunLoop().RunUntilIdle();
}
-// Verify that data can be sent over a multiplexed channel.
-TEST_F(JingleSessionTest, TestMuxStreamChannel) {
- CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
- ASSERT_NO_FATAL_FAILURE(
- InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
-
- client_session_->GetTransport()
- ->GetMultiplexedChannelFactory()
- ->CreateChannel(kChannelName,
- base::Bind(&JingleSessionTest::OnClientChannelCreated,
- base::Unretained(this)));
- host_session_->GetTransport()
- ->GetMultiplexedChannelFactory()
- ->CreateChannel(kChannelName,
- base::Bind(&JingleSessionTest::OnHostChannelCreated,
- base::Unretained(this)));
-
- int counter = 2;
- ExpectRouteChange("mux");
- EXPECT_CALL(client_channel_callback_, OnDone(_))
- .WillOnce(QuitThreadOnCounter(&counter));
- EXPECT_CALL(host_channel_callback_, OnDone(_))
- .WillOnce(QuitThreadOnCounter(&counter));
- message_loop_->Run();
-
- EXPECT_TRUE(client_socket_.get());
- EXPECT_TRUE(host_socket_.get());
-
- StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
- kMessageSize, kMessages);
- tester.Start();
- message_loop_->Run();
- tester.CheckResults();
-}
-
-// Verify that channels are never marked connected if transport is broken.
-TEST_F(JingleSessionTest, TestBrokenTransport) {
- // Allow only incoming connections on both ends, which effectively renders P2P
- // transport unusable.
- network_settings_ = NetworkSettings(NetworkSettings::NAT_TRAVERSAL_DISABLED);
- CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
-
- scoped_ptr<CandidateSessionConfig> config =
- CandidateSessionConfig::CreateDefault();
- config->PreferTransport(ChannelConfig::TRANSPORT_MUX_STREAM);
- client_server_->set_protocol_config(config.Pass());
-
- ASSERT_NO_FATAL_FAILURE(
- InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
-
- EXPECT_CALL(client_channel_callback_, OnDone(_)).Times(0);
- EXPECT_CALL(host_channel_callback_, OnDone(_)).Times(0);
-
- client_session_->GetTransport()
- ->GetMultiplexedChannelFactory()
- ->CreateChannel(kChannelName,
- base::Bind(&JingleSessionTest::OnClientChannelCreated,
- base::Unretained(this)));
- host_session_->GetTransport()->GetMultiplexedChannelFactory()->CreateChannel(
- kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
- base::Unretained(this)));
-
- message_loop_->RunUntilIdle();
-
- // Verify that neither of the two ends of the channel is connected.
- EXPECT_FALSE(client_socket_);
- EXPECT_FALSE(host_socket_);
-
- client_session_->GetTransport()
- ->GetMultiplexedChannelFactory()
- ->CancelChannelCreation(kChannelName);
- host_session_->GetTransport()
- ->GetMultiplexedChannelFactory()
- ->CancelChannelCreation(kChannelName);
-}
-
-// Verify that we can connect channels with multistep auth.
-TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) {
+// Verify that we can connect with multistep authentication.
+TEST_F(JingleSessionTest, TestMultistepAuth) {
CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
ASSERT_NO_FATAL_FAILURE(
InitiateConnection(3, FakeAuthenticator::ACCEPT, false));
-
- ASSERT_NO_FATAL_FAILURE(CreateChannel());
-
- StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
- kMessageSize, kMessages);
- tester.Start();
- message_loop_->Run();
- tester.CheckResults();
-}
-
-// Verify that we shutdown properly when channel authentication fails.
-TEST_F(JingleSessionTest, TestFailedChannelAuth) {
- CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL);
- ASSERT_NO_FATAL_FAILURE(
- InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
-
- client_session_->GetTransport()->GetStreamChannelFactory()->CreateChannel(
- kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
- base::Unretained(this)));
- host_session_->GetTransport()->GetStreamChannelFactory()->CreateChannel(
- kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
- base::Unretained(this)));
-
- // Terminate the message loop when we get rejection notification
- // from the host.
- EXPECT_CALL(host_channel_callback_, OnDone(nullptr))
- .WillOnce(QuitThread());
- ExpectRouteChange(kChannelName);
-
- message_loop_->Run();
-
- client_session_->GetTransport()
- ->GetStreamChannelFactory()
- ->CancelChannelCreation(kChannelName);
-
- EXPECT_TRUE(!host_socket_.get());
-}
-
-TEST_F(JingleSessionTest, TestCancelChannelCreation) {
- CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL);
- ASSERT_NO_FATAL_FAILURE(
- InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
-
- client_session_->GetTransport()
- ->GetStreamChannelFactory()
- ->CreateChannel(kChannelName,
- base::Bind(&JingleSessionTest::OnClientChannelCreated,
- base::Unretained(this)));
- client_session_->GetTransport()
- ->GetStreamChannelFactory()
- ->CancelChannelCreation(kChannelName);
-
- EXPECT_TRUE(!client_socket_.get());
-}
-
-// Verify that we can still connect even when there is a delay in signaling
-// messages delivery.
-TEST_F(JingleSessionTest, TestDelayedSignaling) {
- CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
- ASSERT_NO_FATAL_FAILURE(
- InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
-
- host_signal_strategy_->set_send_delay(
- base::TimeDelta::FromMilliseconds(100));
-
- ASSERT_NO_FATAL_FAILURE(CreateChannel());
-
- StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
- kMessageSize, 1);
- tester.Start();
- message_loop_->Run();
- tester.CheckResults();
}
} // namespace protocol
diff --git a/remoting/remoting_test.gypi b/remoting/remoting_test.gypi
index d0f156b..4ce76d7 100644
--- a/remoting/remoting_test.gypi
+++ b/remoting/remoting_test.gypi
@@ -314,6 +314,7 @@
'protocol/connection_tester.h',
'protocol/content_description_unittest.cc',
'protocol/ice_connection_to_client_unittest.cc',
+ 'protocol/ice_transport_unittest.cc',
'protocol/input_event_tracker_unittest.cc',
'protocol/input_filter_unittest.cc',
'protocol/jingle_messages_unittest.cc',