From e4e65d7b48796cf8e3e3bc406f58e7d2c102be42 Mon Sep 17 00:00:00 2001 From: Paul Hu Date: Tue, 29 Jul 2025 09:20:32 +0000 Subject: [PATCH] Fix UnfinishedStubbingException when running testAutomotiveEthernetAllowedUids Mocking the PackageManager while ConnectivityService is running could throw an UnfinishedStubbingException. This change splits the test into two distinct tests that don't need to change the mocking value for PackageManager during testing. Fix: 433600031 Test: atest ConnectivityServiceTest Flag: TEST_ONLY Change-Id: Ibcff2082d1e50e89c272573b4c719a7325c959fd --- .../com/android/server/ConnectivityServiceTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java index 23c6ecfe87..d88d15c803 100644 --- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java @@ -17801,12 +17801,18 @@ public class ConnectivityServiceTest { } @Test - public void testAutomotiveEthernetAllowedUids() throws Exception { + public void testAutomotiveEthernetAllowedUids_withAutoFeature() throws Exception { mServiceContext.setPermission(NETWORK_FACTORY, PERMISSION_GRANTED); mServiceContext.setPermission(MANAGE_TEST_NETWORKS, PERMISSION_GRANTED); // Has automotive feature. validateAutomotiveEthernetAllowedUids(true); + } + + @Test + public void testAutomotiveEthernetAllowedUids_withoutAutoFeature() throws Exception { + mServiceContext.setPermission(NETWORK_FACTORY, PERMISSION_GRANTED); + mServiceContext.setPermission(MANAGE_TEST_NETWORKS, PERMISSION_GRANTED); // No automotive feature. validateAutomotiveEthernetAllowedUids(false); @@ -19347,7 +19353,7 @@ public class ConnectivityServiceTest { verifyClatdStop(null /* inOrder */, MOBILE_IFNAME); } - private static final int EXPECTED_TEST_METHOD_COUNT = 332; + private static final int EXPECTED_TEST_METHOD_COUNT = 333; @Test public void testTestMethodCount() {