Skip to content
Browse files

Add back button for Android

  • Loading branch information...
1 parent b1deb59 commit ff463c7dc653de6dd1a7b06eaabbd94a619521f5 @bootstraponline committed Mar 22, 2013
Showing with 27 additions and 1 deletion.
  1. +9 −0 app/android.js
  2. +4 −0 app/controller.js
  3. +4 −0 app/ios.js
  4. +1 −1 app/routing.js
  5. +9 −0 uiautomator/adb.js
View
9 app/android.js
@@ -352,6 +352,15 @@ Android.prototype.getWindowSize = function(windowHandle, cb) {
this.proxy(["getDeviceSize"], cb);
};
+Android.prototype.back = function(cb) {
+ this.adb.back(function() {
+ cb(null, {
+ status: status.codes.Success.code
+ , value: null
+ });
+ });
+};
+
Android.prototype.getPageIndex = function(elementId, cb) {
cb(new NotYetImplementedError(), null);
};
View
4 app/controller.js
@@ -349,6 +349,10 @@ exports.keyevent = function(req, res) {
req.device.keyevent(keycode, getResponseHandler(req, res));
};
+exports.back = function(req, res) {
+ req.device.back(getResponseHandler(req, res));
+};
+
exports.keys = function(req, res) {
var keys = req.body.value.join('');
View
4 app/ios.js
@@ -849,6 +849,10 @@ IOS.prototype.getWindowSize = function(windowHandle, cb) {
}
};
+IOS.prototype.back = function(cb) {
+ cb(new NotImplementedError(), null);
+};
+
IOS.prototype.getPageIndex = function(elementId, cb) {
if (this.curWindowHandle) {
cb(new NotImplementedError(), null);
View
2 app/routing.js
@@ -64,6 +64,7 @@ module.exports = function(appium) {
rest.post('/wd/hub/session/:sessionId?/element/:elementId?/submit', controller.submit);
rest.post('/wd/hub/session/:sessionId?/moveto', controller.moveTo);
rest.post('/wd/hub/session/:sessionId?/click', controller.clickCurrent);
+ rest.post('/wd/hub/session/:sessionId?/back', controller.back);
// these are for testing purposes only
rest.post('/wd/hub/produce_error', controller.produceError);
@@ -95,7 +96,6 @@ var routeNotYetImplemented = function(rest) {
rest.post('/wd/hub/session/:sessionId?/execute_async', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/timeouts/async_script', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/forward', controller.notYetImplemented);
- rest.post('/wd/hub/session/:sessionId?/back', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/refresh', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/available_engines', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/active_engine', controller.notYetImplemented);
View
9 uiautomator/adb.js
@@ -801,6 +801,15 @@ ADB.prototype.installApp = function(cb) {
}
};
+ADB.prototype.back = function(cb) {
+ this.requireDeviceId();
+ this.debug("Pressing the BACK button");
+ var cmd = this.adbCmd + " shell input keyevent 4";
+ exec(cmd, function() {
+ cb();
+ });
+};
+
ADB.prototype.goToHome = function(cb) {
this.requireDeviceId();
this.debug("Pressing the HOME button");

0 comments on commit ff463c7

Please sign in to comment.
Something went wrong with that request. Please try again.