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