| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return false; | 148 return false; |
| 149 | 149 |
| 150 return result == kTitlePageOfAppEngineAdminPage; | 150 return result == kTitlePageOfAppEngineAdminPage; |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool WaitForCallToComeUp(content::WebContents* tab_contents) { | 153 bool WaitForCallToComeUp(content::WebContents* tab_contents) { |
| 154 return test::PollingWaitUntil(kIsApprtcCallUpJavascript, "true", | 154 return test::PollingWaitUntil(kIsApprtcCallUpJavascript, "true", |
| 155 tab_contents); | 155 tab_contents); |
| 156 } | 156 } |
| 157 | 157 |
| 158 bool WaitForCallToHangUp(content::WebContents* tab_contents) { | |
| 159 return test::PollingWaitUntil(kIsApprtcCallUpJavascript, "false", | |
| 160 tab_contents); | |
| 161 } | |
| 162 | |
| 163 bool EvalInJavascriptFile(content::WebContents* tab_contents, | 158 bool EvalInJavascriptFile(content::WebContents* tab_contents, |
| 164 const base::FilePath& path) { | 159 const base::FilePath& path) { |
| 165 std::string javascript; | 160 std::string javascript; |
| 166 if (!ReadFileToString(path, &javascript)) { | 161 if (!ReadFileToString(path, &javascript)) { |
| 167 LOG(ERROR) << "Missing javascript code at " << path.value() << "."; | 162 LOG(ERROR) << "Missing javascript code at " << path.value() << "."; |
| 168 return false; | 163 return false; |
| 169 } | 164 } |
| 170 | 165 |
| 171 if (!content::ExecuteScript(tab_contents, javascript)) { | 166 if (!content::ExecuteScript(tab_contents, javascript)) { |
| 172 LOG(ERROR) << "Failed to execute the following javascript: " << | 167 LOG(ERROR) << "Failed to execute the following javascript: " << |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 if (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append( | 178 if (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append( |
| 184 FILE_PATH_LITERAL("chrome/test/data/webrtc/video_detector.js")))) | 179 FILE_PATH_LITERAL("chrome/test/data/webrtc/video_detector.js")))) |
| 185 return false; | 180 return false; |
| 186 | 181 |
| 187 // The remote video tag is called remoteVideo in the AppRTC code. | 182 // The remote video tag is called remoteVideo in the AppRTC code. |
| 188 StartDetectingVideo(tab_contents, "remote-video"); | 183 StartDetectingVideo(tab_contents, "remote-video"); |
| 189 WaitForVideoToPlay(tab_contents); | 184 WaitForVideoToPlay(tab_contents); |
| 190 return true; | 185 return true; |
| 191 } | 186 } |
| 192 | 187 |
| 193 bool HangUpApprtcCall(content::WebContents* tab_contents) { | |
| 194 // This is the same as clicking the Hangup button in the AppRTC call. | |
| 195 return content::ExecuteScript(tab_contents, "hangup()"); | |
| 196 } | |
| 197 | |
| 198 base::FilePath GetSourceDir() { | 188 base::FilePath GetSourceDir() { |
| 199 base::FilePath source_dir; | 189 base::FilePath source_dir; |
| 200 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | 190 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); |
| 201 return source_dir; | 191 return source_dir; |
| 202 } | 192 } |
| 203 | 193 |
| 204 bool LaunchFirefoxWithUrl(const GURL& url) { | 194 bool LaunchFirefoxWithUrl(const GURL& url) { |
| 205 base::FilePath firefox_binary = | 195 base::FilePath firefox_binary = |
| 206 GetSourceDir().Append( | 196 GetSourceDir().Append( |
| 207 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); | 197 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 243 |
| 254 chrome::AddTabAt(browser(), GURL(), -1, true); | 244 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 255 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); | 245 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); |
| 256 | 246 |
| 257 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); | 247 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); |
| 258 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); | 248 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); |
| 259 | 249 |
| 260 ASSERT_TRUE(DetectRemoteVideoPlaying(left_tab)); | 250 ASSERT_TRUE(DetectRemoteVideoPlaying(left_tab)); |
| 261 ASSERT_TRUE(DetectRemoteVideoPlaying(right_tab)); | 251 ASSERT_TRUE(DetectRemoteVideoPlaying(right_tab)); |
| 262 | 252 |
| 263 ASSERT_TRUE(HangUpApprtcCall(left_tab)); | |
| 264 | |
| 265 ASSERT_TRUE(WaitForCallToHangUp(left_tab)); | |
| 266 ASSERT_TRUE(WaitForCallToHangUp(right_tab)); | |
| 267 | |
| 268 chrome::CloseWebContents(browser(), left_tab, false); | 253 chrome::CloseWebContents(browser(), left_tab, false); |
| 269 chrome::CloseWebContents(browser(), right_tab, false); | 254 chrome::CloseWebContents(browser(), right_tab, false); |
| 270 } | 255 } |
| 271 | 256 |
| 272 #if defined(OS_LINUX) | 257 #if defined(OS_LINUX) |
| 273 #define MAYBE_MANUAL_FirefoxApprtcInteropTest MANUAL_FirefoxApprtcInteropTest | 258 #define MAYBE_MANUAL_FirefoxApprtcInteropTest MANUAL_FirefoxApprtcInteropTest |
| 274 #else | 259 #else |
| 275 // Not implemented yet on Windows and Mac. | 260 // Not implemented yet on Windows and Mac. |
| 276 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter
opTest | 261 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter
opTest |
| 277 #endif | 262 #endif |
| (...skipping 15 matching lines...) Expand all Loading... |
| 293 "&firefox_fake_device=1"); | 278 "&firefox_fake_device=1"); |
| 294 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); | 279 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); |
| 295 | 280 |
| 296 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | 281 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |
| 297 | 282 |
| 298 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | 283 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); |
| 299 | 284 |
| 300 // Ensure Firefox manages to send video our way. | 285 // Ensure Firefox manages to send video our way. |
| 301 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); | 286 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); |
| 302 } | 287 } |
| OLD | NEW |