Files
app_Settings/tests/unit
Chun-Ku Lin a1fe1ef36e Change the settings value and wait for it to propagate.
**Root cause**
Two reasons of the flaky test:
- Settings value not reset to default after tests
- Need time for the settings value changes to propagate to its listeners

Other clean up: When creating a preference, by default it will store
values in the shared preferences. If we don't intent to save the
preference to the sharedPreferences, we should set presistent as false.

Bug: 279818352
Test: atest
SettingsUnitTests:com.android.settings.accessibility.DisableAnimationsPreferenceControllerTest#onStart_disabledAnimation_shouldReturnTrue
--iterations 50

Change-Id: Ie645f8e847fc8ce188a7e5ed45bf5050f81e1d9a
2023-05-15 19:45:24 +00:00
..
2022-01-27 08:46:18 +00:00

The simplest way to run all SettingsUnitTests is with atest
$ atest SettingsUnitTests

A single class can also be tested with the following command
$ atest -c <YourClassName>

// The following instructions show how to run the test suite using make + adb //

To build the tests you can use the following command at the root of your android source tree
$ make -j SettingsUnitTests

The test apk then needs to be installed onto your test device. The apk's location will vary
depending on your device model and architecture. At the end of the make command's output, there
should be a line similar to the following:
"Copy: ${ANDROID_PRODUCT_OUT}/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk"
Install via the following command:
$ adb install -r ${ANDROID_PRODUCT_OUT}/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk

To run all tests:
$ adb shell am instrument -w com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner

To run all tests in a specific class:
$ adb shell am instrument -w -e class com.android.settings.<class> com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner

To run a specific test:
$ adb shell am instrument -w -e class com.android.settings.<class>#<test> com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner

More general information can be found at
http://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html