|
@@ -1,37 +1,13 @@
|
1
|
1
|
const exec = require('shell-utils').exec;
|
2
|
|
-
|
3
|
|
-module.exports = {
|
4
|
|
- pressBack: () => {
|
5
|
|
- exec.execSync('adb shell input keyevent 4');
|
6
|
|
- },
|
7
|
|
- pressMenu: () => {
|
8
|
|
- exec.execSync('adb shell input keyevent 82');
|
9
|
|
- },
|
10
|
|
- pressEnter: (keyCode) => {
|
11
|
|
- exec.execSync(`adb shell input keyevent 66`);
|
12
|
|
- },
|
13
|
|
- pressLockButton: () => {
|
14
|
|
- exec.execSync(`adb shell input keyevent 26`);
|
15
|
|
- },
|
16
|
|
- pressKeyCode: (keyCode) => {
|
17
|
|
- exec.execSync(`adb shell input keyevent ${keyCode}`);
|
18
|
|
- },
|
19
|
|
- grantPermission: () => {
|
20
|
|
- exec.execSync('adb shell pm grant com.reactnativenavigation.playground android.permission.READ_PHONE_STATE');
|
21
|
|
- },
|
22
|
|
- revokePermission: () => {
|
23
|
|
- exec.execSync('adb shell pm revoke com.reactnativenavigation.playground android.permission.READ_PHONE_STATE');
|
24
|
|
- },
|
25
|
|
- openActivity: () => {
|
26
|
|
- exec.execSync('adb shell am start -n com.reactnativenavigation.playground/.MainActivity');
|
27
|
|
- },
|
|
2
|
+const utils = {
|
|
3
|
+ pressBack: () => utils.pressKeyCode(4),
|
|
4
|
+ pressMenu: () => utils.pressKeyCode(82),
|
|
5
|
+ pressKeyCode: (keyCode) => utils.executeShellCommand(`input keyevent ${keyCode}`),
|
|
6
|
+ grantPermission: () => utils.executeShellCommand('pm grant com.reactnativenavigation.playground android.permission.READ_PHONE_STATE'),
|
|
7
|
+ revokePermission: () => utils.executeShellCommand('pm revoke com.reactnativenavigation.playground android.permission.READ_PHONE_STATE'),
|
28
|
8
|
executeShellCommand: (command) => {
|
29
|
|
- exec.execSync(`adb shell ${command}`);
|
|
9
|
+ exec.execSync(`adb -s ${device.id} shell ${command}`);
|
30
|
10
|
},
|
31
|
|
- enterText: (text) => {
|
32
|
|
- exec.execSync(`adb shell input text ${text}`);
|
33
|
|
- },
|
34
|
|
- swipeUp: () => {
|
35
|
|
- exec.execSync('adb shell input touchscreen swipe 300 1200 500 0 100');
|
36
|
|
- }
|
37
|
11
|
};
|
|
12
|
+
|
|
13
|
+module.exports = utils;
|