From 4d4cdb96f1ef4e9ad7dfd83e85cee7b147cff51a Mon Sep 17 00:00:00 2001 From: Eric Millin Date: Mon, 10 Nov 2014 14:44:46 -0500 Subject: [PATCH] removed deprecated swipe api references (fix #3989) --- lib/server/controller.js | 20 +-- .../android/apidemos/gestures/swipe-specs.js | 38 ----- .../ios/uicatalog-61/gestures-specs.js | 140 ------------------ .../uicatalog/gestures/swipe-element-specs.js | 71 --------- .../ios/uicatalog/gestures/swipe-specs.js | 97 ------------ 5 files changed, 10 insertions(+), 356 deletions(-) delete mode 100644 test/functional/android/apidemos/gestures/swipe-specs.js delete mode 100644 test/functional/ios/uicatalog/gestures/swipe-element-specs.js delete mode 100644 test/functional/ios/uicatalog/gestures/swipe-specs.js diff --git a/lib/server/controller.js b/lib/server/controller.js index f84c149d2..816352d40 100644 --- a/lib/server/controller.js +++ b/lib/server/controller.js @@ -325,7 +325,7 @@ exports.performTouch = function (req, res) { gestures[1].action === 'wait' && gestures[2].action === 'moveTo' && gestures[3].action === 'release') { - return exports.mobileSwipe(gestures, req, res); + return exports.mobileSwipe(req, res, gestures); } req.device.performTouch(gestures, getResponseHandler(req, res)); @@ -479,7 +479,7 @@ var _getSwipeTouchDuration = function (waitGesture) { return duration; }; -exports.mobileSwipe = function (gestures, req, res) { +exports.mobileSwipe = function (req, res, gestures) { var getCoordDefault = function (val) { // going the long way and checking for undefined and null since @@ -489,13 +489,13 @@ exports.mobileSwipe = function (gestures, req, res) { }; var touchCount = req.body.touchCount || 1 - , startX = getCoordDefault(gestures[0].options.x) - , startY = getCoordDefault(gestures[0].options.y) - , endX = getCoordDefault(gestures[2].options.x) - , endY = getCoordDefault(gestures[2].options.y) - , duration = _getSwipeTouchDuration(gestures[1]) - , element = gestures[0].options.element - , destElement = gestures[2].options.element || gestures[0].options.element; + , startX = getCoordDefault(gestures[0].options.x) + , startY = getCoordDefault(gestures[0].options.y) + , endX = getCoordDefault(gestures[2].options.x) + , endY = getCoordDefault(gestures[2].options.y) + , duration = _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 (notNullOrUndefined(destElement)) { @@ -507,6 +507,7 @@ exports.mobileSwipe = function (gestures, req, res) { if (er) { respondError(req, res, er); } else { + var offsetX = (Math.abs(endX) < 1 && Math.abs(endX) > 0) ? sizeResult.value.width * endX : endX; @@ -1169,7 +1170,6 @@ var mobileCmdMap = { 'tap': exports.mobileTap , 'drag': exports.mobileDrag , 'flick': exports.mobileFlick -, 'swipe': exports.mobileSwipe , 'scrollTo': exports.mobileScrollTo , 'scroll': exports.mobileScroll , 'longClick' : exports.touchLongClick diff --git a/test/functional/android/apidemos/gestures/swipe-specs.js b/test/functional/android/apidemos/gestures/swipe-specs.js deleted file mode 100644 index ce6afc21d..000000000 --- a/test/functional/android/apidemos/gestures/swipe-specs.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -var setup = require("../../../common/setup-base") - , desired = require("../desired"); - -describe("apidemo - gestures - swipe", function () { - var driver; - setup(this, desired).then(function (d) { driver = d; }); - - // todo fix this: got Error response status: 13, The swipe did not complete successfully - it('should swipe screen by pixels @skip-android-all', function (done) { - var swipeOpts = { - startX: 100 - , startY: 500 - , endX: 100 - , endY: 100 - , duration: 1.2 - }; - driver - .elementByName("Views").should.be.rejected // shouldn't be visible - .execute("mobile: swipe", [swipeOpts]) - .elementByName("Views").should.eventually.exist - .nodeify(done); - }); - // todo fix this: got Error response status: 13, The swipe did not complete successfully - it('should swipe screen by pct @skip-android-all', function (done) { - var swipeOpts = { - endX: 0.5 - , endY: 0.05 - , duration: 0.7 - }; - driver - .elementByName("Views").should.be.rejected // shouldn't be visible - .execute("mobile: swipe", [swipeOpts]) - .elementByName("Views").should.eventually.exist - .nodeify(done); - }); -}); diff --git a/test/functional/ios/uicatalog-61/gestures-specs.js b/test/functional/ios/uicatalog-61/gestures-specs.js index b4c8b5dc6..4dca9fa34 100644 --- a/test/functional/ios/uicatalog-61/gestures-specs.js +++ b/test/functional/ios/uicatalog-61/gestures-specs.js @@ -3,7 +3,6 @@ var env = require('../../../helpers/env') , setup = require("../../common/setup-base") , desired = require('./desired') - , spinWait = require('../../../helpers/spin.js').spinWait , textBlock = "Now is the time for all good developers to come to serve their country.\n"; // sebv: had to cut down original textBlock, cause text retrieved depends on device size @@ -75,93 +74,6 @@ describe('uicatalog - gestures @skip-ios7up', function () { }).nodeify(done); }); }); - describe('swipe gesture @skip-ios7up', function () { - var driver; - setup(this, desired).then(function (d) { driver = d; }); - - if (env.FAST_TESTS) { - afterEach(function (done) { - driver - .flick(0, 70, false) - .flick(0, 70, false) - .sleep(SLOW_DOWN_MS) - .nodeify(done); - }); - } - it('should work with wd function in pixels', function (done) { - driver - .elementByClassName('UIATableCell').getLocation() - .then(function (location1) { - return spinWait(function () { - return driver - .flick(0, -70, true) - .elementByClassName('UIATableCell').getLocation() - .then(function (location2) { - ((location2.x === location1.x) && - (location2.y !== location1.y) - ).should.be.ok; - }); - }, 5000); - - }).nodeify(done); - }); - it('should work with wd function in percent', function (done) { - driver - .elementByClassName('UIATableCell').getLocation() - .then(function (location1) { - return driver - .flick(0, -0.1, true) // flaky - .flick(0, -0.1, true) - .flick(0, -0.1, true) - .elementByClassName('UIATableCell').getLocation() - .then(function (location2) { - location2.x.should.equal(location1.x); - location2.y.should.not.equal(location1.y, '===y'); - }); - }).nodeify(done); - }); - it('should work with mobile function in pixels', function (done) { - var opts = {startX: 50, startY: 400, endX: 50, endY: 300, duration: 2}; - driver - .elementByClassName('UIATableCell').getLocation() - .then(function (location1) { - return spinWait(function () { - return driver - .execute("mobile: swipe", [opts]) - .elementByClassName('UIATableCell').getLocation() - .then(function (location2) { - location2.x.should.equal(location1.x); - location2.y.should.not.equal(location1.y); - }); - }); - }).nodeify(done); - }); - it('should work with mobile function in percent', function (done) { - var opts = {startX: 0.5, startY: 0.9, endX: 0.5, endY: 0.7, duration: 2}; - driver - .elementByClassName('UIATableCell').getLocation() - .then(function (location1) { - return spinWait(function () { - return driver - .execute("mobile: swipe", [opts]) - .elementByClassName('UIATableCell').getLocation() - .then(function (location2) { - location2.x.should.equal(location1.x); - location2.y.should.not.equal(location1.y); - }); - }); - }).nodeify(done); - }); - it('should not complete instantaneously', function (done) { - var start = Date.now(); - var opts = {startX: 0.5, startY: 0.9, endX: 0.5, endY: 0.7, duration: 2}; - driver - .execute("mobile: swipe", [opts]) - .then(function () { - (Date.now() - start).should.be.above(1999); - }).nodeify(done); - }); - }); describe("flick element @skip-ios7up", function () { var driver; @@ -232,59 +144,7 @@ describe('uicatalog - gestures @skip-ios7up', function () { }).nodeify(done); }); }); - describe("swipe element @skip-ios7up", function () { - var driver; - setup(this, desired).then(function (d) { driver = d; }); - if (env.FAST_TESTS) { - afterEach(function (done) { - driver - .elementByClassName("UIASlider") - .then(function (el) { if (el) return el.sendKeys(0.5); }) - .clickBack() - .sleep(SLOW_DOWN_MS) - .nodeify(done); - }); - } - - it("slider value should change", function (done) { - var valueBefore, slider; - driver - .elementsByClassName('UIATableCell').then(function (els) { return els[1]; }) - .click() - .elementByClassName("UIASlider").then(function (el) { slider = el; }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (value) { valueBefore = value; }) - .then(function () { - var opts = {startX: 0.5, startY: 0.5, endX: 0.25, endY: 0.5, - duration: 0.3, element: slider.value}; - return driver.execute("mobile: swipe", [opts]); - }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (valueAfter) { - valueBefore.should.equal("50%"); - valueAfter.should.equal("20%"); - }).nodeify(done); - }); - it("slider value should change by pixels", function (done) { - var valueBefore, slider; - driver - .elementsByClassName('UIATableCell').then(function (els) { return els[1]; }) - .click() - .elementByClassName("UIASlider").then(function (el) { slider = el; }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (value) { valueBefore = value; }) - .then(function () { - var opts = {endX: 15, endY: 10, duration: 0.3, element: slider.value}; - return driver.execute("mobile: swipe", [opts]); - }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (valueAfter) { - valueBefore.should.equal("50%"); - valueAfter.should.equal("5%"); - }).nodeify(done); - }); - }); describe('complex tap', function () { var driver; setup(this, desired).then(function (d) { driver = d; }); diff --git a/test/functional/ios/uicatalog/gestures/swipe-element-specs.js b/test/functional/ios/uicatalog/gestures/swipe-element-specs.js deleted file mode 100644 index 0d56e64e9..000000000 --- a/test/functional/ios/uicatalog/gestures/swipe-element-specs.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; - -var env = require('../../../../helpers/env') - , setup = require("../../../common/setup-base") - , desired = require('../desired'); - -var SLOW_DOWN_MS = 1000; - -describe("uicatalog - gestures - swipe element @skip-ios7 @skip-ios6", function () { - var driver; - setup(this, desired).then(function (d) { driver = d; }); - - if (env.FAST_TESTS) { - afterEach(function (done) { - driver - .elementByClassName("UIASlider") - .then(function (el) { if (el) return el.sendKeys(0.42); }) - .clickButton('UICatalog') - .sleep(SLOW_DOWN_MS) - .nodeify(done); - }); - } - - var getNumericValue = function (pctVal) { - pctVal = pctVal.replace("%", ""); - pctVal = parseInt(pctVal, 10); - return pctVal; - }; - - it("slider value should change", function (done) { - var valueBefore, slider; - driver - .elementByAccessibilityId('Sliders').click() - .elementByClassName("UIASlider").then(function (el) { slider = el; }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (value) { valueBefore = value; }) - .then(function () { - var opts = {startX: 0.5, startY: 0.5, endX: 0.25, endY: 0.5, - duration: 0.3, element: slider.value}; - return driver.execute("mobile: swipe", [opts]); - }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (valueAfter) { - valueBefore.should.equal("42%"); - valueAfter = getNumericValue(valueAfter); - // should be around 20 - valueAfter.should.be.above(15); - valueAfter.should.be.below(25); - }).nodeify(done); - }); - it("slider value should change by pixels", function (done) { - var valueBefore, slider; - driver - .elementByAccessibilityId('Sliders').click() - .elementByClassName("UIASlider").then(function (el) { slider = el; }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (value) { valueBefore = value; }) - .then(function () { - var opts = {endX: 15, endY: 10, duration: 0.3, element: slider.value}; - return driver.execute("mobile: swipe", [opts]); - }) - .then(function () { return slider.getAttribute("value"); }) - .then(function (valueAfter) { - valueBefore.should.equal("42%"); - valueAfter = getNumericValue(valueAfter); - // should be around 5 - valueAfter.should.be.below(8); - }).nodeify(done); - }); -}); - diff --git a/test/functional/ios/uicatalog/gestures/swipe-specs.js b/test/functional/ios/uicatalog/gestures/swipe-specs.js deleted file mode 100644 index 7d45f8838..000000000 --- a/test/functional/ios/uicatalog/gestures/swipe-specs.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; - -var env = require('../../../../helpers/env') - , setup = require("../../../common/setup-base") - , desired = require('../desired') - , spinWait = require('../../../../helpers/spin.js').spinWait; - -var SLOW_DOWN_MS = 1000; - -describe('uicatalog - gestures - swipe @skip-ios8 @skip-ios7 @skip-ios6', function () { - var driver; - setup(this, desired).then(function (d) { driver = d; }); - - if (env.FAST_TESTS) { - afterEach(function (done) { - driver - .flick(0, 70, false) - .flick(0, 70, false) - .sleep(SLOW_DOWN_MS) - .nodeify(done); - }); - } - it('should work with wd function in pixels', function (done) { - driver - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location1) { - return spinWait(function () { - return driver - .flick(0, -70, true) - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location2) { - ((location2.x === location1.x) && - (location2.y !== location1.y) - ).should.be.ok; - }); - }, 5000); - - }).nodeify(done); - }); - it('should work with wd function in percent', function (done) { - driver - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location1) { - return driver - .flick(0, -0.1, true) // flaky - .flick(0, -0.1, true) - .flick(0, -0.1, true) - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location2) { - location2.x.should.equal(location1.x); - location2.y.should.not.equal(location1.y, '===y'); - }); - }).nodeify(done); - }); - it('should work with mobile function in pixels', function (done) { - var opts = {startX: 50, startY: 400, endX: 50, endY: 300, duration: 2}; - driver - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location1) { - return spinWait(function () { - return driver - .execute("mobile: swipe", [opts]) - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location2) { - location2.x.should.equal(location1.x); - location2.y.should.not.equal(location1.y); - }); - }); - }).nodeify(done); - }); - it('should work with mobile function in percent', function (done) { - var opts = {startX: 0.5, startY: 0.9, endX: 0.5, endY: 0.7, duration: 2}; - driver - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location1) { - return spinWait(function () { - return driver - .execute("mobile: swipe", [opts]) - .elementByClassName('UIATableCell').getLocationInView() - .then(function (location2) { - location2.x.should.equal(location1.x); - location2.y.should.not.equal(location1.y); - }); - }); - }).nodeify(done); - }); - it('should not complete instantaneously', function (done) { - var start = Date.now(); - var opts = {startX: 0.5, startY: 0.9, endX: 0.5, endY: 0.7, duration: 2}; - driver - .execute("mobile: swipe", [opts]) - .then(function () { - (Date.now() - start).should.be.above(1999); - }).nodeify(done); - }); -}); -