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

Side by Side Diff: ui/file_manager/integration_tests/remote_call.js

Issue 942393002: Add a simple way of performing step by step tests for testers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename the flag. Created 5 years, 10 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Class to manipulate the window in the remote extension. 8 * Class to manipulate the window in the remote extension.
9 * 9 *
10 * @param {string} extensionId ID of extension to be manipulated. 10 * @param {string} extensionId ID of extension to be manipulated.
11 * @constructor 11 * @constructor
12 */ 12 */
13 function RemoteCall(extensionId) { 13 function RemoteCall(extensionId) {
14 this.extensionId_ = extensionId; 14 this.extensionId_ = extensionId;
15 } 15 }
16 16
17 /** 17 /**
18 * Checks whether step by step tests are enabled or not.
19 * @return {Promise<bool>}
20 */
21 RemoteCall.isStepByStepEnabled = function() {
22 return new Promise(function(fulfill) {
23 chrome.commandLinePrivate.hasSwitch(
24 'enable-file-manager-step-by-step-tests', fulfill);
25 });
26 };
27
28 /**
18 * Calls a remote test util in Files.app's extension. See: test_util.js. 29 * Calls a remote test util in Files.app's extension. See: test_util.js.
19 * 30 *
20 * @param {string} func Function name. 31 * @param {string} func Function name.
21 * @param {?string} appId Target window's App ID or null for functions 32 * @param {?string} appId Target window's App ID or null for functions
22 * not requiring a window. 33 * not requiring a window.
23 * @param {Array.<*>} args Array of arguments. 34 * @param {Array.<*>} args Array of arguments.
24 * @param {function(*)=} opt_callback Callback handling the function's result. 35 * @param {function(*)=} opt_callback Callback handling the function's result.
25 * @return {Promise} Promise to be fulfilled with the result of the remote 36 * @return {Promise} Promise to be fulfilled with the result of the remote
26 * utility. 37 * utility.
27 */ 38 */
28 RemoteCall.prototype.callRemoteTestUtil = 39 RemoteCall.prototype.callRemoteTestUtil =
29 function(func, appId, args, opt_callback) { 40 function(func, appId, args, opt_callback) {
30 return new Promise(function(onFulfilled) { 41 return RemoteCall.isStepByStepEnabled().then(function(stepByStep) {
31 chrome.runtime.sendMessage( 42 if (!stepByStep)
32 this.extensionId_, 43 return false;
33 { 44 return new Promise(function(onFulfilled) {
34 func: func, 45 console.info('Executing: ' + func + ' on ' + appId + ' with args: ');
35 appId: appId, 46 console.info(args);
36 args: args 47 console.info('Type step() to continue...');
37 }, 48 window.step = function() {
38 function() { 49 window.step = null;
39 if (opt_callback) 50 onFulfilled(stepByStep);
40 opt_callback.apply(null, arguments); 51 };
41 onFulfilled(arguments[0]); 52 });
42 }); 53 }).then(function(stepByStep) {
54 return new Promise(function(onFulfilled) {
55 chrome.runtime.sendMessage(
56 this.extensionId_,
57 {
58 func: func,
59 appId: appId,
60 args: args
61 },
62 function(var_args) {
63 if (stepByStep) {
64 console.info('Returned value:');
65 console.info(arguments);
66 }
67 if (opt_callback)
68 opt_callback.apply(null, arguments);
69 onFulfilled(arguments[0]);
70 });
71 }.bind(this));
43 }.bind(this)); 72 }.bind(this));
44 }; 73 };
45 74
46 /** 75 /**
47 * Waits until a window having the given ID prefix appears. 76 * Waits until a window having the given ID prefix appears.
48 * @param {string} windowIdPrefix ID prefix of the requested window. 77 * @param {string} windowIdPrefix ID prefix of the requested window.
49 * @return {Promise} promise Promise to be fulfilled with a found window's ID. 78 * @return {Promise} promise Promise to be fulfilled with a found window's ID.
50 */ 79 */
51 RemoteCall.prototype.waitForWindow = function(windowIdPrefix) { 80 RemoteCall.prototype.waitForWindow = function(windowIdPrefix) {
52 return repeatUntil(function() { 81 return repeatUntil(function() {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 RemoteCallFilesApp.prototype.waitUntilCurrentDirectoryIsChanged = 328 RemoteCallFilesApp.prototype.waitUntilCurrentDirectoryIsChanged =
300 function(windowId, expectedPath) { 329 function(windowId, expectedPath) {
301 return repeatUntil(function () { 330 return repeatUntil(function () {
302 return this.callRemoteTestUtil('getBreadcrumbPath', windowId, []).then( 331 return this.callRemoteTestUtil('getBreadcrumbPath', windowId, []).then(
303 function(path) { 332 function(path) {
304 if(path !== expectedPath) 333 if(path !== expectedPath)
305 return pending('Expected path is %s', expectedPath); 334 return pending('Expected path is %s', expectedPath);
306 }); 335 });
307 }.bind(this)); 336 }.bind(this));
308 }; 337 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698