Added support for locking the IOS device for a number of seconds.

Removed unused code
This commit is contained in:
Eric Plaster
2013-06-20 15:00:02 -05:00
parent 40e8769d63
commit 2b72d64c2f
5 changed files with 38 additions and 0 deletions
+4
View File
@@ -565,6 +565,10 @@ Android.prototype.postDismissAlert = function(cb) {
cb(new NotYetImplementedError(), null);
};
Android.prototype.lock = function(secs, cb) {
cb(new NotYetImplementedError(), null);
};
Android.prototype.getOrientation = function(cb) {
this.proxy(["orientation", {}], cb);
};
+8
View File
@@ -207,6 +207,13 @@ exports.reset = function(req, res) {
req.appium.reset(getResponseHandler(req, res));
};
exports.lock = function(req, res) {
var seconds = req.body.seconds;
if (checkMissingParams(res, {seconds: seconds})) {
req.device.lock(seconds, getResponseHandler(req, res));
}
};
exports.deleteSession = function(req, res) {
req.appium.stop(getResponseHandler(req, res));
};
@@ -852,6 +859,7 @@ var mobileCmdMap = {
, 'findAndAct': exports.findAndAct
, 'setValue' : exports.setValueImmediate
, 'reset' : exports.reset
, 'lock' : exports.lock
, 'keyevent' : exports.keyevent
, 'leaveWebView': exports.leaveWebView
, 'fireEvent': exports.fireEvent
+4
View File
@@ -1442,6 +1442,10 @@ IOS.prototype.postDismissAlert = function(cb) {
this.proxy("au.dismissAlert()", cb);
};
IOS.prototype.lock = function(secs, cb) {
this.proxy(["au.lock(", secs, ")"].join(''), cb);
};
IOS.prototype.getOrientation = function(cb) {
this.proxy("au.getScreenOrientation()", cb);
};
+5
View File
@@ -558,6 +558,11 @@ $.extend(au, {
return $(this.mainWindow).getActiveElement();
}
, lock: function(secs) {
var seconds = parseInt(secs, 10);
return this.target.lockForDuration(secs);
}
// Gesture functions
, getAbsCoords: function(startX, startY, endX, endY) {
+17
View File
@@ -0,0 +1,17 @@
/*global it:true */
"use strict";
var describeWd = require("../../helpers/driverblock.js").describeForApp('UICatalog')
, should = require('should');
describeWd('device lock', function(h) {
it("should lock the device for 4 of seconds (+/- 2 secs)", function(done) {
var before = new Date().getTime() / 1000;
h.driver.execute("mobile: lock", [{seconds: 4}], function(err) {
should.not.exist(err);
var after = new Date().getTime() / 1000;
should.ok(after - before <= 6);
done();
});
});
});