Skip to content

Commit

Permalink
Merge 7d7918b into 6e6478c
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Dixon committed Oct 12, 2015
2 parents 6e6478c + 7d7918b commit be647bc
Show file tree
Hide file tree
Showing 13 changed files with 403 additions and 68 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[![NPM version](http://img.shields.io/npm/v/appium-android-driver.svg)](https://npmjs.org/package/appium-android-driver)
[![Downloads](http://img.shields.io/npm/dm/appium-android-driver.svg)](https://npmjs.org/package/appium-android-driver)
[![Dependency Status](https://david-dm.org/appium/appium-android-driver.svg)](https://david-dm.org/appium/appium-android-driver)
[![devDependency Status](https://david-dm.org/appium/appium-android-driver/dev-status.svg)](https://david-dm.org/appium/appium-android-driver#info=devDependencies)

[![Build Status](https://travis-ci.org/appium/appium-android-driver.svg?branch=master)](https://travis-ci.org/appium/appium-android-driver)
[![Coverage Status](https://coveralls.io/repos/appium/appium-android-driver/badge.svg?branch=master)](https://coveralls.io/r/appium/appium-android-driver?branch=master)

appium-android-driver
===================

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ boilerplate({
build: 'appium-android-driver',
jscs: false,
e2eTest: {android: true},
testTimeout: 20000
testTimeout: 40000
});
2 changes: 1 addition & 1 deletion lib/commands/ime.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ commands.activateIMEEngine = async function (imeId) {
let availableEngines = await this.adb.availableIMEs();
if (availableEngines.indexOf(imeId) === -1) {
log.debug("IME not found, failing");
throw new errors.IMENotAvailable();
throw new errors.IMENotAvailableError();
}
log.debug("Found installed IME, attempting to activate");
await this.adb.enableIME(imeId);
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
"gulp": "^3.8.11",
"sample-apps": "1.1.0",
"sinon": "^1.16.1",
"xmldom": "^0.1.19",
"xpath": "0.0.9",
"yargs": "^3.10.0"
}
}
59 changes: 59 additions & 0 deletions test/functional/api-demos/attribute-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';

chai.should();
chai.use(chaiAsPromised);

let driver;
let animationEl;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android'
};

describe('apidemo - attributes', function() {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
let animation = await driver.findElOrEls('accessibility id', 'Animation', false);
animationEl = animation.ELEMENT;
});
after(async () => {
await driver.deleteSession();
});
it('should be able to find resourceId attribute', async () => {
await driver.getAttribute('resourceId', animationEl).should.eventually.become('android:id/text1');
});
it('should be able to find text attribute', async () => {
await driver.getAttribute('text', animationEl).should.eventually.become('Animation');
});
it('should be able to find name attribute', async () => {
await driver.getAttribute('name', animationEl).should.eventually.become('Animation');
});
it('should be able to find name attribute, falling back to text', async () => {
await driver.click(animationEl);
let textView = await driver.findElOrEls('class name', 'android.widget.TextView', true);
let textViewEl = textView[1].ELEMENT;
await driver.getAttribute('name', textViewEl).should.eventually.become('Bouncing Balls');
await driver.back();
});
it('should be able to find displayed attribute', async () => {
await driver.getAttribute('displayed', animationEl).should.eventually.become('true');
});
it('should be able to find displayed attribute through normal func', async () => {
await driver.elementDisplayed(animationEl).should.eventually.become(true);
});
it('should be able to get element location', async () => {
let location = await driver.getLocationInView(animationEl);
location.x.should.be.at.least(0);
location.y.should.be.at.least(0);
});
it('should be able to get element size', async () => {
let size = await driver.getSize(animationEl);
size.width.should.be.at.least(0);
size.height.should.be.at.least(0);
});
});
50 changes: 50 additions & 0 deletions test/functional/api-demos/ime-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android',
appActivity: "view.Controls1",
unicodeKeyboard: true,
resetKeyboard: true
};
let unicodeImeId = 'io.appium.android.ime/.UnicodeIME';

describe('apidemo - IME', function () {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
beforeEach(async () => {
await driver.reset();
});
after(async () => {
await driver.deleteSession();
});
it('should get the default (enabled) input method', async () => {
await driver.getActiveIMEEngine().should.eventually.equal(unicodeImeId);
});
it('should get the available input methods', async () => {
await driver.availableIMEEngines().should.eventually.have.length.at.least(4);
});
it('should activate an installed input method', async () => {
await driver.activateIMEEngine(unicodeImeId).should.not.be.rejected;
});
it('should fail to activate an uninstalled input method', async () => {
let invalidImeId = 'sdf.wer.gdasdfsf/.OsdfEfgd';
await driver.activateIMEEngine(invalidImeId).should.eventually.be.rejectedWith(/not available/);
});
it('should deactivate the current input method', async () => {
await driver.activateIMEEngine(unicodeImeId);
await driver.getActiveIMEEngine().should.eventually.equal(unicodeImeId);
await driver.deactivateIMEEngine();
await driver.getActiveIMEEngine().should.eventually.not.equal(unicodeImeId);
});
});
52 changes: 52 additions & 0 deletions test/functional/api-demos/localization/language-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../../..';
import sampleApps from 'sample-apps';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android'
};

describe('Localization - language and country @skip-ci @skip-real-device', function() {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
after(async () => {
await driver.deleteSession();
});
it('should set language to FR', async () => {
await driver.adb.setDeviceLanguage('FR');
await driver.adb.getDeviceLanguage().should.eventually.equal('fr');
});
it('should set country to US', async () => {
await driver.adb.setDeviceCountry('US');
await driver.adb.getDeviceCountry().should.eventually.equal('US');
});
});

describe('Localization - locale @skip-ci @skip-real-device', function() {
// Stalls on API 23, works in CI
beforeEach(async () => {
driver = new AndroidDriver();
});
after(async () => {
await driver.deleteSession();
});
it('should start as FR', async () => {
let frCaps = Object.assign({}, defaultCaps, {locale: 'FR'});
await driver.createSession(frCaps);
await driver.adb.getDeviceCountry().should.eventually.equal('FR');
});
it('should start as US', async () => {
let usCaps = Object.assign({}, defaultCaps, {locale: 'US'});
await driver.createSession(usCaps);
await driver.adb.getDeviceCountry().should.eventually.equal('US');
});
});
40 changes: 40 additions & 0 deletions test/functional/api-demos/notifications-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';
import B from 'bluebird';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android',
appActivity: '.app.StatusBarNotifications'
};

describe('apidemo - notifications', function () {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
after(async () => {
await driver.deleteSession();
});
it('should open the notification shade @skip-ci', async () => {
let el = await driver.findElOrEls('accessibility id', ':-|', false);
await driver.click(el.ELEMENT);
await driver.openNotifications();
await B.delay(500);
let textViews = await driver.findElOrEls('class name', 'android.widget.TextView', true);
let text = [];
for (let view of textViews) {
text.push(await driver.getText(view.ELEMENT));
}
text.should.include('Mood ring');
await driver.keyevent(4);
await driver.getText(el.ELEMENT).should.become(':-|');
});
});
46 changes: 46 additions & 0 deletions test/functional/api-demos/orientation-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';
import B from 'bluebird';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android'
};

describe('apidemo - orientation', function () {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
after(async () => {
await driver.deleteSession();
});
it('should rotate screen to landscape', async () => {
await driver.setOrientation('PORTRAIT');
await B.delay(3000);
await driver.setOrientation('LANDSCAPE');
await B.delay(3000);
await driver.getOrientation().should.eventually.become('LANDSCAPE');
});
it('should rotate screen to landscape', async () => {
await driver.setOrientation('LANDSCAPE');
await B.delay(3000);
await driver.setOrientation('PORTRAIT');
await B.delay(3000);
await driver.getOrientation().should.eventually.become('PORTRAIT');
});
it('should not error when trying to rotate to portrait again', async () => {
await driver.setOrientation('PORTRAIT');
await B.delay(3000);
await driver.setOrientation('PORTRAIT');
await B.delay(3000);
await driver.getOrientation().should.eventually.become('PORTRAIT');
});
});
49 changes: 49 additions & 0 deletions test/functional/api-demos/source-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../..';
import sampleApps from 'sample-apps';
import { DOMParser } from 'xmldom';
import xpath from 'xpath';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android'
};
let assertSource = async (source) => {
source.should.exist;
let dom = new DOMParser().parseFromString(source);
let nodes = xpath.select('//android.widget.TextView[@content-desc="App"]', dom);
nodes.length.should.equal(1);
};

describe('apidemo - source', function () {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
after(async () => {
await driver.deleteSession();
});
it('should return the page source', async () => {
let source = await driver.getPageSource();
await assertSource(source);
});
it('should get less source when compression is enabled', async () => {
let getSourceWithoutCompression = async () => {
await driver.updateSettings({'ignoreUnimportantViews': false});
return await driver.getPageSource();
};
let getSourceWithCompression = async () => {
await driver.updateSettings({"ignoreUnimportantViews": true});
return await driver.getPageSource();
};
let sourceWithoutCompression = await getSourceWithoutCompression();
let sourceWithCompression = await getSourceWithCompression();
sourceWithoutCompression.length.should.be.greaterThan(sourceWithCompression.length);
});
});
50 changes: 50 additions & 0 deletions test/functional/api-demos/touch/drag-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../../..';
import sampleApps from 'sample-apps';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
app: sampleApps('ApiDemos-debug'),
deviceName: 'Android',
platformName: 'Android',
appActivity: '.view.DragAndDropDemo'
};

describe('apidemo - drag', function() {
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
after(async () => {
await driver.deleteSession();
});
it('should drag by element', async () => {
let dot3 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_3', false);
let dot2 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_2', false);
let gestures = [
{options: {element: dot3.ELEMENT}},
{options: {element: dot2.ELEMENT}}
];
await driver.doTouchDrag(gestures);
let results = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_result_text', false);
await driver.getText(results.ELEMENT).should.eventually.include('Dropped');
});
it('should drag by element with an offset', async () => {
// reset the app
await driver.reset();

let dot3 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_3', false);
let dot2 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_2', false);
let gestures = [
{options: {element: dot3.ELEMENT, x: 5, y: 5}},
{options: {element: dot2.ELEMENT, x: 5, y: 5}}
];
await driver.doTouchDrag(gestures);
let results = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_result_text', false);
await driver.getText(results.ELEMENT).should.eventually.include('Dropped');
});
});
Loading

0 comments on commit be647bc

Please sign in to comment.