Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 return result == kTitlePageOfAppEngineAdminPage; | 115 return result == kTitlePageOfAppEngineAdminPage; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool WaitForCallToComeUp(content::WebContents* tab_contents) { | 118 bool WaitForCallToComeUp(content::WebContents* tab_contents) { |
| 119 // Apprtc will set remoteVideo.style.opacity to 1 when the call comes up. | 119 // Apprtc will set remoteVideo.style.opacity to 1 when the call comes up. |
| 120 std::string javascript = | 120 std::string javascript = |
| 121 "window.domAutomationController.send(remoteVideo.style.opacity)"; | 121 "window.domAutomationController.send(remoteVideo.style.opacity)"; |
| 122 return test::PollingWaitUntil(javascript, "1", tab_contents); | 122 return test::PollingWaitUntil(javascript, "1", tab_contents); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool WaitForCallToHangUp(content::WebContents* tab_contents) { | |
| 126 // Apprtc will set remoteVideo.style.opacity to 1 when the call comes up. | |
| 127 std::string javascript = | |
| 128 "window.domAutomationController.send(remoteVideo.style.opacity)"; | |
|
kjellander_chromium
2014/05/27 09:47:52
We really should have a better way to check this s
| |
| 129 return test::PollingWaitUntil(javascript, "0", tab_contents); | |
| 130 } | |
| 131 | |
| 125 bool EvalInJavascriptFile(content::WebContents* tab_contents, | 132 bool EvalInJavascriptFile(content::WebContents* tab_contents, |
| 126 const base::FilePath& path) { | 133 const base::FilePath& path) { |
| 127 std::string javascript; | 134 std::string javascript; |
| 128 if (!ReadFileToString(path, &javascript)) { | 135 if (!ReadFileToString(path, &javascript)) { |
| 129 LOG(ERROR) << "Missing javascript code at " << path.value() << "."; | 136 LOG(ERROR) << "Missing javascript code at " << path.value() << "."; |
| 130 return false; | 137 return false; |
| 131 } | 138 } |
| 132 | 139 |
| 133 if (!content::ExecuteScript(tab_contents, javascript)) { | 140 if (!content::ExecuteScript(tab_contents, javascript)) { |
| 134 LOG(ERROR) << "Failed to execute the following javascript: " << | 141 LOG(ERROR) << "Failed to execute the following javascript: " << |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 145 if (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append( | 152 if (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append( |
| 146 FILE_PATH_LITERAL("chrome/test/data/webrtc/video_detector.js")))) | 153 FILE_PATH_LITERAL("chrome/test/data/webrtc/video_detector.js")))) |
| 147 return false; | 154 return false; |
| 148 | 155 |
| 149 // The remote video tag is called remoteVideo in the AppRTC code. | 156 // The remote video tag is called remoteVideo in the AppRTC code. |
| 150 StartDetectingVideo(tab_contents, "remoteVideo"); | 157 StartDetectingVideo(tab_contents, "remoteVideo"); |
| 151 WaitForVideoToPlay(tab_contents); | 158 WaitForVideoToPlay(tab_contents); |
| 152 return true; | 159 return true; |
| 153 } | 160 } |
| 154 | 161 |
| 162 bool HangUpApprtcCall(content::WebContents* tab_contents) { | |
| 163 // This is the same as clicking the Hangup button in the AppRTC call. | |
| 164 return content::ExecuteScript(tab_contents, "onHangup()"); | |
| 165 } | |
| 166 | |
| 155 base::FilePath GetSourceDir() { | 167 base::FilePath GetSourceDir() { |
| 156 base::FilePath source_dir; | 168 base::FilePath source_dir; |
| 157 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | 169 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); |
| 158 return source_dir; | 170 return source_dir; |
| 159 } | 171 } |
| 160 | 172 |
| 161 bool LaunchFirefoxWithUrl(const GURL& url) { | 173 bool LaunchFirefoxWithUrl(const GURL& url) { |
| 162 base::FilePath firefox_binary = | 174 base::FilePath firefox_binary = |
| 163 GetSourceDir().Append( | 175 GetSourceDir().Append( |
| 164 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); | 176 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 chrome::AddTabAt(browser(), GURL(), -1, true); | 236 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 225 content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url); | 237 content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url); |
| 226 chrome::AddTabAt(browser(), GURL(), -1, true); | 238 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 227 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); | 239 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); |
| 228 | 240 |
| 229 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); | 241 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); |
| 230 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); | 242 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); |
| 231 | 243 |
| 232 ASSERT_TRUE(DetectRemoteVideoPlaying(left_tab)); | 244 ASSERT_TRUE(DetectRemoteVideoPlaying(left_tab)); |
| 233 ASSERT_TRUE(DetectRemoteVideoPlaying(right_tab)); | 245 ASSERT_TRUE(DetectRemoteVideoPlaying(right_tab)); |
| 246 | |
| 247 ASSERT_TRUE(HangUpApprtcCall(left_tab)); | |
| 248 | |
| 249 ASSERT_TRUE(WaitForCallToHangUp(left_tab)); | |
| 250 ASSERT_TRUE(WaitForCallToHangUp(right_tab)); | |
| 234 } | 251 } |
| 235 | 252 |
| 236 #if defined(OS_LINUX) | 253 #if defined(OS_LINUX) |
| 237 #define MAYBE_MANUAL_FirefoxApprtcInteropTest MANUAL_FirefoxApprtcInteropTest | 254 #define MAYBE_MANUAL_FirefoxApprtcInteropTest MANUAL_FirefoxApprtcInteropTest |
| 238 #else | 255 #else |
| 239 // Not implemented yet on Windows and Mac. | 256 // Not implemented yet on Windows and Mac. |
| 240 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter opTest | 257 #define MAYBE_MANUAL_FirefoxApprtcInteropTest DISABLED_MANUAL_FirefoxApprtcInter opTest |
| 241 #endif | 258 #endif |
| 242 | 259 |
| 243 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, | 260 IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 263 base::RandInt(0, 65536))); | 280 base::RandInt(0, 65536))); |
| 264 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); | 281 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); |
| 265 | 282 |
| 266 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | 283 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); |
| 267 | 284 |
| 268 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | 285 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); |
| 269 | 286 |
| 270 // Ensure Firefox manages to send video our way. | 287 // Ensure Firefox manages to send video our way. |
| 271 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); | 288 ASSERT_TRUE(DetectRemoteVideoPlaying(chrome_tab)); |
| 272 } | 289 } |
| OLD | NEW |