Merge "Test if VpnManager event will be sent to Settings VPN or not"
This commit is contained in:
@@ -1614,6 +1614,30 @@ public class VpnTest extends VpnTestBase {
|
|||||||
assertEquals(LegacyVpnInfo.STATE_FAILED, vpn.getLegacyVpnInfo().state);
|
assertEquals(LegacyVpnInfo.STATE_FAILED, vpn.getLegacyVpnInfo().state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVpnManagerEventWillNotBeSentToSettingsVpn() throws Exception {
|
||||||
|
startLegacyVpn(createVpn(PRIMARY_USER.id), mVpnProfile);
|
||||||
|
triggerOnAvailableAndGetCallback();
|
||||||
|
|
||||||
|
verifyInterfaceSetCfgWithFlags(IF_STATE_UP);
|
||||||
|
|
||||||
|
final IkeNonProtocolException exception = mock(IkeNonProtocolException.class);
|
||||||
|
final IkeTimeoutException ikeTimeoutException =
|
||||||
|
new IkeTimeoutException("IkeTimeoutException");
|
||||||
|
when(exception.getCause()).thenReturn(ikeTimeoutException);
|
||||||
|
|
||||||
|
final ArgumentCaptor<IkeSessionCallback> captor =
|
||||||
|
ArgumentCaptor.forClass(IkeSessionCallback.class);
|
||||||
|
verify(mIkev2SessionCreator, timeout(TEST_TIMEOUT_MS))
|
||||||
|
.createIkeSession(any(), any(), any(), any(), captor.capture(), any());
|
||||||
|
final IkeSessionCallback ikeCb = captor.getValue();
|
||||||
|
ikeCb.onClosedWithException(exception);
|
||||||
|
|
||||||
|
final Context userContext =
|
||||||
|
mContext.createContextAsUser(UserHandle.of(PRIMARY_USER.id), 0 /* flags */);
|
||||||
|
verify(userContext, never()).startService(any());
|
||||||
|
}
|
||||||
|
|
||||||
private void setAndVerifyAlwaysOnPackage(Vpn vpn, int uid, boolean lockdownEnabled) {
|
private void setAndVerifyAlwaysOnPackage(Vpn vpn, int uid, boolean lockdownEnabled) {
|
||||||
assertTrue(vpn.setAlwaysOnPackage(TEST_VPN_PKG, lockdownEnabled, null));
|
assertTrue(vpn.setAlwaysOnPackage(TEST_VPN_PKG, lockdownEnabled, null));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user