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