Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two fingers tap support #170

Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6f4a929
Added twoFingerTap to the supported actions
sergey-plevako-badoo Sep 16, 2016
25da960
Merge branch 'master' into add_two_fingers_tap_support
sergey-plevako-badoo Sep 22, 2016
f7569f9
Updated WebDriverAgent submodule
sergey-plevako-badoo Sep 23, 2016
2925eb9
Merge branch 'master' into add_two_fingers_tap_support
sergey-plevako-badoo Sep 23, 2016
c9c4b38
Merge branch 'master' of https://github.com/appium/appium-xcuitest-dr…
sergey-plevako-badoo Oct 4, 2016
c80e61d
fixed typo
sergey-plevako-badoo Oct 13, 2016
caf6d84
Merge branch 'master' of https://github.com/appium/appium-xcuitest-dr…
sergey-plevako-badoo Nov 2, 2016
3818c91
minor refactoring
sergey-plevako-badoo Nov 2, 2016
8d8baa0
minor change
sergey-plevako-badoo Nov 2, 2016
8924801
Merge branch 'master' into add_two_fingers_tap_support
sergey-plevako-badoo Dec 14, 2016
65bd7db
Merge branch 'master' into add_two_fingers_tap_support
sergey-plevako-badoo Dec 14, 2016
842f9fd
Merge branch 'add_two_fingers_tap_support' of https://github.com/serg…
sergey-plevako-badoo Dec 14, 2016
2d9679e
Merge branch 'add_two_fingers_tap_support' of https://github.com/serg…
sergey-plevako-badoo Dec 14, 2016
fc87872
Merge branch 'add_two_fingers_tap_support' of https://github.com/serg…
sergey-plevako-badoo Dec 14, 2016
34b7db9
merge master upstream
sergey-plevako-badoo Jan 23, 2017
23fb502
merge and resolve conflicts
sergey-plevako-badoo Jan 23, 2017
19081d3
Merge branch 'master' of https://github.com/appium/appium-xcuitest-dr…
sergey-plevako-badoo Jan 27, 2017
c31e2dc
Merge branch 'master' into add_two_fingers_tap_support
sergey-plevako-badoo Jan 30, 2017
4e87a70
Merge branch 'master' into add_two_fingers_tap_support
sergey-plevako-badoo Feb 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion lib/commands/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ commands.click = async function (el) {
};

commands.performTouch = async function (gestures) {
log.debug(`Received the following touch gestures: ${gestures}`);
log.debug(`Received the following touch action: ${_.map(gestures, 'action').join('-')}`);

if (isDoubleTap(gestures)) {
return await this.handleDoubleTap(gestures);
} else if (isTap(gestures)) {
return await this.handleTap(gestures[0]);
} else if (isDoubleTap(gestures)) {
return await this.handleDoubleTap(gestures);
} else if (isTwoFingerTap(gestures)) {
return await this.handleTwoFingerTap(gestures);
} else if (isLongPress(gestures)) {
return await this.handleLongPress(gestures);
} else if (isDrag(gestures)) {
Expand Down Expand Up @@ -80,6 +85,13 @@ function isDoubleTap (gestures) {
return false;
}

function isTwoFingerTap (gestures) {
if (gestures.length === 1 && gestures[0].action.toLowerCase() === 'twofingertap') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sergey-plevako-badoo! Is twofingertap in the W3C gesture spec? I don't remember it being there.

If not, we can't just add new actions. I like this change in general but I think this function probably needs to be rewritten to actually detect a 2-digit tap based on the number of digits in the action chain, rather than creating a new action type.

I'm not up on the spec these days though so maybe I can be convinced otherwise. @imurchie should probably also comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just saw some more changes come through here. @imurchie have you taken a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically nothing of this is in the W3C spec, so we could add it. Otherwise it could be mapped from a two tap gestures in the multi-action api.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, however given that when we do migrate to the new W3C spec, and it doesn't seem to have a "double-tap" primitive, probably better to do it the way that will be more easy to map to the spec later.

return true;
}
return false;
}

function isTap (gestures) {
if (gestures.length === 1 && gestures[0].action === 'tap') {
return true;
Expand Down Expand Up @@ -200,7 +212,22 @@ helpers.handleDoubleTap = async function (gestures) {
}

let el = util.unwrapElement(opts.element);
let endpoint = `/wda/element/${el}/doubleTap`;

let endpoint = `/uiaElement/${el}/doubleTap`;

return await this.proxyCommand(endpoint, 'POST');
};

helpers.handleTwoFingerTap = async function (gestures) {
let gesture = gestures[0];
let opts = gesture.options || {};

if (!opts.element) {
log.errorAndThrow('WDA double tap needs an element');
}

let el = util.unwrapElement(opts.element);
let endpoint = `/uiaElement/${el}/twoFingerTap`;

return await this.proxyCommand(endpoint, 'POST');
};
Expand Down