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

Unified 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 side-by-side diff with in-line comments
Download patch
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..07ac44300d9784b873ebb48ed368d3cdbd2a70fd 100644
--- a/ui/file_manager/integration_tests/remote_call.js
+++ b/ui/file_manager/integration_tests/remote_call.js
@@ -15,6 +15,17 @@ 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-file-manager-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 +38,37 @@ 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]);
- });
+ return RemoteCall.isStepByStepEnabled().then(function(stepByStep) {
+ if (!stepByStep)
+ return false;
+ 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(stepByStep);
+ };
+ });
+ }).then(function(stepByStep) {
+ return new Promise(function(onFulfilled) {
+ chrome.runtime.sendMessage(
+ this.extensionId_,
+ {
+ func: func,
+ appId: appId,
+ args: args
+ },
+ function(var_args) {
+ if (stepByStep) {
+ console.info('Returned value:');
+ console.info(arguments);
+ }
+ if (opt_callback)
+ opt_callback.apply(null, arguments);
+ onFulfilled(arguments[0]);
+ });
+ }.bind(this));
}.bind(this));
};

Powered by Google App Engine
This is Rietveld 408576698