Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #310 from bootstraponline/mobile_keyevent

mobile: keyevent for Android
  • Loading branch information...
commit d8e014e0373fad83d31737185a9e6064b8a3db5a 2 parents 5fb3dc5 + 1fc3197
@jlipps jlipps authored
Showing with 29 additions and 0 deletions.
  1. +19 −0 app/android.js
  2. +6 −0 app/controller.js
  3. +4 −0 app/ios.js
View
19 app/android.js
@@ -47,6 +47,25 @@ Android.prototype.fastReset = function(cb) {
this.adb.runFastReset(function(err) { if (err) return cb(err); return cb(null); });
};
+Android.prototype.keyevent = function(keycode, cb) {
+ // keycode must be an int.
+ var cmd = 'adb shell input keyevent ' + parseInt(keycode, 10);
+ logger.info(cmd);
+ exec(cmd, {}, function(err, stdout, stderr) {
+ if (err) {
+ logger.warn(stderr);
+ return cb(null, {
+ status: status.codes.UnknownError.code
+ , value: null
+ });
+ }
+ cb(null, {
+ status: status.codes.Success.code
+ , value: null
+ });
+ });
+};
+
Android.prototype.start = function(cb, onDie) {
if (typeof onDie === "function") {
this.onStop = onDie;
View
6 app/controller.js
@@ -343,6 +343,11 @@ exports.getPageIndex = function(req, res) {
req.device.getPageIndex(elementId, getResponseHandler(req, res));
};
+exports.keyevent = function(req, res) {
+ var keycode = req.body.keycode;
+ req.device.keyevent(keycode, getResponseHandler(req, res));
+};
+
exports.keys = function(req, res) {
var keys = req.body.value.join('');
@@ -622,6 +627,7 @@ var mobileCmdMap = {
, 'findAndAct': exports.findAndAct
, 'setValue' : exports.setValueImmediate
, 'reset' : exports.reset
+ , 'keyevent' : exports.keyevent
};
exports.produceError = function(req, res) {
View
4 app/ios.js
@@ -713,6 +713,10 @@ IOS.prototype.submit = function(elementId, cb) {
}
};
+IOS.prototype.keyevent = function(keycode, cb) {
+ cb(new NotImplementedError(), null);
+};
+
IOS.prototype.complexTap = function(tapCount, touchCount, duration, x, y, elementId, cb) {
var command
, options = {
Please sign in to comment.
Something went wrong with that request. Please try again.