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

Side by Side Diff: remoting/protocol/webrtc_transport_unittest.cc

Issue 1843333002: Fix WebRTC transport to normalize SDP messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « remoting/protocol/webrtc_transport.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/protocol/webrtc_transport.h" 5 #include "remoting/protocol/webrtc_transport.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/string_util.h"
12 #include "jingle/glue/thread_wrapper.h" 13 #include "jingle/glue/thread_wrapper.h"
13 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
14 #include "net/url_request/url_request_context_getter.h" 15 #include "net/url_request/url_request_context_getter.h"
15 #include "remoting/protocol/connection_tester.h" 16 #include "remoting/protocol/connection_tester.h"
16 #include "remoting/protocol/fake_authenticator.h" 17 #include "remoting/protocol/fake_authenticator.h"
17 #include "remoting/protocol/message_channel_factory.h" 18 #include "remoting/protocol/message_channel_factory.h"
18 #include "remoting/protocol/message_pipe.h" 19 #include "remoting/protocol/message_pipe.h"
19 #include "remoting/protocol/network_settings.h" 20 #include "remoting/protocol/network_settings.h"
20 #include "remoting/protocol/transport_context.h" 21 #include "remoting/protocol/transport_context.h"
21 #include "remoting/signaling/fake_signal_strategy.h" 22 #include "remoting/signaling/fake_signal_strategy.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void TearDown() override { 88 void TearDown() override {
88 run_loop_.reset(); 89 run_loop_.reset();
89 client_message_pipe_.reset(); 90 client_message_pipe_.reset();
90 client_transport_.reset(); 91 client_transport_.reset();
91 host_message_pipe_.reset(); 92 host_message_pipe_.reset();
92 host_transport_.reset(); 93 host_transport_.reset();
93 base::RunLoop().RunUntilIdle(); 94 base::RunLoop().RunUntilIdle();
94 } 95 }
95 96
96 void ProcessTransportInfo(scoped_ptr<WebrtcTransport>* target_transport, 97 void ProcessTransportInfo(scoped_ptr<WebrtcTransport>* target_transport,
98 bool normalize_line_endings,
97 scoped_ptr<buzz::XmlElement> transport_info) { 99 scoped_ptr<buzz::XmlElement> transport_info) {
98 ASSERT_TRUE(target_transport); 100 ASSERT_TRUE(target_transport);
101
102 // Reformat the message to normalize line endings by removing CR symbol.
103 if (normalize_line_endings) {
104 std::string xml = transport_info->Str();
105 base::ReplaceChars(xml, "\r", std::string(), &xml);
106 transport_info.reset(buzz::XmlElement::ForStr(xml));
107 }
108
99 EXPECT_TRUE( 109 EXPECT_TRUE(
100 (*target_transport)->ProcessTransportInfo(transport_info.get())); 110 (*target_transport)->ProcessTransportInfo(transport_info.get()));
101 } 111 }
102 112
103 void InitializeConnection() { 113 void InitializeConnection() {
104 host_transport_.reset( 114 host_transport_.reset(
105 new WebrtcTransport(jingle_glue::JingleThreadWrapper::current(), 115 new WebrtcTransport(jingle_glue::JingleThreadWrapper::current(),
106 TransportContext::ForTests(TransportRole::SERVER), 116 TransportContext::ForTests(TransportRole::SERVER),
107 &host_event_handler_)); 117 &host_event_handler_));
108 host_authenticator_.reset(new FakeAuthenticator( 118 host_authenticator_.reset(new FakeAuthenticator(
(...skipping 17 matching lines...) Expand all
126 base::Bind(&WebrtcTransportTest::OnSessionError, base::Unretained(this), 136 base::Bind(&WebrtcTransportTest::OnSessionError, base::Unretained(this),
127 TransportRole::SERVER)); 137 TransportRole::SERVER));
128 client_event_handler_.set_error_callback( 138 client_event_handler_.set_error_callback(
129 base::Bind(&WebrtcTransportTest::OnSessionError, base::Unretained(this), 139 base::Bind(&WebrtcTransportTest::OnSessionError, base::Unretained(this),
130 TransportRole::CLIENT)); 140 TransportRole::CLIENT));
131 141
132 // Start both transports. 142 // Start both transports.
133 host_transport_->Start( 143 host_transport_->Start(
134 host_authenticator_.get(), 144 host_authenticator_.get(),
135 base::Bind(&WebrtcTransportTest::ProcessTransportInfo, 145 base::Bind(&WebrtcTransportTest::ProcessTransportInfo,
136 base::Unretained(this), &client_transport_)); 146 base::Unretained(this), &client_transport_, true));
137 client_transport_->Start( 147 client_transport_->Start(
138 client_authenticator_.get(), 148 client_authenticator_.get(),
139 base::Bind(&WebrtcTransportTest::ProcessTransportInfo, 149 base::Bind(&WebrtcTransportTest::ProcessTransportInfo,
140 base::Unretained(this), &host_transport_)); 150 base::Unretained(this), &host_transport_, false));
141 } 151 }
142 152
143 void WaitUntilConnected() { 153 void WaitUntilConnected() {
144 int counter = 2; 154 int counter = 2;
145 host_event_handler_.set_connected_callback( 155 host_event_handler_.set_connected_callback(
146 base::Bind(&WebrtcTransportTest::QuitRunLoopOnCounter, 156 base::Bind(&WebrtcTransportTest::QuitRunLoopOnCounter,
147 base::Unretained(this), &counter)); 157 base::Unretained(this), &counter));
148 client_event_handler_.set_connected_callback( 158 client_event_handler_.set_connected_callback(
149 base::Bind(&WebrtcTransportTest::QuitRunLoopOnCounter, 159 base::Bind(&WebrtcTransportTest::QuitRunLoopOnCounter,
150 base::Unretained(this), &counter)); 160 base::Unretained(this), &counter));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 run_loop_.reset(new base::RunLoop()); 319 run_loop_.reset(new base::RunLoop());
310 run_loop_->Run(); 320 run_loop_->Run();
311 321
312 // Check that OnSessionError() has been called. 322 // Check that OnSessionError() has been called.
313 EXPECT_EQ(CHANNEL_CONNECTION_ERROR, host_error_); 323 EXPECT_EQ(CHANNEL_CONNECTION_ERROR, host_error_);
314 EXPECT_FALSE(host_transport_); 324 EXPECT_FALSE(host_transport_);
315 } 325 }
316 326
317 } // namespace protocol 327 } // namespace protocol
318 } // namespace remoting 328 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_transport.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698