| 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/files/file_enumerator.h" | 6 #include "base/files/file_enumerator.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process/launch.h" | 8 #include "base/process/launch.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/infobars/infobar_responder.h" | 13 #include "chrome/browser/infobars/infobar_responder.h" |
| 14 #include "chrome/browser/infobars/infobar_service.h" | 14 #include "chrome/browser/infobars/infobar_service.h" |
| 15 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" | 15 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" |
| 16 #include "chrome/browser/media/webrtc/webrtc_browsertest_common.h" | 16 #include "chrome/browser/media/webrtc/webrtc_browsertest_common.h" |
| 17 #include "chrome/browser/permissions/permission_request_manager.h" | 17 #include "chrome/browser/permissions/permission_request_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" | 19 #include "chrome/browser/ui/browser_tabstrip.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 24 #include "content/public/common/feature_h264_with_openh264_ffmpeg.h" |
| 25 #include "content/public/common/features.h" |
| 24 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
| 25 #include "media/base/media_switches.h" | 27 #include "media/base/media_switches.h" |
| 26 #include "net/test/python_utils.h" | 28 #include "net/test/python_utils.h" |
| 27 #include "ui/gl/gl_switches.h" | 29 #include "ui/gl/gl_switches.h" |
| 28 | 30 |
| 29 const char kTitlePageOfAppEngineAdminPage[] = "Instances"; | 31 const char kTitlePageOfAppEngineAdminPage[] = "Instances"; |
| 30 | 32 |
| 31 const char kIsApprtcCallUpJavascript[] = | 33 const char kIsApprtcCallUpJavascript[] = |
| 32 "var remoteVideo = document.querySelector('#remote-video');" | 34 "var remoteVideo = document.querySelector('#remote-video');" |
| 33 "var remoteVideoActive =" | 35 "var remoteVideoActive =" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 221 |
| 220 base::CommandLine command_line(firefox_launcher); | 222 base::CommandLine command_line(firefox_launcher); |
| 221 command_line.AppendSwitchPath("--binary", firefox_binary); | 223 command_line.AppendSwitchPath("--binary", firefox_binary); |
| 222 command_line.AppendSwitchASCII("--webpage", url.spec()); | 224 command_line.AppendSwitchASCII("--webpage", url.spec()); |
| 223 | 225 |
| 224 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 226 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
| 225 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); | 227 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
| 226 return firefox_.IsValid(); | 228 return firefox_.IsValid(); |
| 227 } | 229 } |
| 228 | 230 |
| 231 void FirefoxApprtcInteropTest(const char* codec) { |
| 232 DetectErrorsInJavaScript(); |
| 233 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); |
| 234 ASSERT_TRUE(LaunchColliderOnLocalHost("http://localhost:9999", "8089")); |
| 235 while (!LocalApprtcInstanceIsUp()) |
| 236 DVLOG(1) << "Waiting for AppRTC to come up..."; |
| 237 |
| 238 GURL room_url = |
| 239 GURL(base::StringPrintf("http://localhost:9999/r/some_room" |
| 240 "?wshpp=localhost:8089&wstls=false" |
| 241 "&firefox_fake_device=1&vsc=%s&vrc=%s", |
| 242 codec, codec) |
| 243 .c_str()); |
| 244 |
| 245 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 246 content::WebContents* chrome_tab = |
| 247 browser()->tab_strip_model()->GetActiveWebContents(); |
| 248 PermissionRequestManager::FromWebContents(chrome_tab) |
| 249 ->set_auto_response_for_test(PermissionRequestManager::ACCEPT_ALL); |
| 250 InfoBarResponder infobar_responder( |
| 251 InfoBarService::FromWebContents(chrome_tab), InfoBarResponder::ACCEPT); |
| 252 ui_test_utils::NavigateToURL(browser(), room_url); |
| 253 |
| 254 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |
| 255 |
| 256 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); |
| 257 |
| 258 // Ensure Firefox manages to send video our way. |
| 259 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); |
| 260 |
| 261 CheckVideoFormat(chrome_tab, codec); |
| 262 } |
| 263 |
| 229 private: | 264 private: |
| 230 base::Process dev_appserver_; | 265 base::Process dev_appserver_; |
| 231 base::Process firefox_; | 266 base::Process firefox_; |
| 232 base::Process collider_server_; | 267 base::Process collider_server_; |
| 233 }; | 268 }; |
| 234 | 269 |
| 235 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { | 270 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { |
| 236 base::ThreadRestrictions::ScopedAllowIO allow_io; | 271 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 237 DetectErrorsInJavaScript(); | 272 DetectErrorsInJavaScript(); |
| 238 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); | 273 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 267 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); | 302 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); |
| 268 | 303 |
| 269 ASSERT_TRUE(DetectRemoteVideoPlaying(left_tab)); | 304 ASSERT_TRUE(DetectRemoteVideoPlaying(left_tab)); |
| 270 ASSERT_TRUE(DetectRemoteVideoPlaying(right_tab)); | 305 ASSERT_TRUE(DetectRemoteVideoPlaying(right_tab)); |
| 271 | 306 |
| 272 chrome::CloseWebContents(browser(), left_tab, false); | 307 chrome::CloseWebContents(browser(), left_tab, false); |
| 273 chrome::CloseWebContents(browser(), right_tab, false); | 308 chrome::CloseWebContents(browser(), right_tab, false); |
| 274 } | 309 } |
| 275 | 310 |
| 276 #if defined(OS_LINUX) | 311 #if defined(OS_LINUX) |
| 277 #define MAYBE_MANUAL_FirefoxApprtcInteropTest MANUAL_FirefoxApprtcInteropTest | 312 #define MAYBE_MANUAL_FirefoxApprtcInteropTestVP8 \ |
| 313 MANUAL_FirefoxApprtcInteropTestVP8 |
| 314 // Firefox does not support VP9. |
| 315 #define MAYBE_MANUAL_FirefoxApprtcInteropTestVP9 \ |
| 316 DISABLED_MANUAL_FirefoxApprtcInteropTestVP9 |
| 317 #define MAYBE_MANUAL_FirefoxApprtcInteropTestH264 \ |
| 318 MANUAL_FirefoxApprtcInteropTestH264 |
| 278 #else | 319 #else |
| 279 // Not implemented yet on Windows and Mac. | 320 // Not implemented yet on Windows and Mac. |
| 280 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter
opTest | 321 #define MAYBE_MANUAL_FirefoxApprtcInteropTestVP9 \ |
| 322 DISABLED_MANUAL_FirefoxApprtcInteropTestVP8 |
| 323 #define MAYBE_MANUAL_FirefoxApprtcInteropTestVP8 \ |
| 324 DISABLED_MANUAL_FirefoxApprtcInteropTestVP9 |
| 325 #define MAYBE_MANUAL_FirefoxApprtcInteropTestH264 \ |
| 326 DISABLED_MANUAL_FirefoxApprtcInteropTestH264 |
| 281 #endif | 327 #endif |
| 282 | 328 |
| 283 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, | 329 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, |
| 284 MAYBE_MANUAL_FirefoxApprtcInteropTest) { | 330 MAYBE_MANUAL_FirefoxApprtcInteropTestVP8) { |
| 285 DetectErrorsInJavaScript(); | 331 FirefoxApprtcInteropTest("VP8"); |
| 286 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); | 332 } |
| 287 ASSERT_TRUE(LaunchColliderOnLocalHost("http://localhost:9999", "8089")); | |
| 288 while (!LocalApprtcInstanceIsUp()) | |
| 289 DVLOG(1) << "Waiting for AppRTC to come up..."; | |
| 290 | 333 |
| 291 GURL room_url = GURL("http://localhost:9999/r/some_room" | 334 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, |
| 292 "?wshpp=localhost:8089&wstls=false" | 335 MAYBE_MANUAL_FirefoxApprtcInteropTestVP9) { |
| 293 "&firefox_fake_device=1"); | 336 FirefoxApprtcInteropTest("VP9"); |
| 294 chrome::AddTabAt(browser(), GURL(), -1, true); | 337 } |
| 295 content::WebContents* chrome_tab = | |
| 296 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 297 PermissionRequestManager::FromWebContents(chrome_tab) | |
| 298 ->set_auto_response_for_test(PermissionRequestManager::ACCEPT_ALL); | |
| 299 InfoBarResponder infobar_responder( | |
| 300 InfoBarService::FromWebContents(chrome_tab), InfoBarResponder::ACCEPT); | |
| 301 ui_test_utils::NavigateToURL(browser(), room_url); | |
| 302 | 338 |
| 303 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | 339 #if BUILDFLAG(RTC_USE_H264) |
| 304 | 340 |
| 305 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | 341 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, |
| 342 MAYBE_MANUAL_FirefoxApprtcInteropTestH264) { |
| 343 // Only run test if run-time feature corresponding to |rtc_use_h264| is on. |
| 344 if (!base::FeatureList::IsEnabled(content::kWebRtcH264WithOpenH264FFmpeg)) { |
| 345 LOG(WARNING) << "Run-time feature WebRTC-H264WithOpenH264FFmpeg disabled. " |
| 346 "Skipping " |
| 347 "WebRtcApprtcBrowserTest.MANUAL_" |
| 348 "FirefoxApprtcInteropTestH264 " |
| 349 "(test \"OK\")"; |
| 350 return; |
| 351 } |
| 352 FirefoxApprtcInteropTest("H264"); |
| 353 } |
| 306 | 354 |
| 307 // Ensure Firefox manages to send video our way. | 355 #endif // #if BUILDFLAG(RTC_USE_H264) |
| 308 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); | |
| 309 } | |
| OLD | NEW |