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

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

Issue 807343002: Adding the first set of remote test cases and associated framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First round of fixes for the remote me2me tests and the associated remote_test_helper code. 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 #ifndef CHROME_TEST_REMOTING_REMOTE_DESKTOP_BROWSERTEST_H_ 5 #ifndef CHROME_TEST_REMOTING_REMOTE_DESKTOP_BROWSERTEST_H_
6 #define CHROME_TEST_REMOTING_REMOTE_DESKTOP_BROWSERTEST_H_ 6 #define CHROME_TEST_REMOTING_REMOTE_DESKTOP_BROWSERTEST_H_
7 7
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "chrome/browser/apps/app_browsertest_util.h" 9 #include "chrome/browser/apps/app_browsertest_util.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "chrome/test/remoting/remote_test_helper.h"
13 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
14 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
15 #include "net/dns/mock_host_resolver.h" 16 #include "net/dns/mock_host_resolver.h"
16 17
17 namespace { 18 namespace {
18 // Command line arguments specific to the chromoting browser tests. 19 // Command line arguments specific to the chromoting browser tests.
19 const char kOverrideUserDataDir[] = "override-user-data-dir"; 20 const char kOverrideUserDataDir[] = "override-user-data-dir";
20 const char kNoCleanup[] = "no-cleanup"; 21 const char kNoCleanup[] = "no-cleanup";
21 const char kNoInstall[] = "no-install"; 22 const char kNoInstall[] = "no-install";
22 const char kWebAppCrx[] = "webapp-crx"; 23 const char kWebAppCrx[] = "webapp-crx";
23 const char kWebAppUnpacked[] = "webapp-unpacked"; 24 const char kWebAppUnpacked[] = "webapp-unpacked";
24 const char kUserName[] = "username"; 25 const char kUserName[] = "username";
25 const char kUserPassword[] = "password"; 26 const char kUserPassword[] = "password";
26 const char kAccountsFile[] = "accounts-file"; 27 const char kAccountsFile[] = "accounts-file";
27 const char kAccountType[] = "account-type"; 28 const char kAccountType[] = "account-type";
28 const char kMe2MePin[] = "me2me-pin"; 29 const char kMe2MePin[] = "me2me-pin";
29 const char kRemoteHostName[] = "remote-host-name"; 30 const char kRemoteHostName[] = "remote-host-name";
30 const char kExtensionName[] = "extension-name"; 31 const char kExtensionName[] = "extension-name";
31 const char kHttpServer[] = "http-server"; 32 const char kHttpServer[] = "http-server";
32 33
33 // ASSERT_TRUE can only be used in void returning functions. This version
34 // should be used in non-void-returning functions.
35 inline void _ASSERT_TRUE(bool condition) {
36 if (!condition) {
37 // ASSERT_TRUE only prints the first call frame in the error message.
38 // In our case, this is the _ASSERT_TRUE wrapper function, which is not
39 // useful. To help with debugging, we will dump the full callstack.
40 LOG(ERROR) << "Assertion failed.";
41 LOG(ERROR) << base::debug::StackTrace().ToString();
42 }
43 ASSERT_TRUE(condition);
44 return;
45 }
46
47 } // namespace 34 } // namespace
48 35
49 using extensions::Extension; 36 using extensions::Extension;
50 37
51 namespace remoting { 38 namespace remoting {
52 39
53 class RemoteDesktopBrowserTest : public extensions::PlatformAppBrowserTest { 40 class RemoteDesktopBrowserTest : public extensions::PlatformAppBrowserTest {
54 public: 41 public:
55 RemoteDesktopBrowserTest(); 42 RemoteDesktopBrowserTest();
56 ~RemoteDesktopBrowserTest() override; 43 ~RemoteDesktopBrowserTest() override;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 193
207 // The client WebContents instance the test needs to interact with. 194 // The client WebContents instance the test needs to interact with.
208 content::WebContents* client_web_content() { 195 content::WebContents* client_web_content() {
209 return client_web_content_; 196 return client_web_content_;
210 } 197 }
211 198
212 content::WebContents* app_web_content() { 199 content::WebContents* app_web_content() {
213 return app_web_content_; 200 return app_web_content_;
214 } 201 }
215 202
203 RemoteTestHelper* remote_test_helper() const {
204 return remote_test_helper_.get();
205 }
206
216 // Whether to perform the cleanup tasks (uninstalling chromoting, etc). 207 // Whether to perform the cleanup tasks (uninstalling chromoting, etc).
217 // This is useful for diagnostic purposes. 208 // This is useful for diagnostic purposes.
218 bool NoCleanup() { return no_cleanup_; } 209 bool NoCleanup() { return no_cleanup_; }
219 210
220 // Whether to install the chromoting extension before running the test cases. 211 // Whether to install the chromoting extension before running the test cases.
221 // This is useful for diagnostic purposes. 212 // This is useful for diagnostic purposes.
222 bool NoInstall() { return no_install_; } 213 bool NoInstall() { return no_install_; }
223 214
224 // Helper to construct the starting URL of the installed chromoting webapp. 215 // Helper to construct the starting URL of the installed chromoting webapp.
225 GURL Chromoting_Main_URL() { 216 GURL Chromoting_Main_URL() {
(...skipping 17 matching lines...) Expand all
243 // Helper to execute a JavaScript code snippet in the active WebContents. 234 // Helper to execute a JavaScript code snippet in the active WebContents.
244 void ExecuteScript(const std::string& script); 235 void ExecuteScript(const std::string& script);
245 236
246 // Helper to execute a JavaScript code snippet in the active WebContents 237 // Helper to execute a JavaScript code snippet in the active WebContents
247 // and wait for page load to complete. 238 // and wait for page load to complete.
248 void ExecuteScriptAndWaitForAnyPageLoad(const std::string& script); 239 void ExecuteScriptAndWaitForAnyPageLoad(const std::string& script);
249 240
250 // Helper to execute a JavaScript code snippet in the active WebContents 241 // Helper to execute a JavaScript code snippet in the active WebContents
251 // and extract the boolean result. 242 // and extract the boolean result.
252 bool ExecuteScriptAndExtractBool(const std::string& script) { 243 bool ExecuteScriptAndExtractBool(const std::string& script) {
253 return ExecuteScriptAndExtractBool(active_web_contents(), script); 244 return RemoteTestHelper::ExecuteScriptAndExtractBool(
245 active_web_contents(), script);
254 } 246 }
255 247
256 // Helper to execute a JavaScript code snippet and extract the boolean result.
257 static bool ExecuteScriptAndExtractBool(content::WebContents* web_contents,
258 const std::string& script);
259
260 // Helper to execute a JavaScript code snippet in the active WebContents 248 // Helper to execute a JavaScript code snippet in the active WebContents
261 // and extract the int result. 249 // and extract the int result.
262 int ExecuteScriptAndExtractInt(const std::string& script) { 250 int ExecuteScriptAndExtractInt(const std::string& script) {
263 return ExecuteScriptAndExtractInt(active_web_contents(), script); 251 return RemoteTestHelper::ExecuteScriptAndExtractInt(
252 active_web_contents(), script);
264 } 253 }
265 254
266 // Helper to execute a JavaScript code snippet and extract the int result.
267 static int ExecuteScriptAndExtractInt(content::WebContents* web_contents,
268 const std::string& script);
269
270 // Helper to execute a JavaScript code snippet in the active WebContents 255 // Helper to execute a JavaScript code snippet in the active WebContents
271 // and extract the string result. 256 // and extract the string result.
272 std::string ExecuteScriptAndExtractString(const std::string& script) { 257 std::string ExecuteScriptAndExtractString(const std::string& script) {
273 return ExecuteScriptAndExtractString(active_web_contents(), script); 258 return RemoteTestHelper::ExecuteScriptAndExtractString(
259 active_web_contents(), script);
274 } 260 }
275 261
276 // Helper to execute a JavaScript code snippet and extract the string result.
277 static std::string ExecuteScriptAndExtractString(
278 content::WebContents* web_contents, const std::string& script);
279
280 // Helper to load a JavaScript file from |path| and inject it to 262 // Helper to load a JavaScript file from |path| and inject it to
281 // current web_content. The variable |path| is relative to the directory of 263 // current web_content. The variable |path| is relative to the directory of
282 // the |browsertest| executable. 264 // the |browsertest| executable.
283 static bool LoadScript(content::WebContents* web_contents, 265 static bool LoadScript(content::WebContents* web_contents,
284 const base::FilePath::StringType& path); 266 const base::FilePath::StringType& path);
285 267
286 // Helper to execute a JavaScript browser test. It creates an object using 268 // Helper to execute a JavaScript browser test. It creates an object using
287 // the |browserTest.testName| ctor and calls |run| on the created object with 269 // the |browserTest.testName| ctor and calls |run| on the created object with
288 // |testData|, which can be any arbitrary object literal. The script 270 // |testData|, which can be any arbitrary object literal. The script
289 // browser_test.js must be loaded (using LoadScript) before calling this 271 // browser_test.js must be loaded (using LoadScript) before calling this
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // push it onto the stack and that becomes the active instance. 345 // push it onto the stack and that becomes the active instance.
364 // And once we are done with the current WebContents instance 346 // And once we are done with the current WebContents instance
365 // we pop it off the stack, returning to the previous instance. 347 // we pop it off the stack, returning to the previous instance.
366 std::vector<content::WebContents*> web_contents_stack_; 348 std::vector<content::WebContents*> web_contents_stack_;
367 349
368 // WebContent of the client page that facilitates communication with 350 // WebContent of the client page that facilitates communication with
369 // the HTTP server. This is how the remoting browser tests 351 // the HTTP server. This is how the remoting browser tests
370 // will get acknowledgments of actions completed on the host. 352 // will get acknowledgments of actions completed on the host.
371 content::WebContents* client_web_content_; 353 content::WebContents* client_web_content_;
372 354
355 // Helper class to assist in performing and verifying remote operations.
356 scoped_ptr<RemoteTestHelper> remote_test_helper_;
357
373 // WebContent of the landing page in the chromoting app. 358 // WebContent of the landing page in the chromoting app.
374 content::WebContents* app_web_content_; 359 content::WebContents* app_web_content_;
375 360
376 bool no_cleanup_; 361 bool no_cleanup_;
377 bool no_install_; 362 bool no_install_;
378 const Extension* extension_; 363 const Extension* extension_;
379 base::FilePath webapp_crx_; 364 base::FilePath webapp_crx_;
380 base::FilePath webapp_unpacked_; 365 base::FilePath webapp_unpacked_;
381 std::string username_; 366 std::string username_;
382 std::string password_; 367 std::string password_;
383 std::string me2me_pin_; 368 std::string me2me_pin_;
384 std::string remote_host_name_; 369 std::string remote_host_name_;
385 std::string extension_name_; 370 std::string extension_name_;
386 std::string http_server_; 371 std::string http_server_;
387 }; 372 };
388 373
389 } // namespace remoting 374 } // namespace remoting
390 375
391 #endif // CHROME_TEST_REMOTING_REMOTE_DESKTOP_BROWSERTEST_H_ 376 #endif // CHROME_TEST_REMOTING_REMOTE_DESKTOP_BROWSERTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698