-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a helper method to simulate low-memory event
- Loading branch information
1 parent
6498a6f
commit 3cf9cc5
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {errors} from 'appium/driver'; | ||
import {mixin} from './mixins'; | ||
|
||
/** | ||
* @type {import('./mixins').MemoryMixin & ThisType<import('../driver').AndroidDriver>} | ||
* @satisfies {import('@appium/types').ExternalDriver} | ||
*/ | ||
const MemoryMixin = { | ||
/** | ||
* Simulates the onTrimMemory() event for the given package. | ||
* Read https://developer.android.com/topic/performance/memory | ||
* for more details. | ||
* | ||
* @param {import('./types').SendTrimMemoryOpts} opts | ||
*/ | ||
async mobileSendTrimMemory(opts) { | ||
const { | ||
pkg, | ||
level, | ||
} = opts; | ||
|
||
if (!pkg) { | ||
throw new errors.InvalidArgumentError(`The 'pkg' argument must be provided`); | ||
} | ||
if (!level) { | ||
throw new errors.InvalidArgumentError(`The 'level' argument must be provided`); | ||
} | ||
|
||
await this.adb.shell(['am', 'send-trim-memory', pkg, level]); | ||
}, | ||
}; | ||
|
||
mixin(MemoryMixin); | ||
|
||
export default MemoryMixin; | ||
|
||
/** | ||
* @typedef {import('appium-adb').ADB} ADB | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters