From 1815100bf62d86fd517ef4a1283acf8b5b486725 Mon Sep 17 00:00:00 2001 From: Isaac Murchie Date: Thu, 23 Apr 2015 08:40:59 -0700 Subject: [PATCH] Add tests for sending simple key events to Android --- .../common/android-keyboard-base.js | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/test/functional/common/android-keyboard-base.js b/test/functional/common/android-keyboard-base.js index 9d3b04cf..d84eb329 100644 --- a/test/functional/common/android-keyboard-base.js +++ b/test/functional/common/android-keyboard-base.js @@ -3,7 +3,8 @@ var env = require('../../helpers/env') , setup = require("./setup-base") , _ = require('underscore') - , getAppPath = require('../../helpers/app').getAppPath; + , getAppPath = require('../../helpers/app').getAppPath + , status = require('../../../lib/server/status'); var desired = { @@ -87,6 +88,32 @@ module.exports = function () { var testText = 'Super-test.'; runTextEditTest(testText, done); }); + + describe('pressing device key', function () { + it('should be able to send keyevents', function (done) { + driver + .waitForElementByClassName('android.widget.EditText') + .elementById('com.android.launcher:id/search_button') + .should.be.rejectedWith(status.codes.NoSuchElement.code) + .pressDeviceKey(3) + .waitForElementById('com.android.launcher:id/search_button') + .elementByClassName('android.widget.EditText') + .should.be.rejectedWith(status.codes.NoSuchElement.code) + .nodeify(done); + }); + + // skip selendroid because selendroid implements keyevent with an adb + // call, and we are unable to send metastate that way + it('should be able to send combination keyevents @skip-selendroid-all', function (done) { + driver + .waitForElementByClassName('android.widget.EditText') + .clear() + .pressDeviceKey(29, 193) + .elementByClassName('android.widget.EditText') + .text().should.become('A') + .nodeify(done); + }); + }); }); describe('editing unicode text field', function () { @@ -178,6 +205,18 @@ module.exports = function () { }); describe('pressing device key with unicode keyboard', function () { + it('should be able to send keyevents', function (done) { + driver + .waitForElementByClassName('android.widget.EditText') + .elementById('com.android.launcher:id/search_button') + .should.be.rejectedWith(status.codes.NoSuchElement.code) + .pressDeviceKey(3) + .waitForElementById('com.android.launcher:id/search_button') + .elementByClassName('android.widget.EditText') + .should.be.rejectedWith(status.codes.NoSuchElement.code) + .nodeify(done); + }); + // skip selendroid because selendroid implements keyevent with an adb // call, and we are unable to send metastate that way it('should be able to send combination keyevents @skip-selendroid-all', function (done) {