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
This commit is contained in:
Paul Hu 2025-07-29 09:20:32 +00:00
commit e4e65d7b48

View file

@ -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() {