Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/media/webrtc_browsertest_base.h" | 5 #include "chrome/browser/media/webrtc_browsertest_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 EXPECT_EQ("ok-added", ExecuteJavascript("addLocalStream()", tab)); | 308 EXPECT_EQ("ok-added", ExecuteJavascript("addLocalStream()", tab)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void WebRtcTestBase::SetupPeerconnectionWithoutLocalStream( | 311 void WebRtcTestBase::SetupPeerconnectionWithoutLocalStream( |
| 312 content::WebContents* tab) const { | 312 content::WebContents* tab) const { |
| 313 EXPECT_EQ("ok-peerconnection-created", | 313 EXPECT_EQ("ok-peerconnection-created", |
| 314 ExecuteJavascript("preparePeerConnection()", tab)); | 314 ExecuteJavascript("preparePeerConnection()", tab)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 std::string WebRtcTestBase::CreateLocalOffer( | 317 std::string WebRtcTestBase::CreateLocalOffer( |
| 318 content::WebContents* from_tab) const { | 318 content::WebContents* from_tab, |
| 319 std::string response = ExecuteJavascript("createLocalOffer({})", from_tab); | 319 std::string default_video_codec) const { |
| 320 if (default_video_codec != "") | |
|
phoglund_chromium
2016/02/01 14:20:44
nit:
if (default_video_codec.empty())
default_vi
hbos_chromium
2016/02/02 14:07:19
Done.
| |
| 321 default_video_codec = "'" + default_video_codec + "'"; | |
| 322 else | |
| 323 default_video_codec = "null"; | |
| 324 std::string javascript = base::StringPrintf( | |
| 325 "createLocalOffer({}, %s)", default_video_codec.c_str()); | |
| 326 std::string response = ExecuteJavascript(javascript, from_tab); | |
| 320 EXPECT_EQ("ok-", response.substr(0, 3)) << "Failed to create local offer: " | 327 EXPECT_EQ("ok-", response.substr(0, 3)) << "Failed to create local offer: " |
| 321 << response; | 328 << response; |
| 322 | 329 |
| 323 std::string local_offer = response.substr(3); | 330 std::string local_offer = response.substr(3); |
| 324 return local_offer; | 331 return local_offer; |
| 325 } | 332 } |
| 326 | 333 |
| 327 std::string WebRtcTestBase::CreateAnswer(std::string local_offer, | 334 std::string WebRtcTestBase::CreateAnswer( |
| 328 content::WebContents* to_tab) const { | 335 std::string local_offer, |
| 336 content::WebContents* to_tab, | |
| 337 std::string default_video_codec) const { | |
| 338 if (default_video_codec != "") | |
|
phoglund_chromium
2016/02/01 14:20:44
Nit: same here
hbos_chromium
2016/02/02 14:07:19
Done.
| |
| 339 default_video_codec = "'" + default_video_codec + "'"; | |
| 340 else | |
| 341 default_video_codec = "null"; | |
| 329 std::string javascript = | 342 std::string javascript = |
| 330 base::StringPrintf("receiveOfferFromPeer('%s', {})", local_offer.c_str()); | 343 base::StringPrintf("receiveOfferFromPeer('%s', {}, %s)", |
| 344 local_offer.c_str(), | |
| 345 default_video_codec.c_str()); | |
| 331 std::string response = ExecuteJavascript(javascript, to_tab); | 346 std::string response = ExecuteJavascript(javascript, to_tab); |
| 332 EXPECT_EQ("ok-", response.substr(0, 3)) | 347 EXPECT_EQ("ok-", response.substr(0, 3)) |
| 333 << "Receiving peer failed to receive offer and create answer: " | 348 << "Receiving peer failed to receive offer and create answer: " |
| 334 << response; | 349 << response; |
| 335 | 350 |
| 336 std::string answer = response.substr(3); | 351 std::string answer = response.substr(3); |
| 337 return answer; | 352 return answer; |
| 338 } | 353 } |
| 339 | 354 |
| 340 void WebRtcTestBase::ReceiveAnswer(const std::string& answer, | 355 void WebRtcTestBase::ReceiveAnswer(const std::string& answer, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 351 content::WebContents* to_tab) const { | 366 content::WebContents* to_tab) const { |
| 352 std::string ice_candidates = | 367 std::string ice_candidates = |
| 353 ExecuteJavascript("getAllIceCandidates()", from_tab); | 368 ExecuteJavascript("getAllIceCandidates()", from_tab); |
| 354 | 369 |
| 355 EXPECT_EQ("ok-received-candidates", ExecuteJavascript( | 370 EXPECT_EQ("ok-received-candidates", ExecuteJavascript( |
| 356 base::StringPrintf("receiveIceCandidates('%s')", ice_candidates.c_str()), | 371 base::StringPrintf("receiveIceCandidates('%s')", ice_candidates.c_str()), |
| 357 to_tab)); | 372 to_tab)); |
| 358 } | 373 } |
| 359 | 374 |
| 360 void WebRtcTestBase::NegotiateCall(content::WebContents* from_tab, | 375 void WebRtcTestBase::NegotiateCall(content::WebContents* from_tab, |
| 361 content::WebContents* to_tab) const { | 376 content::WebContents* to_tab, |
| 362 std::string local_offer = CreateLocalOffer(from_tab); | 377 const std::string& video_codec) const { |
| 363 std::string answer = CreateAnswer(local_offer, to_tab); | 378 std::string local_offer = CreateLocalOffer(from_tab, video_codec); |
| 379 std::string answer = CreateAnswer(local_offer, to_tab, video_codec); | |
| 364 ReceiveAnswer(answer, from_tab); | 380 ReceiveAnswer(answer, from_tab); |
| 365 | 381 |
| 366 // Send all ICE candidates (wait for gathering to finish if necessary). | 382 // Send all ICE candidates (wait for gathering to finish if necessary). |
| 367 GatherAndSendIceCandidates(to_tab, from_tab); | 383 GatherAndSendIceCandidates(to_tab, from_tab); |
| 368 GatherAndSendIceCandidates(from_tab, to_tab); | 384 GatherAndSendIceCandidates(from_tab, to_tab); |
| 369 } | 385 } |
| 370 | 386 |
| 371 void WebRtcTestBase::HangUp(content::WebContents* from_tab) const { | 387 void WebRtcTestBase::HangUp(content::WebContents* from_tab) const { |
| 372 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab)); | 388 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab)); |
| 373 } | 389 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 #endif | 433 #endif |
| 418 } | 434 } |
| 419 | 435 |
| 420 bool WebRtcTestBase::OnWin8() const { | 436 bool WebRtcTestBase::OnWin8() const { |
| 421 #if defined(OS_WIN) | 437 #if defined(OS_WIN) |
| 422 return base::win::GetVersion() > base::win::VERSION_WIN7; | 438 return base::win::GetVersion() > base::win::VERSION_WIN7; |
| 423 #else | 439 #else |
| 424 return false; | 440 return false; |
| 425 #endif | 441 #endif |
| 426 } | 442 } |
| OLD | NEW |