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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void SetUpCommandLine(CommandLine* command_line) override { | 54 void SetUpCommandLine(CommandLine* command_line) override { |
55 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 55 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
56 | 56 |
57 // 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. |
58 command_line->AppendSwitch(switches::kUseGpuInTests); | 58 command_line->AppendSwitch(switches::kUseGpuInTests); |
59 CommandLine::ForCurrentProcess()->AppendSwitch( | 59 CommandLine::ForCurrentProcess()->AppendSwitch( |
60 switches::kUseFakeDeviceForMediaStream); | 60 switches::kUseFakeDeviceForMediaStream); |
61 } | 61 } |
62 | 62 |
63 void TearDown() override { | 63 void TearDown() override { |
64 // Kill any processes we may have brought up. | 64 // Kill any processes we may have brought up. Note: this isn't perfect, |
| 65 // especially if the test hangs or if we're on Windows. |
65 LOG(INFO) << "Entering TearDown"; | 66 LOG(INFO) << "Entering TearDown"; |
66 if (dev_appserver_.IsValid()) | 67 if (dev_appserver_.IsValid()) |
67 base::KillProcess(dev_appserver_.Handle(), 0, false); | 68 base::KillProcess(dev_appserver_.Handle(), 0, false); |
68 // TODO(phoglund): Find some way to shut down Firefox cleanly on Windows. | 69 if (collider_server_.IsValid()) |
| 70 base::KillProcess(collider_server_.Handle(), 0, false); |
69 if (firefox_.IsValid()) | 71 if (firefox_.IsValid()) |
70 base::KillProcess(firefox_.Handle(), 0, false); | 72 base::KillProcess(firefox_.Handle(), 0, false); |
71 LOG(INFO) << "Exiting TearDown"; | 73 LOG(INFO) << "Exiting TearDown"; |
72 } | 74 } |
73 | 75 |
74 protected: | 76 protected: |
75 bool LaunchApprtcInstanceOnLocalhost() { | 77 bool LaunchApprtcInstanceOnLocalhost(const std::string& port) { |
76 base::FilePath appengine_dev_appserver = | 78 base::FilePath appengine_dev_appserver = |
77 GetSourceDir().Append( | 79 GetSourceDir().Append( |
78 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); | 80 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); |
79 if (!base::PathExists(appengine_dev_appserver)) { | 81 if (!base::PathExists(appengine_dev_appserver)) { |
80 LOG(ERROR) << "Missing appengine sdk at " << | 82 LOG(ERROR) << "Missing appengine sdk at " << |
81 appengine_dev_appserver.value() << ". " << kAdviseOnGclientSolution; | 83 appengine_dev_appserver.value() << ". " << kAdviseOnGclientSolution; |
82 return false; | 84 return false; |
83 } | 85 } |
84 | 86 |
85 base::FilePath apprtc_dir = | 87 base::FilePath apprtc_dir = |
86 GetSourceDir().Append(FILE_PATH_LITERAL("out/apprtc")); | 88 GetSourceDir().Append(FILE_PATH_LITERAL("out/apprtc")); |
87 if (!base::PathExists(apprtc_dir)) { | 89 if (!base::PathExists(apprtc_dir)) { |
88 LOG(ERROR) << "Missing AppRTC code at " << | 90 LOG(ERROR) << "Missing AppRTC code at " << |
89 apprtc_dir.value() << ". " << kAdviseOnGclientSolution; | 91 apprtc_dir.value() << ". " << kAdviseOnGclientSolution; |
90 return false; | 92 return false; |
91 } | 93 } |
92 | 94 |
93 CommandLine command_line(CommandLine::NO_PROGRAM); | 95 CommandLine command_line(CommandLine::NO_PROGRAM); |
94 EXPECT_TRUE(GetPythonCommand(&command_line)); | 96 EXPECT_TRUE(GetPythonCommand(&command_line)); |
95 | 97 |
96 command_line.AppendArgPath(appengine_dev_appserver); | 98 command_line.AppendArgPath(appengine_dev_appserver); |
97 command_line.AppendArgPath(apprtc_dir); | 99 command_line.AppendArgPath(apprtc_dir); |
98 command_line.AppendArg("--port=9999"); | 100 command_line.AppendArg("--port=" + port); |
99 command_line.AppendArg("--admin_port=9998"); | 101 command_line.AppendArg("--admin_port=9998"); |
100 command_line.AppendArg("--skip_sdk_update_check"); | 102 command_line.AppendArg("--skip_sdk_update_check"); |
101 command_line.AppendArg("--clear_datastore=yes"); | 103 command_line.AppendArg("--clear_datastore=yes"); |
102 | 104 |
103 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 105 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
104 dev_appserver_ = base::LaunchProcess(command_line, base::LaunchOptions()); | 106 dev_appserver_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
105 return dev_appserver_.IsValid(); | 107 return dev_appserver_.IsValid(); |
106 } | 108 } |
107 | 109 |
| 110 bool LaunchColliderOnLocalHost(const std::string& apprtc_url, |
| 111 const std::string& collider_port) { |
| 112 // The go workspace should be created, and collidermain built, at the |
| 113 // runhooks stage when webrtc.DEPS/build_apprtc_collider.py runs. |
| 114 #if defined(OS_WIN) |
| 115 base::FilePath collider_server = GetSourceDir().Append( |
| 116 FILE_PATH_LITERAL("out/go-workspace/bin/collidermain.exe")); |
| 117 #else |
| 118 base::FilePath collider_server = GetSourceDir().Append( |
| 119 FILE_PATH_LITERAL("out/go-workspace/bin/collidermain")); |
| 120 #endif |
| 121 if (!base::PathExists(collider_server)) { |
| 122 LOG(ERROR) << "Missing Collider server binary at " << |
| 123 collider_server.value() << ". " << kAdviseOnGclientSolution; |
| 124 return false; |
| 125 } |
| 126 |
| 127 CommandLine command_line(collider_server); |
| 128 |
| 129 command_line.AppendArg("-tls=false"); |
| 130 command_line.AppendArg("-port=" + collider_port); |
| 131 command_line.AppendArg("-room-server=" + apprtc_url); |
| 132 |
| 133 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
| 134 collider_server_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
| 135 return collider_server_.IsValid(); |
| 136 } |
| 137 |
108 bool LocalApprtcInstanceIsUp() { | 138 bool LocalApprtcInstanceIsUp() { |
109 // Load the admin page and see if we manage to load it right. | 139 // Load the admin page and see if we manage to load it right. |
110 ui_test_utils::NavigateToURL(browser(), GURL("localhost:9998")); | 140 ui_test_utils::NavigateToURL(browser(), GURL("localhost:9998")); |
111 content::WebContents* tab_contents = | 141 content::WebContents* tab_contents = |
112 browser()->tab_strip_model()->GetActiveWebContents(); | 142 browser()->tab_strip_model()->GetActiveWebContents(); |
113 std::string javascript = | 143 std::string javascript = |
114 "window.domAutomationController.send(document.title)"; | 144 "window.domAutomationController.send(document.title)"; |
115 std::string result; | 145 std::string result; |
116 if (!content::ExecuteScriptAndExtractString(tab_contents, javascript, | 146 if (!content::ExecuteScriptAndExtractString(tab_contents, javascript, |
117 &result)) | 147 &result)) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 221 |
192 CommandLine command_line(firefox_launcher); | 222 CommandLine command_line(firefox_launcher); |
193 command_line.AppendSwitchPath("--binary", firefox_binary); | 223 command_line.AppendSwitchPath("--binary", firefox_binary); |
194 command_line.AppendSwitchASCII("--webpage", url.spec()); | 224 command_line.AppendSwitchASCII("--webpage", url.spec()); |
195 | 225 |
196 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 226 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
197 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); | 227 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
198 return firefox_.IsValid(); | 228 return firefox_.IsValid(); |
199 } | 229 } |
200 | 230 |
201 bool HasWebcamOnSystem() { | |
202 #if defined(OS_LINUX) | |
203 // Implementation note: normally we would be able to figure this out with | |
204 // MediaStreamTrack.getSources, but we can't ask Chrome since it runs in | |
205 // fake device mode where it will not enumerate webcams on the system. | |
206 // Therefore, look for /dev/video* entries directly since this test only | |
207 // runs on Linux for now anyway. | |
208 base::FileEnumerator dev_video(base::FilePath(FILE_PATH_LITERAL("/dev")), | |
209 false, base::FileEnumerator::FILES, | |
210 FILE_PATH_LITERAL("video*")); | |
211 return !dev_video.Next().empty(); | |
212 #endif | |
213 NOTREACHED(); | |
214 return false; | |
215 } | |
216 | |
217 private: | 231 private: |
218 base::Process dev_appserver_; | 232 base::Process dev_appserver_; |
219 base::Process firefox_; | 233 base::Process firefox_; |
| 234 base::Process collider_server_; |
220 }; | 235 }; |
221 | 236 |
222 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { | 237 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { |
223 // Disabled on Win XP: http://code.google.com/p/webrtc/issues/detail?id=2703. | 238 // Disabled on Win XP: http://code.google.com/p/webrtc/issues/detail?id=2703. |
224 if (OnWinXp()) | 239 if (OnWinXp()) |
225 return; | 240 return; |
226 | 241 |
227 DetectErrorsInJavaScript(); | 242 DetectErrorsInJavaScript(); |
228 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); | 243 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); |
| 244 ASSERT_TRUE(LaunchColliderOnLocalHost("http://localhost:9999", "8089")); |
229 while (!LocalApprtcInstanceIsUp()) | 245 while (!LocalApprtcInstanceIsUp()) |
230 DVLOG(1) << "Waiting for AppRTC to come up..."; | 246 DVLOG(1) << "Waiting for AppRTC to come up..."; |
231 | 247 |
232 GURL room_url = GURL(base::StringPrintf("localhost:9999?r=room_%d", | 248 GURL room_url = GURL("http://localhost:9999/r/some_room" |
233 base::RandInt(0, 65536))); | 249 "?wsh=localhost&wsp=8089&wstls=false"); |
234 | 250 |
235 chrome::AddTabAt(browser(), GURL(), -1, true); | 251 chrome::AddTabAt(browser(), GURL(), -1, true); |
236 content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url); | 252 content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url); |
237 | 253 |
238 chrome::AddTabAt(browser(), GURL(), -1, true); | 254 chrome::AddTabAt(browser(), GURL(), -1, true); |
239 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); | 255 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); |
240 | 256 |
241 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); | 257 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); |
242 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); | 258 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); |
243 | 259 |
(...skipping 16 matching lines...) Expand all Loading... |
260 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter
opTest | 276 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter
opTest |
261 #endif | 277 #endif |
262 | 278 |
263 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, | 279 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, |
264 MAYBE_MANUAL_FirefoxApprtcInteropTest) { | 280 MAYBE_MANUAL_FirefoxApprtcInteropTest) { |
265 // Disabled on Win XP: http://code.google.com/p/webrtc/issues/detail?id=2703. | 281 // Disabled on Win XP: http://code.google.com/p/webrtc/issues/detail?id=2703. |
266 if (OnWinXp()) | 282 if (OnWinXp()) |
267 return; | 283 return; |
268 | 284 |
269 DetectErrorsInJavaScript(); | 285 DetectErrorsInJavaScript(); |
270 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); | 286 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost("9999")); |
| 287 ASSERT_TRUE(LaunchColliderOnLocalHost("http://localhost:9999", "8089")); |
271 while (!LocalApprtcInstanceIsUp()) | 288 while (!LocalApprtcInstanceIsUp()) |
272 DVLOG(1) << "Waiting for AppRTC to come up..."; | 289 DVLOG(1) << "Waiting for AppRTC to come up..."; |
273 | 290 |
274 GURL room_url = GURL( | 291 GURL room_url = GURL("http://localhost:9999/r/some_room" |
275 "http://localhost:9999?r=some_room_id&firefox_fake_device=1"); | 292 "?wsh=localhost&wsp=8089&wstls=false" |
| 293 "&firefox_fake_device=1"); |
276 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); | 294 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); |
277 | 295 |
278 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | 296 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |
279 | 297 |
280 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | 298 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); |
281 | 299 |
282 // Ensure Firefox manages to send video our way. | 300 // Ensure Firefox manages to send video our way. |
283 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); | 301 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); |
284 } | 302 } |
OLD | NEW |