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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/process/launch.h" | 7 #include "base/process/launch.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 const char kAdviseOnGclientSolution[] = | 26 const char kAdviseOnGclientSolution[] = |
27 "You need to add this solution to your .gclient to run this test:\n" | 27 "You need to add this solution to your .gclient to run this test:\n" |
28 "{\n" | 28 "{\n" |
29 " \"name\" : \"webrtc.DEPS\",\n" | 29 " \"name\" : \"webrtc.DEPS\",\n" |
30 " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/" | 30 " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/" |
31 "third_party/webrtc/webrtc.DEPS\",\n" | 31 "third_party/webrtc/webrtc.DEPS\",\n" |
32 "}"; | 32 "}"; |
33 const char kTitlePageOfAppEngineAdminPage[] = "Instances"; | 33 const char kTitlePageOfAppEngineAdminPage[] = "Instances"; |
34 | 34 |
35 | 35 |
36 // WebRTC-AppRTC integration test. Requires a real webcam and microphone | 36 // WebRTC-AppRTC integration test. Requires a real webcam and microphone |
kjellander_chromium
2013/12/13 10:19:11
Please clarify that for the Firefox-Chrome test, t
phoglund_chromium
2013/12/13 14:35:10
Done.
| |
37 // on the running system. This test is not meant to run in the main browser | 37 // on the running system. This test is not meant to run in the main browser |
38 // test suite since normal tester machines do not have webcams. | 38 // test suite since normal tester machines do not have webcams. |
39 // | 39 // |
40 // This test will bring up a AppRTC instance on localhost and verify that the | 40 // This test will bring up a AppRTC instance on localhost and verify that the |
41 // call gets up when connecting to the same room from two tabs in a browser. | 41 // call gets up when connecting to the same room from two tabs in a browser. |
42 class WebrtcApprtcBrowserTest : public WebRtcTestBase { | 42 class WebrtcApprtcBrowserTest : public WebRtcTestBase { |
43 public: | 43 public: |
44 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 44 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
45 EXPECT_FALSE(command_line->HasSwitch( | 45 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
46 switches::kUseFakeDeviceForMediaStream)); | |
47 EXPECT_FALSE(command_line->HasSwitch( | |
48 switches::kUseFakeUIForMediaStream)); | |
49 | 46 |
50 // The video playback will not work without a GPU, so force its use here. | 47 // The video playback will not work without a GPU, so force its use here. |
51 command_line->AppendSwitch(switches::kUseGpuInTests); | 48 command_line->AppendSwitch(switches::kUseGpuInTests); |
52 } | 49 } |
53 | 50 |
54 protected: | 51 protected: |
55 bool LaunchApprtcInstanceOnLocalhost() { | 52 bool LaunchApprtcInstanceOnLocalhost() { |
56 base::FilePath appengine_dev_appserver = | 53 base::FilePath appengine_dev_appserver = |
57 GetSourceDir().Append( | 54 GetSourceDir().Append( |
58 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); | 55 FILE_PATH_LITERAL("../google_appengine/dev_appserver.py")); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 "window.domAutomationController.send(remoteVideo.style.opacity)"; | 106 "window.domAutomationController.send(remoteVideo.style.opacity)"; |
110 return PollingWaitUntil(javascript, "1", tab_contents); | 107 return PollingWaitUntil(javascript, "1", tab_contents); |
111 } | 108 } |
112 | 109 |
113 base::FilePath GetSourceDir() { | 110 base::FilePath GetSourceDir() { |
114 base::FilePath source_dir; | 111 base::FilePath source_dir; |
115 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | 112 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); |
116 return source_dir; | 113 return source_dir; |
117 } | 114 } |
118 | 115 |
116 bool LaunchFirefoxWithUrl(const GURL& url) { | |
117 base::FilePath firefox_binary = | |
118 GetSourceDir().Append( | |
119 FILE_PATH_LITERAL("../firefox-nightly/firefox/firefox")); | |
tommi (sloooow) - chröme
2013/12/12 18:41:33
Add each path component separately for cross platf
phoglund_chromium
2013/12/13 14:35:10
I can do that, but it will _work_ like this. For i
tommi (sloooow) - chröme
2013/12/13 14:51:26
OK, if Append takes care of this then it's fine as
| |
120 if (!base::PathExists(firefox_binary)) { | |
121 LOG(ERROR) << "Missing firefox binary at " << | |
122 firefox_binary.value() << ". " << kAdviseOnGclientSolution; | |
123 return false; | |
124 } | |
125 base::FilePath firefox_launcher = | |
126 GetSourceDir().Append( | |
127 FILE_PATH_LITERAL("../webrtc.DEPS/run_firefox_webrtc.py")); | |
128 if (!base::PathExists(firefox_launcher)) { | |
129 LOG(ERROR) << "Missing firefox launcher at " << | |
130 firefox_launcher.value() << ". " << kAdviseOnGclientSolution; | |
131 return false; | |
132 } | |
133 | |
134 CommandLine command_line(firefox_launcher); | |
135 command_line.AppendSwitchPath("--binary", firefox_binary); | |
136 command_line.AppendSwitchASCII("--webpage", url.spec()); | |
137 | |
138 VLOG(0) << "Running " << command_line.GetCommandLineString(); | |
tommi (sloooow) - chröme
2013/12/12 19:52:05
forgot one thing - VLOG(0) is apparently frowned u
phoglund_chromium
2013/12/13 14:35:10
Done.
| |
139 return base::LaunchProcess(command_line, base::LaunchOptions(), | |
kjellander_chromium
2013/12/13 10:19:11
What happens if there's no webcam available for Fi
phoglund_chromium
2013/12/13 14:35:10
Don't know, I guess gUM will fail there and the ca
| |
140 &firefox_); | |
141 | |
142 return true; | |
143 } | |
144 | |
145 bool StopFirefox() { | |
146 return base::KillProcess(firefox_, 0, false); | |
kjellander_chromium
2013/12/13 10:19:11
Is there some way we can check if firefox crashed
tommi (sloooow) - chröme
2013/12/13 12:21:31
Can we find a better way to close Firefox?
Killing
phoglund_chromium
2013/12/13 14:35:10
I can't see any easy portable way of doing that un
phoglund_chromium
2013/12/13 14:35:10
It will shut down cleanly on Linux, because I hook
tommi (sloooow) - chröme
2013/12/13 14:51:26
Signals like that don't exist on Windows unfortuna
phoglund_chromium
2013/12/13 15:13:35
Nope, you are right, I actually tried it and regis
tommi (sloooow) - chröme
2013/12/13 15:22:30
Sounds good. Can you add a note explaining that a
| |
147 } | |
148 | |
119 private: | 149 private: |
120 base::ProcessHandle dev_appserver_; | 150 base::ProcessHandle dev_appserver_; |
151 base::ProcessHandle firefox_; | |
121 }; | 152 }; |
122 | 153 |
123 IN_PROC_BROWSER_TEST_F(WebrtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { | 154 IN_PROC_BROWSER_TEST_F(WebrtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { |
124 // TODO(mcasas): Remove Win version filtering when this bug gets fixed: | 155 // TODO(mcasas): Remove Win version filtering when this bug gets fixed: |
125 // http://code.google.com/p/webrtc/issues/detail?id=2703 | 156 // http://code.google.com/p/webrtc/issues/detail?id=2703 |
126 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
127 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 158 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
128 return; | 159 return; |
129 #endif | 160 #endif |
130 DetectErrorsInJavaScript(); | 161 DetectErrorsInJavaScript(); |
(...skipping 10 matching lines...) Expand all Loading... | |
141 // http://code.google.com/p/webrtc/issues/detail?id=1742 | 172 // http://code.google.com/p/webrtc/issues/detail?id=1742 |
142 SleepInJavascript(left_tab, 5000); | 173 SleepInJavascript(left_tab, 5000); |
143 chrome::AddTabAt(browser(), GURL(), -1, true); | 174 chrome::AddTabAt(browser(), GURL(), -1, true); |
144 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); | 175 content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); |
145 | 176 |
146 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); | 177 ASSERT_TRUE(WaitForCallToComeUp(left_tab)); |
147 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); | 178 ASSERT_TRUE(WaitForCallToComeUp(right_tab)); |
148 | 179 |
149 ASSERT_TRUE(StopApprtcInstance()); | 180 ASSERT_TRUE(StopApprtcInstance()); |
150 } | 181 } |
182 | |
183 IN_PROC_BROWSER_TEST_F(WebrtcApprtcBrowserTest, | |
184 MANUAL_FirefoxApprtcInteropTest) { | |
185 ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost()); | |
kjellander_chromium
2013/12/13 10:19:11
I think we want to skip this on Vista as well, as
kjellander_chromium
2013/12/13 10:19:11
Add DetectErrorsInJavaScript(); since communicatin
phoglund_chromium
2013/12/13 14:35:10
You mean skip it on XP? Yeah, probably. Actually I
phoglund_chromium
2013/12/13 14:35:10
Done.
| |
186 while (!LocalApprtcInstanceIsUp()) | |
187 VLOG(0) << "Waiting for AppRTC to come up..."; | |
tommi (sloooow) - chröme
2013/12/12 19:52:05
would be nice to change all the VLOG(0)'s to VLOG(
phoglund_chromium
2013/12/13 14:35:10
Done.
| |
188 | |
189 // Run Chrome with a fake device to avoid having the browsers fight over the | |
190 // camera (we'll just give that to firefox here). | |
191 CommandLine::ForCurrentProcess()->AppendSwitch( | |
192 switches::kUseFakeDeviceForMediaStream); | |
193 | |
194 GURL room_url = GURL(base::StringPrintf("http://localhost:9999?r=room_%d", | |
195 base::RandInt(0, 65536))); | |
kjellander_chromium
2013/12/13 10:19:11
Do we really need to randomize this? I would be su
phoglund_chromium
2013/12/13 14:35:10
Yeah, this test can't execute in parallel, but it
tommi (sloooow) - chröme
2013/12/13 14:51:26
The room number could also be the thread id. As i
kjellander_chromium
2013/12/13 14:53:21
Fair enough, as we don't run these tests in parall
| |
196 content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); | |
197 | |
198 // TODO(phoglund): Remove when this bug gets fixed: | |
199 // http://code.google.com/p/webrtc/issues/detail?id=1742 | |
200 SleepInJavascript(chrome_tab, 5000); | |
201 | |
202 ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); | |
203 | |
204 ASSERT_TRUE(WaitForCallToComeUp(chrome_tab)); | |
tommi (sloooow) - chröme
2013/12/12 18:41:33
EXPECT_TRUE so that the next line will be run.
Fi
phoglund_chromium
2013/12/13 14:35:10
I think it's good to return early if we have alrea
| |
205 ASSERT_TRUE(StopFirefox()); | |
kjellander_chromium
2013/12/13 10:19:11
Add
ASSERT_TRUE(StopApprtcInstance());
after stop
phoglund_chromium
2013/12/13 14:35:10
Done.
| |
206 } | |
OLD | NEW |