Skip to content

Commit

Permalink
feat: Add mobile: startActivity extension (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
skmurug authored Jul 28, 2022
1 parent 5bd6212 commit baad328
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,19 @@ Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
remotePath | string | yes | The full path to the remote file or a file inside an application bundle | `/sdcard/myfile.txt` or `@my.app.id/path/in/bundle`

### mobile: startActivity

Starts the given activity with intent options, activity options and locale. Activity could only be executed in scope of the current app package.

#### Arguments

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
appActivity | string | yes | Applicaiton acitivity identifier to start | `com.myapp.myacitivty`
locale | object | no | Sets the locale for the app under test. It only uses public APIs for its purpose. See https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers to get the list of available language abbreviations. | `{"language": "zh", "country": "CN", "variant": "Hans"}`
optionalIntentArguments | object | no | The mapping of custom options for the intent that is going to be passed to the main app activity. Check [Intent Options](#intent-options) for more details. | `{ 'flags': 'ACTIVITY_NEW_TASK', 'action': '<intent_action>', 'className': '<fullyQualifiedAppActivity>', 'es': {'foo': 'bar'} }`
optionalActivityArguments | object | no | The mapping of custom options for the main app activity that is going to be started. Check [Activity Options](#activity-options) for more details. | `{ 'launchDisplayId': 1 }`

### mobile: startService

Starts the given service intent.
Expand Down
2 changes: 2 additions & 0 deletions lib/commands/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ extensions.executeMobile = async function executeMobile (mobileCommand, opts = {

deleteFile: 'mobileDeleteFile',

startActivity: 'mobileStartActivity',

startService: 'mobileStartService',
stopService: 'mobileStopService',

Expand Down
25 changes: 25 additions & 0 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,31 @@ helpers.suspendChromedriverProxy = function suspendChromedriverProxy () {
this.jwpProxyActive = true;
};

/**
* Starts the given activity with intent options, activity options and locale.
* Activity could only be executed in scope of the current app package.
*
* appActivity is mandatory
*
* locale, optionalIntentArguments, optionalActivityArguments are optional
*/
commands.mobileStartActivity = async function mobileStartActivity (opts = {}) {
const appPackage = this.caps.appPackage;
const {
appActivity,
locale,
optionalIntentArguments,
optionalActivityArguments
} = assertRequiredOptions(opts, ['appActivity']);
return await this.espresso.jwproxy.command(`/appium/device/start_activity`, 'POST', {
appPackage,
appActivity,
locale,
optionalIntentArguments,
optionalActivityArguments
});
};

commands.startActivity = async function startActivity (appPackage, appActivity,
appWaitPackage, appWaitActivity) {
// intentAction, intentCategory, intentFlags, optionalIntentArguments, dontStopAppOnReset
Expand Down

0 comments on commit baad328

Please sign in to comment.