Awesome
DroidTestHelper
Helper application to test android applications. This application handle some settings via adb broadcast. So, you can handle some settings via adb broadcast.
Some features are similar to https://github.com/linkedin/test-butler published by LinkedIn.
Feature
- Remove particular account from AccountManager via
adb
broadcast.- You can remove application local data via
adb shell am clear your.package.name
. - But if your application support account manager, the command can't remove the data.
- You can remove application local data via
- Change language/country setting via some adb commands
- Change animation scale
- Clear data
How to use
-
- Git clone this repository, build and install this apk into your target device.
- run the apk once
$ adb shell am start -n com.kazucocoa.droidtesthelper/.MainActivity
remove account from account manager
-
- Execute the following command. ( Should replace
your.target.account.type
to fit your application. )
$ adb shell am broadcast -a 'DroidTestHelper' --es ACCOUNT_TYPE your.target.account.type
- Managing account only for API level 22 and lower.
- If you clone this repository and build apk with the same signature for your test target apk, you can manage the account without permissions.
- Execute the following command. ( Should replace
change locale
-
- Execute the following command to allow permission.
$ adb shell pm grant com.kazucocoa.droidtesthelper android.permission.CHANGE_CONFIGURATION
-
- Set
ja_JP
$ adb shell am broadcast -a 'DroidTestHelper' --es LANG ja --es COUNTRY JP
- Set
reference
- https://developer.android.com/reference/java/util/Locale.html
- http://stackoverflow.com/questions/7973023/what-is-the-list-of-supported-languages-locales-on-android
Change animations
-
- Execute the following command to allow permission.
$ adb shell pm grant com.kazucocoa.droidtesthelper android.permission.SET_ANIMATION_SCALE
$ adb shell pm grant com.kazucocoa.droidtesthelper android.permission.WRITE_SECURE_SETTINGS
-
- enable/disable animation scale 1.0f
- enable
$ adb shell am broadcast -a 'DroidTestHelper' --ez ANIMATION true
- disable
$ adb shell am broadcast -a 'DroidTestHelper' --ez ANIMATION false
Clear Data
-
- clear data (Requires API level 21+)
$ adb shell am broadcast -a 'DroidTestHelper' --es CLEAR_DATA com.example
DroidTestHelperLib
- HandleAccountHelper
- HandleAnimations
- HandleLocale
- HandlePermission
- HandleClearData
Embedded DroidTestHelperLib into your library
from Jitpack
dependencies {
compile 'com.github.KazuCocoa:DroidTestHelper:0.3.0'
}
Need Permissions to enable the above handler in AndroidManifest.xml
<uses-permission android:name="android.permission.GET_ACCOUNTS" android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<!-- to grant permission -->
<uses-permission android:name="android.permission.GRANT_REVOKE_PERMISSIONS"/>
<uses-permission
android:name="android.permission.MANAGE_ACCOUNTS"
android:maxSdkVersion="22" />
Implementations
A package com.kazucocoa.droidtesthelper
is example to use com.kazucocoa.droidtesthelperlib
.
Note for Android P
-
Android P has
Restrictions on non-SDK interfaces
feature. -
java.lang.NoSuchMethodException: setAnimationScales [class [F]
happen when we callsetAnimationScales
in animation handler -
To available the interface, we need below adb commands
adb shell settings put global hidden_api_policy_pre_p_apps 1 adb shell settings put global hidden_api_policy_p_apps 1
-
To disable again, we need below adb commands
adb shell settings delete global hidden_api_policy_pre_p_apps adb shell settings delete global hidden_api_policy_p_apps
load map
I will add additional feature if I need.
LICENSE
MIT