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" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/infobars/infobar_responder.h" | 12 #include "chrome/browser/infobars/infobar_responder.h" |
13 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
14 #include "chrome/browser/media/webrtc_browsertest_base.h" | 14 #include "chrome/browser/media/webrtc_browsertest_base.h" |
15 #include "chrome/browser/media/webrtc_browsertest_common.h" | 15 #include "chrome/browser/media/webrtc_browsertest_common.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_tabstrip.h" | 17 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 19 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "media/base/media_switches.h" | 24 #include "media/base/media_switches.h" |
25 #include "net/test/python_utils.h" | 25 #include "net/test/python_utils.h" |
26 #include "ui/gl/gl_switches.h" | 26 #include "ui/gl/gl_switches.h" |
27 | 27 |
28 // You need this solution to run this test. The solution will download appengine | |
29 // and the apprtc code for you. | |
30 const char kAdviseOnGclientSolution[] = | |
31 "You need to add this solution to your .gclient to run this test:\n" | |
32 "{\n" | |
33 " \"name\" : \"webrtc.DEPS\",\n" | |
34 " \"url\" : \"https://chromium.googlesource.com/chromium/deps/" | |
35 "webrtc/webrtc.DEPS\",\n" | |
36 "}"; | |
37 const char kTitlePageOfAppEngineAdminPage[] = "Instances"; | 28 const char kTitlePageOfAppEngineAdminPage[] = "Instances"; |
38 | 29 |
39 const char kIsApprtcCallUpJavascript[] = | 30 const char kIsApprtcCallUpJavascript[] = |
40 "var remoteVideo = document.querySelector('#remote-video');" | 31 "var remoteVideo = document.querySelector('#remote-video');" |
41 "var remoteVideoActive =" | 32 "var remoteVideoActive =" |
42 " remoteVideo != null &&" | 33 " remoteVideo != null &&" |
43 " remoteVideo.classList.contains('active');" | 34 " remoteVideo.classList.contains('active');" |
44 "window.domAutomationController.send(remoteVideoActive.toString());"; | 35 "window.domAutomationController.send(remoteVideoActive.toString());"; |
45 | 36 |
46 | 37 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 LOG(INFO) << "Exiting TearDown"; | 69 LOG(INFO) << "Exiting TearDown"; |
79 } | 70 } |
80 | 71 |
81 protected: | 72 protected: |
82 bool LaunchApprtcInstanceOnLocalhost(const std::string& port) { | 73 bool LaunchApprtcInstanceOnLocalhost(const std::string& port) { |
83 base::FilePath appengine_dev_appserver = | 74 base::FilePath appengine_dev_appserver = |
84 GetSourceDir().Append( | 75 GetSourceDir().Append( |
85 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); | 76 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); |
86 if (!base::PathExists(appengine_dev_appserver)) { | 77 if (!base::PathExists(appengine_dev_appserver)) { |
87 LOG(ERROR) << "Missing appengine sdk at " << | 78 LOG(ERROR) << "Missing appengine sdk at " << |
88 appengine_dev_appserver.value() << ". " << kAdviseOnGclientSolution; | 79 appengine_dev_appserver.value() << ".\n" << |
| 80 test::kAdviseOnGclientSolution; |
89 return false; | 81 return false; |
90 } | 82 } |
91 | 83 |
92 base::FilePath apprtc_dir = | 84 base::FilePath apprtc_dir = |
93 GetSourceDir().Append(FILE_PATH_LITERAL("out/apprtc/out/app_engine")); | 85 GetSourceDir().Append(FILE_PATH_LITERAL("out/apprtc/out/app_engine")); |
94 if (!base::PathExists(apprtc_dir)) { | 86 if (!base::PathExists(apprtc_dir)) { |
95 LOG(ERROR) << "Missing AppRTC AppEngine app at " << | 87 LOG(ERROR) << "Missing AppRTC AppEngine app at " << |
96 apprtc_dir.value() << ". " << kAdviseOnGclientSolution; | 88 apprtc_dir.value() << ".\n" << test::kAdviseOnGclientSolution; |
97 return false; | 89 return false; |
98 } | 90 } |
99 if (!base::PathExists(apprtc_dir.Append(FILE_PATH_LITERAL("app.yaml")))) { | 91 if (!base::PathExists(apprtc_dir.Append(FILE_PATH_LITERAL("app.yaml")))) { |
100 LOG(ERROR) << "The AppRTC AppEngine app at " << | 92 LOG(ERROR) << "The AppRTC AppEngine app at " << |
101 apprtc_dir.value() << " appears to have not been built." << | 93 apprtc_dir.value() << " appears to have not been built." << |
102 "This should have been done by webrtc.DEPS scripts which invoke " << | 94 "This should have been done by webrtc.DEPS scripts which invoke " << |
103 "'grunt build' on AppRTC."; | 95 "'grunt build' on AppRTC."; |
104 return false; | 96 return false; |
105 } | 97 } |
106 | 98 |
(...skipping 18 matching lines...) Expand all Loading... |
125 // runhooks stage when webrtc.DEPS/build_apprtc_collider.py runs. | 117 // runhooks stage when webrtc.DEPS/build_apprtc_collider.py runs. |
126 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
127 base::FilePath collider_server = GetSourceDir().Append( | 119 base::FilePath collider_server = GetSourceDir().Append( |
128 FILE_PATH_LITERAL("out/go-workspace/bin/collidermain.exe")); | 120 FILE_PATH_LITERAL("out/go-workspace/bin/collidermain.exe")); |
129 #else | 121 #else |
130 base::FilePath collider_server = GetSourceDir().Append( | 122 base::FilePath collider_server = GetSourceDir().Append( |
131 FILE_PATH_LITERAL("out/go-workspace/bin/collidermain")); | 123 FILE_PATH_LITERAL("out/go-workspace/bin/collidermain")); |
132 #endif | 124 #endif |
133 if (!base::PathExists(collider_server)) { | 125 if (!base::PathExists(collider_server)) { |
134 LOG(ERROR) << "Missing Collider server binary at " << | 126 LOG(ERROR) << "Missing Collider server binary at " << |
135 collider_server.value() << ". " << kAdviseOnGclientSolution; | 127 collider_server.value() << ".\n" << test::kAdviseOnGclientSolution; |
136 return false; | 128 return false; |
137 } | 129 } |
138 | 130 |
139 base::CommandLine command_line(collider_server); | 131 base::CommandLine command_line(collider_server); |
140 | 132 |
141 command_line.AppendArg("-tls=false"); | 133 command_line.AppendArg("-tls=false"); |
142 command_line.AppendArg("-port=" + collider_port); | 134 command_line.AppendArg("-port=" + collider_port); |
143 command_line.AppendArg("-room-server=" + apprtc_url); | 135 command_line.AppendArg("-room-server=" + apprtc_url); |
144 | 136 |
145 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 137 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | 194 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); |
203 return source_dir; | 195 return source_dir; |
204 } | 196 } |
205 | 197 |
206 bool LaunchFirefoxWithUrl(const GURL& url) { | 198 bool LaunchFirefoxWithUrl(const GURL& url) { |
207 base::FilePath firefox_binary = | 199 base::FilePath firefox_binary = |
208 GetSourceDir().Append( | 200 GetSourceDir().Append( |
209 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); | 201 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); |
210 if (!base::PathExists(firefox_binary)) { | 202 if (!base::PathExists(firefox_binary)) { |
211 LOG(ERROR) << "Missing firefox binary at " << | 203 LOG(ERROR) << "Missing firefox binary at " << |
212 firefox_binary.value() << ". " << kAdviseOnGclientSolution; | 204 firefox_binary.value() << ".\n" << test::kAdviseOnGclientSolution; |
213 return false; | 205 return false; |
214 } | 206 } |
215 base::FilePath firefox_launcher = | 207 base::FilePath firefox_launcher = |
216 GetSourceDir().Append( | 208 GetSourceDir().Append( |
217 FILE_PATH_LITERAL("../webrtc.DEPS/run_firefox_webrtc.py")); | 209 FILE_PATH_LITERAL("../webrtc.DEPS/run_firefox_webrtc.py")); |
218 if (!base::PathExists(firefox_launcher)) { | 210 if (!base::PathExists(firefox_launcher)) { |
219 LOG(ERROR) << "Missing firefox launcher at " << | 211 LOG(ERROR) << "Missing firefox launcher at " << |
220 firefox_launcher.value() << ". " << kAdviseOnGclientSolution; | 212 firefox_launcher.value() << ".\n" << test::kAdviseOnGclientSolution; |
221 return false; | 213 return false; |
222 } | 214 } |
223 | 215 |
224 base::CommandLine command_line(firefox_launcher); | 216 base::CommandLine command_line(firefox_launcher); |
225 command_line.AppendSwitchPath("--binary", firefox_binary); | 217 command_line.AppendSwitchPath("--binary", firefox_binary); |
226 command_line.AppendSwitchASCII("--webpage", url.spec()); | 218 command_line.AppendSwitchASCII("--webpage", url.spec()); |
227 | 219 |
228 DVLOG(1) << "Running " << command_line.GetCommandLineString(); | 220 DVLOG(1) << "Running " << command_line.GetCommandLineString(); |
229 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); | 221 firefox_ = base::LaunchProcess(command_line, base::LaunchOptions()); |
230 return firefox_.IsValid(); | 222 return firefox_.IsValid(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 InfoBarService::FromWebContents(chrome_tab), InfoBarResponder::ACCEPT); | 304 InfoBarService::FromWebContents(chrome_tab), InfoBarResponder::ACCEPT); |
313 ui_test_utils::NavigateToURL(browser(), room_url); | 305 ui_test_utils::NavigateToURL(browser(), room_url); |
314 | 306 |
315 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | 307 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |
316 | 308 |
317 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | 309 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); |
318 | 310 |
319 // Ensure Firefox manages to send video our way. | 311 // Ensure Firefox manages to send video our way. |
320 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); | 312 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); |
321 } | 313 } |
OLD | NEW |