Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added KillApp command to reproduce System-initiated Process Death on Android #1727

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

galex
Copy link
Contributor

@galex galex commented Apr 25, 2024

Proposed Changes

This PR allows to test a screen against what is called a System-initiated Process Death which is something very specific to the Android platform, but gives a very strong proposal value to Maestro for Android developers 👍

Currently, only stopApp is available as a command to try to reproduce it but it fails to as it uses the force-stop adb command:

adb shell am force-stop <package name>

To trigger System-initiated Process Death properly, Android developers need to be able to call the kill command on adb:

adb shell am kill <package name>

I suggest doing so by adding a killApp command:

appId: com.example.app
---
- killApp

Different behaviors per platform:

  • Android: Calls adb shell am kill under the hood
  • iOS: Calls stopApp (synonym command) as there is no such thing as a Process Death on iOS
  • Web: Calls stopApp (synonym command) as there is no such thing as a Process Death on Web

Using this new command, an Android developer can really test for this use case by doing the following:

appId: com.example.app
---
# Puts the app into the background
- pressKey: Home
# Kills the app (adb shell am kill) 
- killApp
# Relaunches the app
- launchApp:
    stopApp: false # Without adb shell am force-stop

A test to detect the Process Death issue can be found there and running it does manage to detect the issue properly:

Screenshot from 2024-04-25 17-32-54

Testing

Let me know what you think or if something missing! 😊
Thank you 🙏

@axelniklasson axelniklasson added external-contribution platform: android Testing Android apps is affected enhancement New feature request or improvement of an existing feature labels May 20, 2024
@amanjeetsingh150 amanjeetsingh150 merged commit fc17954 into mobile-dev-inc:main Jun 3, 2024
1 check passed
@galex galex deleted the add-killapp-command branch June 7, 2024 08:32
@amanjeetsingh150
Copy link
Collaborator

@galex can you help raising PR on maestro-docs. For adding docs around what this solves and usage?

https://github.com/mobile-dev-inc/maestro-docs

@galex
Copy link
Contributor Author

galex commented Jun 7, 2024

@amanjeetsingh150 Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request or improvement of an existing feature platform: android Testing Android apps is affected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants