diff options
Diffstat (limited to 'tests/unit/java/com/android/server/connectivity/VpnTest.java')
| -rw-r--r-- | tests/unit/java/com/android/server/connectivity/VpnTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/java/com/android/server/connectivity/VpnTest.java b/tests/unit/java/com/android/server/connectivity/VpnTest.java index eb35469a43..6266d8c1f7 100644 --- a/tests/unit/java/com/android/server/connectivity/VpnTest.java +++ b/tests/unit/java/com/android/server/connectivity/VpnTest.java @@ -1422,6 +1422,31 @@ public class VpnTest { assertEquals(LegacyVpnInfo.STATE_FAILED, vpn.getLegacyVpnInfo().state); } + @Test + public void testVpnManagerEventWillNotBeSentToSettingsVpn() throws Exception { + startLegacyVpn(createVpn(primaryUser.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); + + // userContext is the same Context that VPN is using, see createVpn(). + final Context userContext = + mContext.createContextAsUser(UserHandle.of(primaryUser.id), 0 /* flags */); + verify(userContext, never()).startService(any()); + } + private void setAndVerifyAlwaysOnPackage(Vpn vpn, int uid, boolean lockdownEnabled) { assertTrue(vpn.setAlwaysOnPackage(TEST_VPN_PKG, lockdownEnabled, null)); |
