Add a possibility to execute commands without queueing them
MODIFY
lib/basedriver/driver.js
lib/basedriver/driver.js
@@ -76,6 +76,21 @@ class BaseDriver extends MobileJsonWireProtocol {
return {};
}
+ /**
+ * This property controls the way {#executeCommand} method
+ * handles new driver commands received from the client.
+ * Override it for inherited classes only in special cases.
+ *
+ * @return {boolean} If the returned value is true (default) then all the commands
+ * received by the particular driver instance are going to be put into the queue,
+ * so each following command will not be executed until the previous command
+ * execution is completed. False value disables that queue, so each driver command
+ * is executed independently and does not wait for anything.
+ */
+ get isCommandsQueueEnabled () {
+ return true;
+ }
+
/*
* make eventHistory a property and return a cloned object so a consumer can't
* inadvertently change data outside of logEvent
@@ -195,6 +210,8 @@ class BaseDriver extends MobileJsonWireProtocol {
throw new errors.NotYetImplementedError();
}
+ let res;
+ if (this.isCommandsQueueEnabled) {
// What we're doing here is pretty clever. this.curCommand is always
// a promise representing the command currently being executed by the
// driver, or the last command executed by the driver (it starts off as
@@ -221,7 +238,13 @@ class BaseDriver extends MobileJsonWireProtocol {
return this.curCommandCancellable;
});
this.curCommand = nextCommand.catch(() => {});
- let res = await nextCommand;
+ res = await nextCommand;
+ } else {
+ if (this.shutdownUnexpectedly) {
+ throw new errors.NoSuchDriverError('The driver was unexpectedly shut down!');
+ }
+ res = await this[cmd](...args);
+ }
// if we have set a new command timeout (which is the default), start a
// timer once we've finished executing this command. If we don't clear

Add a possibility to execute commands without queueing them