revert(base-driver): "chore: merge base-driver master (de7e41b) to base-driver for 2.0"
This reverts commit
MODIFY
packages/base-driver/lib/basedriver/driver.js
packages/base-driver/lib/basedriver/driver.js
@@ -12,6 +12,7 @@ import { desiredCapabilityConstraints } from './desired-caps';
import { validateCaps } from './capabilities';
import B from 'bluebird';
import _ from 'lodash';
+import { util } from 'appium-support';
import AsyncLock from 'async-lock';
import { EventEmitter } from 'events';
@@ -420,6 +421,34 @@ class BaseDriver extends Protocol {
this.clearNewCommandTimeout();
}
+ async getSwipeOptions (gestures, touchCount = 1) {
+ let startX = this.helpers.getCoordDefault(gestures[0].options.x),
+ startY = this.helpers.getCoordDefault(gestures[0].options.y),
+ endX = this.helpers.getCoordDefault(gestures[2].options.x),
+ endY = this.helpers.getCoordDefault(gestures[2].options.y),
+ duration = this.helpers.getSwipeTouchDuration(gestures[1]),
+ element = gestures[0].options.element,
+ destElement = gestures[2].options.element || gestures[0].options.element;
+
+ // there's no destination element handling in bootstrap and since it applies to all platforms, we handle it here
+ if (util.hasValue(destElement)) {
+ let locResult = await this.getLocationInView(destElement);
+ let sizeResult = await this.getSize(destElement);
+ let offsetX = (Math.abs(endX) < 1 && Math.abs(endX) > 0) ? sizeResult.width * endX : endX;
+ let offsetY = (Math.abs(endY) < 1 && Math.abs(endY) > 0) ? sizeResult.height * endY : endY;
+ endX = locResult.x + offsetX;
+ endY = locResult.y + offsetY;
+ // if the target element was provided, the coordinates for the destination need to be relative to it.
+ if (util.hasValue(element)) {
+ let firstElLocation = await this.getLocationInView(element);
+ endX -= firstElLocation.x;
+ endY -= firstElLocation.y;
+ }
+ }
+ // clients are responsible to use these options correctly
+ return {startX, startY, endX, endY, duration, touchCount, element};
+ }
+
proxyActive (/* sessionId */) {
return false;
}

MODIFY
packages/base-driver/lib/basedriver/helpers.js
packages/base-driver/lib/basedriver/helpers.js
@@ -359,6 +359,28 @@ function isPackageOrBundle (app) {
return (/^([a-zA-Z0-9\-_]+\.[a-zA-Z0-9\-_]+)+$/).test(app);
}
+function getCoordDefault (val) {
+ // going the long way and checking for undefined and null since
+ // we can't be assured `elId` is a string and not an int. Same
+ // thing with destElement below.
+ return util.hasValue(val) ? val : 0.5;
+}
+
+function getSwipeTouchDuration (waitGesture) {
+ // the touch action api uses ms, we want seconds
+ // 0.8 is the default time for the operation
+ let duration = 0.8;
+ if (typeof waitGesture.options.ms !== 'undefined' && waitGesture.options.ms) {
+ duration = waitGesture.options.ms / 1000;
+ if (duration === 0) {
+ // set to a very low number, since they wanted it fast
+ // but below 0.1 becomes 0 steps, which causes errors
+ duration = 0.1;
+ }
+ }
+ return duration;
+}
+
/**
* Finds all instances 'firstKey' and create a duplicate with the key 'secondKey',
* Do the same thing in reverse. If we find 'secondKey', create a duplicate with the key 'firstKey'.
@@ -421,5 +443,5 @@ function parseCapsArray (cap) {
}
export {
- configureApp, isPackageOrBundle, duplicateKeys, parseCapsArray
+ configureApp, isPackageOrBundle, getCoordDefault, getSwipeTouchDuration, duplicateKeys, parseCapsArray
};

MODIFY
packages/base-driver/lib/jsonwp-proxy/proxy.js
packages/base-driver/lib/jsonwp-proxy/proxy.js
@@ -41,6 +41,7 @@ class JWProxy {
keepAlive: opts.keepAlive ?? true,
maxSockets: 10,
maxFreeSockets: 5,
+ timeout: 60000,
};
this.httpAgent = new http.Agent(agentOpts);
this.httpsAgent = new https.Agent(agentOpts);

MODIFY
packages/base-driver/package.json
packages/base-driver/package.json
],
"dependencies": {
"@babel/runtime": "^7.0.0",
- "@appium/support": "^2.52.0",
+ "@appium/support": "^2.48.0",
"async-lock": "^1.0.0",
"asyncbox": "^2.3.1",
- "axios": "^0.x",
+ "axios": "^0.21.0",
"bluebird": "^3.5.3",
"body-parser": "^1.18.2",
"colors": "^1.1.2",
"method-override": "^3.0.0",
"morgan": "^1.9.0",
"serve-favicon": "^2.4.5",
- "source-map-support": "^0.x",
+ "source-map-support": "^0.5.5",
"validate.js": "^0.13.0",
"webdriverio": "^6.0.2",
"ws": "^7.0.0"

revert(base-driver): "chore: merge base-driver master (de7e41b) to base-driver for 2.0" (#15454)

This reverts commit 01abeac864d55c30e8b3cf4d36dc83d4259fd4ba.