appium-android-driver 5.14.7 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build/lib/commands/actions.d.ts +6 -224
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +306 -405
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +7 -9
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +24 -18
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -313
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +135 -293
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/context.d.ts +8 -92
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +381 -439
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +8 -35
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +153 -136
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/emu-console.d.ts +6 -48
- package/build/lib/commands/emu-console.d.ts.map +1 -1
- package/build/lib/commands/emu-console.js +19 -34
- package/build/lib/commands/emu-console.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -5
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +77 -66
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +7 -128
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +183 -219
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +19 -23
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +9 -132
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +281 -312
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/ime.d.ts +7 -10
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +47 -35
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/index.d.ts +27 -2
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +41 -19
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/commands/intent.d.ts +7 -417
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +104 -216
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +6 -5
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +16 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/log.d.ts +7 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +146 -108
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +7 -143
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +113 -140
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/mixins.d.ts +740 -0
- package/build/lib/commands/mixins.d.ts.map +1 -0
- package/build/lib/commands/mixins.js +19 -0
- package/build/lib/commands/mixins.js.map +1 -0
- package/build/lib/commands/network.d.ts +7 -138
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +212 -254
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +24 -70
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +144 -100
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +8 -92
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +75 -87
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -193
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +151 -182
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/shell.d.ts +7 -7
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +40 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +9 -103
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +261 -218
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +22 -90
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +76 -74
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/touch.d.ts +10 -29
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +301 -285
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +978 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/constraints.d.ts +291 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/{desired-caps.js → constraints.js} +103 -102
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/driver.d.ts +68 -37
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +123 -80
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +164 -0
- package/build/lib/helpers/android.d.ts.map +1 -0
- package/build/lib/helpers/android.js +819 -0
- package/build/lib/helpers/android.js.map +1 -0
- package/build/lib/helpers/index.d.ts +7 -0
- package/build/lib/helpers/index.d.ts.map +1 -0
- package/build/lib/helpers/index.js +29 -0
- package/build/lib/helpers/index.js.map +1 -0
- package/build/lib/helpers/types.d.ts +121 -0
- package/build/lib/helpers/types.d.ts.map +1 -0
- package/build/lib/helpers/types.js +3 -0
- package/build/lib/helpers/types.js.map +1 -0
- package/build/lib/helpers/unlock.d.ts +32 -0
- package/build/lib/helpers/unlock.d.ts.map +1 -0
- package/build/lib/helpers/unlock.js +273 -0
- package/build/lib/helpers/unlock.js.map +1 -0
- package/build/lib/helpers/webview.d.ts +74 -0
- package/build/lib/helpers/webview.d.ts.map +1 -0
- package/build/lib/helpers/webview.js +421 -0
- package/build/lib/helpers/webview.js.map +1 -0
- package/build/lib/index.d.ts +9 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +37 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/method-map.d.ts +0 -8
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +63 -74
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/stubs.d.ts +0 -1
- package/build/lib/stubs.d.ts.map +1 -1
- package/build/lib/stubs.js +1 -0
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/lib/commands/actions.js +351 -464
- package/lib/commands/alert.js +27 -17
- package/lib/commands/app-management.js +156 -314
- package/lib/commands/context.js +457 -441
- package/lib/commands/element.js +201 -157
- package/lib/commands/emu-console.js +25 -45
- package/lib/commands/execute.js +106 -90
- package/lib/commands/file-actions.js +222 -240
- package/lib/commands/find.ts +103 -0
- package/lib/commands/general.js +327 -339
- package/lib/commands/ime.js +50 -34
- package/lib/commands/{index.js → index.ts} +20 -24
- package/lib/commands/intent.js +108 -249
- package/lib/commands/keyboard.js +20 -8
- package/lib/commands/log.js +172 -116
- package/lib/commands/media-projection.js +134 -161
- package/lib/commands/mixins.ts +966 -0
- package/lib/commands/network.js +252 -281
- package/lib/commands/performance.js +203 -132
- package/lib/commands/permissions.js +108 -109
- package/lib/commands/recordscreen.js +212 -209
- package/lib/commands/shell.js +51 -40
- package/lib/commands/streamscreen.js +355 -289
- package/lib/commands/system-bars.js +92 -83
- package/lib/commands/touch.js +357 -294
- package/lib/commands/types.ts +1097 -0
- package/lib/{desired-caps.js → constraints.ts} +106 -103
- package/lib/{driver.js → driver.ts} +278 -132
- package/lib/helpers/android.ts +1143 -0
- package/lib/helpers/index.ts +6 -0
- package/lib/helpers/types.ts +134 -0
- package/lib/helpers/unlock.ts +329 -0
- package/lib/helpers/webview.ts +582 -0
- package/lib/index.ts +18 -0
- package/lib/method-map.js +87 -98
- package/lib/stubs.ts +0 -1
- package/package.json +26 -19
- package/build/index.js +0 -51
- package/build/lib/android-helpers.d.ts +0 -136
- package/build/lib/android-helpers.d.ts.map +0 -1
- package/build/lib/android-helpers.js +0 -855
- package/build/lib/android-helpers.js.map +0 -1
- package/build/lib/commands/coverage.d.ts +0 -5
- package/build/lib/commands/coverage.d.ts.map +0 -1
- package/build/lib/commands/coverage.js +0 -19
- package/build/lib/commands/coverage.js.map +0 -1
- package/build/lib/desired-caps.d.ts +0 -353
- package/build/lib/desired-caps.d.ts.map +0 -1
- package/build/lib/desired-caps.js.map +0 -1
- package/build/lib/unlock-helpers.d.ts +0 -38
- package/build/lib/unlock-helpers.d.ts.map +0 -1
- package/build/lib/unlock-helpers.js +0 -266
- package/build/lib/unlock-helpers.js.map +0 -1
- package/build/lib/webview-helpers.d.ts +0 -224
- package/build/lib/webview-helpers.d.ts.map +0 -1
- package/build/lib/webview-helpers.js +0 -528
- package/build/lib/webview-helpers.js.map +0 -1
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// @ts-check
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.commands = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const asyncbox_1 = require("asyncbox");
|
|
9
7
|
const support_1 = require("@appium/support");
|
|
10
|
-
const
|
|
8
|
+
const asyncbox_1 = require("asyncbox");
|
|
11
9
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
12
|
-
const
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
13
11
|
const moment_1 = __importDefault(require("moment"));
|
|
14
|
-
const
|
|
15
|
-
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const helpers_1 = require("../helpers");
|
|
14
|
+
const mixins_1 = require("./mixins");
|
|
16
15
|
// https://github.com/appium/io.appium.settings#internal-audio--video-recording
|
|
17
16
|
const DEFAULT_EXT = '.mp4';
|
|
18
17
|
const RECORDING_STARTUP_TIMEOUT_MS = 3 * 1000;
|
|
19
18
|
const RECORDING_STOP_TIMEOUT_MS = 3 * 1000;
|
|
20
19
|
const MIN_API_LEVEL = 29;
|
|
21
|
-
const RECORDING_SERVICE_NAME = `${
|
|
22
|
-
const RECORDING_ACTIVITY_NAME = `${
|
|
23
|
-
const RECORDING_ACTION_START = `${
|
|
24
|
-
const RECORDING_ACTION_STOP = `${
|
|
25
|
-
const RECORDINGS_ROOT = `/storage/emulated/0/Android/data/${
|
|
20
|
+
const RECORDING_SERVICE_NAME = `${helpers_1.SETTINGS_HELPER_PKG_ID}/.recorder.RecorderService`;
|
|
21
|
+
const RECORDING_ACTIVITY_NAME = `${helpers_1.SETTINGS_HELPER_PKG_ID}/io.appium.settings.Settings`;
|
|
22
|
+
const RECORDING_ACTION_START = `${helpers_1.SETTINGS_HELPER_PKG_ID}.recording.ACTION_START`;
|
|
23
|
+
const RECORDING_ACTION_STOP = `${helpers_1.SETTINGS_HELPER_PKG_ID}.recording.ACTION_STOP`;
|
|
24
|
+
const RECORDINGS_ROOT = `/storage/emulated/0/Android/data/${helpers_1.SETTINGS_HELPER_PKG_ID}/files`;
|
|
26
25
|
const DEFAULT_FILENAME_FORMAT = 'YYYY-MM-DDTHH-mm-ss';
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {string} localFile
|
|
29
|
+
* @param {string} [remotePath]
|
|
30
|
+
* @param {import('./types').StopMediaProjectionRecordingOpts} uploadOptions
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
async function uploadRecordedMedia(localFile, remotePath, uploadOptions = {}) {
|
|
28
34
|
if (lodash_1.default.isEmpty(remotePath)) {
|
|
29
35
|
return (await support_1.util.toInMemoryBase64(localFile)).toString();
|
|
30
36
|
}
|
|
31
37
|
const { user, pass, method, headers, fileFieldName, formFields, uploadTimeout: timeout, } = uploadOptions;
|
|
38
|
+
/**
|
|
39
|
+
* @type {Omit<import('./types').StopMediaProjectionRecordingOpts, 'uploadTimeout'> & {auth?: {user: string, pass: string}, timeout?: number}}
|
|
40
|
+
*/
|
|
32
41
|
const options = {
|
|
33
42
|
method: method || 'PUT',
|
|
34
43
|
headers,
|
|
@@ -39,12 +48,21 @@ async function uploadRecordedMedia(localFile, remotePath = null, uploadOptions =
|
|
|
39
48
|
if (user && pass) {
|
|
40
49
|
options.auth = { user, pass };
|
|
41
50
|
}
|
|
42
|
-
await support_1.net.uploadFile(localFile, remotePath, options);
|
|
51
|
+
await support_1.net.uploadFile(localFile, /** @type {string} */ (remotePath), options);
|
|
43
52
|
return '';
|
|
44
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param {string} name
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
45
59
|
function adjustMediaExtension(name) {
|
|
46
60
|
return lodash_1.default.toLower(name).endsWith(DEFAULT_EXT) ? name : `${name}${DEFAULT_EXT}`;
|
|
47
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {ADB} adb
|
|
65
|
+
*/
|
|
48
66
|
async function verifyMediaProjectionRecordingIsSupported(adb) {
|
|
49
67
|
const apiLevel = await adb.getApiLevel();
|
|
50
68
|
if (apiLevel < MIN_API_LEVEL) {
|
|
@@ -53,26 +71,33 @@ async function verifyMediaProjectionRecordingIsSupported(adb) {
|
|
|
53
71
|
}
|
|
54
72
|
}
|
|
55
73
|
class MediaProjectionRecorder {
|
|
74
|
+
/**
|
|
75
|
+
* @param {ADB} adb
|
|
76
|
+
*/
|
|
56
77
|
constructor(adb) {
|
|
57
78
|
this.adb = adb;
|
|
58
79
|
}
|
|
59
80
|
async isRunning() {
|
|
60
81
|
const stdout = await this.adb.shell([
|
|
61
|
-
'dumpsys',
|
|
82
|
+
'dumpsys',
|
|
83
|
+
'activity',
|
|
84
|
+
'services',
|
|
85
|
+
RECORDING_SERVICE_NAME,
|
|
62
86
|
]);
|
|
63
87
|
return stdout.includes(RECORDING_SERVICE_NAME);
|
|
64
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {import('./types').StartMediaProjectionRecordingOpts} opts
|
|
92
|
+
* @returns {Promise<boolean>}
|
|
93
|
+
*/
|
|
65
94
|
async start(opts = {}) {
|
|
66
95
|
if (await this.isRunning()) {
|
|
67
96
|
return false;
|
|
68
97
|
}
|
|
69
98
|
await this.cleanup();
|
|
70
|
-
const { filename, maxDurationSec, priority, resolution
|
|
71
|
-
const args = [
|
|
72
|
-
'am', 'start',
|
|
73
|
-
'-n', RECORDING_ACTIVITY_NAME,
|
|
74
|
-
'-a', RECORDING_ACTION_START,
|
|
75
|
-
];
|
|
99
|
+
const { filename, maxDurationSec, priority, resolution } = opts;
|
|
100
|
+
const args = ['am', 'start', '-n', RECORDING_ACTIVITY_NAME, '-a', RECORDING_ACTION_START];
|
|
76
101
|
if (filename) {
|
|
77
102
|
args.push('--es', 'filename', filename);
|
|
78
103
|
}
|
|
@@ -88,7 +113,7 @@ class MediaProjectionRecorder {
|
|
|
88
113
|
await this.adb.shell(args);
|
|
89
114
|
await new bluebird_1.default((resolve, reject) => {
|
|
90
115
|
setTimeout(async () => {
|
|
91
|
-
if (!await this.isRunning()) {
|
|
116
|
+
if (!(await this.isRunning())) {
|
|
92
117
|
return reject(new Error(`The media projection recording is not running after ${RECORDING_STARTUP_TIMEOUT_MS}ms. ` +
|
|
93
118
|
`Please check the logcat output for more details.`));
|
|
94
119
|
}
|
|
@@ -105,19 +130,22 @@ class MediaProjectionRecorder {
|
|
|
105
130
|
if (lodash_1.default.isEmpty(recordings)) {
|
|
106
131
|
return null;
|
|
107
132
|
}
|
|
108
|
-
const dstPath =
|
|
133
|
+
const dstPath = node_path_1.default.join(await support_1.tempDir.openDir(), recordings[0]);
|
|
109
134
|
// increase timeout to 5 minutes because it might take a while to pull a large video file
|
|
110
135
|
await this.adb.pull(`${RECORDINGS_ROOT}/${recordings[0]}`, dstPath, { timeout: 300000 });
|
|
111
136
|
return dstPath;
|
|
112
137
|
}
|
|
113
138
|
async stop() {
|
|
114
|
-
if (!await this.isRunning()) {
|
|
139
|
+
if (!(await this.isRunning())) {
|
|
115
140
|
return false;
|
|
116
141
|
}
|
|
117
142
|
await this.adb.shell([
|
|
118
|
-
'am',
|
|
119
|
-
'
|
|
120
|
-
'-
|
|
143
|
+
'am',
|
|
144
|
+
'start',
|
|
145
|
+
'-n',
|
|
146
|
+
RECORDING_ACTIVITY_NAME,
|
|
147
|
+
'-a',
|
|
148
|
+
RECORDING_ACTION_STOP,
|
|
121
149
|
]);
|
|
122
150
|
try {
|
|
123
151
|
await (0, asyncbox_1.waitForCondition)(async () => !(await this.isRunning()), {
|
|
@@ -133,121 +161,66 @@ class MediaProjectionRecorder {
|
|
|
133
161
|
}
|
|
134
162
|
}
|
|
135
163
|
/**
|
|
136
|
-
* @
|
|
137
|
-
*
|
|
138
|
-
* @property {string?} resolution Maximum supported resolution on-device (Detected
|
|
139
|
-
* automatically by the app itself), which usually equals to Full HD 1920x1080 on most
|
|
140
|
-
* phones however you can change it to following supported resolutions
|
|
141
|
-
* as well: "1920x1080", "1280x720", "720x480", "320x240", "176x144".
|
|
142
|
-
* @property {number?} maxDurationSec [900] Default value: 900 seconds which means
|
|
143
|
-
* maximum allowed duration is 15 minute, you can increase it if your test takes
|
|
144
|
-
* longer than that.
|
|
145
|
-
* @property {string?} priority [high] Means recording thread priority is maximum
|
|
146
|
-
* however if you face performance drops during testing with recording enabled, you
|
|
147
|
-
* can reduce recording priority to "normal" or "low".
|
|
148
|
-
* @property {string?} filename You can type recording video file name as you want,
|
|
149
|
-
* but recording currently supports only "mp4" format so your filename must end with ".mp4".
|
|
150
|
-
* An invalid file name will fail to start the recording.
|
|
151
|
-
* If not provided then the current timestamp will be used as file name.
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* Record the display of a real devices running Android 10 (API level 29) and higher.
|
|
155
|
-
* The screen activity is recorded to a MPEG-4 file. Audio is also recorded by default
|
|
156
|
-
* (only for apps that allow it in their manifests).
|
|
157
|
-
* If another recording has been already started then the command will exit silently.
|
|
158
|
-
* The previously recorded video file is deleted when a new recording session is started.
|
|
159
|
-
* Recording continues it is stopped explicitly or until the timeout happens.
|
|
160
|
-
*
|
|
161
|
-
* @param {?StartRecordingOptions} options Available options.
|
|
162
|
-
* @returns {boolean} True if a new recording has successfully started.
|
|
163
|
-
* @throws {Error} If recording has failed to start or is not supported on the device under test.
|
|
164
|
-
*/
|
|
165
|
-
commands.mobileStartMediaProjectionRecording = async function mobileStartMediaProjectionRecording(options = {}) {
|
|
166
|
-
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
167
|
-
const { resolution, priority, maxDurationSec, filename } = options;
|
|
168
|
-
const recorder = new MediaProjectionRecorder(this.adb);
|
|
169
|
-
const fname = adjustMediaExtension(filename || (0, moment_1.default)().format(DEFAULT_FILENAME_FORMAT));
|
|
170
|
-
const didStart = await recorder.start({
|
|
171
|
-
resolution,
|
|
172
|
-
priority,
|
|
173
|
-
maxDurationSec,
|
|
174
|
-
filename: fname,
|
|
175
|
-
});
|
|
176
|
-
if (didStart) {
|
|
177
|
-
this.log.info(`A new media projection recording '${fname}' has been successfully started`);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
this.log.info('Another media projection recording is already in progress. There is nothing to start');
|
|
181
|
-
}
|
|
182
|
-
return didStart;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Checks if a media projection-based recording is currently running.
|
|
186
|
-
*
|
|
187
|
-
* @returns {boolean} True if a recording is in progress.
|
|
188
|
-
* @throws {Error} If a recording is not supported on the device under test.
|
|
164
|
+
* @type {import('./mixins').MediaProjectionMixin & ThisType<import('../driver').AndroidDriver>}
|
|
165
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
189
166
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
167
|
+
const MediaProjectionMixin = {
|
|
168
|
+
async mobileStartMediaProjectionRecording(options = {}) {
|
|
169
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
170
|
+
await verifyMediaProjectionRecordingIsSupported(adb);
|
|
171
|
+
const { resolution, priority, maxDurationSec, filename } = options;
|
|
172
|
+
const recorder = new MediaProjectionRecorder(adb);
|
|
173
|
+
const fname = adjustMediaExtension(filename || (0, moment_1.default)().format(DEFAULT_FILENAME_FORMAT));
|
|
174
|
+
const didStart = await recorder.start({
|
|
175
|
+
resolution,
|
|
176
|
+
priority,
|
|
177
|
+
maxDurationSec,
|
|
178
|
+
filename: fname,
|
|
179
|
+
});
|
|
180
|
+
if (didStart) {
|
|
181
|
+
this.log.info(`A new media projection recording '${fname}' has been successfully started`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.log.info('Another media projection recording is already in progress. There is nothing to start');
|
|
185
|
+
}
|
|
186
|
+
return didStart;
|
|
187
|
+
},
|
|
188
|
+
async mobileIsMediaProjectionRecordingRunning() {
|
|
189
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
190
|
+
await verifyMediaProjectionRecordingIsSupported(adb);
|
|
191
|
+
const recorder = new MediaProjectionRecorder(adb);
|
|
192
|
+
return await recorder.isRunning();
|
|
193
|
+
},
|
|
194
|
+
async mobileStopMediaProjectionRecording(options = {}) {
|
|
195
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
196
|
+
await verifyMediaProjectionRecordingIsSupported(adb);
|
|
197
|
+
const recorder = new MediaProjectionRecorder(adb);
|
|
198
|
+
if (await recorder.stop()) {
|
|
199
|
+
this.log.info('Successfully stopped a media projection recording. Pulling the recorded media');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.log.info('Media projection recording is not running. There is nothing to stop');
|
|
203
|
+
}
|
|
204
|
+
const recentRecordingPath = await recorder.pullRecent();
|
|
205
|
+
if (!recentRecordingPath) {
|
|
206
|
+
throw new Error(`No recent media projection recording have been found. Did you start any?`);
|
|
207
|
+
}
|
|
208
|
+
const { remotePath } = options;
|
|
209
|
+
if (lodash_1.default.isEmpty(remotePath)) {
|
|
210
|
+
const { size } = await support_1.fs.stat(recentRecordingPath);
|
|
211
|
+
this.log.debug(`The size of the resulting media projection recording is ${support_1.util.toReadableSizeString(size)}`);
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
return await uploadRecordedMedia(recentRecordingPath, remotePath, options);
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
await support_1.fs.rimraf(node_path_1.default.dirname(recentRecordingPath));
|
|
218
|
+
}
|
|
219
|
+
},
|
|
194
220
|
};
|
|
221
|
+
(0, mixins_1.mixin)(MediaProjectionMixin);
|
|
222
|
+
exports.default = MediaProjectionMixin;
|
|
195
223
|
/**
|
|
196
|
-
* @typedef {
|
|
197
|
-
*
|
|
198
|
-
* @property {string?} remotePath The path to the remote location, where the resulting video should be uploaded.
|
|
199
|
-
* The following protocols are supported: http/https, ftp.
|
|
200
|
-
* Null or empty string value (the default setting) means the content of resulting
|
|
201
|
-
* file should be encoded as Base64 and passed as the endpoont response value.
|
|
202
|
-
* An exception will be thrown if the generated media file is too big to
|
|
203
|
-
* fit into the available process memory.
|
|
204
|
-
* @property {string?} user The name of the user for the remote authentication.
|
|
205
|
-
* @property {string?} pass The password for the remote authentication.
|
|
206
|
-
* @property {string?} method The http multipart upload method name. The 'PUT' one is used by default.
|
|
207
|
-
* @property {Object?} headers Additional headers mapping for multipart http(s) uploads
|
|
208
|
-
* @property {string?} fileFieldName [file] The name of the form field, where the file content BLOB should be stored for
|
|
209
|
-
* http(s) uploads
|
|
210
|
-
* @property {Object|Array<Pair>?} formFields Additional form fields for multipart http(s) uploads
|
|
211
|
-
* @property {number?} uploadTimeout - The actual media upload request timeout in milliseconds;
|
|
212
|
-
* defaults to @appium/support net DEFAULT_TIMEOUT_MS
|
|
213
|
-
*/
|
|
214
|
-
/**
|
|
215
|
-
* Stop a media projection-based recording.
|
|
216
|
-
* If no recording has been started before then an error is thrown.
|
|
217
|
-
* If the recording has been already finished before this API has been called
|
|
218
|
-
* then the most recent recorded file is returned.
|
|
219
|
-
*
|
|
220
|
-
* @param {?StopRecordingOptions} options Available options.
|
|
221
|
-
* @returns {string} Base64-encoded content of the recorded media file if 'remotePath'
|
|
222
|
-
* parameter is falsy or an empty string.
|
|
223
|
-
* @throws {Error} If there was an error while stopping a recording,
|
|
224
|
-
* fetching the content of the remote media file,
|
|
225
|
-
* or if a recording is not supported on the device under test.
|
|
224
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
226
225
|
*/
|
|
227
|
-
commands.mobileStopMediaProjectionRecording = async function mobileStopMediaProjectionRecording(options = {}) {
|
|
228
|
-
await verifyMediaProjectionRecordingIsSupported(this.adb);
|
|
229
|
-
const recorder = new MediaProjectionRecorder(this.adb);
|
|
230
|
-
if (await recorder.stop()) {
|
|
231
|
-
this.log.info('Successfully stopped a media projection recording. Pulling the recorded media');
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
this.log.info('Media projection recording is not running. There is nothing to stop');
|
|
235
|
-
}
|
|
236
|
-
const recentRecordingPath = await recorder.pullRecent();
|
|
237
|
-
if (!recentRecordingPath) {
|
|
238
|
-
throw new Error(`No recent media projection recording have been found. Did you start any?`);
|
|
239
|
-
}
|
|
240
|
-
const { remotePath } = options;
|
|
241
|
-
if (lodash_1.default.isEmpty(remotePath)) {
|
|
242
|
-
const { size } = await support_1.fs.stat(recentRecordingPath);
|
|
243
|
-
this.log.debug(`The size of the resulting media projection recording is ${support_1.util.toReadableSizeString(size)}`);
|
|
244
|
-
}
|
|
245
|
-
try {
|
|
246
|
-
return await uploadRecordedMedia(recentRecordingPath, remotePath, options);
|
|
247
|
-
}
|
|
248
|
-
finally {
|
|
249
|
-
await support_1.fs.rimraf(path_1.default.dirname(recentRecordingPath));
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
exports.default = commands;
|
|
253
226
|
//# sourceMappingURL=media-projection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-projection.js","sourceRoot":"","sources":["../../../lib/commands/media-projection.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media-projection.js","sourceRoot":"","sources":["../../../lib/commands/media-projection.js"],"names":[],"mappings":";AAAA,YAAY;;;;;AAEZ,6CAAuD;AACvD,uCAA0C;AAC1C,wDAAyB;AACzB,oDAAuB;AACvB,oDAA4B;AAC5B,0DAA6B;AAC7B,wCAAkD;AAClD,qCAA+B;AAE/B,+EAA+E;AAC/E,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,4BAA4B,GAAG,CAAC,GAAG,IAAI,CAAC;AAC9C,MAAM,yBAAyB,GAAG,CAAC,GAAG,IAAI,CAAC;AAC3C,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,sBAAsB,GAAG,GAAG,gCAAsB,4BAA4B,CAAC;AACrF,MAAM,uBAAuB,GAAG,GAAG,gCAAsB,8BAA8B,CAAC;AACxF,MAAM,sBAAsB,GAAG,GAAG,gCAAsB,yBAAyB,CAAC;AAClF,MAAM,qBAAqB,GAAG,GAAG,gCAAsB,wBAAwB,CAAC;AAChF,MAAM,eAAe,GAAG,oCAAoC,gCAAsB,QAAQ,CAAC;AAC3F,MAAM,uB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