| 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/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "media/base/media_switches.h" | 31 #include "media/base/media_switches.h" |
| 32 #include "net/test/embedded_test_server/embedded_test_server.h" | 32 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 33 #include "testing/perf/perf_test.h" | 33 #include "testing/perf/perf_test.h" |
| 34 | 34 |
| 35 static const char kMainWebrtcTestHtmlPage[] = | 35 static const char kMainWebrtcTestHtmlPage[] = |
| 36 "/webrtc/webrtc_jsep01_test.html"; | 36 "/webrtc/webrtc_jsep01_test.html"; |
| 37 | 37 |
| 38 // Top-level integration test for WebRTC. The test methods here must run | 38 // Top-level integration test for WebRTC. The test methods here must run |
| 39 // sequentially since they use a server binary on the system (hence they are | 39 // sequentially since they use a server binary on the system (hence they are |
| 40 // tagged as MANUAL). | 40 // tagged as MANUAL). |
| 41 class WebRtcBrowserTest : public WebRtcTestBase { | 41 class WebRtcBrowserTest : public WebRtcTestBase, |
| 42 public testing::WithParamInterface<bool> { |
| 42 public: | 43 public: |
| 44 WebRtcBrowserTest() {} |
| 43 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 45 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 44 PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); | 46 PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); |
| 45 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 47 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
| 46 } | 48 } |
| 47 | 49 |
| 48 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 50 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 49 // Ensure the infobar is enabled, since we expect that in this test. | 51 // Ensure the infobar is enabled, since we expect that in this test. |
| 50 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 52 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
| 51 | 53 |
| 52 // TODO(phoglund): allow this test to also run with real devices once we | 54 // TODO(phoglund): allow this test to also run with real devices once we |
| 53 // get real webcam bots up. | 55 // get real webcam bots up. |
| 54 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 56 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 55 | 57 |
| 56 // Flag used by TestWebAudioMediaStream to force garbage collection. | 58 // Flag used by TestWebAudioMediaStream to force garbage collection. |
| 57 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 59 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
| 60 |
| 61 bool enable_audio_track_processing = GetParam(); |
| 62 if (enable_audio_track_processing) |
| 63 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); |
| 58 } | 64 } |
| 59 | 65 |
| 60 void PrintProcessMetrics(base::ProcessMetrics* process_metrics, | 66 void PrintProcessMetrics(base::ProcessMetrics* process_metrics, |
| 61 const std::string& suffix) { | 67 const std::string& suffix) { |
| 62 perf_test::PrintResult("cpu", "", "cpu" + suffix, | 68 perf_test::PrintResult("cpu", "", "cpu" + suffix, |
| 63 process_metrics->GetCPUUsage(), | 69 process_metrics->GetCPUUsage(), |
| 64 "%", true); | 70 "%", true); |
| 65 perf_test::PrintResult("memory", "", "ws_peak" + suffix, | 71 perf_test::PrintResult("memory", "", "ws_peak" + suffix, |
| 66 process_metrics->GetPeakWorkingSetSize(), | 72 process_metrics->GetPeakWorkingSetSize(), |
| 67 "bytes", true); | 73 "bytes", true); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 const base::DictionaryValue* result; | 109 const base::DictionaryValue* result; |
| 104 if (!iterator.IsAtEnd() && iterator.value().GetAsDictionary(&result)) | 110 if (!iterator.IsAtEnd() && iterator.value().GetAsDictionary(&result)) |
| 105 return result; | 111 return result; |
| 106 | 112 |
| 107 return NULL; | 113 return NULL; |
| 108 } | 114 } |
| 109 | 115 |
| 110 PeerConnectionServerRunner peerconnection_server_; | 116 PeerConnectionServerRunner peerconnection_server_; |
| 111 }; | 117 }; |
| 112 | 118 |
| 113 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, | 119 static const bool kRunTestsWithFlag[] = { false, true }; |
| 120 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, |
| 121 WebRtcBrowserTest, |
| 122 testing::ValuesIn(kRunTestsWithFlag)); |
| 123 |
| 124 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
| 114 MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { | 125 MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { |
| 115 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 126 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 116 ASSERT_TRUE(peerconnection_server_.Start()); | 127 ASSERT_TRUE(peerconnection_server_.Start()); |
| 117 | 128 |
| 118 content::WebContents* left_tab = | 129 content::WebContents* left_tab = |
| 119 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 130 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 120 content::WebContents* right_tab = | 131 content::WebContents* right_tab = |
| 121 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 132 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 122 | 133 |
| 123 EstablishCall(left_tab, right_tab); | 134 EstablishCall(left_tab, right_tab); |
| 124 | 135 |
| 125 StartDetectingVideo(left_tab, "remote-view"); | 136 StartDetectingVideo(left_tab, "remote-view"); |
| 126 StartDetectingVideo(right_tab, "remote-view"); | 137 StartDetectingVideo(right_tab, "remote-view"); |
| 127 | 138 |
| 128 WaitForVideoToPlay(left_tab); | 139 WaitForVideoToPlay(left_tab); |
| 129 WaitForVideoToPlay(right_tab); | 140 WaitForVideoToPlay(right_tab); |
| 130 | 141 |
| 131 HangUp(left_tab); | 142 HangUp(left_tab); |
| 132 WaitUntilHangupVerified(left_tab); | 143 WaitUntilHangupVerified(left_tab); |
| 133 WaitUntilHangupVerified(right_tab); | 144 WaitUntilHangupVerified(right_tab); |
| 134 | 145 |
| 135 ASSERT_TRUE(peerconnection_server_.Stop()); | 146 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 136 } | 147 } |
| 137 | 148 |
| 138 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { | 149 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { |
| 139 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 150 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 140 ASSERT_TRUE(peerconnection_server_.Start()); | 151 ASSERT_TRUE(peerconnection_server_.Start()); |
| 141 | 152 |
| 142 base::FilePath results_file; | 153 base::FilePath results_file; |
| 143 ASSERT_TRUE(base::CreateTemporaryFile(&results_file)); | 154 ASSERT_TRUE(base::CreateTemporaryFile(&results_file)); |
| 144 | 155 |
| 145 content::WebContents* left_tab = | 156 content::WebContents* left_tab = |
| 146 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 157 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 147 | 158 |
| 148 #if defined(OS_MACOSX) | 159 #if defined(OS_MACOSX) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 179 | 190 |
| 180 #if !defined(OS_MACOSX) | 191 #if !defined(OS_MACOSX) |
| 181 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); | 192 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); |
| 182 #endif | 193 #endif |
| 183 PrintProcessMetrics(browser_process_metrics.get(), "_b"); | 194 PrintProcessMetrics(browser_process_metrics.get(), "_b"); |
| 184 | 195 |
| 185 ASSERT_TRUE(peerconnection_server_.Stop()); | 196 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 186 } | 197 } |
| 187 | 198 |
| 188 // This is manual for its long execution time. | 199 // This is manual for its long execution time. |
| 189 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, | 200 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
| 190 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { | 201 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { |
| 191 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 202 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 192 ASSERT_TRUE(peerconnection_server_.Start()); | 203 ASSERT_TRUE(peerconnection_server_.Start()); |
| 193 | 204 |
| 194 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) << | 205 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) << |
| 195 "This is a long-running test; you must specify " | 206 "This is a long-running test; you must specify " |
| 196 "--ui-test-action-max-timeout to have a value of at least 100000."; | 207 "--ui-test-action-max-timeout to have a value of at least 100000."; |
| 197 | 208 |
| 198 content::WebContents* left_tab = | 209 content::WebContents* left_tab = |
| 199 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 210 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 229 PrintBweForVideoMetrics(*first_pc_dict); | 240 PrintBweForVideoMetrics(*first_pc_dict); |
| 230 PrintMetricsForAllStreams(*first_pc_dict); | 241 PrintMetricsForAllStreams(*first_pc_dict); |
| 231 | 242 |
| 232 HangUp(left_tab); | 243 HangUp(left_tab); |
| 233 WaitUntilHangupVerified(left_tab); | 244 WaitUntilHangupVerified(left_tab); |
| 234 WaitUntilHangupVerified(right_tab); | 245 WaitUntilHangupVerified(right_tab); |
| 235 | 246 |
| 236 ASSERT_TRUE(peerconnection_server_.Stop()); | 247 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 237 } | 248 } |
| 238 | 249 |
| 239 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, TestWebAudioMediaStream) { | 250 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) { |
| 240 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 251 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 241 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); | 252 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); |
| 242 ui_test_utils::NavigateToURL(browser(), url); | 253 ui_test_utils::NavigateToURL(browser(), url); |
| 243 content::WebContents* tab = | 254 content::WebContents* tab = |
| 244 browser()->tab_strip_model()->GetActiveWebContents(); | 255 browser()->tab_strip_model()->GetActiveWebContents(); |
| 245 | 256 |
| 246 // A sleep is necessary to be able to detect the crash. | 257 // A sleep is necessary to be able to detect the crash. |
| 247 SleepInJavascript(tab, 1000); | 258 SleepInJavascript(tab, 1000); |
| 248 | 259 |
| 249 ASSERT_FALSE(tab->IsCrashed()); | 260 ASSERT_FALSE(tab->IsCrashed()); |
| 250 } | 261 } |
| OLD | NEW |