Enable Safety Center & Security unit tests on presubmit.
See b/323650746 and b/323649900 for issues that should’ve been caught by pre-submit.
Bug: 323649900
Bug: 323650746
Change-Id: I77d664b6fce6a3f76a4c9a6b39202f6e9d47da33
Test: atest SettingsUnitTests
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 9722a85..fd6bcbf 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -7,13 +7,19 @@
"name": "SettingsUnitTests",
"options": [
{
- "include-filter": "com.android.settings.password"
- },
- {
"include-filter": "com.android.settings.biometrics"
},
{
"include-filter": "com.android.settings.biometrics2"
+ },
+ {
+ "include-filter": "com.android.settings.password"
+ },
+ {
+ "include-filter": "com.android.settings.safetycenter"
+ },
+ {
+ "include-filter": "com.android.settings.security"
}
]
}
diff --git a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
index bf2c84a..6c4c5b4 100644
--- a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -101,18 +101,20 @@
public FastPairFeatureProvider mFastPairFeatureProvider;
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
- /**
- * Call this in {@code @Before} method of the test class to use fake factory.
- */
+ /** Call this in {@code @Before} method of the test class to use fake factory. */
public static FakeFeatureFactory setupForTest() {
FakeFeatureFactory factory = new FakeFeatureFactory();
- setFactory(getAppContext(), factory);
+ try {
+ setFactory(getAppContext(), factory);
+ } catch (NoSuchMethodError ex) {
+ // The getAppContext() @JvmStatic method doesn't appear to generated in AOSP. Falling
+ // back to using the companion object method instead.
+ setFactory(FeatureFactory.Companion.getAppContext(), factory);
+ }
return factory;
}
- /**
- * FeatureFactory constructor.
- */
+ /** FeatureFactory constructor. */
public FakeFeatureFactory() {
supportFeatureProvider = mock(SupportFeatureProvider.class);
metricsFeatureProvider = mock(MetricsFeatureProvider.class);