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 "chrome/test/remoting/remote_desktop_browsertest.h" | 5 #include "chrome/test/remoting/remote_desktop_browsertest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 extensions::Manifest::Type type = extension_->GetType(); | 159 extensions::Manifest::Type type = extension_->GetType(); |
160 EXPECT_TRUE(type == extensions::Manifest::TYPE_PLATFORM_APP || | 160 EXPECT_TRUE(type == extensions::Manifest::TYPE_PLATFORM_APP || |
161 type == extensions::Manifest::TYPE_LEGACY_PACKAGED_APP); | 161 type == extensions::Manifest::TYPE_LEGACY_PACKAGED_APP); |
162 | 162 |
163 EXPECT_TRUE(extension_->ShouldDisplayInAppLauncher()); | 163 EXPECT_TRUE(extension_->ShouldDisplayInAppLauncher()); |
164 } | 164 } |
165 | 165 |
166 ASSERT_EQ(installed, expected); | 166 ASSERT_EQ(installed, expected); |
167 } | 167 } |
168 | 168 |
169 void RemoteDesktopBrowserTest::LaunchChromotingApp() { | 169 void RemoteDesktopBrowserTest::LaunchChromotingApp(bool defer_start) { |
170 ASSERT_TRUE(extension_); | 170 ASSERT_TRUE(extension_); |
171 | 171 |
172 GURL chromoting_main = Chromoting_Main_URL(); | 172 GURL chromoting_main = Chromoting_Main_URL(); |
173 // We cannot simply wait for any page load because the first page | 173 // We cannot simply wait for any page load because the first page |
174 // loaded could be the generated background page. We need to wait | 174 // loaded could be the generated background page. We need to wait |
175 // till the chromoting main page is loaded. | 175 // till the chromoting main page is loaded. |
176 PageLoadNotificationObserver observer(chromoting_main); | 176 PageLoadNotificationObserver observer(chromoting_main); |
177 observer.set_ignore_url_parameters(true); | |
178 | |
179 // Start the app in deferred mode by setting a URL parameter. | |
180 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_trace_app_source; | |
181 if (defer_start) { | |
182 enable_trace_app_source.reset( | |
183 new extensions::FeatureSwitch::ScopedOverride( | |
184 extensions::FeatureSwitch::trace_app_source(), | |
185 true)); | |
186 } | |
weitao
2014/12/12 22:49:52
Where is the "test" URL parameter added?
Jamie
2014/12/13 01:03:43
extensions::FeatureSwitch::trace_app_source() is a
weitao
2014/12/16 01:06:27
I see. The combination of trace_app_source being t
Jamie
2014/12/16 01:33:51
Done.
| |
177 | 187 |
178 OpenApplication(AppLaunchParams(browser()->profile(), extension_, | 188 OpenApplication(AppLaunchParams(browser()->profile(), extension_, |
179 is_platform_app() | 189 is_platform_app() |
180 ? extensions::LAUNCH_CONTAINER_NONE | 190 ? extensions::LAUNCH_CONTAINER_NONE |
181 : extensions::LAUNCH_CONTAINER_TAB, | 191 : extensions::LAUNCH_CONTAINER_TAB, |
182 is_platform_app() ? NEW_WINDOW : CURRENT_TAB, | 192 is_platform_app() ? NEW_WINDOW : CURRENT_TAB, |
183 extensions::SOURCE_TEST)); | 193 extensions::SOURCE_TEST)); |
184 | 194 |
185 observer.Wait(); | 195 observer.Wait(); |
186 | 196 |
(...skipping 16 matching lines...) Expand all Loading... | |
203 // event. A half second wait is necessary for the subsequent javascript | 213 // event. A half second wait is necessary for the subsequent javascript |
204 // injection to work. | 214 // injection to work. |
205 // TODO(weitaosu): Find out whether there is a more appropriate notification | 215 // TODO(weitaosu): Find out whether there is a more appropriate notification |
206 // to wait for so we can get rid of this wait. | 216 // to wait for so we can get rid of this wait. |
207 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait()); | 217 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait()); |
208 } | 218 } |
209 | 219 |
210 EXPECT_EQ(Chromoting_Main_URL(), GetCurrentURL()); | 220 EXPECT_EQ(Chromoting_Main_URL(), GetCurrentURL()); |
211 } | 221 } |
212 | 222 |
223 void RemoteDesktopBrowserTest::StartChromotingApp() { | |
224 ClickOnControl("browser-test-continue-init"); | |
225 }; | |
226 | |
213 void RemoteDesktopBrowserTest::Authorize() { | 227 void RemoteDesktopBrowserTest::Authorize() { |
214 // The chromoting extension should be installed. | 228 // The chromoting extension should be installed. |
215 ASSERT_TRUE(extension_); | 229 ASSERT_TRUE(extension_); |
216 | 230 |
217 // The chromoting main page should be loaded in the current tab | 231 // The chromoting main page should be loaded in the current tab |
218 // and isAuthenticated() should be false (auth dialog visible). | 232 // and isAuthenticated() should be false (auth dialog visible). |
219 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL()); | 233 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL()); |
220 ASSERT_FALSE(IsAuthenticated()); | 234 ASSERT_FALSE(IsAuthenticated()); |
221 | 235 |
222 // The second observer monitors the loading of the Google login page. | 236 // The second observer monitors the loading of the Google login page. |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 // TODO(chaitali): Remove this additional timeout after we figure out | 472 // TODO(chaitali): Remove this additional timeout after we figure out |
459 // why this is needed for the v1 app to work. | 473 // why this is needed for the v1 app to work. |
460 // Without this timeout the test fail with a "CloseWebContents called for | 474 // Without this timeout the test fail with a "CloseWebContents called for |
461 // tab not in our strip" error for the v1 app. | 475 // tab not in our strip" error for the v1 app. |
462 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait()); | 476 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait()); |
463 } | 477 } |
464 | 478 |
465 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() { | 479 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() { |
466 VerifyInternetAccess(); | 480 VerifyInternetAccess(); |
467 Install(); | 481 Install(); |
468 LaunchChromotingApp(); | 482 LaunchChromotingApp(false); |
469 Auth(); | 483 Auth(); |
470 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); | 484 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); |
471 ExpandMe2Me(); | 485 ExpandMe2Me(); |
472 // The call to EnsureRemoteConnectionEnabled() does a PIN reset. | 486 // The call to EnsureRemoteConnectionEnabled() does a PIN reset. |
473 // This causes the test to fail because of a recent bug: | 487 // This causes the test to fail because of a recent bug: |
474 // crbug.com/430676 | 488 // crbug.com/430676 |
475 // TODO(anandc): Reactivate this call after above bug is fixed. | 489 // TODO(anandc): Reactivate this call after above bug is fixed. |
476 //EnsureRemoteConnectionEnabled(); | 490 //EnsureRemoteConnectionEnabled(); |
477 } | 491 } |
478 | 492 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
887 // static | 901 // static |
888 bool RemoteDesktopBrowserTest::IsEnabled( | 902 bool RemoteDesktopBrowserTest::IsEnabled( |
889 content::WebContents* client_web_content, | 903 content::WebContents* client_web_content, |
890 const std::string& element_name) { | 904 const std::string& element_name) { |
891 return !ExecuteScriptAndExtractBool( | 905 return !ExecuteScriptAndExtractBool( |
892 client_web_content, | 906 client_web_content, |
893 "document.getElementById(\"" + element_name + "\").disabled"); | 907 "document.getElementById(\"" + element_name + "\").disabled"); |
894 } | 908 } |
895 | 909 |
896 } // namespace remoting | 910 } // namespace remoting |
OLD | NEW |