Skip one SlicePurchaseControllerTest test on auto when flaky
Bug: 401032628
Test: com.android.phone.slice.SlicePurchaseControllerTest#testPurchasePremiumCapabilityResultNotDefaultDataSubscription
Flag: TEST_ONLY
Change-Id: I4970cdf11526b893248dc38115ff5d2e4ab5051c
diff --git a/tests/src/com/android/phone/slice/SlicePurchaseControllerTest.java b/tests/src/com/android/phone/slice/SlicePurchaseControllerTest.java
index 5637c3a..a792780 100644
--- a/tests/src/com/android/phone/slice/SlicePurchaseControllerTest.java
+++ b/tests/src/com/android/phone/slice/SlicePurchaseControllerTest.java
@@ -21,6 +21,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
@@ -40,6 +41,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.HandlerThread;
@@ -56,6 +58,7 @@
import android.telephony.data.UrspRule;
import android.testing.TestableLooper;
+import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.TelephonyTestBase;
@@ -335,6 +338,12 @@
mSlicePurchaseController.purchasePremiumCapability(
TelephonyManager.PREMIUM_CAPABILITY_PRIORITIZE_LATENCY, mHandler.obtainMessage());
mTestableLooper.processAllMessages();
+ if (isAutomotive()) {
+ // TODO(b/401032628): this test is flaky here
+ assumeTrue(
+ TelephonyManager.PURCHASE_PREMIUM_CAPABILITY_RESULT_NETWORK_NOT_AVAILABLE
+ != mResult);
+ }
assertEquals(
TelephonyManager.PURCHASE_PREMIUM_CAPABILITY_RESULT_NOT_DEFAULT_DATA_SUBSCRIPTION,
mResult);
@@ -350,6 +359,11 @@
mResult);
}
+ private boolean isAutomotive() {
+ return InstrumentationRegistry.getTargetContext().getPackageManager()
+ .hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
+ }
+
@Test
public void testPurchasePremiumCapabilityResultNetworkNotAvailable() {
doReturn((int) TelephonyManager.NETWORK_TYPE_BITMASK_NR).when(mPhone)