-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add mobile: wrappers to clipboard APIs (#1018)
- Loading branch information
1 parent
a336476
commit 13beafb
Showing
5 changed files
with
69 additions
and
10 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
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,41 @@ | ||
/** | ||
* @this {import('../driver').EspressoDriver} | ||
* @returns {Promise<string>} Base64-encoded content of the clipboard | ||
* or an empty string if the clipboard is empty. | ||
*/ | ||
export async function getClipboard () { | ||
return /** @type {string} */ ((await this.adb.getApiLevel() < 29) | ||
? (await this.espresso.jwproxy.command('/appium/device/get_clipboard', 'POST', {})) | ||
: (await this.settingsApp.getClipboard())); | ||
} | ||
|
||
/** | ||
* @typedef {Object} SetClipboardOptions | ||
* @property {string} content Base64-encoded clipboard payload | ||
* @property {'plaintext'} [contentType] Only a single | ||
* content type is supported, which is 'plaintext' | ||
* @property {string} [label] Optinal label to identify the current | ||
* clipboard payload | ||
*/ | ||
|
||
/** | ||
* @this {EspressoDriver} | ||
* @param {SetClipboardOptions} opts | ||
* @returns {Promise<void>} | ||
*/ | ||
export async function mobileSetClipboard(opts) { | ||
const { | ||
content, | ||
contentType, | ||
label, | ||
} = opts; | ||
await this.espresso.jwproxy.command( | ||
'/appium/device/set_clipboard', | ||
'POST', | ||
{content, contentType, label} | ||
); | ||
} | ||
|
||
/** | ||
* @typedef {import('../driver').EspressoDriver} EspressoDriver | ||
*/ |
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
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