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

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

Issue 2534633002: Preparation CL for WebRTC performance test using promise-based getStats (Closed)
Patch Set: 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 EXPECT_EQ("ok-got-stats", ExecuteJavascript("verifyStatsGenerated()", tab)); 487 EXPECT_EQ("ok-got-stats", ExecuteJavascript("verifyStatsGenerated()", tab));
488 } 488 }
489 489
490 std::vector<std::string> WebRtcTestBase::VerifyStatsGeneratedPromise( 490 std::vector<std::string> WebRtcTestBase::VerifyStatsGeneratedPromise(
491 content::WebContents* tab) const { 491 content::WebContents* tab) const {
492 std::string result = ExecuteJavascript("verifyStatsGeneratedPromise()", tab); 492 std::string result = ExecuteJavascript("verifyStatsGeneratedPromise()", tab);
493 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); 493 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE));
494 return JsonArrayToVectorOfStrings(result.substr(3)); 494 return JsonArrayToVectorOfStrings(result.substr(3));
495 } 495 }
496 496
497 scoped_refptr<content::RTCStatsReportDictionary>
498 WebRtcTestBase::GetStatsReportDictionary(content::WebContents* tab) const {
499 std::string result = ExecuteJavascript("getStatsAsDictionary()", tab);
hbos_chromium 2016/11/30 11:30:56 nit: I'll rename this to getStatsReportDictionary
500 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE));
501 std::unique_ptr<base::Value> parsed_json = base::JSONReader::Read(
502 result.substr(3));
503 base::DictionaryValue* dictionary;
504 CHECK(parsed_json);
505 CHECK(parsed_json->GetAsDictionary(&dictionary));
506 ignore_result(parsed_json.release());
507 return scoped_refptr<content::RTCStatsReportDictionary>(
508 new content::RTCStatsReportDictionary(
509 std::unique_ptr<base::DictionaryValue>(dictionary)));
510 }
511
497 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes( 512 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes(
498 content::WebContents* tab) const { 513 content::WebContents* tab) const {
499 return JsonArrayToVectorOfStrings( 514 return JsonArrayToVectorOfStrings(
500 ExecuteJavascript("getWhitelistedStatsTypes()", tab)); 515 ExecuteJavascript("getWhitelistedStatsTypes()", tab));
501 } 516 }
502 517
503 void WebRtcTestBase::SetDefaultVideoCodec( 518 void WebRtcTestBase::SetDefaultVideoCodec(
504 content::WebContents* tab, 519 content::WebContents* tab,
505 const std::string& video_codec) const { 520 const std::string& video_codec) const {
506 EXPECT_EQ("ok-forced", 521 EXPECT_EQ("ok-forced",
507 ExecuteJavascript("forceVideoCodec('" + video_codec + "')", tab)); 522 ExecuteJavascript("forceVideoCodec('" + video_codec + "')", tab));
508 } 523 }
509 524
510 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const { 525 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const {
511 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab)); 526 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab));
512 } 527 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698