Merge "unit test of offernetwork and unoffernetwork"
This commit is contained in:
commit
c6c4dc719f
1 changed files with 20 additions and 0 deletions
20
tests/unit/java/com/android/server/ConnectivityServiceTest.java
Normal file → Executable file
20
tests/unit/java/com/android/server/ConnectivityServiceTest.java
Normal file → Executable 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());
|
||||
|
|
|
|||
Loading…
Reference in a new issue