Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/test/remoting/remote_desktop_browsertest.cc

Issue 771003002: Add support for deferring app initialization when testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 extensions::FeatureSwitch::ScopedOverride enable_trace_app_source(
180 extensions::FeatureSwitch::trace_app_source(),
181 true);
182
183 // Lacking any other convenient mechanism for passing a URL parameter to the
184 // web-app, we use the |source| field. Since there's no way to launch the
185 // app from the About page, this should never be encountered by real users,
186 // even if they have the trace_app_source command-line option enabled.
Jamie 2014/12/02 01:30:13 cylee@: What I would like to do here is add a BROW
cylee1 2014/12/02 14:10:32 Adding a new enum BROWSER_TEST sounds much reasona
187 extensions::AppLaunchSource source =
188 defer_start ? extensions::SOURCE_ABOUT_PAGE
189 : extensions::SOURCE_UNTRACKED;
177 190
178 OpenApplication(AppLaunchParams(browser()->profile(), extension_, 191 OpenApplication(AppLaunchParams(browser()->profile(), extension_,
179 is_platform_app() 192 is_platform_app()
180 ? extensions::LAUNCH_CONTAINER_NONE 193 ? extensions::LAUNCH_CONTAINER_NONE
181 : extensions::LAUNCH_CONTAINER_TAB, 194 : extensions::LAUNCH_CONTAINER_TAB,
182 is_platform_app() ? NEW_WINDOW : CURRENT_TAB, 195 is_platform_app() ? NEW_WINDOW : CURRENT_TAB,
183 extensions::SOURCE_UNTRACKED)); 196 source));
184 197
185 observer.Wait(); 198 observer.Wait();
186 199
187 200
188 // The active WebContents instance should be the source of the LOAD_STOP 201 // The active WebContents instance should be the source of the LOAD_STOP
189 // notification. 202 // notification.
190 content::NavigationController* controller = 203 content::NavigationController* controller =
191 content::Source<content::NavigationController>(observer.source()).ptr(); 204 content::Source<content::NavigationController>(observer.source()).ptr();
192 205
193 content::WebContents* web_contents = controller->GetWebContents(); 206 content::WebContents* web_contents = controller->GetWebContents();
194 if (web_contents != active_web_contents()) 207 if (web_contents != active_web_contents())
195 web_contents_stack_.push_back(web_contents); 208 web_contents_stack_.push_back(web_contents);
196 209
197 app_web_content_ = web_contents; 210 app_web_content_ = web_contents;
198 211
199 if (is_platform_app()) { 212 if (is_platform_app()) {
200 EXPECT_EQ(GetFirstAppWindowWebContents(), active_web_contents()); 213 EXPECT_EQ(GetFirstAppWindowWebContents(), active_web_contents());
201 } else { 214 } else {
202 // For apps v1 only, the DOMOperationObserver is not ready at the LOAD_STOP 215 // For apps v1 only, the DOMOperationObserver is not ready at the LOAD_STOP
203 // event. A half second wait is necessary for the subsequent javascript 216 // event. A half second wait is necessary for the subsequent javascript
204 // injection to work. 217 // injection to work.
205 // TODO(weitaosu): Find out whether there is a more appropriate notification 218 // TODO(weitaosu): Find out whether there is a more appropriate notification
206 // to wait for so we can get rid of this wait. 219 // to wait for so we can get rid of this wait.
207 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait()); 220 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait());
208 } 221 }
209 222
210 EXPECT_EQ(Chromoting_Main_URL(), GetCurrentURL()); 223 EXPECT_EQ(Chromoting_Main_URL(), GetCurrentURL());
211 } 224 }
212 225
226 void RemoteDesktopBrowserTest::StartChromotingApp() {
227 ClickOnControl("browser-test-continue-init");
228 };
229
213 void RemoteDesktopBrowserTest::Authorize() { 230 void RemoteDesktopBrowserTest::Authorize() {
214 // The chromoting extension should be installed. 231 // The chromoting extension should be installed.
215 ASSERT_TRUE(extension_); 232 ASSERT_TRUE(extension_);
216 233
217 // The chromoting main page should be loaded in the current tab 234 // The chromoting main page should be loaded in the current tab
218 // and isAuthenticated() should be false (auth dialog visible). 235 // and isAuthenticated() should be false (auth dialog visible).
219 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL()); 236 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL());
220 ASSERT_FALSE(IsAuthenticated()); 237 ASSERT_FALSE(IsAuthenticated());
221 238
222 // The second observer monitors the loading of the Google login page. 239 // The second observer monitors the loading of the Google login page.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // TODO(chaitali): Remove this additional timeout after we figure out 475 // TODO(chaitali): Remove this additional timeout after we figure out
459 // why this is needed for the v1 app to work. 476 // why this is needed for the v1 app to work.
460 // Without this timeout the test fail with a "CloseWebContents called for 477 // Without this timeout the test fail with a "CloseWebContents called for
461 // tab not in our strip" error for the v1 app. 478 // tab not in our strip" error for the v1 app.
462 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait()); 479 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait());
463 } 480 }
464 481
465 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() { 482 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() {
466 VerifyInternetAccess(); 483 VerifyInternetAccess();
467 Install(); 484 Install();
468 LaunchChromotingApp(); 485 LaunchChromotingApp(false);
469 Auth(); 486 Auth();
470 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); 487 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js"));
471 ExpandMe2Me(); 488 ExpandMe2Me();
472 // The call to EnsureRemoteConnectionEnabled() does a PIN reset. 489 // The call to EnsureRemoteConnectionEnabled() does a PIN reset.
473 // This causes the test to fail because of a recent bug: 490 // This causes the test to fail because of a recent bug:
474 // crbug.com/430676 491 // crbug.com/430676
475 // TODO(anandc): Reactivate this call after above bug is fixed. 492 // TODO(anandc): Reactivate this call after above bug is fixed.
476 //EnsureRemoteConnectionEnabled(); 493 //EnsureRemoteConnectionEnabled();
477 } 494 }
478 495
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 // static 904 // static
888 bool RemoteDesktopBrowserTest::IsEnabled( 905 bool RemoteDesktopBrowserTest::IsEnabled(
889 content::WebContents* client_web_content, 906 content::WebContents* client_web_content,
890 const std::string& element_name) { 907 const std::string& element_name) {
891 return !ExecuteScriptAndExtractBool( 908 return !ExecuteScriptAndExtractBool(
892 client_web_content, 909 client_web_content,
893 "document.getElementById(\"" + element_name + "\").disabled"); 910 "document.getElementById(\"" + element_name + "\").disabled");
894 } 911 }
895 912
896 } // namespace remoting 913 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698