Skip to content

Commit a6424cc

Browse files
authored
fix: add backgroundApp (#988)
* fix: add backgroundApp * modify default arg * remove extra new line * remove debuug deps
1 parent ab0404c commit a6424cc

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/commands/app-management.js

+13
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,19 @@ export async function background(seconds) {
345345
return await this.adb.startApp(args);
346346
}
347347

348+
/**
349+
* Puts the app to background and waits the given number of seconds then restores the app
350+
* if necessary. The call is blocking.
351+
*
352+
* @this {AndroidDriver}
353+
* @param {number} [seconds=-1] The amount of seconds to wait between putting the app to background and restoring it.
354+
* Any negative value means to not restore the app after putting it to background.
355+
* @returns {Promise<void>}
356+
*/
357+
export async function mobileBackgroundApp (seconds = -1) {
358+
await this.background(seconds);
359+
}
360+
348361
/**
349362
* @this {AndroidDriver}
350363
* @param {import('../driver').AndroidDriverOpts?} [opts=null]

lib/driver.ts

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import {
7171
installAUT,
7272
resetAUT,
7373
background,
74+
mobileBackgroundApp,
7475
getCurrentActivity,
7576
getCurrentPackage,
7677
mobileClearApp,
@@ -413,6 +414,7 @@ class AndroidDriver
413414
activateApp = activateApp;
414415
queryAppState = queryAppState;
415416
isAppInstalled = isAppInstalled;
417+
mobileBackgroundApp = mobileBackgroundApp;
416418

417419
mobileGetUiMode = mobileGetUiMode;
418420
mobileSetUiMode = mobileSetUiMode;

lib/execute-method-map.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ export const executeMethodMap = {
174174
required: ['appId'],
175175
},
176176
},
177-
177+
'mobile: backgroundApp': {
178+
command: 'mobileBackgroundApp',
179+
params: {
180+
optional: ['seconds'],
181+
}
182+
},
178183
'mobile: startService': {
179184
command: 'mobileStartService',
180185
params: {

0 commit comments

Comments
 (0)