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