| 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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // WebRTC-AppRTC integration test. Requires a real webcam and microphone | 42 // WebRTC-AppRTC integration test. Requires a real webcam and microphone |
| 43 // on the running system. This test is not meant to run in the main browser | 43 // on the running system. This test is not meant to run in the main browser |
| 44 // test suite since normal tester machines do not have webcams. Chrome will use | 44 // test suite since normal tester machines do not have webcams. Chrome will use |
| 45 // its fake camera for both tests, but Firefox will use the real webcam in the | 45 // its fake camera for both tests, but Firefox will use the real webcam in the |
| 46 // Firefox interop test. Thus, this test must on a machine with a real webcam. | 46 // Firefox interop test. Thus, this test must on a machine with a real webcam. |
| 47 // | 47 // |
| 48 // This test will bring up a AppRTC instance on localhost and verify that the | 48 // This test will bring up a AppRTC instance on localhost and verify that the |
| 49 // call gets up when connecting to the same room from two tabs in a browser. | 49 // call gets up when connecting to the same room from two tabs in a browser. |
| 50 class WebRtcApprtcBrowserTest : public WebRtcTestBase { | 50 class WebRtcApprtcBrowserTest : public WebRtcTestBase { |
| 51 public: | 51 public: |
| 52 WebRtcApprtcBrowserTest() | 52 WebRtcApprtcBrowserTest() {} |
| 53 : dev_appserver_(base::kNullProcessHandle), | |
| 54 firefox_(base::kNullProcessHandle) { | |
| 55 } | |
| 56 | 53 |
| 57 void SetUpCommandLine(CommandLine* command_line) override { | 54 void SetUpCommandLine(CommandLine* command_line) override { |
| 58 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 55 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
| 59 | 56 |
| 60 // The video playback will not work without a GPU, so force its use here. | 57 // The video playback will not work without a GPU, so force its use here. |
| 61 command_line->AppendSwitch(switches::kUseGpuInTests); | 58 command_line->AppendSwitch(switches::kUseGpuInTests); |
| 62 CommandLine::ForCurrentProcess()->AppendSwitch( | 59 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 63 switches::kUseFakeDeviceForMediaStream); | 60 switches::kUseFakeDeviceForMediaStream); |
| 64 } | 61 } |
| 65 | 62 |
| 66 void TearDown() override { | 63 void TearDown() override { |
| 67 // Kill any processes we may have brought up. | 64 // Kill any processes we may have brought up. |
| 68 LOG(INFO) << "Entering TearDown"; | 65 LOG(INFO) << "Entering TearDown"; |
| 69 if (dev_appserver_ != base::kNullProcessHandle) | 66 if (dev_appserver_.IsValid()) |
| 70 base::KillProcess(dev_appserver_, 0, false); | 67 base::KillProcess(dev_appserver_.Handle(), 0, false); |
| 71 // TODO(phoglund): Find some way to shut down Firefox cleanly on Windows. | 68 // TODO(phoglund): Find some way to shut down Firefox cleanly on Windows. |
| 72 if (firefox_ != base::kNullProcessHandle) | 69 if (firefox_.IsValid()) |
| 73 base::KillProcess(firefox_, 0, false); | 70 base::KillProcess(firefox_.Handle(), 0, false); |
| 74 LOG(INFO) << "Exiting TearDown"; | 71 LOG(INFO) << "Exiting TearDown"; |
| 75 } | 72 } |
| 76 | 73 |
| 77 protected: | 74 protected: |
| 78 bool LaunchApprtcInstanceOnLocalhost() { | 75 bool LaunchApprtcInstanceOnLocalhost() { |
| 79 base::FilePath appengine_dev_appserver = | 76 base::FilePath appengine_dev_appserver = |
| 80 GetSourceDir().Append( | 77 GetSourceDir().Append( |
| 81 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); | 78 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); |
| 82 if (!base::PathExists(appengine_dev_appserver)) { | 79 if (!base::PathExists(appengine_dev_appserver)) { |
| 83 LOG(ERROR) << "Missing appengine sdk at " << | 80 LOG(ERROR) << "Missing appengine sdk at " << |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 EXPECT_TRUE(GetPythonCommand(&command_line)); | 94 EXPECT_TRUE(GetPythonCommand(&command_line)); |
| 98 | 95 |
| 99 command_line.AppendArgPath(appengine_dev_appserver); | 96 command_line.AppendArgPath(appengine_dev_appserver); |
| 100 command_line.AppendArgPath(apprtc_dir); | 97 command_line.AppendArgPath(apprtc_dir); |
| 101 command_line.AppendArg("--port=9999"); | 98 command_line.AppendArg("--port=9999"); |
| 102 command_line.AppendArg("--admin_port=9998"); | 99 command_line.AppendArg("--admin_port=9998"); |
| 103 command_line.AppendArg("--skip_sdk_update_check"); | 100 command_line.AppendArg("--skip_sdk_update_check"); |
| 104 command_line.AppendArg("--clear_datastore=yes"); | 101 command_line.AppendArg("--clear_datastore=yes"); |
| 105 | 102 |
| 106 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 103 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
| 107 return base::LaunchProcess(command_line, base::LaunchOptions(), | 104 dev_appserver_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
| 108 &dev_appserver_); | 105 return dev_appserver_.IsValid(); |
| 109 } | 106 } |
| 110 | 107 |
| 111 bool LocalApprtcInstanceIsUp() { | 108 bool LocalApprtcInstanceIsUp() { |
| 112 // Load the admin page and see if we manage to load it right. | 109 // Load the admin page and see if we manage to load it right. |
| 113 ui_test_utils::NavigateToURL(browser(), GURL("localhost:9998")); | 110 ui_test_utils::NavigateToURL(browser(), GURL("localhost:9998")); |
| 114 content::WebContents* tab_contents = | 111 content::WebContents* tab_contents = |
| 115 browser()->tab_strip_model()->GetActiveWebContents(); | 112 browser()->tab_strip_model()->GetActiveWebContents(); |
| 116 std::string javascript = | 113 std::string javascript = |
| 117 "window.domAutomationController.send(document.title)"; | 114 "window.domAutomationController.send(document.title)"; |
| 118 std::string result; | 115 std::string result; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 LOG(ERROR) << "Missing firefox launcher at " << | 187 LOG(ERROR) << "Missing firefox launcher at " << |
| 191 firefox_launcher.value() << ". " << kAdviseOnGclientSolution; | 188 firefox_launcher.value() << ". " << kAdviseOnGclientSolution; |
| 192 return false; | 189 return false; |
| 193 } | 190 } |
| 194 | 191 |
| 195 CommandLine command_line(firefox_launcher); | 192 CommandLine command_line(firefox_launcher); |
| 196 command_line.AppendSwitchPath("--binary", firefox_binary); | 193 command_line.AppendSwitchPath("--binary", firefox_binary); |
| 197 command_line.AppendSwitchASCII("--webpage", url.spec()); | 194 command_line.AppendSwitchASCII("--webpage", url.spec()); |
| 198 | 195 |
| 199 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 196 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
| 200 return base::LaunchProcess(command_line, base::LaunchOptions(), | 197 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
| 201 &firefox_); | 198 return firefox_.IsValid(); |
| 202 } | 199 } |
| 203 | 200 |
| 204 bool HasWebcamOnSystem() { | 201 bool HasWebcamOnSystem() { |
| 205 #if defined(OS_LINUX) | 202 #if defined(OS_LINUX) |
| 206 // Implementation note: normally we would be able to figure this out with | 203 // Implementation note: normally we would be able to figure this out with |
| 207 // MediaStreamTrack.getSources, but we can't ask Chrome since it runs in | 204 // MediaStreamTrack.getSources, but we can't ask Chrome since it runs in |
| 208 // fake device mode where it will not enumerate webcams on the system. | 205 // fake device mode where it will not enumerate webcams on the system. |
| 209 // Therefore, look for /dev/video* entries directly since this test only | 206 // Therefore, look for /dev/video* entries directly since this test only |
| 210 // runs on Linux for now anyway. | 207 // runs on Linux for now anyway. |
| 211 base::FileEnumerator dev_video(base::FilePath(FILE_PATH_LITERAL("/dev")), | 208 base::FileEnumerator dev_video(base::FilePath(FILE_PATH_LITERAL("/dev")), |
| 212 false, base::FileEnumerator::FILES, | 209 false, base::FileEnumerator::FILES, |
| 213 FILE_PATH_LITERAL("video*")); | 210 FILE_PATH_LITERAL("video*")); |
| 214 return !dev_video.Next().empty(); | 211 return !dev_video.Next().empty(); |
| 215 #endif | 212 #endif |
| 216 NOTREACHED(); | 213 NOTREACHED(); |
| 217 return false; | 214 return false; |
| 218 } | 215 } |
| 219 | 216 |
| 220 private: | 217 private: |
| 221 base::ProcessHandle dev_appserver_; | 218 base::Process dev_appserver_; |
| 222 base::ProcessHandle firefox_; | 219 base::Process firefox_; |
| 223 }; | 220 }; |
| 224 | 221 |
| 225 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { | 222 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { |
| 226 // Disabled on Win XP: http://code.google.com/p/webrtc/issues/detail?id=2703. | 223 // Disabled on Win XP: http://code.google.com/p/webrtc/issues/detail?id=2703. |
| 227 if (OnWinXp()) | 224 if (OnWinXp()) |
| 228 return; | 225 return; |
| 229 | 226 |
| 230 DetectErrorsInJavaScript(); | 227 DetectErrorsInJavaScript(); |
| 231 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); | 228 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); |
| 232 while (!LocalApprtcInstanceIsUp()) | 229 while (!LocalApprtcInstanceIsUp()) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 "http://localhost:9999?r=some_room_id&firefox_fake_device=1"); | 275 "http://localhost:9999?r=some_room_id&firefox_fake_device=1"); |
| 279 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); | 276 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); |
| 280 | 277 |
| 281 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | 278 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |
| 282 | 279 |
| 283 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | 280 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); |
| 284 | 281 |
| 285 // Ensure Firefox manages to send video our way. | 282 // Ensure Firefox manages to send video our way. |
| 286 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); | 283 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); |
| 287 } | 284 } |
| OLD | NEW |