Loading tests/net/common/java/android/net/CaptivePortalTest.java +21 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; import org.junit.Rule; Loading Loading @@ -53,6 +54,12 @@ public class CaptivePortalTest { public void appRequest(final int request) throws RemoteException { mCode = request; } // This is only @Override on R- public void logEvent(int eventId, String packageName) throws RemoteException { mCode = eventId; mPackageName = packageName; } } private interface TestFunctor { Loading Loading @@ -91,14 +98,24 @@ public class CaptivePortalTest { assertEquals(result.mCode, CaptivePortal.APP_REQUEST_REEVALUATION_REQUIRED); } /** * Test testLogEvent is expected to do nothing but shouldn't crash, because the API logEvent * has been deprecated. */ @IgnoreUpTo(Build.VERSION_CODES.R) @Test public void testLogEvent() { /** * From S testLogEvent is expected to do nothing but shouldn't crash (the API * logEvent has been deprecated). */ final MyCaptivePortalImpl result = runCaptivePortalTest(c -> c.logEvent( 0, TEST_PACKAGE_NAME)); } @IgnoreAfter(Build.VERSION_CODES.R) @Test public void testLogEvent_UntilR() { final MyCaptivePortalImpl result = runCaptivePortalTest(c -> c.logEvent( 42, TEST_PACKAGE_NAME)); assertEquals(result.mCode, 42); assertEquals(result.mPackageName, TEST_PACKAGE_NAME); } } Loading
tests/net/common/java/android/net/CaptivePortalTest.java +21 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; import org.junit.Rule; Loading Loading @@ -53,6 +54,12 @@ public class CaptivePortalTest { public void appRequest(final int request) throws RemoteException { mCode = request; } // This is only @Override on R- public void logEvent(int eventId, String packageName) throws RemoteException { mCode = eventId; mPackageName = packageName; } } private interface TestFunctor { Loading Loading @@ -91,14 +98,24 @@ public class CaptivePortalTest { assertEquals(result.mCode, CaptivePortal.APP_REQUEST_REEVALUATION_REQUIRED); } /** * Test testLogEvent is expected to do nothing but shouldn't crash, because the API logEvent * has been deprecated. */ @IgnoreUpTo(Build.VERSION_CODES.R) @Test public void testLogEvent() { /** * From S testLogEvent is expected to do nothing but shouldn't crash (the API * logEvent has been deprecated). */ final MyCaptivePortalImpl result = runCaptivePortalTest(c -> c.logEvent( 0, TEST_PACKAGE_NAME)); } @IgnoreAfter(Build.VERSION_CODES.R) @Test public void testLogEvent_UntilR() { final MyCaptivePortalImpl result = runCaptivePortalTest(c -> c.logEvent( 42, TEST_PACKAGE_NAME)); assertEquals(result.mCode, 42); assertEquals(result.mPackageName, TEST_PACKAGE_NAME); } }