cabbie-async
Version:
An asynchronous webdriver client
378 lines (291 loc) • 11.9 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _debug = require('./debug');
var _debug2 = _interopRequireDefault(_debug);
var _driver = require('./driver');
var _driver2 = _interopRequireDefault(_driver);
var _element = require('./element');
var _element2 = _interopRequireDefault(_element);
var _util = require('util');
var _addDebugging = require('./add-debugging');
var _addDebugging2 = _interopRequireDefault(_addDebugging);
var _flowRuntime = require('flow-runtime');
var _flowRuntime2 = _interopRequireDefault(_flowRuntime);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
*
* This file is generated automatically, run npm run build to re-generate.
**/
var Element = _flowRuntime2.default.tdz(function () {
return _element2.default;
});
/*
* Touch commands relative to a DOM-element
*/
var Driver = _flowRuntime2.default.tdz(function () {
return _driver2.default;
});
var Debug = _flowRuntime2.default.tdz(function () {
return _debug2.default;
});
var Touch = function () {
/*
* @private
*/
function Touch(driver /*: Driver*/, parent /*: Element*/) {
(0, _classCallCheck3.default)(this, Touch);
var _driverType = _flowRuntime2.default.ref(Driver);
var _parentType = _flowRuntime2.default.ref(Element);
_flowRuntime2.default.param('driver', _driverType).assert(driver);
_flowRuntime2.default.param('parent', _parentType).assert(parent);
this.debug = driver.debug;
this.driver = driver;
this._parent = parent;
}
/*
* Tap with the finger on the element
*/
/*
* @private
*/
(0, _createClass3.default)(Touch, [{
key: 'tap',
value: function tap() /*: Promise<void>*/ {
var _returnType;
return _regenerator2.default.async(function tap$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_returnType = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context.next = 3;
return _regenerator2.default.awrap(this.driver.activeWindow.touch._tap(this._parent.elementID));
case 3:
case 'end':
return _context.stop();
}
}
}, null, this);
}
/*
* Double tap with the finger on the element
*/
}, {
key: 'doubleTap',
value: function doubleTap() /*: Promise<void>*/ {
var _returnType2;
return _regenerator2.default.async(function doubleTap$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_returnType2 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context2.next = 3;
return _regenerator2.default.awrap(this.driver.activeWindow.touch._doubleTap(this._parent.elementID));
case 3:
case 'end':
return _context2.stop();
}
}
}, null, this);
}
/*
* Long tap with the finger on the element
*/
}, {
key: 'longTap',
value: function longTap() /*: Promise<void>*/ {
var _returnType3;
return _regenerator2.default.async(function longTap$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_returnType3 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context3.next = 3;
return _regenerator2.default.awrap(this.driver.activeWindow.touch._longTap(this._parent.elementID));
case 3:
case 'end':
return _context3.stop();
}
}
}, null, this);
}
/*
* Finger down on the screen at an offset relative to the element
*/
}, {
key: 'down',
value: function down(xOffset /*: number*/, yOffset /*: number*/) /*: Promise<void>*/ {
var _xOffsetType, _yOffsetType, _returnType4, location;
return _regenerator2.default.async(function down$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_xOffsetType = _flowRuntime2.default.number();
_yOffsetType = _flowRuntime2.default.number();
_returnType4 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_flowRuntime2.default.param('xOffset', _xOffsetType).assert(xOffset);
_flowRuntime2.default.param('yOffset', _yOffsetType).assert(yOffset);
_context4.next = 7;
return _regenerator2.default.awrap(this._parent.getPosition());
case 7:
location = _context4.sent;
_context4.next = 10;
return _regenerator2.default.awrap(this.driver.activeWindow.touch.down(location.x + xOffset, location.y + yOffset));
case 10:
case 'end':
return _context4.stop();
}
}
}, null, this);
}
/*
* Finger down on the screen at the center of the element
*/
}, {
key: 'downAtCenter',
value: function downAtCenter() /*: Promise<void>*/ {
var _returnType5, center;
return _regenerator2.default.async(function downAtCenter$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_returnType5 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context5.next = 3;
return _regenerator2.default.awrap(this._parent.getAbsoluteCenter());
case 3:
center = _context5.sent;
_context5.next = 6;
return _regenerator2.default.awrap(this.driver.activeWindow.touch.down(center.x, center.y));
case 6:
case 'end':
return _context5.stop();
}
}
}, null, this);
}
/*
* Finger up on the screen at an offset relative to the element
*/
}, {
key: 'up',
value: function up(xOffset /*: number*/, yOffset /*: number*/) /*: Promise<void>*/ {
var _xOffsetType2, _yOffsetType2, _returnType6, location;
return _regenerator2.default.async(function up$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_xOffsetType2 = _flowRuntime2.default.number();
_yOffsetType2 = _flowRuntime2.default.number();
_returnType6 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_flowRuntime2.default.param('xOffset', _xOffsetType2).assert(xOffset);
_flowRuntime2.default.param('yOffset', _yOffsetType2).assert(yOffset);
_context6.next = 7;
return _regenerator2.default.awrap(this._parent.getPosition());
case 7:
location = _context6.sent;
_context6.next = 10;
return _regenerator2.default.awrap(this.driver.activeWindow.touch.down(location.x + xOffset, location.y + yOffset));
case 10:
case 'end':
return _context6.stop();
}
}
}, null, this);
}
/*
* Finger up on the screen at the center of the element
*/
}, {
key: 'upAtCenter',
value: function upAtCenter() /*: Promise<void>*/ {
var _returnType7, center;
return _regenerator2.default.async(function upAtCenter$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_returnType7 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context7.next = 3;
return _regenerator2.default.awrap(this._parent.getAbsoluteCenter());
case 3:
center = _context7.sent;
_context7.next = 6;
return _regenerator2.default.awrap(this.driver.activeWindow.touch.down(center.x, center.y));
case 6:
case 'end':
return _context7.stop();
}
}
}, null, this);
}
/*
* Move finger to an offset relative to the element
*/
}, {
key: 'moveTo',
value: function moveTo(xOffset /*: number*/, yOffset /*: number*/) /*: Promise<void>*/ {
var _xOffsetType3, _yOffsetType3, _returnType8, location;
return _regenerator2.default.async(function moveTo$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_xOffsetType3 = _flowRuntime2.default.number();
_yOffsetType3 = _flowRuntime2.default.number();
_returnType8 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_flowRuntime2.default.param('xOffset', _xOffsetType3).assert(xOffset);
_flowRuntime2.default.param('yOffset', _yOffsetType3).assert(yOffset);
_context8.next = 7;
return _regenerator2.default.awrap(this._parent.getPosition());
case 7:
location = _context8.sent;
_context8.next = 10;
return _regenerator2.default.awrap(this.driver.activeWindow.touch.move(location.x + xOffset, location.y + yOffset));
case 10:
case 'end':
return _context8.stop();
}
}
}, null, this);
}
/*
* Move finger to the center of the element
*/
}, {
key: 'moveToCenter',
value: function moveToCenter() /*: Promise<void>*/ {
var _returnType9, center;
return _regenerator2.default.async(function moveToCenter$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_returnType9 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context9.next = 3;
return _regenerator2.default.awrap(this._parent.getAbsoluteCenter());
case 3:
center = _context9.sent;
_context9.next = 6;
return _regenerator2.default.awrap(this.driver.activeWindow.touch.move(center.x, center.y));
case 6:
case 'end':
return _context9.stop();
}
}
}, null, this);
}
//TODO: Element touch flick
//TODO: Element touch scroll
}]);
return Touch;
}();
(0, _addDebugging2.default)(Touch, {
inspect: function inspect(obj, depth, options) {
return obj._parent[_util.inspect.custom || 'inspect'](depth, options) + '.touch';
}
});
exports.default = Touch;