Merge "unit test of offernetwork and unoffernetwork"

This commit is contained in:
Treehugger Robot 2022-08-29 13:59:18 +00:00 • committed by Gerrit Code Review
commit c6c4dc719f

View file

@ -16451,6 +16451,26 @@ public class ConnectivityServiceTest {
assertNull(readHead.poll(TEST_CALLBACK_TIMEOUT_MS, it -> true));
}
@Test
public void testOfferNetwork_ChecksArgumentsOutsideOfHandler() throws Exception {
final TestableNetworkOfferCallback callback = new TestableNetworkOfferCallback(
TIMEOUT_MS /* timeout */, TEST_CALLBACK_TIMEOUT_MS /* noCallbackTimeout */);
final NetworkProvider testProvider = new NetworkProvider(mServiceContext,
mCsHandlerThread.getLooper(), "Test provider");
final NetworkCapabilities caps = new NetworkCapabilities.Builder()
.addCapability(NET_CAPABILITY_INTERNET)
.addCapability(NET_CAPABILITY_NOT_VCN_MANAGED)
.build();
final NetworkScore score = new NetworkScore.Builder().build();
testProvider.registerNetworkOffer(score, caps, r -> r.run(), callback);
testProvider.unregisterNetworkOffer(callback);
assertThrows(NullPointerException.class,
() -> mService.offerNetwork(100, score, caps, null));
assertThrows(NullPointerException.class, () -> mService.unofferNetwork(null));
}
@Test
public void testIgnoreValidationAfterRoamDisabled() throws Exception {
assumeFalse(SdkLevel.isAtLeastT());