removed deprecated swipe api references (fix #3989)

This commit is contained in:
Eric Millin
2014-11-10 15:00:07 -05:00
parent f669f95603
commit 4d4cdb96f1
5 changed files with 10 additions and 356 deletions
+10 -10
View File
@@ -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
@@ -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);
});
});
@@ -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; });
@@ -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);
});
});
@@ -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);
});
});