Rather than mocking the PreferenceScreen's getPreference function, a PreferenceManager has been created, which instantiates the Screen. The desired Preference is added to the Screen with the testing key. Rather than using a shadow XML, contexts' resources are mocked. A mock WifiManager is used instead of a shadow Duplicate test case removed, and test which succeeds locally but not on cuttlefish marked as ignored for now. Bug: 175389659 Test: atest -c DeviceNamePreferenceControllerTest Change-Id: I643b22993a1d102614fed1883af7f4925947be20
Running Settings Robolectric tests
The full suite
$ croot
$ make RunSettingsRoboTests
Running a single test class
$ croot
$ make RunSettingsRoboTests ROBOTEST_FILTER=<ClassName>
For example:
make RunSettingsRoboTests ROBOTEST_FILTER=CodeInspectionTest
You can also use partial class name in ROBOTEST_FILTER. If the partial class name matches multiple file names, all of them will be executed.