Chromium Code Reviews| Index: chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc |
| diff --git a/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc b/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc |
| index fe56b30b669eac49f5206adefc8df5efbfd5976e..e80e6fc15c371dec26aadd47f452b82606c2dcf9 100644 |
| --- a/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc |
| +++ b/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc |
| @@ -68,6 +68,8 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase { |
| LOG(INFO) << "Entering TearDown"; |
| if (dev_appserver_ != base::kNullProcessHandle) |
| base::KillProcess(dev_appserver_, 0, false); |
| + if (collider_server_ != base::kNullProcessHandle) |
| + base::KillProcess(collider_server_, 0, false); |
| // TODO(phoglund): Find some way to shut down Firefox cleanly on Windows. |
| if (firefox_ != base::kNullProcessHandle) |
| base::KillProcess(firefox_, 0, false); |
| @@ -75,7 +77,7 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase { |
| } |
| protected: |
| - bool LaunchApprtcInstanceOnLocalhost() { |
| + bool LaunchApprtcInstanceOnLocalhost(const std::string& port) { |
| base::FilePath appengine_dev_appserver = |
| GetSourceDir().Append( |
| FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); |
| @@ -98,7 +100,7 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase { |
| command_line.AppendArgPath(appengine_dev_appserver); |
| command_line.AppendArgPath(apprtc_dir); |
| - command_line.AppendArg("--port=9999"); |
| + command_line.AppendArg("--port=" + port); |
| command_line.AppendArg("--admin_port=9998"); |
| command_line.AppendArg("--skip_sdk_update_check"); |
| command_line.AppendArg("--clear_datastore=yes"); |
| @@ -108,6 +110,34 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase { |
| &dev_appserver_); |
| } |
| + bool LaunchColliderOnLocalHost(const std::string& apprtc_url, |
| + const std::string& collider_port) { |
| + // The go workspace should be created, and collidermain built, at the |
| + // runhooks stage when webrtc.DEPS/build_apprtc_collider.py runs. |
| + base::FilePath collider_server = |
| + GetSourceDir().Append(FILE_PATH_LITERAL( |
| +#if defined(OS_WIN) |
| + "out/go-workspace/bin/collidermain.exe")); |
| +#else |
| + "out/go-workspace/bin/collidermain")); |
| +#endif |
| + if (!base::PathExists(collider_server)) { |
| + LOG(ERROR) << "Missing Collider server binary at " << |
| + collider_server.value() << ". " << kAdviseOnGclientSolution; |
| + return false; |
| + } |
| + |
| + CommandLine command_line(collider_server); |
| + |
| + command_line.AppendArg("-tls=false"); |
| + command_line.AppendArg("-port=" + collider_port); |
| + command_line.AppendArg("-room-server=" + apprtc_url); |
| + |
| + DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
| + return base::LaunchProcess(command_line, base::LaunchOptions(), |
| + &collider_server_); |
| + } |
| + |
| bool LocalApprtcInstanceIsUp() { |
| // Load the admin page and see if we manage to load it right. |
| ui_test_utils::NavigateToURL(browser(), GURL("localhost:9998")); |
| @@ -201,24 +231,9 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase { |
| &firefox_); |
| } |
| - bool HasWebcamOnSystem() { |
| -#if defined(OS_LINUX) |
| - // Implementation note: normally we would be able to figure this out with |
| - // MediaStreamTrack.getSources, but we can't ask Chrome since it runs in |
| - // fake device mode where it will not enumerate webcams on the system. |
| - // Therefore, look for /dev/video* entries directly since this test only |
| - // runs on Linux for now anyway. |
| - base::FileEnumerator dev_video(base::FilePath(FILE_PATH_LITERAL("/dev")), |
| - false, base::FileEnumerator::FILES, |
| - FILE_PATH_LITERAL("video*")); |
| - return !dev_video.Next().empty(); |
| -#endif |
| - NOTREACHED(); |
| - return false; |
| - } |
| - |
| private: |
| base::ProcessHandle dev_appserver_; |
| + base::ProcessHandle collider_server_; |
| base::ProcessHandle firefox_; |
| }; |
| @@ -228,12 +243,13 @@ IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { |
| return; |
| DetectErrorsInJavaScript(); |
| - ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); |
| + ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); |
| + ASSERT_TRUE(LaunchColliderOnLocalHost("http://localhost:9999", "8089")); |
|
kjellander_chromium
2014/12/08 14:57:43
I'd suggest extracting a few constants here...
phoglund_chromium
2014/12/08 15:28:32
Not sure if that makes stuff better. Sure, I menti
|
| while (!LocalApprtcInstanceIsUp()) |
| DVLOG(1) << "Waiting for AppRTC to come up..."; |
| - GURL room_url = GURL(base::StringPrintf("localhost:9999?r=room_%d", |
| - base::RandInt(0, 65536))); |
| + GURL room_url = GURL("http://localhost:9999/r/some_room" |
|
kjellander_chromium
2014/12/08 14:57:43
Create a constant? Then you could just append the
phoglund_chromium
2014/12/08 15:28:32
Yeah, but then the juicy parts about how stuff is
|
| + "?wsh=localhost&wsp=8089&wstls=false"); |
| chrome::AddTabAt(browser(), GURL(), -1, true); |
| content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url); |
| @@ -270,12 +286,14 @@ IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, |
| return; |
| DetectErrorsInJavaScript(); |
| - ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); |
| + ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); |
| + ASSERT_TRUE(LaunchColliderOnLocalHost("http://localhost:9999", "8089")); |
| while (!LocalApprtcInstanceIsUp()) |
| DVLOG(1) << "Waiting for AppRTC to come up..."; |
| - GURL room_url = GURL( |
| - "http://localhost:9999?r=some_room_id&firefox_fake_device=1"); |
| + GURL room_url = GURL("http://localhost:9999/r/some_room" |
| + "?wsh=localhost&wsp=8089&wstls=false" |
| + "&firefox_fake_device=1"); |
| content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); |
| ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |