Files
app_Settings/tests/unit
Chun-Ku Lin 24b045c987 Move DisplayDataSizeTest to AndroidJunitTest
**Root cause**
- When DisplayDataSizeTest was created, it was ignored already due to
b/214161063. That means the test never passed in the beginning.

- The default display's type in Robolectric is TYPE_UNKNOWN. However, in
the constructor of DisplayDensityUtils, we check all the display that is
not TYPE_INTERNAL can't be a default display. Hence the test failed.

- Even if we shadow the DisplayInfo to have TYPE_INTERNAL for default
  display, the test still failed, because whenever we tried to get the
  default display density we always get 0, and doens't have other diplay
  density values. Hence we can't test increasing the display size in
  Robolectric Test.

Note: the solution here is a workaround for waiting AsyncTask to finish.
If we ever change the implementation in DisplayDensityUtils to not use
AsyncTask, we'll need to update the test.

Bug: 279082331
Test: atest DisplaySizeDataTest --iterations 20

Change-Id: I3ccee5e7ba4d9399a8b715d84a9d53e106f88762
2023-06-07 00:06:48 +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