From 28162c4fd414538bd1f5db98c5d30a197d6b7981 Mon Sep 17 00:00:00 2001 From: moizjv Date: Wed, 29 Apr 2015 16:27:19 -0700 Subject: [PATCH] Fixing perform touch with release action --- lib/devices/android/android-controller.js | 2 +- .../android/apidemos/touch/press-specs.js | 35 +++++++++++++++++++ test/unit/android-controller-specs.js | 11 +++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/lib/devices/android/android-controller.js b/lib/devices/android/android-controller.js index 22d28d80e..eb2991974 100644 --- a/lib/devices/android/android-controller.js +++ b/lib/devices/android/android-controller.js @@ -1026,7 +1026,7 @@ androidController.performTouch = function (gestures, cb) { }; androidController.parseTouch = function (gestures, multi, cb) { - if (_.last(gestures).action === 'release') { + if (multi && _.last(gestures).action === 'release') { gestures.pop(); } diff --git a/test/functional/android/apidemos/touch/press-specs.js b/test/functional/android/apidemos/touch/press-specs.js index 4cf22a3f8..b21f225ee 100644 --- a/test/functional/android/apidemos/touch/press-specs.js +++ b/test/functional/android/apidemos/touch/press-specs.js @@ -57,3 +57,38 @@ describe("apidemo - touch - press", function () { }); }); }); + +describe("apidemo - touch - longpress - release", function () { + var driver; + setup(this, _.defaults({ + appActivity: '.view.SecureView' + }, desired)).then(function (d) { driver= d;}); + describe('press released after pause should call release', function () { + it('should open an alert dialog', function (done) { + driver + .elementByName("Don't click! It'll cost you!") + .then(function (el) { + var action = new TouchAction(driver); + return action.press({el: el}).wait(1000).release().perform(); + }) + .elementByName("Oops...").should.eventually.exist + .then(function (el) { + el.click(); + }) + .nodeify(done); + }); + }); + + describe('longPress should call release', function () { + it('should open an alert dialog', function (done) { + driver + .elementByName("Don't click! It'll cost you!") + .then(function (el) { + var action = new TouchAction(driver); + return action.longPress({el: el}).release().perform(); + }) + .elementByName("Oh no!").should.eventually.exist + .nodeify(done); + }); + }); +}); diff --git a/test/unit/android-controller-specs.js b/test/unit/android-controller-specs.js index 582c1587b..8ae130ccf 100644 --- a/test/unit/android-controller-specs.js +++ b/test/unit/android-controller-specs.js @@ -17,16 +17,19 @@ describe('android-controller', function () { { action: 'moveTo', options: { x: -40, y: -41 } }, { action: 'release', options: {} } ]; controller.parseTouch(actions, false, function (err, touchStates) { - touchStates.length.should.equal(4); + touchStates.length.should.equal(5); var actions = [{action: 'press', x: 100, y: 101}, {action: 'moveTo', x: 150, y: 152}, {action: 'wait', x: 150, y: 152}, - {action: 'moveTo', x: 110, y: 111}]; + {action: 'moveTo', x: 110, y: 111}, + {action: 'release'}]; _.each(touchStates, function (state, index) { state.action.should.equal(actions[index].action); - state.options.x.should.equal(actions[index].x); - state.options.y.should.equal(actions[index].y); + if (actions[index].action !== 'release') { + state.options.x.should.equal(actions[index].x); + state.options.y.should.equal(actions[index].y); + } }); done();