Loading tests/net/java/android/net/ConnectivityMetricsLoggerTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net; import android.os.Bundle; import android.os.Parcel; import android.test.suitebuilder.annotation.SmallTest; import java.util.List; import junit.framework.TestCase; import org.mockito.ArgumentCaptor; Loading Loading @@ -49,6 +50,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { mLog = new ConnectivityMetricsLogger(mService); } @SmallTest public void testLogEvents() throws Exception { mLog.logEvent(1, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV); mLog.logEvent(2, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV); Loading @@ -60,6 +62,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(3), gotEvents.get(2)); } @SmallTest public void testLogEventTriggerThrottling() throws Exception { when(mService.logEvent(any())).thenReturn(1234L); Loading @@ -70,6 +73,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(1), gotEvents.get(0)); } @SmallTest public void testLogEventFails() throws Exception { when(mService.logEvent(any())).thenReturn(-1L); // Error. Loading @@ -80,6 +84,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(1), gotEvents.get(0)); } @SmallTest public void testLogEventWhenThrottling() throws Exception { when(mService.logEvent(any())).thenReturn(Long.MAX_VALUE); // Throttled Loading @@ -92,6 +97,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(1), gotEvents.get(0)); } @SmallTest public void testLogEventRecoverFromThrottling() throws Exception { final long throttleTimeout = System.currentTimeMillis() + 10; when(mService.logEvent(any())).thenReturn(throttleTimeout, 0L); Loading tests/net/java/android/net/apf/ApfTest.java +7 −8 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.system.ErrnoException; import android.system.Os; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.MediumTest; import static android.system.OsConstants.*; import com.android.frameworks.tests.net.R; Loading Loading @@ -155,7 +154,7 @@ public class ApfTest extends AndroidTestCase { * generating bytecode for that program and running it through the * interpreter to verify it functions correctly. */ @MediumTest @SmallTest public void testApfInstructions() throws IllegalInstructionException { // Empty program should pass because having the program counter reach the // location immediately after the program indicates the packet should be Loading Loading @@ -563,7 +562,7 @@ public class ApfTest extends AndroidTestCase { * Generate some BPF programs, translate them to APF, then run APF and BPF programs * over packet traces and verify both programs filter out the same packets. */ @MediumTest @SmallTest public void testApfAgainstBpf() throws Exception { String[] tcpdump_filters = new String[]{ "udp", "tcp", "icmp", "icmp6", "udp port 53", "arp", "dst 239.255.255.250", "arp or tcp or udp port 53", "net 192.168.1.0/24", Loading Loading @@ -721,7 +720,7 @@ public class ApfTest extends AndroidTestCase { private static final byte[] ANOTHER_IPV4_ADDR = {10, 0, 0, 2}; private static final byte[] IPV4_ANY_HOST_ADDR = {0, 0, 0, 0}; @MediumTest @SmallTest public void testApfFilterIPv4() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19); Loading Loading @@ -776,7 +775,7 @@ public class ApfTest extends AndroidTestCase { apfFilter.shutdown(); } @MediumTest @SmallTest public void testApfFilterIPv6() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); Loading @@ -802,7 +801,7 @@ public class ApfTest extends AndroidTestCase { apfFilter.shutdown(); } @MediumTest @SmallTest public void testApfFilterMulticast() throws Exception { final byte[] unicastIpv4Addr = {(byte)192,0,2,63}; final byte[] broadcastIpv4Addr = {(byte)192,0,2,(byte)255}; Loading Loading @@ -912,7 +911,7 @@ public class ApfTest extends AndroidTestCase { assertDrop(program, garpReply()); } @MediumTest @SmallTest public void testApfFilterArp() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); Loading Loading @@ -1031,7 +1030,7 @@ public class ApfTest extends AndroidTestCase { ipManagerCallback.assertNoProgramUpdate(); } @MediumTest @SmallTest public void testApfFilterRa() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog); Loading tests/net/java/android/net/dhcp/DhcpPacketTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -473,6 +473,7 @@ public class DhcpPacketTest extends TestCase { assertEquals(Integer.toHexString(expected), Integer.toHexString(got)); } @SmallTest public void testTruncatedOfferPackets() throws Exception { final byte[] packet = HexDump.hexStringToByteArray( // IP header. Loading Loading @@ -506,6 +507,7 @@ public class DhcpPacketTest extends TestCase { } } @SmallTest public void testRandomPackets() throws Exception { final int maxRandomPacketSize = 512; final Random r = new Random(); Loading tests/net/java/android/net/netlink/NetlinkErrorMessageTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.net.netlink.NetlinkConstants; import android.net.netlink.NetlinkErrorMessage; import android.net.netlink.NetlinkMessage; import android.net.netlink.StructNlMsgErr; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; import java.nio.ByteBuffer; import java.nio.ByteOrder; Loading Loading @@ -53,6 +54,7 @@ public class NetlinkErrorMessageTest extends TestCase { public static final byte[] NLM_ERROR_OK = HexEncoding.decode(NLM_ERROR_OK_HEX.toCharArray(), false); @SmallTest public void testParseNlmErrorOk() { final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing. Loading tests/net/java/android/net/netlink/NetlinkSocketTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.net.netlink.NetlinkSocket; import android.net.netlink.RtNetlinkNeighborMessage; import android.net.netlink.StructNdMsg; import android.net.netlink.StructNlMsgHdr; import android.test.suitebuilder.annotation.SmallTest; import android.system.ErrnoException; import android.system.NetlinkSocketAddress; import android.system.OsConstants; Loading @@ -33,6 +34,7 @@ import junit.framework.TestCase; public class NetlinkSocketTest extends TestCase { private final String TAG = "NetlinkSocketTest"; @SmallTest public void testBasicWorkingGetNeighborsQuery() throws Exception { NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE); assertNotNull(s); Loading Loading @@ -91,6 +93,7 @@ public class NetlinkSocketTest extends TestCase { s.close(); } @SmallTest public void testRepeatedCloseCallsAreQuiet() throws Exception { // Create a working NetlinkSocket. NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE); Loading Loading
tests/net/java/android/net/ConnectivityMetricsLoggerTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net; import android.os.Bundle; import android.os.Parcel; import android.test.suitebuilder.annotation.SmallTest; import java.util.List; import junit.framework.TestCase; import org.mockito.ArgumentCaptor; Loading Loading @@ -49,6 +50,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { mLog = new ConnectivityMetricsLogger(mService); } @SmallTest public void testLogEvents() throws Exception { mLog.logEvent(1, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV); mLog.logEvent(2, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV); Loading @@ -60,6 +62,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(3), gotEvents.get(2)); } @SmallTest public void testLogEventTriggerThrottling() throws Exception { when(mService.logEvent(any())).thenReturn(1234L); Loading @@ -70,6 +73,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(1), gotEvents.get(0)); } @SmallTest public void testLogEventFails() throws Exception { when(mService.logEvent(any())).thenReturn(-1L); // Error. Loading @@ -80,6 +84,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(1), gotEvents.get(0)); } @SmallTest public void testLogEventWhenThrottling() throws Exception { when(mService.logEvent(any())).thenReturn(Long.MAX_VALUE); // Throttled Loading @@ -92,6 +97,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase { assertEventsEqual(expectedEvent(1), gotEvents.get(0)); } @SmallTest public void testLogEventRecoverFromThrottling() throws Exception { final long throttleTimeout = System.currentTimeMillis() + 10; when(mService.logEvent(any())).thenReturn(throttleTimeout, 0L); Loading
tests/net/java/android/net/apf/ApfTest.java +7 −8 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.system.ErrnoException; import android.system.Os; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.MediumTest; import static android.system.OsConstants.*; import com.android.frameworks.tests.net.R; Loading Loading @@ -155,7 +154,7 @@ public class ApfTest extends AndroidTestCase { * generating bytecode for that program and running it through the * interpreter to verify it functions correctly. */ @MediumTest @SmallTest public void testApfInstructions() throws IllegalInstructionException { // Empty program should pass because having the program counter reach the // location immediately after the program indicates the packet should be Loading Loading @@ -563,7 +562,7 @@ public class ApfTest extends AndroidTestCase { * Generate some BPF programs, translate them to APF, then run APF and BPF programs * over packet traces and verify both programs filter out the same packets. */ @MediumTest @SmallTest public void testApfAgainstBpf() throws Exception { String[] tcpdump_filters = new String[]{ "udp", "tcp", "icmp", "icmp6", "udp port 53", "arp", "dst 239.255.255.250", "arp or tcp or udp port 53", "net 192.168.1.0/24", Loading Loading @@ -721,7 +720,7 @@ public class ApfTest extends AndroidTestCase { private static final byte[] ANOTHER_IPV4_ADDR = {10, 0, 0, 2}; private static final byte[] IPV4_ANY_HOST_ADDR = {0, 0, 0, 0}; @MediumTest @SmallTest public void testApfFilterIPv4() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19); Loading Loading @@ -776,7 +775,7 @@ public class ApfTest extends AndroidTestCase { apfFilter.shutdown(); } @MediumTest @SmallTest public void testApfFilterIPv6() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); Loading @@ -802,7 +801,7 @@ public class ApfTest extends AndroidTestCase { apfFilter.shutdown(); } @MediumTest @SmallTest public void testApfFilterMulticast() throws Exception { final byte[] unicastIpv4Addr = {(byte)192,0,2,63}; final byte[] broadcastIpv4Addr = {(byte)192,0,2,(byte)255}; Loading Loading @@ -912,7 +911,7 @@ public class ApfTest extends AndroidTestCase { assertDrop(program, garpReply()); } @MediumTest @SmallTest public void testApfFilterArp() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); Loading Loading @@ -1031,7 +1030,7 @@ public class ApfTest extends AndroidTestCase { ipManagerCallback.assertNoProgramUpdate(); } @MediumTest @SmallTest public void testApfFilterRa() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog); Loading
tests/net/java/android/net/dhcp/DhcpPacketTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -473,6 +473,7 @@ public class DhcpPacketTest extends TestCase { assertEquals(Integer.toHexString(expected), Integer.toHexString(got)); } @SmallTest public void testTruncatedOfferPackets() throws Exception { final byte[] packet = HexDump.hexStringToByteArray( // IP header. Loading Loading @@ -506,6 +507,7 @@ public class DhcpPacketTest extends TestCase { } } @SmallTest public void testRandomPackets() throws Exception { final int maxRandomPacketSize = 512; final Random r = new Random(); Loading
tests/net/java/android/net/netlink/NetlinkErrorMessageTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.net.netlink.NetlinkConstants; import android.net.netlink.NetlinkErrorMessage; import android.net.netlink.NetlinkMessage; import android.net.netlink.StructNlMsgErr; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; import java.nio.ByteBuffer; import java.nio.ByteOrder; Loading Loading @@ -53,6 +54,7 @@ public class NetlinkErrorMessageTest extends TestCase { public static final byte[] NLM_ERROR_OK = HexEncoding.decode(NLM_ERROR_OK_HEX.toCharArray(), false); @SmallTest public void testParseNlmErrorOk() { final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing. Loading
tests/net/java/android/net/netlink/NetlinkSocketTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.net.netlink.NetlinkSocket; import android.net.netlink.RtNetlinkNeighborMessage; import android.net.netlink.StructNdMsg; import android.net.netlink.StructNlMsgHdr; import android.test.suitebuilder.annotation.SmallTest; import android.system.ErrnoException; import android.system.NetlinkSocketAddress; import android.system.OsConstants; Loading @@ -33,6 +34,7 @@ import junit.framework.TestCase; public class NetlinkSocketTest extends TestCase { private final String TAG = "NetlinkSocketTest"; @SmallTest public void testBasicWorkingGetNeighborsQuery() throws Exception { NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE); assertNotNull(s); Loading Loading @@ -91,6 +93,7 @@ public class NetlinkSocketTest extends TestCase { s.close(); } @SmallTest public void testRepeatedCloseCallsAreQuiet() throws Exception { // Create a working NetlinkSocket. NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE); Loading