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