| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/media/webrtc_browsertest_base.h" | 8 #include "chrome/browser/media/webrtc_browsertest_base.h" |
| 9 #include "chrome/browser/media/webrtc_browsertest_common.h" | 9 #include "chrome/browser/media/webrtc_browsertest_common.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_tabstrip.h" | 11 #include "chrome/browser/ui/browser_tabstrip.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" | 17 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" |
| 18 #include "content/public/common/features.h" | 18 #include "content/public/common/features.h" |
| 19 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
| 20 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
| 21 #include "net/test/embedded_test_server/embedded_test_server.h" | 21 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 22 | 22 |
| 23 static const char kMainWebrtcTestHtmlPage[] = | 23 static const char kMainWebrtcTestHtmlPage[] = |
| 24 "/webrtc/webrtc_jsep01_test.html"; | 24 "/webrtc/webrtc_jsep01_test.html"; |
| 25 | 25 |
| 26 static const char kKeygenAlgorithmRSA[] = |
| 27 "{ name: \"RSASSA-PKCS1-v1_5\", modulusLength: 2048, publicExponent: " |
| 28 "new Uint8Array([1, 0, 1]), hash: \"SHA-256\" }"; |
| 29 static const char kKeygenAlgorithmECDSA[] = |
| 30 "{ name: \"ECDSA\", namedCurve: \"P-256\" }"; |
| 31 |
| 26 // Top-level integration test for WebRTC. It always uses fake devices; see | 32 // Top-level integration test for WebRTC. It always uses fake devices; see |
| 27 // WebRtcWebcamBrowserTest for a test that acquires any real webcam on the | 33 // WebRtcWebcamBrowserTest for a test that acquires any real webcam on the |
| 28 // system. | 34 // system. |
| 29 class WebRtcBrowserTest : public WebRtcTestBase { | 35 class WebRtcBrowserTest : public WebRtcTestBase { |
| 30 public: | 36 public: |
| 31 void SetUpInProcessBrowserTestFixture() override { | 37 void SetUpInProcessBrowserTestFixture() override { |
| 32 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 38 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
| 33 } | 39 } |
| 34 | 40 |
| 35 void SetUpCommandLine(base::CommandLine* command_line) override { | 41 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 36 // Ensure the infobar is enabled, since we expect that in this test. | 42 // Ensure the infobar is enabled, since we expect that in this test. |
| 37 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 43 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
| 38 | 44 |
| 39 // Always use fake devices. | 45 // Always use fake devices. |
| 40 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 46 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 41 | 47 |
| 42 // Flag used by TestWebAudioMediaStream to force garbage collection. | 48 // Flag used by TestWebAudioMediaStream to force garbage collection. |
| 43 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 49 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
| 50 |
| 51 // command_line->AppendSwitch("expose-internals-for-testing"); |
| 44 } | 52 } |
| 45 | 53 |
| 46 void RunsAudioVideoWebRTCCallInTwoTabs( | 54 void RunsAudioVideoWebRTCCallInTwoTabs( |
| 47 std::string certificate_keygen_algorithm, | 55 std::string certificate_keygen_algorithm, |
| 48 std::string video_codec) { | 56 std::string video_codec) { |
| 49 if (OnWinXp()) return; | 57 if (OnWinXp()) return; |
| 50 | 58 |
| 51 ASSERT_TRUE(embedded_test_server()->Start()); | 59 ASSERT_TRUE(embedded_test_server()->Start()); |
| 52 | 60 |
| 53 content::WebContents* left_tab = | 61 content::WebContents* left_tab = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 #endif | 78 #endif |
| 71 | 79 |
| 72 HangUp(left_tab); | 80 HangUp(left_tab); |
| 73 HangUp(right_tab); | 81 HangUp(right_tab); |
| 74 } | 82 } |
| 75 }; | 83 }; |
| 76 | 84 |
| 77 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, | 85 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 78 RunsAudioVideoWebRTCCallInTwoTabsRSACertificate) { | 86 RunsAudioVideoWebRTCCallInTwoTabsRSACertificate) { |
| 79 RunsAudioVideoWebRTCCallInTwoTabs( | 87 RunsAudioVideoWebRTCCallInTwoTabs( |
| 80 "{ name: \"RSASSA-PKCS1-v1_5\", modulusLength: 2048, publicExponent: " | 88 kKeygenAlgorithmRSA, WebRtcTestBase::kUseDefaultVideoCodec); |
| 81 "new Uint8Array([1, 0, 1]), hash: \"SHA-256\" }", | |
| 82 WebRtcTestBase::kUseDefaultVideoCodec); | |
| 83 } | 89 } |
| 84 | 90 |
| 85 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, | 91 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 86 RunsAudioVideoWebRTCCallInTwoTabsECDSACertificate) { | 92 RunsAudioVideoWebRTCCallInTwoTabsECDSACertificate) { |
| 87 RunsAudioVideoWebRTCCallInTwoTabs( | 93 RunsAudioVideoWebRTCCallInTwoTabs( |
| 88 "{ name: \"ECDSA\", namedCurve: \"P-256\" }", | 94 kKeygenAlgorithmECDSA, WebRtcTestBase::kUseDefaultVideoCodec); |
| 89 WebRtcTestBase::kUseDefaultVideoCodec); | |
| 90 } | 95 } |
| 91 | 96 |
| 92 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, | 97 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 98 RTCCertificateIndexedDBCloningRSA) { |
| 99 ASSERT_TRUE(embedded_test_server()->Start()); |
| 100 content::WebContents* tab = |
| 101 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 102 |
| 103 DeleteDatabase(tab); |
| 104 OpenDatabase(tab); |
| 105 GenerateAndCloneCertificate(tab, kKeygenAlgorithmRSA); |
| 106 CloseDatabase(tab); |
| 107 DeleteDatabase(tab); |
| 108 } |
| 109 |
| 110 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 111 RTCCertificateIndexedDBCloningECDSA) { |
| 112 ASSERT_TRUE(embedded_test_server()->Start()); |
| 113 content::WebContents* tab = |
| 114 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 115 |
| 116 DeleteDatabase(tab); |
| 117 OpenDatabase(tab); |
| 118 GenerateAndCloneCertificate(tab, kKeygenAlgorithmECDSA); |
| 119 CloseDatabase(tab); |
| 120 DeleteDatabase(tab); |
| 121 } |
| 122 |
| 123 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 93 RunsAudioVideoWebRTCCallInTwoTabsVP8) { | 124 RunsAudioVideoWebRTCCallInTwoTabsVP8) { |
| 94 RunsAudioVideoWebRTCCallInTwoTabs( | 125 RunsAudioVideoWebRTCCallInTwoTabs( |
| 95 WebRtcTestBase::kUseDefaultCertKeygen, "VP8"); | 126 WebRtcTestBase::kUseDefaultCertKeygen, "VP8"); |
| 96 } | 127 } |
| 97 | 128 |
| 98 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, | 129 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 99 RunsAudioVideoWebRTCCallInTwoTabsVP9) { | 130 RunsAudioVideoWebRTCCallInTwoTabsVP9) { |
| 100 RunsAudioVideoWebRTCCallInTwoTabs( | 131 RunsAudioVideoWebRTCCallInTwoTabs( |
| 101 WebRtcTestBase::kUseDefaultCertKeygen, "VP9"); | 132 WebRtcTestBase::kUseDefaultCertKeygen, "VP9"); |
| 102 } | 133 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 127 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); | 158 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); |
| 128 ui_test_utils::NavigateToURL(browser(), url); | 159 ui_test_utils::NavigateToURL(browser(), url); |
| 129 content::WebContents* tab = | 160 content::WebContents* tab = |
| 130 browser()->tab_strip_model()->GetActiveWebContents(); | 161 browser()->tab_strip_model()->GetActiveWebContents(); |
| 131 | 162 |
| 132 // A sleep is necessary to be able to detect the crash. | 163 // A sleep is necessary to be able to detect the crash. |
| 133 test::SleepInJavascript(tab, 1000); | 164 test::SleepInJavascript(tab, 1000); |
| 134 | 165 |
| 135 ASSERT_FALSE(tab->IsCrashed()); | 166 ASSERT_FALSE(tab->IsCrashed()); |
| 136 } | 167 } |
| OLD | NEW |