| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/values.h" | |
| 15 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 16 #include "chrome/browser/media/webrtc/webrtc_browsertest_common.h" | 15 #include "chrome/browser/media/webrtc/webrtc_browsertest_common.h" |
| 17 #include "chrome/browser/permissions/permission_request_manager.h" | 16 #include "chrome/browser/permissions/permission_request_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
| 23 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 24 | 23 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 EXPECT_EQ("ok-got-stats", ExecuteJavascript("verifyStatsGenerated()", tab)); | 487 EXPECT_EQ("ok-got-stats", ExecuteJavascript("verifyStatsGenerated()", tab)); |
| 489 } | 488 } |
| 490 | 489 |
| 491 std::vector<std::string> WebRtcTestBase::VerifyStatsGeneratedPromise( | 490 std::vector<std::string> WebRtcTestBase::VerifyStatsGeneratedPromise( |
| 492 content::WebContents* tab) const { | 491 content::WebContents* tab) const { |
| 493 std::string result = ExecuteJavascript("verifyStatsGeneratedPromise()", tab); | 492 std::string result = ExecuteJavascript("verifyStatsGeneratedPromise()", tab); |
| 494 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); | 493 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); |
| 495 return JsonArrayToVectorOfStrings(result.substr(3)); | 494 return JsonArrayToVectorOfStrings(result.substr(3)); |
| 496 } | 495 } |
| 497 | 496 |
| 498 scoped_refptr<content::TestStatsReportDictionary> | |
| 499 WebRtcTestBase::GetStatsReportDictionary(content::WebContents* tab) const { | |
| 500 std::string result = ExecuteJavascript("getStatsReportDictionary()", tab); | |
| 501 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); | |
| 502 std::unique_ptr<base::Value> parsed_json = base::JSONReader::Read( | |
| 503 result.substr(3)); | |
| 504 base::DictionaryValue* dictionary; | |
| 505 CHECK(parsed_json); | |
| 506 CHECK(parsed_json->GetAsDictionary(&dictionary)); | |
| 507 ignore_result(parsed_json.release()); | |
| 508 return scoped_refptr<content::TestStatsReportDictionary>( | |
| 509 new content::TestStatsReportDictionary( | |
| 510 std::unique_ptr<base::DictionaryValue>(dictionary))); | |
| 511 } | |
| 512 | |
| 513 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes( | 497 std::vector<std::string> WebRtcTestBase::GetWhitelistedStatsTypes( |
| 514 content::WebContents* tab) const { | 498 content::WebContents* tab) const { |
| 515 return JsonArrayToVectorOfStrings( | 499 return JsonArrayToVectorOfStrings( |
| 516 ExecuteJavascript("getWhitelistedStatsTypes()", tab)); | 500 ExecuteJavascript("getWhitelistedStatsTypes()", tab)); |
| 517 } | 501 } |
| 518 | 502 |
| 519 void WebRtcTestBase::SetDefaultVideoCodec( | 503 void WebRtcTestBase::SetDefaultVideoCodec( |
| 520 content::WebContents* tab, | 504 content::WebContents* tab, |
| 521 const std::string& video_codec) const { | 505 const std::string& video_codec) const { |
| 522 EXPECT_EQ("ok-forced", | 506 EXPECT_EQ("ok-forced", |
| 523 ExecuteJavascript("forceVideoCodec('" + video_codec + "')", tab)); | 507 ExecuteJavascript("forceVideoCodec('" + video_codec + "')", tab)); |
| 524 } | 508 } |
| 525 | 509 |
| 526 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const { | 510 void WebRtcTestBase::EnableOpusDtx(content::WebContents* tab) const { |
| 527 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab)); | 511 EXPECT_EQ("ok-forced", ExecuteJavascript("forceOpusDtx()", tab)); |
| 528 } | 512 } |
| OLD | NEW |