Commit Graph

853 Commits

Author SHA1 Message Date
Jeremy Goldman
125301d590 Fix flaky JUnit test
This test sometimes fails in PostSubmits because the background
thread which calls the verified class does not have time to execute
before the class is verified.

This creates a helper function to monitor background thread completion.

Test: atest -c AutoSelectPreferenceControllerTest
Change-Id: I6c320abd70fcb5fe823ec122fb0dac67174ecb4a
2020-10-28 05:15:52 +00:00
Jeremy Goldman
1d068385c6 Mock SystemProperties in CDMA JUnit test
Bug: 170608563
Test: atest -c CdmaSubscriptionPreferenceControllerTest
Change-Id: Ibeca5e508d8277a9b84e26829e085c43ce7c26cc
2020-10-27 09:50:42 +00:00
Jeremy Goldman
29c4b84312 Merge "Update JUnit test readme to include atest command." 2020-10-21 04:08:21 +00:00
Jeremy Goldman
ce46d9be6b Update JUnit test readme to include atest command.
Test: N/A
Change-Id: I4c4521ad8077ce120e415afe2907cc26f63e3206
2020-10-21 02:21:54 +00:00
Jeremy Goldman
f9befbb347 Move JUnit tests not from telephony settings into legacy directory.
In order to enable the junit tests as a blocking presubmit, we want
to ensure that all tests within this directory are being actively
maintained. A number of these tests were migrated to robolectric
sometime in 2017-2018, and because they are no longer maintained this CL
moves them into a separate folder, so that they will not be included in
the presubmit.

Please verify that this is the appropriate action to take for these
tests. In the future, the settings team may decide to delete this legacy
directory entirely.

Note that AutoSelectPreferenceControllerTest.setChecked_isChecked_showProgressDialog
is currently failing, but we can fix it in a separate CL.

Test: make SettingsUnitTests && adb install -r out/target/product/shamu/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk
Change-Id: Iafc15b9ac69b5ca2fec76d3c0c7e247ea0017d49
2020-10-20 10:21:41 +00:00
Jeremy Goldman
6e6d785c06 JUnit readme displays updated apk file location
Test: N/A
Change-Id: I265319c726b5b5ca3e8273be0be61e1b9063e7d6
2020-10-19 10:16:38 +00:00
Jeff DeCew
03ebcc2474 Merge "Update NotificationChannelSettings Preferences in place to prevent re-layout." into rvc-qpr-dev am: e9523b7636
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12792910

Change-Id: I55f6310b344baebfe6a4425d3644d22d8e479638
2020-10-14 14:41:46 +00:00
Jeff DeCew
5bfe1d3f9c Update NotificationChannelSettings Preferences in place to prevent re-layout.
(cherry picked from commit b409b64045)

Fixes: 110093185
Test: ChannelListPreferenceControllerTest
Change-Id: If6acf305c44085e502a3304ea57e409ce049b40f
Merged-In: If6acf305c44085e502a3304ea57e409ce049b40f
2020-10-12 20:06:48 -04:00
Hall Liu
9d39cc3d63 Merge "Replace TelephonyManager methods for mobile data" 2020-10-09 17:03:16 +00:00
Hall Liu
d67a1c3d8e Replace TelephonyManager methods for mobile data
TelephonyManager had a minor refactor of some of the methods revolving
around mobile data. Change code in Settings to use the new ones instead.

Bug: 169367013
Test: existing unit tests, manual
Change-Id: I7ebae37373d53fb2c59b6b546232dbddf77398d4
2020-10-08 19:37:57 -07:00
Arc Wang
63e015962c [Settings] Remove failure JUnit test cases
This change removes all the files which have any failure JUnit test case.

Bug: 168429329
Test: atest --test-mapping tests/unit:postsubmit
Change-Id: I1665565760f9dfc185bf9b8dd871ee106eba5dd5
2020-10-07 21:26:09 +08:00
Alexander Dorokhine
6decca7890 Migrate away from deprecated Truth APIs.
This is a transitional step towards truth 1.0.1, where these APIs have
been completely removed.

Bug: 168765701
Test: m checkbuild
Merged-In: I76f9c37cb699ce6ab8715ffe35d11668ccbceea1
Change-Id: I76f9c37cb699ce6ab8715ffe35d11668ccbceea1
(cherry picked from commit 46e85a2fad)
2020-10-06 00:25:04 -07:00
Alexander Dorokhine
7aadf2da70 Merge "Migrate away from deprecated Truth APIs." 2020-10-06 07:06:00 +00:00
Tom Hsu
272c21911d Merge "[Settings] Refractor ApnSettings code to independent package folder." 2020-10-06 03:30:10 +00:00
tom hsu
2fd7c9ffd1 [Settings] Refractor ApnSettings code to independent package folder.
Bug: 169750507
Test: make RunSettingsRoboTests
Change-Id: I8b2709ba8d16c625863d8a17abc3d0ab5d019bb8
2020-09-30 15:56:01 +00:00
Betty Chang
e8fa746299 Merge "[Testing] Use AndroidJUnit4 instead in CellDataPreferenceTest" 2020-09-30 06:12:31 +00:00
Treehugger Robot
93cec35cea Merge "[Testing] Use AndroidJUnit4 instead in TelephonyBasePreferenceControllerTest" 2020-09-29 04:33:23 +00:00
Treehugger Robot
27806fde5e Merge "[Testing] use AndroidJUnit4 in new MobileDataPreferenceControllerTest" 2020-09-29 04:30:56 +00:00
Treehugger Robot
1cd8904fc5 Merge "[Testing] use AndroidJUnit4 in new EuiccPreferenceControllerTest" 2020-09-29 04:29:55 +00:00
Treehugger Robot
3eeb8b44c2 Merge "[Testing] use AndroidJUnit4 in new MultiNetworkHeaderControllerTest" 2020-09-29 04:28:34 +00:00
Treehugger Robot
71c667322c Merge "[Testing] Use AndroidJUnit4 instead in TelephonyTogglePreferenceControllerTest" 2020-09-29 04:27:45 +00:00
Betty Chang
40bc88e8ab Merge "[Testing] Use AndroidJUnit4 instead in telephony/cdma/ test files" 2020-09-29 01:56:14 +00:00
Alexander Dorokhine
46e85a2fad Migrate away from deprecated Truth APIs.
This is a transitional step towards truth 1.0.1, where these APIs have
been completely removed.

Bug: 168765701
Test: m checkbuild
Change-Id: I76f9c37cb699ce6ab8715ffe35d11668ccbceea1
2020-09-24 23:09:41 +00:00
Jeremy Goldman
6620c84d89 create junit MobileNetworkPreferenceControllerTest.
1. androidx lifecycle used rather than settingslib wrapper. This allows
us to handle lifecycle events from junit tests as well.
2. Use Mocks or get/set functions rather than robolectric shadows.

MobileNetworkPreferenceControllerTest Diff:
    https://diff.googleplex.com/#key=5P0b2G4iYmcz
Test: atest -c MobileNetworkPreferenceControllerTest
Change-Id: If49fe64e5db89a0cdcac7d26329b8c18626a00de
2020-09-23 17:26:14 +00:00
changbetty
c707b90d0a [Testing] Use AndroidJUnit4 instead in telephony/cdma/ test files
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Use ApplicationProvider instead of RuntimeEnvironment to get context
3. Change Copy Right
4. To get the original value and add @After to restore the data

Bug:
Test: atest -c CdmaListPreferenceTest
      atest -c CdmaSubscriptionPreferenceControllerTest
      atest -c CdmaSystemSelectPreferenceControllerTest
Change-Id: I110727b643a6755ee888708bd1fb2a39cf524a2d
2020-09-23 17:46:30 +08:00
changbetty
9e78b620d3 [Testing] Use AndroidJUnit4 instead in CellDataPreferenceTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Use ApplicationProvider instead of RuntimeEnvironment to get context
3. Change Copy Right
4. Remove the PreferenceViewHolder that not used in test
5. Remove the ProxySubscriptionManager that can get the real object by
context

Bug: 168767478
Test: atest -c CellDataPreferenceTest
Change-Id: I1fa5747c8c6d224d6b13f1a693ff88e57fd150d3
2020-09-23 16:30:59 +08:00
Jeremy Goldman
37cfec7ac2 Merge "[Testing] AndroidJunit Enhanced4gLteSliceHelperTest" 2020-09-21 03:46:18 +00:00
Jeremy
1885f027d8 [Testing] AndroidJunit Enhanced4gLteSliceHelperTest
Test: atest -c Enhanced4gLteSliceHelperTest
Change-Id: I548ffe60f00cea76d0c4af33ca4ec6f38cbf6247
2020-09-18 15:30:41 -04:00
Jeremy Goldman
d620baa3d7 Merge "[Testing] AndroidJUnit4 NetworkSelectSettingsTest" 2020-09-17 18:58:36 +00:00
Jeremy Goldman
7cb2738fdb [Testing] AndroidJUnit4 NetworkSelectSettingsTest
Test: atest -c NetworkSelectSettingsTest
Change-Id: I1d842cd522df87d1cc762b50ae43e9efc723b154
2020-09-17 16:08:33 +00:00
Jeremy Goldman
953ed3dcd2 Merge "[Testing] AndroidJUnit4 RoamingPreferenceControllerTest" 2020-09-16 00:48:31 +00:00
Jeremy Goldman
b1f8405a83 [Testing] AndroidJUnit4 RoamingPreferenceControllerTest
Test: atest -c RoamingPreferenceControllerTest
Change-Id: I155b1c36381b65d23ca1745e72a6f8388f6909e3
2020-09-15 19:53:54 +00:00
Betty Chang
195aa70291 Merge "[Testing] Use AndroidJUnit4 instead in DataUsageInfoControllerTest" 2020-09-15 06:17:53 +00:00
changbetty
8de635ea7b [Testing] Remove Robolectric import and use AndroidJUnit4 instead in MobileDataEnabledListenerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Use ApplicationProvider instead of RuntimeEnvironment to get context

Bug: 162048313
Test: atest -c MobileDataEnabledListenerTest
Merged-In: I81b3d6ac075666a45649c8d811832a40bdb1b41b
Change-Id: I34687eb69ef62cd3b6ea6519cee608a7b95f242b
2020-09-15 12:24:10 +08:00
changbetty
5c46c0f881 [Testing] Use AndroidJUnit4 instead in TelephonyTogglePreferenceControllerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Use ApplicationProvider instead of RuntimeEnvironment to get context
3. Change the Copy Right

Bug: 164986958
Test: atest -c TelephonyTogglePreferenceControllerTest
Merged-In: I3d6c39f45cb1efb1742148f20f03372214eb0cbe
Change-Id: Ie7343f8c6dd45add2832679d95372e750ce350ce
2020-09-15 12:20:10 +08:00
changbetty
2817fa8e44 [Testing] Use AndroidJUnit4 instead in TelephonyBasePreferenceControllerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Use ApplicationProvider instead of RuntimeEnvironment to get context
3. Change Copy Right

Bug: 164986221
Test: atest -c TelephonyBasePreferenceControllerTest
Merged-In: Iabe24aef0b7a5c3aa9d7be275f0c4ed552cdd2e8
Change-Id: I96e99506b534dbe7fc9e66739295e09fc543663f
2020-09-15 12:12:31 +08:00
Jeremy Goldman
0c48f53cfe [Testing] use AndroidJUnit4 in new EuiccPreferenceControllerTest
Test: atest -c EuiccPreferenceControllerTest
Merged-In: I028ca81d38252beb3abccef9e938988510f3f55e
Change-Id: I5fcd2f3e9d2e845ec9e1e2693c10330e4292fb7a
2020-09-15 12:05:44 +08:00
Betty Chang
090f32f03d Merge "[Testing] Use AndroidJUnit4 instead in CarrierSettingsVersionPreferenceControllerTest" 2020-09-15 02:37:19 +00:00
Jeremy Goldman
ca5aa8786d [Testing] use AndroidJUnit4 in new MobileDataPreferenceControllerTest
Diff: https://diff.googleplex.com/#key=OYsSkuGzJNkP
Test: atest -c MobileDataPreferenceControllerTest
Merged-In: I1a2d7b38023681f3db3320aa9f315109280cfbd0
Change-Id: Ica6625bb924ad0e813b4f9cdca62b0126b63214e
2020-09-15 10:36:14 +08:00
Jeremy Goldman
d713cc6873 [Testing] use AndroidJUnit4 in new MultiNetworkHeaderControllerTest
1. Rather than mocking the PreferenceScreen, create an instance via
PreferenceManager. Rather than stubbing PreferenceScreen functions to
return the PreferenceCategory mock, the mock is inserted using public
functions.
2. PreferenceCategory active state is checked rather than verifying the
arguments of function calls.
3. mHeaderController test superclass overrides functions which use the
Lifecycle, because doReturn+when on Spy objects has undesired side
effects.
4. Looper message queue prepared for the PreferenceScreen.

Bug: 168130550
Diff: https://diff.googleplex.com/#key=w7a7L3seOowE
Test: atest -c MultiNetworkHeaderControllerTest
Merged-In: Ic66425aca4047d2eacd04509f3bfb315f6dd57fc
Change-Id: I07925cfbb05636bdf7f0efe1811405a01dcf6523
2020-09-15 10:34:24 +08:00
changbetty
3644df3a9e [Testing] Use AndroidJUnit4 instead in DataUsageInfoControllerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Use ApplicationProvider instead of RuntimeEnvironment to get context
3. Change Copy Right
4. Rename the test case for apply the naming rule

Bug: 167948471
Test: atest -c DataUsageInfoControllerTest
Change-Id: Id8591f77d6ab2840223501962ae19eaa2749f326
2020-09-14 18:31:43 +08:00
Jeremy Goldman
1f718138e5 Merge "[Testing] use AndroidJUnit4 in new MultiNetworkHeaderControllerTest" 2020-09-11 17:38:52 +00:00
Jeremy Goldman
9b8efdbe4c Merge "[Testing] use AndroidJUnit4 in new MobileDataPreferenceControllerTest" 2020-09-11 17:38:18 +00:00
Betty Chang
b5cc1860f3 Merge "[Testing] Use AndroidJUnit4 instead in MmsMessagePreferenceControllerTest" 2020-09-11 09:50:06 +00:00
changbetty
018ab8e800 [Testing] Use AndroidJUnit4 instead in CarrierSettingsVersionPreferenceControllerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Change the Copy Right
3. Remove the shadowCarrierConfigManager to mock the
CarrierConfigManager

Bug: 168281601
Test: atest -c CarrierSettingsVersionPreferenceControllerTest
Change-Id: Id14d103a82d2d2954721624ed7a16204ee0f25b6
2020-09-11 08:45:03 +00:00
Betty Chang
4c8756704c Merge "[Testing] Use AndroidJUnit4 instead in AppPrefLoaderTest" 2020-09-11 08:38:59 +00:00
changbetty
866f40b2f6 [Testing] Use AndroidJUnit4 instead in MmsMessagePreferenceControllerTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Change the Copy Right
3. Remove the ShadowSubscriptionManager

Bug: 168278301
Test: atest -c MmsMessagePreferenceControllerTest
Change-Id: Ie2e9c99f9899d422fde41fcd6cf4a918bc0eaf98
2020-09-11 14:52:28 +08:00
changbetty
5a22464bfa [Testing] Use AndroidJUnit4 instead in AppPrefLoaderTest
1. Use AndroidJunit4 instead of RobolectricTestRunner
2. Change the Copy Right

Bug: 168277399
Test: atest -c AppPrefLoaderTest
Change-Id: If4c79ae1831bd531c7e4f0a068f06a592418d7fe
2020-09-11 06:36:54 +00:00
Jeremy Goldman
a1aaccf670 [Testing] use AndroidJUnit4 in new MultiNetworkHeaderControllerTest
1. Rather than mocking the PreferenceScreen, create an instance via
PreferenceManager. Rather than stubbing PreferenceScreen functions to
return the PreferenceCategory mock, the mock is inserted using public
functions.
2. PreferenceCategory active state is checked rather than verifying the
arguments of function calls.
3. mHeaderController test superclass overrides functions which use the
Lifecycle, because doReturn+when on Spy objects has undesired side
effects.
4. Looper message queue prepared for the PreferenceScreen.

Bug: 168130550
Diff: https://diff.googleplex.com/#key=w7a7L3seOowE
Test: atest -c MultiNetworkHeaderControllerTest
Change-Id: Ic66425aca4047d2eacd04509f3bfb315f6dd57fc
2020-09-10 20:10:22 +00:00
Jeremy Goldman
4126ec2d32 [Testing] use AndroidJUnit4 in new EuiccPreferenceControllerTest
Test: atest -c EuiccPreferenceControllerTest
Change-Id: I028ca81d38252beb3abccef9e938988510f3f55e
2020-09-10 15:19:01 +00:00