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/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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 EXPECT_EQ("ok-got-stats", ExecuteJavascript("verifyStatsGenerated()", tab)); | 490 EXPECT_EQ("ok-got-stats", ExecuteJavascript("verifyStatsGenerated()", tab)); |
491 } | 491 } |
492 | 492 |
493 std::vector<std::string> WebRtcTestBase::VerifyStatsGeneratedPromise( | 493 std::vector<std::string> WebRtcTestBase::VerifyStatsGeneratedPromise( |
494 content::WebContents* tab) const { | 494 content::WebContents* tab) const { |
495 std::string result = ExecuteJavascript("verifyStatsGeneratedPromise()", tab); | 495 std::string result = ExecuteJavascript("verifyStatsGeneratedPromise()", tab); |
496 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); | 496 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); |
497 return JsonArrayToVectorOfStrings(result.substr(3)); | 497 return JsonArrayToVectorOfStrings(result.substr(3)); |
498 } | 498 } |
499 | 499 |
| 500 void WebRtcTestBase::GetStatsCallbackAndReturn( |
| 501 content::WebContents* tab) const { |
| 502 EXPECT_EQ(ExecuteJavascript("getStatsCallbackAndReturn()", tab), "done"); |
| 503 } |
| 504 |
500 scoped_refptr<content::TestStatsReportDictionary> | 505 scoped_refptr<content::TestStatsReportDictionary> |
501 WebRtcTestBase::GetStatsReportDictionary(content::WebContents* tab) const { | 506 WebRtcTestBase::GetStatsReportDictionary(content::WebContents* tab) const { |
502 std::string result = ExecuteJavascript("getStatsReportDictionary()", tab); | 507 std::string result = ExecuteJavascript("getStatsReportDictionary()", tab); |
503 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); | 508 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); |
504 std::unique_ptr<base::Value> parsed_json = base::JSONReader::Read( | 509 std::unique_ptr<base::Value> parsed_json = base::JSONReader::Read( |
505 result.substr(3)); | 510 result.substr(3)); |
506 base::DictionaryValue* dictionary; | 511 base::DictionaryValue* dictionary; |
507 CHECK(parsed_json); | 512 CHECK(parsed_json); |
508 CHECK(parsed_json->GetAsDictionary(&dictionary)); | 513 CHECK(parsed_json->GetAsDictionary(&dictionary)); |
509 ignore_result(parsed_json.release()); | 514 ignore_result(parsed_json.release()); |
510 return scoped_refptr<content::TestStatsReportDictionary>( | 515 return scoped_refptr<content::TestStatsReportDictionary>( |
511 new content::TestStatsReportDictionary( | 516 new content::TestStatsReportDictionary( |
512 std::unique_ptr<base::DictionaryValue>(dictionary))); | 517 std::unique_ptr<base::DictionaryValue>(dictionary))); |
513 } | 518 } |
514 | 519 |
| 520 void WebRtcTestBase::GetStatsAndReturn(content::WebContents* tab) const { |
| 521 EXPECT_EQ(ExecuteJavascript("getStatsAndReturn()", tab), "done"); |
| 522 } |
| 523 |
515 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes( | 524 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes( |
516 content::WebContents* tab) const { | 525 content::WebContents* tab) const { |
517 return JsonArrayToVectorOfStrings( | 526 return JsonArrayToVectorOfStrings( |
518 ExecuteJavascript("getWhitelistedStatsTypes()", tab)); | 527 ExecuteJavascript("getWhitelistedStatsTypes()", tab)); |
519 } | 528 } |
520 | 529 |
521 void WebRtcTestBase::SetDefaultAudioCodec( | 530 void WebRtcTestBase::SetDefaultAudioCodec( |
522 content::WebContents* tab, | 531 content::WebContents* tab, |
523 const std::string& audio_codec) const { | 532 const std::string& audio_codec) const { |
524 EXPECT_EQ("ok", ExecuteJavascript( | 533 EXPECT_EQ("ok", ExecuteJavascript( |
525 "setDefaultAudioCodec('" + audio_codec + "')", tab)); | 534 "setDefaultAudioCodec('" + audio_codec + "')", tab)); |
526 } | 535 } |
527 | 536 |
528 void WebRtcTestBase::SetDefaultVideoCodec( | 537 void WebRtcTestBase::SetDefaultVideoCodec( |
529 content::WebContents* tab, | 538 content::WebContents* tab, |
530 const std::string& video_codec) const { | 539 const std::string& video_codec) const { |
531 EXPECT_EQ("ok", ExecuteJavascript( | 540 EXPECT_EQ("ok", ExecuteJavascript( |
532 "setDefaultVideoCodec('" + video_codec + "')", tab)); | 541 "setDefaultVideoCodec('" + video_codec + "')", tab)); |
533 } | 542 } |
534 | 543 |
535 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const { | 544 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const { |
536 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab)); | 545 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab)); |
537 } | 546 } |
OLD | NEW |