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

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

Issue 2545553003: WebRtcStatsPerfBrowserTest added, a perf test using the new getStats (Closed)
Patch Set: Addressed nits, rebase, default initialize Created 4 years 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/webrtc_browsertest_base.h" 5 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 "failed-with-error-PermissionDeniedError"; 52 "failed-with-error-PermissionDeniedError";
53 const char WebRtcTestBase::kFailedWithPermissionDismissedError[] = 53 const char WebRtcTestBase::kFailedWithPermissionDismissedError[] =
54 "failed-with-error-PermissionDismissedError"; 54 "failed-with-error-PermissionDismissedError";
55 const char WebRtcTestBase::kAudioVideoCallConstraints360p[] = 55 const char WebRtcTestBase::kAudioVideoCallConstraints360p[] =
56 "{audio: true, video: {mandatory: {minWidth: 640, maxWidth: 640, " 56 "{audio: true, video: {mandatory: {minWidth: 640, maxWidth: 640, "
57 " minHeight: 360, maxHeight: 360}}}"; 57 " minHeight: 360, maxHeight: 360}}}";
58 const char WebRtcTestBase::kAudioVideoCallConstraints720p[] = 58 const char WebRtcTestBase::kAudioVideoCallConstraints720p[] =
59 "{audio: true, video: {mandatory: {minWidth: 1280, maxWidth: 1280, " 59 "{audio: true, video: {mandatory: {minWidth: 1280, maxWidth: 1280, "
60 " minHeight: 720, maxHeight: 720}}}"; 60 " minHeight: 720, maxHeight: 720}}}";
61 const char WebRtcTestBase::kUseDefaultCertKeygen[] = "null"; 61 const char WebRtcTestBase::kUseDefaultCertKeygen[] = "null";
62 const char WebRtcTestBase::kUseDefaultAudioCodec[] = "";
62 const char WebRtcTestBase::kUseDefaultVideoCodec[] = ""; 63 const char WebRtcTestBase::kUseDefaultVideoCodec[] = "";
63 64
64 namespace { 65 namespace {
65 66
66 base::LazyInstance<bool> hit_javascript_errors_ = 67 base::LazyInstance<bool> hit_javascript_errors_ =
67 LAZY_INSTANCE_INITIALIZER; 68 LAZY_INSTANCE_INITIALIZER;
68 69
69 // Intercepts all log messages. We always attach this handler but only look at 70 // Intercepts all log messages. We always attach this handler but only look at
70 // the results if the test requests so. Note that this will only work if the 71 // the results if the test requests so. Note that this will only work if the
71 // WebrtcTestBase-inheriting test cases do not run in parallel (if they did they 72 // WebrtcTestBase-inheriting test cases do not run in parallel (if they did they
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 content::WebContents* to_tab) const { 373 content::WebContents* to_tab) const {
373 std::string javascript = 374 std::string javascript =
374 base::StringPrintf("receiveOfferFromPeer('%s', {})", local_offer.c_str()); 375 base::StringPrintf("receiveOfferFromPeer('%s', {})", local_offer.c_str());
375 std::string response = ExecuteJavascript(javascript, to_tab); 376 std::string response = ExecuteJavascript(javascript, to_tab);
376 EXPECT_EQ("ok-", response.substr(0, 3)) 377 EXPECT_EQ("ok-", response.substr(0, 3))
377 << "Receiving peer failed to receive offer and create answer: " 378 << "Receiving peer failed to receive offer and create answer: "
378 << response; 379 << response;
379 380
380 std::string answer = response.substr(3); 381 std::string answer = response.substr(3);
381 response = ExecuteJavascript( 382 response = ExecuteJavascript(
382 base::StringPrintf("verifyDefaultVideoCodec('%s')", answer.c_str()), 383 base::StringPrintf("verifyDefaultCodecs('%s')", answer.c_str()),
383 to_tab); 384 to_tab);
384 EXPECT_EQ("ok-", response.substr(0, 3)) 385 EXPECT_EQ("ok-", response.substr(0, 3))
385 << "Receiving peer failed to verify default codec: " << response; 386 << "Receiving peer failed to verify default codec: " << response;
386 return answer; 387 return answer;
387 } 388 }
388 389
389 void WebRtcTestBase::ReceiveAnswer(const std::string& answer, 390 void WebRtcTestBase::ReceiveAnswer(const std::string& answer,
390 content::WebContents* from_tab) const { 391 content::WebContents* from_tab) const {
391 ASSERT_EQ( 392 ASSERT_EQ(
392 "ok-accepted-answer", 393 "ok-accepted-answer",
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 new content::TestStatsReportDictionary( 511 new content::TestStatsReportDictionary(
511 std::unique_ptr<base::DictionaryValue>(dictionary))); 512 std::unique_ptr<base::DictionaryValue>(dictionary)));
512 } 513 }
513 514
514 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes( 515 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes(
515 content::WebContents* tab) const { 516 content::WebContents* tab) const {
516 return JsonArrayToVectorOfStrings( 517 return JsonArrayToVectorOfStrings(
517 ExecuteJavascript("getWhitelistedStatsTypes()", tab)); 518 ExecuteJavascript("getWhitelistedStatsTypes()", tab));
518 } 519 }
519 520
521 void WebRtcTestBase::SetDefaultAudioCodec(
522 content::WebContents* tab,
523 const std::string& audio_codec) const {
524 EXPECT_EQ("ok", ExecuteJavascript(
525 "setDefaultAudioCodec('" + audio_codec + "')", tab));
526 }
527
520 void WebRtcTestBase::SetDefaultVideoCodec( 528 void WebRtcTestBase::SetDefaultVideoCodec(
521 content::WebContents* tab, 529 content::WebContents* tab,
522 const std::string& video_codec) const { 530 const std::string& video_codec) const {
523 EXPECT_EQ("ok-forced", 531 EXPECT_EQ("ok", ExecuteJavascript(
524 ExecuteJavascript("forceVideoCodec('" + video_codec + "')", tab)); 532 "setDefaultVideoCodec('" + video_codec + "')", tab));
525 } 533 }
526 534
527 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const { 535 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const {
528 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab)); 536 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab));
529 } 537 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698