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

Side by Side Diff: chrome/browser/media/webrtc_browsertest_base.cc

Issue 2195293002: Revert of Adds a WebRTC browser_test with opus dtx enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 void WebRtcTestBase::SetupPeerconnectionWithCertificateWithoutLocalStream( 330 void WebRtcTestBase::SetupPeerconnectionWithCertificateWithoutLocalStream(
331 content::WebContents* tab, 331 content::WebContents* tab,
332 const std::string& certificate) const { 332 const std::string& certificate) const {
333 std::string javascript = base::StringPrintf( 333 std::string javascript = base::StringPrintf(
334 "preparePeerConnectionWithCertificate(%s)", certificate.c_str()); 334 "preparePeerConnectionWithCertificate(%s)", certificate.c_str());
335 EXPECT_EQ("ok-peerconnection-created", ExecuteJavascript(javascript, tab)); 335 EXPECT_EQ("ok-peerconnection-created", ExecuteJavascript(javascript, tab));
336 } 336 }
337 337
338 std::string WebRtcTestBase::CreateLocalOffer( 338 std::string WebRtcTestBase::CreateLocalOffer(
339 content::WebContents* from_tab) const { 339 content::WebContents* from_tab,
340 std::string response = ExecuteJavascript("createLocalOffer({})", from_tab); 340 std::string default_video_codec) const {
341 if (default_video_codec.empty())
342 default_video_codec = "null";
343 else
344 default_video_codec = "'" + default_video_codec + "'";
345 std::string javascript = base::StringPrintf(
346 "createLocalOffer({}, %s)", default_video_codec.c_str());
347 std::string response = ExecuteJavascript(javascript, from_tab);
341 EXPECT_EQ("ok-", response.substr(0, 3)) << "Failed to create local offer: " 348 EXPECT_EQ("ok-", response.substr(0, 3)) << "Failed to create local offer: "
342 << response; 349 << response;
343 350
344 std::string local_offer = response.substr(3); 351 std::string local_offer = response.substr(3);
345 return local_offer; 352 return local_offer;
346 } 353 }
347 354
348 std::string WebRtcTestBase::CreateAnswer(std::string local_offer, 355 std::string WebRtcTestBase::CreateAnswer(
349 content::WebContents* to_tab) const { 356 std::string local_offer,
357 content::WebContents* to_tab,
358 std::string default_video_codec) const {
350 std::string javascript = 359 std::string javascript =
351 base::StringPrintf("receiveOfferFromPeer('%s', {})", local_offer.c_str()); 360 base::StringPrintf("receiveOfferFromPeer('%s', {})", local_offer.c_str());
352 std::string response = ExecuteJavascript(javascript, to_tab); 361 std::string response = ExecuteJavascript(javascript, to_tab);
353 EXPECT_EQ("ok-", response.substr(0, 3)) 362 EXPECT_EQ("ok-", response.substr(0, 3))
354 << "Receiving peer failed to receive offer and create answer: " 363 << "Receiving peer failed to receive offer and create answer: "
355 << response; 364 << response;
356 365
357 std::string answer = response.substr(3); 366 std::string answer = response.substr(3);
358 response = ExecuteJavascript( 367
359 base::StringPrintf("verifyDefaultVideoCodec('%s')", answer.c_str()), 368 if (!default_video_codec.empty()) {
360 to_tab); 369 response = ExecuteJavascript(
361 EXPECT_EQ("ok-", response.substr(0, 3)) 370 base::StringPrintf("verifyDefaultVideoCodec('%s', '%s')",
362 << "Receiving peer failed to verify default codec: " << response; 371 answer.c_str(), default_video_codec.c_str()),
372 to_tab);
373 EXPECT_EQ("ok-", response.substr(0, 3))
374 << "Receiving peer failed to verify default codec: "
375 << response;
376 }
377
363 return answer; 378 return answer;
364 } 379 }
365 380
366 void WebRtcTestBase::ReceiveAnswer(const std::string& answer, 381 void WebRtcTestBase::ReceiveAnswer(const std::string& answer,
367 content::WebContents* from_tab) const { 382 content::WebContents* from_tab) const {
368 ASSERT_EQ( 383 ASSERT_EQ(
369 "ok-accepted-answer", 384 "ok-accepted-answer",
370 ExecuteJavascript( 385 ExecuteJavascript(
371 base::StringPrintf("receiveAnswerFromPeer('%s')", answer.c_str()), 386 base::StringPrintf("receiveAnswerFromPeer('%s')", answer.c_str()),
372 from_tab)); 387 from_tab));
373 } 388 }
374 389
375 void WebRtcTestBase::GatherAndSendIceCandidates( 390 void WebRtcTestBase::GatherAndSendIceCandidates(
376 content::WebContents* from_tab, 391 content::WebContents* from_tab,
377 content::WebContents* to_tab) const { 392 content::WebContents* to_tab) const {
378 std::string ice_candidates = 393 std::string ice_candidates =
379 ExecuteJavascript("getAllIceCandidates()", from_tab); 394 ExecuteJavascript("getAllIceCandidates()", from_tab);
380 395
381 EXPECT_EQ("ok-received-candidates", ExecuteJavascript( 396 EXPECT_EQ("ok-received-candidates", ExecuteJavascript(
382 base::StringPrintf("receiveIceCandidates('%s')", ice_candidates.c_str()), 397 base::StringPrintf("receiveIceCandidates('%s')", ice_candidates.c_str()),
383 to_tab)); 398 to_tab));
384 } 399 }
385 400
386 void WebRtcTestBase::NegotiateCall(content::WebContents* from_tab, 401 void WebRtcTestBase::NegotiateCall(content::WebContents* from_tab,
387 content::WebContents* to_tab) const { 402 content::WebContents* to_tab,
388 std::string local_offer = CreateLocalOffer(from_tab); 403 const std::string& video_codec) const {
389 std::string answer = CreateAnswer(local_offer, to_tab); 404 std::string local_offer = CreateLocalOffer(from_tab, video_codec);
405 std::string answer = CreateAnswer(local_offer, to_tab, video_codec);
390 ReceiveAnswer(answer, from_tab); 406 ReceiveAnswer(answer, from_tab);
391 407
392 // Send all ICE candidates (wait for gathering to finish if necessary). 408 // Send all ICE candidates (wait for gathering to finish if necessary).
393 GatherAndSendIceCandidates(to_tab, from_tab); 409 GatherAndSendIceCandidates(to_tab, from_tab);
394 GatherAndSendIceCandidates(from_tab, to_tab); 410 GatherAndSendIceCandidates(from_tab, to_tab);
395 } 411 }
396 412
397 void WebRtcTestBase::HangUp(content::WebContents* from_tab) const { 413 void WebRtcTestBase::HangUp(content::WebContents* from_tab) const {
398 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab)); 414 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab));
399 } 415 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 478 }
463 479
464 void WebRtcTestBase::GenerateAndCloneCertificate( 480 void WebRtcTestBase::GenerateAndCloneCertificate(
465 content::WebContents* tab, const std::string& keygen_algorithm) const { 481 content::WebContents* tab, const std::string& keygen_algorithm) const {
466 std::string javascript = base::StringPrintf( 482 std::string javascript = base::StringPrintf(
467 "generateAndCloneCertificate(%s)", keygen_algorithm.c_str()); 483 "generateAndCloneCertificate(%s)", keygen_algorithm.c_str());
468 std::string response = ExecuteJavascript(javascript, tab); 484 std::string response = ExecuteJavascript(javascript, tab);
469 EXPECT_EQ("ok-generated-and-cloned", response) << "Failed to generate and " 485 EXPECT_EQ("ok-generated-and-cloned", response) << "Failed to generate and "
470 "clone certificate: " << response; 486 "clone certificate: " << response;
471 } 487 }
472
473 void WebRtcTestBase::SetDefaultVideoCodec(
474 content::WebContents* tab,
475 const std::string& video_codec) const {
476 EXPECT_EQ("ok-forced",
477 ExecuteJavascript("forceVideoCodec('" + video_codec + "')", tab));
478 }
479
480 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const {
481 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab));
482 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_base.h ('k') | chrome/browser/media/webrtc_browsertest_perf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698