| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "chrome/test/ui/ui_test.h" | 27 #include "chrome/test/ui/ui_test.h" |
| 28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
| 30 #include "content/public/test/browser_test_utils.h" | 30 #include "content/public/test/browser_test_utils.h" |
| 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 // For fine-grained suppression. |
| 36 #if defined(OS_WIN) |
| 37 #include "base/win/windows_version.h" |
| 38 #endif |
| 39 |
| 35 static const char kMainWebrtcTestHtmlPage[] = | 40 static const char kMainWebrtcTestHtmlPage[] = |
| 36 "/webrtc/webrtc_jsep01_test.html"; | 41 "/webrtc/webrtc_jsep01_test.html"; |
| 37 | 42 |
| 38 // Top-level integration test for WebRTC. The test methods here must run | 43 // 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 | 44 // sequentially since they use a server binary on the system (hence they are |
| 40 // tagged as MANUAL). | 45 // tagged as MANUAL). In addition, they need the reference videos which require |
| 46 // the webrtc.DEPS solution, which is not generally available on Chromium bots. |
| 41 class WebRtcBrowserTest : public WebRtcTestBase, | 47 class WebRtcBrowserTest : public WebRtcTestBase, |
| 42 public testing::WithParamInterface<bool> { | 48 public testing::WithParamInterface<bool> { |
| 43 public: | 49 public: |
| 44 WebRtcBrowserTest() {} | 50 WebRtcBrowserTest() {} |
| 45 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 51 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 46 PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); | 52 test::PeerConnectionServerRunner::KillAllPeerConnectionServers(); |
| 47 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 53 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
| 48 } | 54 } |
| 49 | 55 |
| 50 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 56 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 51 // Ensure the infobar is enabled, since we expect that in this test. | 57 // Ensure the infobar is enabled, since we expect that in this test. |
| 52 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 58 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
| 53 | 59 |
| 54 // TODO(phoglund): allow this test to also run with real devices once we | 60 // Play a suitable, somewhat realistic video file. |
| 55 // get real webcam bots up. | 61 base::FilePath input_video = test::GetReferenceVideosDir() |
| 62 .Append(test::kReferenceFileName360p) |
| 63 .AddExtension(test::kY4mFileExtension); |
| 64 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, |
| 65 input_video); |
| 56 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 66 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 57 | 67 |
| 58 // Flag used by TestWebAudioMediaStream to force garbage collection. | 68 // Flag used by TestWebAudioMediaStream to force garbage collection. |
| 59 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 69 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
| 60 | 70 |
| 61 bool enable_audio_track_processing = GetParam(); | 71 bool enable_audio_track_processing = GetParam(); |
| 62 if (enable_audio_track_processing) | 72 if (enable_audio_track_processing) |
| 63 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); | 73 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); |
| 64 } | 74 } |
| 65 | 75 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 const base::DictionaryValue* all_data) { | 116 const base::DictionaryValue* all_data) { |
| 107 base::DictionaryValue::Iterator iterator(*all_data); | 117 base::DictionaryValue::Iterator iterator(*all_data); |
| 108 | 118 |
| 109 const base::DictionaryValue* result; | 119 const base::DictionaryValue* result; |
| 110 if (!iterator.IsAtEnd() && iterator.value().GetAsDictionary(&result)) | 120 if (!iterator.IsAtEnd() && iterator.value().GetAsDictionary(&result)) |
| 111 return result; | 121 return result; |
| 112 | 122 |
| 113 return NULL; | 123 return NULL; |
| 114 } | 124 } |
| 115 | 125 |
| 116 PeerConnectionServerRunner peerconnection_server_; | 126 bool OnWinXp() { |
| 127 #if defined(OS_WIN) |
| 128 return base::win::GetVersion() <= base::win::VERSION_XP; |
| 129 #else |
| 130 return false; |
| 131 #endif |
| 132 } |
| 133 |
| 134 test::PeerConnectionServerRunner peerconnection_server_; |
| 117 }; | 135 }; |
| 118 | 136 |
| 119 static const bool kRunTestsWithFlag[] = { false, true }; | 137 static const bool kRunTestsWithFlag[] = { false, true }; |
| 120 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, | 138 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, |
| 121 WebRtcBrowserTest, | 139 WebRtcBrowserTest, |
| 122 testing::ValuesIn(kRunTestsWithFlag)); | 140 testing::ValuesIn(kRunTestsWithFlag)); |
| 123 | 141 |
| 124 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 142 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
| 125 MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { | 143 MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { |
| 144 if (OnWinXp()) return; |
| 145 |
| 146 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 126 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 147 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 127 ASSERT_TRUE(peerconnection_server_.Start()); | 148 ASSERT_TRUE(peerconnection_server_.Start()); |
| 128 | 149 |
| 129 content::WebContents* left_tab = | 150 content::WebContents* left_tab = |
| 130 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 151 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 131 content::WebContents* right_tab = | 152 content::WebContents* right_tab = |
| 132 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 153 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 133 | 154 |
| 134 EstablishCall(left_tab, right_tab); | 155 EstablishCall(left_tab, right_tab); |
| 135 | 156 |
| 136 StartDetectingVideo(left_tab, "remote-view"); | 157 StartDetectingVideo(left_tab, "remote-view"); |
| 137 StartDetectingVideo(right_tab, "remote-view"); | 158 StartDetectingVideo(right_tab, "remote-view"); |
| 138 | 159 |
| 139 WaitForVideoToPlay(left_tab); | 160 WaitForVideoToPlay(left_tab); |
| 140 WaitForVideoToPlay(right_tab); | 161 WaitForVideoToPlay(right_tab); |
| 141 | 162 |
| 142 HangUp(left_tab); | 163 HangUp(left_tab); |
| 143 WaitUntilHangupVerified(left_tab); | 164 WaitUntilHangupVerified(left_tab); |
| 144 WaitUntilHangupVerified(right_tab); | 165 WaitUntilHangupVerified(right_tab); |
| 145 | 166 |
| 146 ASSERT_TRUE(peerconnection_server_.Stop()); | 167 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 147 } | 168 } |
| 148 | 169 |
| 149 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { | 170 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { |
| 171 if (OnWinXp()) return; |
| 172 |
| 173 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 150 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 174 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 151 ASSERT_TRUE(peerconnection_server_.Start()); | 175 ASSERT_TRUE(peerconnection_server_.Start()); |
| 152 | 176 |
| 153 base::FilePath results_file; | 177 base::FilePath results_file; |
| 154 ASSERT_TRUE(base::CreateTemporaryFile(&results_file)); | 178 ASSERT_TRUE(base::CreateTemporaryFile(&results_file)); |
| 155 | 179 |
| 156 content::WebContents* left_tab = | 180 content::WebContents* left_tab = |
| 157 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 181 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 158 | 182 |
| 159 #if defined(OS_MACOSX) | 183 #if defined(OS_MACOSX) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 175 base::ProcessMetrics::CreateProcessMetrics( | 199 base::ProcessMetrics::CreateProcessMetrics( |
| 176 base::Process::Current().handle())); | 200 base::Process::Current().handle())); |
| 177 browser_process_metrics->GetCPUUsage(); | 201 browser_process_metrics->GetCPUUsage(); |
| 178 #endif | 202 #endif |
| 179 | 203 |
| 180 content::WebContents* right_tab = | 204 content::WebContents* right_tab = |
| 181 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 205 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 182 | 206 |
| 183 EstablishCall(left_tab, right_tab); | 207 EstablishCall(left_tab, right_tab); |
| 184 | 208 |
| 185 SleepInJavascript(left_tab, 15000); | 209 test::SleepInJavascript(left_tab, 15000); |
| 186 | 210 |
| 187 HangUp(left_tab); | 211 HangUp(left_tab); |
| 188 WaitUntilHangupVerified(left_tab); | 212 WaitUntilHangupVerified(left_tab); |
| 189 WaitUntilHangupVerified(right_tab); | 213 WaitUntilHangupVerified(right_tab); |
| 190 | 214 |
| 191 #if !defined(OS_MACOSX) | 215 #if !defined(OS_MACOSX) |
| 192 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); | 216 PrintProcessMetrics(renderer_process_metrics.get(), "_r"); |
| 193 #endif | 217 #endif |
| 194 PrintProcessMetrics(browser_process_metrics.get(), "_b"); | 218 PrintProcessMetrics(browser_process_metrics.get(), "_b"); |
| 195 | 219 |
| 196 ASSERT_TRUE(peerconnection_server_.Stop()); | 220 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 197 } | 221 } |
| 198 | 222 |
| 199 // This is manual for its long execution time. | 223 // This is manual for its long execution time. |
| 200 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 224 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
| 201 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { | 225 MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { |
| 226 if (OnWinXp()) return; |
| 227 |
| 228 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 202 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 229 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 203 ASSERT_TRUE(peerconnection_server_.Start()); | 230 ASSERT_TRUE(peerconnection_server_.Start()); |
| 204 | 231 |
| 205 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) << | 232 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) << |
| 206 "This is a long-running test; you must specify " | 233 "This is a long-running test; you must specify " |
| 207 "--ui-test-action-max-timeout to have a value of at least 100000."; | 234 "--ui-test-action-max-timeout to have a value of at least 100000."; |
| 208 | 235 |
| 209 content::WebContents* left_tab = | 236 content::WebContents* left_tab = |
| 210 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 237 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 211 content::WebContents* right_tab = | 238 content::WebContents* right_tab = |
| 212 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 239 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
| 213 | 240 |
| 214 EstablishCall(left_tab, right_tab); | 241 EstablishCall(left_tab, right_tab); |
| 215 | 242 |
| 216 StartDetectingVideo(left_tab, "remote-view"); | 243 StartDetectingVideo(left_tab, "remote-view"); |
| 217 StartDetectingVideo(right_tab, "remote-view"); | 244 StartDetectingVideo(right_tab, "remote-view"); |
| 218 | 245 |
| 219 WaitForVideoToPlay(left_tab); | 246 WaitForVideoToPlay(left_tab); |
| 220 WaitForVideoToPlay(right_tab); | 247 WaitForVideoToPlay(right_tab); |
| 221 | 248 |
| 222 // Let values stabilize, bandwidth ramp up, etc. | 249 // Let values stabilize, bandwidth ramp up, etc. |
| 223 SleepInJavascript(left_tab, 60000); | 250 test::SleepInJavascript(left_tab, 60000); |
| 224 | 251 |
| 225 // Start measurements. | 252 // Start measurements. |
| 226 chrome::AddTabAt(browser(), GURL(), -1, true); | 253 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 227 ui_test_utils::NavigateToURL(browser(), GURL("chrome://webrtc-internals")); | 254 ui_test_utils::NavigateToURL(browser(), GURL("chrome://webrtc-internals")); |
| 228 content::WebContents* webrtc_internals_tab = | 255 content::WebContents* webrtc_internals_tab = |
| 229 browser()->tab_strip_model()->GetActiveWebContents(); | 256 browser()->tab_strip_model()->GetActiveWebContents(); |
| 230 | 257 |
| 231 SleepInJavascript(left_tab, 10000); | 258 test::SleepInJavascript(left_tab, 10000); |
| 232 | 259 |
| 233 scoped_ptr<base::DictionaryValue> all_data( | 260 scoped_ptr<base::DictionaryValue> all_data( |
| 234 GetWebrtcInternalsData(webrtc_internals_tab)); | 261 GetWebrtcInternalsData(webrtc_internals_tab)); |
| 235 ASSERT_TRUE(all_data.get() != NULL); | 262 ASSERT_TRUE(all_data.get() != NULL); |
| 236 | 263 |
| 237 const base::DictionaryValue* first_pc_dict = | 264 const base::DictionaryValue* first_pc_dict = |
| 238 GetDataOnFirstPeerConnection(all_data.get()); | 265 GetDataOnFirstPeerConnection(all_data.get()); |
| 239 ASSERT_TRUE(first_pc_dict != NULL); | 266 ASSERT_TRUE(first_pc_dict != NULL); |
| 240 PrintBweForVideoMetrics(*first_pc_dict); | 267 test::PrintBweForVideoMetrics(*first_pc_dict); |
| 241 PrintMetricsForAllStreams(*first_pc_dict); | 268 test::PrintMetricsForAllStreams(*first_pc_dict); |
| 242 | 269 |
| 243 HangUp(left_tab); | 270 HangUp(left_tab); |
| 244 WaitUntilHangupVerified(left_tab); | 271 WaitUntilHangupVerified(left_tab); |
| 245 WaitUntilHangupVerified(right_tab); | 272 WaitUntilHangupVerified(right_tab); |
| 246 | 273 |
| 247 ASSERT_TRUE(peerconnection_server_.Stop()); | 274 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 248 } | 275 } |
| 249 | 276 |
| 250 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) { | 277 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_TestWebAudioMediaStream) { |
| 278 if (OnWinXp()) return; |
| 279 |
| 280 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 251 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 281 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 252 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); | 282 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); |
| 253 ui_test_utils::NavigateToURL(browser(), url); | 283 ui_test_utils::NavigateToURL(browser(), url); |
| 254 content::WebContents* tab = | 284 content::WebContents* tab = |
| 255 browser()->tab_strip_model()->GetActiveWebContents(); | 285 browser()->tab_strip_model()->GetActiveWebContents(); |
| 256 | 286 |
| 257 // A sleep is necessary to be able to detect the crash. | 287 // A sleep is necessary to be able to detect the crash. |
| 258 SleepInJavascript(tab, 1000); | 288 test::SleepInJavascript(tab, 1000); |
| 259 | 289 |
| 260 ASSERT_FALSE(tab->IsCrashed()); | 290 ASSERT_FALSE(tab->IsCrashed()); |
| 261 } | 291 } |
| OLD | NEW |