Skip to content

Commit dd15f19

Browse files
committed
Added readme
1 parent d956d03 commit dd15f19

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
1-
TODO
1+
# Problem
22

3-
# problem
3+
You want to test your Android Cordova application with [Travis](https://travis-ci.org/) (or any other CI solution).
4+
And your tests need permission to be granted on emulator.
5+
For example, permission to access device storage.
46

5-
# solution
7+
**cordova run** command cannot grant permissions. So you cannot run your tests.
68

7-
# usage
9+
If you use [cordova-paramedic](https://github.com/apache/cordova-paramedic), you also out of luck.
10+
11+
# Solution
12+
13+
Add adb-ci to your project:
814

915
npm install adb-ci --save-dev
16+
17+
After adding adb-ci, CI build will always run cordova in such a way that it installs your app on emulator with
18+
all required permissions granted.
19+
20+
So your tests that require permissions will work.
21+
22+
See [cordova-plugin-photo-library](https://github.com/terikon/cordova-plugin-photo-library) for example of usage of adb-ci.
23+
24+
# How it works
25+
26+
adb-ci adds wrapper to adb command inside your project that will be activated when adb runs, by any node tool.
27+
cordova is one of such tools. Actually, under the hood, crodova runs adb to install and run your app.
28+
29+
The wrapper is installed in node_modules\.bin\adb. This ways, calls to adb will be redirected to adb-ci.
30+
31+
Every call to adb will be passed through by wrapper as is, except **adb install** command.
32+
The wrapper will add -g parameter to **adb install** call, so installed app will have granted permissions
33+
(see [adb docs](https://developer.android.com/studio/command-line/adb.html) for details).
34+
35+
- adb-ci will be activated only when CI environment variable is set, so it will not interfere with development machines.
36+
37+
- ANDROID_HOME envrionment variable should be set for adb-ci to work.
38+
39+
That's it. Hope it will be useful to someone.

adb-ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
'use strict';
44

5-
const IS_CI = true; //process.env.CI;
5+
const IS_CI = process.env.CI;
66

77
const original_location = `${process.env.ANDROID_HOME}/platform-tools/adb`;
88

0 commit comments

Comments
 (0)