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