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

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: Improved comment. 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 // If the app should be started in deferred mode, ensure that a "source" URL
180 // parameter; if not, ensure that no such parameter is present. The value of
181 // the parameter is determined by the AppLaunchParams ("test", in this case).
182 extensions::FeatureSwitch::ScopedOverride override_trace_app_source(
183 extensions::FeatureSwitch::trace_app_source(),
184 defer_start);
177 185
178 OpenApplication(AppLaunchParams(browser()->profile(), extension_, 186 OpenApplication(AppLaunchParams(browser()->profile(), extension_,
179 is_platform_app() 187 is_platform_app()
180 ? extensions::LAUNCH_CONTAINER_NONE 188 ? extensions::LAUNCH_CONTAINER_NONE
181 : extensions::LAUNCH_CONTAINER_TAB, 189 : extensions::LAUNCH_CONTAINER_TAB,
182 is_platform_app() ? NEW_WINDOW : CURRENT_TAB, 190 is_platform_app() ? NEW_WINDOW : CURRENT_TAB,
183 extensions::SOURCE_TEST)); 191 extensions::SOURCE_TEST));
184 192
185 observer.Wait(); 193 observer.Wait();
186 194
(...skipping 16 matching lines...) Expand all
203 // event. A half second wait is necessary for the subsequent javascript 211 // event. A half second wait is necessary for the subsequent javascript
204 // injection to work. 212 // injection to work.
205 // TODO(weitaosu): Find out whether there is a more appropriate notification 213 // TODO(weitaosu): Find out whether there is a more appropriate notification
206 // to wait for so we can get rid of this wait. 214 // to wait for so we can get rid of this wait.
207 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait()); 215 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(5)).Wait());
208 } 216 }
209 217
210 EXPECT_EQ(Chromoting_Main_URL(), GetCurrentURL()); 218 EXPECT_EQ(Chromoting_Main_URL(), GetCurrentURL());
211 } 219 }
212 220
221 void RemoteDesktopBrowserTest::StartChromotingApp() {
222 ClickOnControl("browser-test-continue-init");
223 };
224
213 void RemoteDesktopBrowserTest::Authorize() { 225 void RemoteDesktopBrowserTest::Authorize() {
214 // The chromoting extension should be installed. 226 // The chromoting extension should be installed.
215 ASSERT_TRUE(extension_); 227 ASSERT_TRUE(extension_);
216 228
217 // The chromoting main page should be loaded in the current tab 229 // The chromoting main page should be loaded in the current tab
218 // and isAuthenticated() should be false (auth dialog visible). 230 // and isAuthenticated() should be false (auth dialog visible).
219 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL()); 231 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL());
220 ASSERT_FALSE(IsAuthenticated()); 232 ASSERT_FALSE(IsAuthenticated());
221 233
222 // The second observer monitors the loading of the Google login page. 234 // 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 470 // TODO(chaitali): Remove this additional timeout after we figure out
459 // why this is needed for the v1 app to work. 471 // why this is needed for the v1 app to work.
460 // Without this timeout the test fail with a "CloseWebContents called for 472 // Without this timeout the test fail with a "CloseWebContents called for
461 // tab not in our strip" error for the v1 app. 473 // tab not in our strip" error for the v1 app.
462 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait()); 474 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait());
463 } 475 }
464 476
465 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() { 477 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() {
466 VerifyInternetAccess(); 478 VerifyInternetAccess();
467 Install(); 479 Install();
468 LaunchChromotingApp(); 480 LaunchChromotingApp(false);
469 Auth(); 481 Auth();
470 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); 482 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js"));
471 ExpandMe2Me(); 483 ExpandMe2Me();
472 // The call to EnsureRemoteConnectionEnabled() does a PIN reset. 484 // The call to EnsureRemoteConnectionEnabled() does a PIN reset.
473 // This causes the test to fail because of a recent bug: 485 // This causes the test to fail because of a recent bug:
474 // crbug.com/430676 486 // crbug.com/430676
475 // TODO(anandc): Reactivate this call after above bug is fixed. 487 // TODO(anandc): Reactivate this call after above bug is fixed.
476 //EnsureRemoteConnectionEnabled(); 488 //EnsureRemoteConnectionEnabled();
477 } 489 }
478 490
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 // static 899 // static
888 bool RemoteDesktopBrowserTest::IsEnabled( 900 bool RemoteDesktopBrowserTest::IsEnabled(
889 content::WebContents* client_web_content, 901 content::WebContents* client_web_content,
890 const std::string& element_name) { 902 const std::string& element_name) {
891 return !ExecuteScriptAndExtractBool( 903 return !ExecuteScriptAndExtractBool(
892 client_web_content, 904 client_web_content,
893 "document.getElementById(\"" + element_name + "\").disabled"); 905 "document.getElementById(\"" + element_name + "\").disabled");
894 } 906 }
895 907
896 } // namespace remoting 908 } // namespace remoting
OLDNEW
« no previous file with comments | « chrome/test/remoting/remote_desktop_browsertest.h ('k') | remoting/webapp/crd/html/template_main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698