Chromium Code Reviews| 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_browsertest_base.h" | 5 #include "chrome/browser/media/webrtc_browsertest_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 const char WebRtcTestBase::kFailedWithPermissionDeniedError[] = | 48 const char WebRtcTestBase::kFailedWithPermissionDeniedError[] = |
| 49 "failed-with-error-PermissionDeniedError"; | 49 "failed-with-error-PermissionDeniedError"; |
| 50 const char WebRtcTestBase::kFailedWithPermissionDismissedError[] = | 50 const char WebRtcTestBase::kFailedWithPermissionDismissedError[] = |
| 51 "failed-with-error-PermissionDismissedError"; | 51 "failed-with-error-PermissionDismissedError"; |
| 52 const char WebRtcTestBase::kAudioVideoCallConstraints360p[] = | 52 const char WebRtcTestBase::kAudioVideoCallConstraints360p[] = |
| 53 "{audio: true, video: {mandatory: {minWidth: 640, maxWidth: 640, " | 53 "{audio: true, video: {mandatory: {minWidth: 640, maxWidth: 640, " |
| 54 " minHeight: 360, maxHeight: 360}}}"; | 54 " minHeight: 360, maxHeight: 360}}}"; |
| 55 const char WebRtcTestBase::kAudioVideoCallConstraints720p[] = | 55 const char WebRtcTestBase::kAudioVideoCallConstraints720p[] = |
| 56 "{audio: true, video: {mandatory: {minWidth: 1280, maxWidth: 1280, " | 56 "{audio: true, video: {mandatory: {minWidth: 1280, maxWidth: 1280, " |
| 57 " minHeight: 720, maxHeight: 720}}}"; | 57 " minHeight: 720, maxHeight: 720}}}"; |
| 58 const char WebRtcTestBase::kUseDefaultCertKeygen[] = "null"; | |
| 59 const char WebRtcTestBase::kUseDefaultVideoCodec[] = ""; | |
|
hbos_chromium
2016/04/27 11:19:03
I could default this to "null" too if you want bef
phoglund_chromium
2016/04/27 13:23:12
Hm, I think the video codec is used to construct p
| |
| 58 | 60 |
| 59 namespace { | 61 namespace { |
| 60 | 62 |
| 61 base::LazyInstance<bool> hit_javascript_errors_ = | 63 base::LazyInstance<bool> hit_javascript_errors_ = |
| 62 LAZY_INSTANCE_INITIALIZER; | 64 LAZY_INSTANCE_INITIALIZER; |
| 63 | 65 |
| 64 // Intercepts all log messages. We always attach this handler but only look at | 66 // Intercepts all log messages. We always attach this handler but only look at |
| 65 // the results if the test requests so. Note that this will only work if the | 67 // the results if the test requests so. Note that this will only work if the |
| 66 // WebrtcTestBase-inheriting test cases do not run in parallel (if they did they | 68 // WebrtcTestBase-inheriting test cases do not run in parallel (if they did they |
| 67 // would race to look at the log, which is global to all tests). | 69 // would race to look at the log, which is global to all tests). |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 std::string WebRtcTestBase::ExecuteJavascript( | 298 std::string WebRtcTestBase::ExecuteJavascript( |
| 297 const std::string& javascript, | 299 const std::string& javascript, |
| 298 content::WebContents* tab_contents) const { | 300 content::WebContents* tab_contents) const { |
| 299 std::string result; | 301 std::string result; |
| 300 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 302 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 301 tab_contents, javascript, &result)); | 303 tab_contents, javascript, &result)); |
| 302 return result; | 304 return result; |
| 303 } | 305 } |
| 304 | 306 |
| 305 void WebRtcTestBase::SetupPeerconnectionWithLocalStream( | 307 void WebRtcTestBase::SetupPeerconnectionWithLocalStream( |
| 306 content::WebContents* tab) const { | 308 content::WebContents* tab, |
| 307 SetupPeerconnectionWithoutLocalStream(tab); | 309 std::string certificate_keygen_algorithm) const { |
| 310 SetupPeerconnectionWithoutLocalStream(tab, certificate_keygen_algorithm); | |
| 308 EXPECT_EQ("ok-added", ExecuteJavascript("addLocalStream()", tab)); | 311 EXPECT_EQ("ok-added", ExecuteJavascript("addLocalStream()", tab)); |
| 309 } | 312 } |
| 310 | 313 |
| 311 void WebRtcTestBase::SetupPeerconnectionWithoutLocalStream( | 314 void WebRtcTestBase::SetupPeerconnectionWithoutLocalStream( |
| 312 content::WebContents* tab) const { | 315 content::WebContents* tab, |
| 316 std::string certificate_keygen_algorithm) const { | |
| 317 if (certificate_keygen_algorithm.empty()) | |
|
phoglund_chromium
2016/04/27 13:23:12
Remove this if statement now that null is the defa
hbos_chromium
2016/04/27 15:09:08
Done.
| |
| 318 certificate_keygen_algorithm = "null"; | |
| 319 std::string javascript = base::StringPrintf( | |
| 320 "preparePeerConnection(%s)", certificate_keygen_algorithm.c_str()); | |
| 313 EXPECT_EQ("ok-peerconnection-created", | 321 EXPECT_EQ("ok-peerconnection-created", |
| 314 ExecuteJavascript("preparePeerConnection()", tab)); | 322 ExecuteJavascript(javascript, tab)); |
| 315 } | 323 } |
| 316 | 324 |
| 317 std::string WebRtcTestBase::CreateLocalOffer( | 325 std::string WebRtcTestBase::CreateLocalOffer( |
| 318 content::WebContents* from_tab, | 326 content::WebContents* from_tab, |
| 319 std::string default_video_codec) const { | 327 std::string default_video_codec) const { |
| 320 if (default_video_codec.empty()) | 328 if (default_video_codec.empty()) |
| 321 default_video_codec = "null"; | 329 default_video_codec = "null"; |
| 322 else | 330 else |
| 323 default_video_codec = "'" + default_video_codec + "'"; | 331 default_video_codec = "'" + default_video_codec + "'"; |
| 324 std::string javascript = base::StringPrintf( | 332 std::string javascript = base::StringPrintf( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 #endif | 446 #endif |
| 439 } | 447 } |
| 440 | 448 |
| 441 bool WebRtcTestBase::OnWin8() const { | 449 bool WebRtcTestBase::OnWin8() const { |
| 442 #if defined(OS_WIN) | 450 #if defined(OS_WIN) |
| 443 return base::win::GetVersion() > base::win::VERSION_WIN7; | 451 return base::win::GetVersion() > base::win::VERSION_WIN7; |
| 444 #else | 452 #else |
| 445 return false; | 453 return false; |
| 446 #endif | 454 #endif |
| 447 } | 455 } |
| OLD | NEW |