Index: ui/file_manager/integration_tests/remote_call.js |
diff --git a/ui/file_manager/integration_tests/remote_call.js b/ui/file_manager/integration_tests/remote_call.js |
index 54c59e311712789ca6484962238fb9bd0e82cfe4..f9815b03da8cba47bef3a51d1160cd1557a47c74 100644 |
--- a/ui/file_manager/integration_tests/remote_call.js |
+++ b/ui/file_manager/integration_tests/remote_call.js |
@@ -15,6 +15,16 @@ function RemoteCall(extensionId) { |
} |
/** |
+ * Checks whether step by step tests are enabled or not. |
+ * @return {Promise<bool>} |
+ */ |
+RemoteCall.isStepByStepEnabled = function() { |
+ return new Promise(function(fulfill) { |
+ chrome.commandLinePrivate.hasSwitch('enable-step-by-step-tests', fulfill); |
+ }); |
+}; |
+ |
+/** |
* Calls a remote test util in Files.app's extension. See: test_util.js. |
* |
* @param {string} func Function name. |
@@ -27,19 +37,40 @@ function RemoteCall(extensionId) { |
*/ |
RemoteCall.prototype.callRemoteTestUtil = |
function(func, appId, args, opt_callback) { |
- return new Promise(function(onFulfilled) { |
- chrome.runtime.sendMessage( |
- this.extensionId_, |
- { |
- func: func, |
- appId: appId, |
- args: args |
- }, |
- function() { |
- if (opt_callback) |
- opt_callback.apply(null, arguments); |
- onFulfilled(arguments[0]); |
- }); |
+ var stepByStepEnabled = false; |
+ return RemoteCall.isStepByStepEnabled().then(function(enabled) { |
+ stepByStepEnabled = enabled; |
+ }).then(function() { |
hirono
2015/02/23 07:00:40
nit: We can receive stepByStepEnabled directly fro
mtomasz
2015/02/23 09:30:43
I'm not sure if I understand. You mean to embed #5
hirono
2015/02/23 10:01:10
SGTM!
|
+ if (stepByStepEnabled) { |
+ return new Promise(function(onFulfilled) { |
+ console.info('Executing: ' + func + ' on ' + appId + ' with args: '); |
+ console.info(args); |
+ console.info('Type step() to continue...'); |
+ window.step = function() { |
+ window.step = null; |
+ onFulfilled(); |
+ }; |
+ }); |
+ } |
+ }).then(function() { |
+ return new Promise(function(onFulfilled) { |
+ chrome.runtime.sendMessage( |
+ this.extensionId_, |
+ { |
+ func: func, |
+ appId: appId, |
+ args: args |
+ }, |
+ function(var_args) { |
+ if (stepByStepEnabled) { |
+ console.info('Returned value:'); |
+ console.info(arguments); |
+ } |
+ if (opt_callback) |
+ opt_callback.apply(null, arguments); |
+ onFulfilled(arguments[0]); |
+ }); |
+ }.bind(this)); |
}.bind(this)); |
}; |