| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Top-level integration test for WebRTC. The test methods here must run | 42 // Top-level integration test for WebRTC. The test methods here must run |
| 43 // sequentially since they use a server binary on the system (hence they are | 43 // sequentially since they use a server binary on the system (hence they are |
| 44 // tagged as MANUAL). In addition, they need the reference videos which require | 44 // tagged as MANUAL). In addition, they need the reference videos which require |
| 45 // the webrtc.DEPS solution, which is not generally available on Chromium bots. | 45 // the webrtc.DEPS solution, which is not generally available on Chromium bots. |
| 46 class WebRtcBrowserTest : public WebRtcTestBase, | 46 class WebRtcBrowserTest : public WebRtcTestBase, |
| 47 public testing::WithParamInterface<bool> { | 47 public testing::WithParamInterface<bool> { |
| 48 public: | 48 public: |
| 49 WebRtcBrowserTest() {} | 49 WebRtcBrowserTest() {} |
| 50 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 50 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 51 test::PeerConnectionServerRunner::KillAllPeerConnectionServers(); | |
| 52 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 51 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
| 53 } | 52 } |
| 54 | 53 |
| 55 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 54 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 56 // Ensure the infobar is enabled, since we expect that in this test. | 55 // Ensure the infobar is enabled, since we expect that in this test. |
| 57 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 56 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
| 58 | 57 |
| 59 // Play a suitable, somewhat realistic video file. | 58 // Play a suitable, somewhat realistic video file. |
| 60 base::FilePath input_video = test::GetReferenceFilesDir() | 59 base::FilePath input_video = test::GetReferenceFilesDir() |
| 61 .Append(test::kReferenceFileName360p) | 60 .Append(test::kReferenceFileName360p) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return NULL; | 121 return NULL; |
| 123 } | 122 } |
| 124 | 123 |
| 125 bool OnWinXp() { | 124 bool OnWinXp() { |
| 126 #if defined(OS_WIN) | 125 #if defined(OS_WIN) |
| 127 return base::win::GetVersion() <= base::win::VERSION_XP; | 126 return base::win::GetVersion() <= base::win::VERSION_XP; |
| 128 #else | 127 #else |
| 129 return false; | 128 return false; |
| 130 #endif | 129 #endif |
| 131 } | 130 } |
| 132 | |
| 133 test::PeerConnectionServerRunner peerconnection_server_; | |
| 134 }; | 131 }; |
| 135 | 132 |
| 136 static const bool kRunTestsWithFlag[] = { false, true }; | 133 static const bool kRunTestsWithFlag[] = { false, true }; |
| 137 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, | 134 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, |
| 138 WebRtcBrowserTest, | 135 WebRtcBrowserTest, |
| 139 testing::ValuesIn(kRunTestsWithFlag)); | 136 testing::ValuesIn(kRunTestsWithFlag)); |
| 140 | 137 |
| 141 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 138 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
| 142 MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { | 139 MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { |
| 143 if (OnWinXp()) return; | 140 if (OnWinXp()) return; |
| 144 | 141 |
| 145 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 142 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 146 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 143 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 147 ASSERT_TRUE(peerconnection_server_.Start()); | |
| 148 | 144 |
| 149 content::WebContents* left_tab = | 145 content::WebContents* left_tab = |
| 150 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 146 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 151 content::WebContents* right_tab = | 147 content::WebContents* right_tab = |
| 152 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 148 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 153 | 149 |
| 154 EstablishCall(left_tab, right_tab); | 150 SetupPeerconnectionWithLocalStream(left_tab); |
| 151 SetupPeerconnectionWithLocalStream(right_tab); |
| 152 |
| 153 NegotiateCall(left_tab, right_tab); |
| 155 | 154 |
| 156 StartDetectingVideo(left_tab, "remote-view"); | 155 StartDetectingVideo(left_tab, "remote-view"); |
| 157 StartDetectingVideo(right_tab, "remote-view"); | 156 StartDetectingVideo(right_tab, "remote-view"); |
| 158 | 157 |
| 159 WaitForVideoToPlay(left_tab); | 158 WaitForVideoToPlay(left_tab); |
| 160 WaitForVideoToPlay(right_tab); | 159 WaitForVideoToPlay(right_tab); |
| 161 | 160 |
| 162 HangUp(left_tab); | 161 HangUp(left_tab); |
| 163 WaitUntilHangupVerified(left_tab); | |
| 164 WaitUntilHangupVerified(right_tab); | |
| 165 | |
| 166 ASSERT_TRUE(peerconnection_server_.Stop()); | |
| 167 } | 162 } |
| 168 | 163 |
| 169 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { | 164 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { |
| 170 if (OnWinXp()) return; | 165 if (OnWinXp()) return; |
| 171 | 166 |
| 172 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 167 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 173 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 168 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 174 ASSERT_TRUE(peerconnection_server_.Start()); | |
| 175 | 169 |
| 176 base::FilePath results_file; | 170 base::FilePath results_file; |
| 177 ASSERT_TRUE(base::CreateTemporaryFile(&results_file)); | 171 ASSERT_TRUE(base::CreateTemporaryFile(&results_file)); |
| 178 | 172 |
| 179 content::WebContents* left_tab = | 173 content::WebContents* left_tab = |
| 180 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 174 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 181 | 175 |
| 182 #if defined(OS_MACOSX) | 176 #if defined(OS_MACOSX) |
| 183 // Don't measure renderer CPU on mac: requires a mach broker we don't have | 177 // Don't measure renderer CPU on mac: requires a mach broker we don't have |
| 184 // access to from the browser test. | 178 // access to from the browser test. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 196 | 190 |
| 197 scoped_ptr<base::ProcessMetrics> browser_process_metrics( | 191 scoped_ptr<base::ProcessMetrics> browser_process_metrics( |
| 198 base::ProcessMetrics::CreateProcessMetrics( | 192 base::ProcessMetrics::CreateProcessMetrics( |
| 199 base::Process::Current().handle())); | 193 base::Process::Current().handle())); |
| 200 browser_process_metrics->GetCPUUsage(); | 194 browser_process_metrics->GetCPUUsage(); |
| 201 #endif | 195 #endif |
| 202 | 196 |
| 203 content::WebContents* right_tab = | 197 content::WebContents* right_tab = |
| 204 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 198 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 205 | 199 |
| 206 EstablishCall(left_tab, right_tab); | 200 SetupPeerconnectionWithLocalStream(left_tab); |
| 201 SetupPeerconnectionWithLocalStream(right_tab); |
| 202 |
| 203 NegotiateCall(left_tab, right_tab); |
| 207 | 204 |
| 208 test::SleepInJavascript(left_tab, 15000); | 205 test::SleepInJavascript(left_tab, 15000); |
| 209 | 206 |
| 210 HangUp(left_tab); | 207 HangUp(left_tab); |
| 211 WaitUntilHangupVerified(left_tab); | |
| 212 WaitUntilHangupVerified(right_tab); | |
| 213 | 208 |
| 214 #if !defined(OS_MACOSX) | 209 #if !defined(OS_MACOSX) |
| 215 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); | 210 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); |
| 216 #endif | 211 #endif |
| 217 PrintProcessMetrics(browser_process_metrics.get(), "_b"); | 212 PrintProcessMetrics(browser_process_metrics.get(), "_b"); |
| 218 | |
| 219 ASSERT_TRUE(peerconnection_server_.Stop()); | |
| 220 } | 213 } |
| 221 | 214 |
| 222 // This is manual for its long execution time. | 215 // This is manual for its long execution time. |
| 223 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 216 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
| 224 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { | 217 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { |
| 225 if (OnWinXp()) return; | 218 if (OnWinXp()) return; |
| 226 | 219 |
| 227 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 220 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 228 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 221 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 229 ASSERT_TRUE(peerconnection_server_.Start()); | |
| 230 | 222 |
| 231 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) << | 223 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) << |
| 232 "This is a long-running test; you must specify " | 224 "This is a long-running test; you must specify " |
| 233 "--ui-test-action-max-timeout to have a value of at least 100000."; | 225 "--ui-test-action-max-timeout to have a value of at least 100000."; |
| 234 | 226 |
| 235 content::WebContents* left_tab = | 227 content::WebContents* left_tab = |
| 236 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 228 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 237 content::WebContents* right_tab = | 229 content::WebContents* right_tab = |
| 238 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 230 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 239 | 231 |
| 240 EstablishCall(left_tab, right_tab); | 232 SetupPeerconnectionWithLocalStream(left_tab); |
| 233 SetupPeerconnectionWithLocalStream(right_tab); |
| 234 |
| 235 NegotiateCall(left_tab, right_tab); |
| 241 | 236 |
| 242 StartDetectingVideo(left_tab, "remote-view"); | 237 StartDetectingVideo(left_tab, "remote-view"); |
| 243 StartDetectingVideo(right_tab, "remote-view"); | 238 StartDetectingVideo(right_tab, "remote-view"); |
| 244 | 239 |
| 245 WaitForVideoToPlay(left_tab); | 240 WaitForVideoToPlay(left_tab); |
| 246 WaitForVideoToPlay(right_tab); | 241 WaitForVideoToPlay(right_tab); |
| 247 | 242 |
| 248 // Let values stabilize, bandwidth ramp up, etc. | 243 // Let values stabilize, bandwidth ramp up, etc. |
| 249 test::SleepInJavascript(left_tab, 60000); | 244 test::SleepInJavascript(left_tab, 60000); |
| 250 | 245 |
| 251 // Start measurements. | 246 // Start measurements. |
| 252 chrome::AddTabAt(browser(), GURL(), -1, true); | 247 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 253 ui_test_utils::NavigateToURL(browser(), GURL("chrome://webrtc-internals")); | 248 ui_test_utils::NavigateToURL(browser(), GURL("chrome://webrtc-internals")); |
| 254 content::WebContents* webrtc_internals_tab = | 249 content::WebContents* webrtc_internals_tab = |
| 255 browser()->tab_strip_model()->GetActiveWebContents(); | 250 browser()->tab_strip_model()->GetActiveWebContents(); |
| 256 | 251 |
| 257 test::SleepInJavascript(left_tab, 10000); | 252 test::SleepInJavascript(left_tab, 10000); |
| 258 | 253 |
| 259 scoped_ptr<base::DictionaryValue> all_data( | 254 scoped_ptr<base::DictionaryValue> all_data( |
| 260 GetWebrtcInternalsData(webrtc_internals_tab)); | 255 GetWebrtcInternalsData(webrtc_internals_tab)); |
| 261 ASSERT_TRUE(all_data.get() != NULL); | 256 ASSERT_TRUE(all_data.get() != NULL); |
| 262 | 257 |
| 263 const base::DictionaryValue* first_pc_dict = | 258 const base::DictionaryValue* first_pc_dict = |
| 264 GetDataOnFirstPeerConnection(all_data.get()); | 259 GetDataOnFirstPeerConnection(all_data.get()); |
| 265 ASSERT_TRUE(first_pc_dict != NULL); | 260 ASSERT_TRUE(first_pc_dict != NULL); |
| 266 test::PrintBweForVideoMetrics(*first_pc_dict); | 261 test::PrintBweForVideoMetrics(*first_pc_dict); |
| 267 test::PrintMetricsForAllStreams(*first_pc_dict); | 262 test::PrintMetricsForAllStreams(*first_pc_dict); |
| 268 | 263 |
| 269 HangUp(left_tab); | 264 HangUp(left_tab); |
| 270 WaitUntilHangupVerified(left_tab); | |
| 271 WaitUntilHangupVerified(right_tab); | |
| 272 | |
| 273 ASSERT_TRUE(peerconnection_server_.Stop()); | |
| 274 } | 265 } |
| 275 | 266 |
| 276 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_TestWebAudioMediaStream) { | 267 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_TestWebAudioMediaStream) { |
| 277 if (OnWinXp()) return; | 268 if (OnWinXp()) return; |
| 278 | 269 |
| 279 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 270 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 280 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 271 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 281 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); | 272 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); |
| 282 ui_test_utils::NavigateToURL(browser(), url); | 273 ui_test_utils::NavigateToURL(browser(), url); |
| 283 content::WebContents* tab = | 274 content::WebContents* tab = |
| 284 browser()->tab_strip_model()->GetActiveWebContents(); | 275 browser()->tab_strip_model()->GetActiveWebContents(); |
| 285 | 276 |
| 286 // A sleep is necessary to be able to detect the crash. | 277 // A sleep is necessary to be able to detect the crash. |
| 287 test::SleepInJavascript(tab, 1000); | 278 test::SleepInJavascript(tab, 1000); |
| 288 | 279 |
| 289 ASSERT_FALSE(tab->IsCrashed()); | 280 ASSERT_FALSE(tab->IsCrashed()); |
| 290 } | 281 } |
| OLD | NEW |