DO NOT MERGE frameworks-test: adding missing @SmallTest

This activates all frameworks-test tests in runs of the continuous
platform tests.

Test: $ runtest frameworks-net passes (expect Tether
Bug: 32561414

(cherry picked from commit fa8a6f6220)

Change-Id: I84f9aecfbf9ebe07c6fcfec26acb2c2cfaae2d60
This commit is contained in:
Hugo Benichi
2016-11-04 16:06:34 +09:00
parent 5ef316e34d
commit 141923e5b6
9 changed files with 69 additions and 27 deletions

View File

@@ -18,6 +18,7 @@ package android.net;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.List; import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@@ -49,6 +50,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase {
mLog = new ConnectivityMetricsLogger(mService); mLog = new ConnectivityMetricsLogger(mService);
} }
@SmallTest
public void testLogEvents() throws Exception { public void testLogEvents() throws Exception {
mLog.logEvent(1, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV); mLog.logEvent(1, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV);
mLog.logEvent(2, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV); mLog.logEvent(2, FAKE_COMPONENT, FAKE_EVENT, FAKE_EV);
@@ -60,6 +62,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase {
assertEventsEqual(expectedEvent(3), gotEvents.get(2)); assertEventsEqual(expectedEvent(3), gotEvents.get(2));
} }
@SmallTest
public void testLogEventTriggerThrottling() throws Exception { public void testLogEventTriggerThrottling() throws Exception {
when(mService.logEvent(any())).thenReturn(1234L); when(mService.logEvent(any())).thenReturn(1234L);
@@ -70,6 +73,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase {
assertEventsEqual(expectedEvent(1), gotEvents.get(0)); assertEventsEqual(expectedEvent(1), gotEvents.get(0));
} }
@SmallTest
public void testLogEventFails() throws Exception { public void testLogEventFails() throws Exception {
when(mService.logEvent(any())).thenReturn(-1L); // Error. when(mService.logEvent(any())).thenReturn(-1L); // Error.
@@ -80,6 +84,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase {
assertEventsEqual(expectedEvent(1), gotEvents.get(0)); assertEventsEqual(expectedEvent(1), gotEvents.get(0));
} }
@SmallTest
public void testLogEventWhenThrottling() throws Exception { public void testLogEventWhenThrottling() throws Exception {
when(mService.logEvent(any())).thenReturn(Long.MAX_VALUE); // Throttled when(mService.logEvent(any())).thenReturn(Long.MAX_VALUE); // Throttled
@@ -92,6 +97,7 @@ public class ConnectivityMetricsLoggerTest extends TestCase {
assertEventsEqual(expectedEvent(1), gotEvents.get(0)); assertEventsEqual(expectedEvent(1), gotEvents.get(0));
} }
@SmallTest
public void testLogEventRecoverFromThrottling() throws Exception { public void testLogEventRecoverFromThrottling() throws Exception {
final long throttleTimeout = System.currentTimeMillis() + 10; final long throttleTimeout = System.currentTimeMillis() + 10;
when(mService.logEvent(any())).thenReturn(throttleTimeout, 0L); when(mService.logEvent(any())).thenReturn(throttleTimeout, 0L);

View File

@@ -33,7 +33,6 @@ import android.system.ErrnoException;
import android.system.Os; import android.system.Os;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.MediumTest;
import static android.system.OsConstants.*; import static android.system.OsConstants.*;
import com.android.frameworks.tests.net.R; import com.android.frameworks.tests.net.R;
@@ -155,7 +154,7 @@ public class ApfTest extends AndroidTestCase {
* generating bytecode for that program and running it through the * generating bytecode for that program and running it through the
* interpreter to verify it functions correctly. * interpreter to verify it functions correctly.
*/ */
@MediumTest @SmallTest
public void testApfInstructions() throws IllegalInstructionException { public void testApfInstructions() throws IllegalInstructionException {
// Empty program should pass because having the program counter reach the // Empty program should pass because having the program counter reach the
// location immediately after the program indicates the packet should be // location immediately after the program indicates the packet should be
@@ -563,7 +562,7 @@ public class ApfTest extends AndroidTestCase {
* Generate some BPF programs, translate them to APF, then run APF and BPF programs * 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. * over packet traces and verify both programs filter out the same packets.
*/ */
@MediumTest @SmallTest
public void testApfAgainstBpf() throws Exception { public void testApfAgainstBpf() throws Exception {
String[] tcpdump_filters = new String[]{ "udp", "tcp", "icmp", "icmp6", "udp port 53", 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", "arp", "dst 239.255.255.250", "arp or tcp or udp port 53", "net 192.168.1.0/24",
@@ -725,7 +724,7 @@ public class ApfTest extends AndroidTestCase {
private static final byte[] ANOTHER_IPV4_ADDR = {10, 0, 0, 2}; private static final byte[] ANOTHER_IPV4_ADDR = {10, 0, 0, 2};
private static final byte[] IPV4_ANY_HOST_ADDR = {0, 0, 0, 0}; private static final byte[] IPV4_ANY_HOST_ADDR = {0, 0, 0, 0};
@MediumTest @SmallTest
public void testApfFilterIPv4() throws Exception { public void testApfFilterIPv4() throws Exception {
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19); LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19);
@@ -780,7 +779,7 @@ public class ApfTest extends AndroidTestCase {
apfFilter.shutdown(); apfFilter.shutdown();
} }
@MediumTest @SmallTest
public void testApfFilterIPv6() throws Exception { public void testApfFilterIPv6() throws Exception {
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog);
@@ -812,7 +811,7 @@ public class ApfTest extends AndroidTestCase {
apfFilter.shutdown(); apfFilter.shutdown();
} }
@MediumTest @SmallTest
public void testApfFilterMulticast() throws Exception { public void testApfFilterMulticast() throws Exception {
final byte[] unicastIpv4Addr = {(byte)192,0,2,63}; final byte[] unicastIpv4Addr = {(byte)192,0,2,63};
final byte[] broadcastIpv4Addr = {(byte)192,0,2,(byte)255}; final byte[] broadcastIpv4Addr = {(byte)192,0,2,(byte)255};
@@ -922,7 +921,7 @@ public class ApfTest extends AndroidTestCase {
assertDrop(program, garpReply()); assertDrop(program, garpReply());
} }
@MediumTest @SmallTest
public void testApfFilterArp() throws Exception { public void testApfFilterArp() throws Exception {
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog);
@@ -1041,7 +1040,7 @@ public class ApfTest extends AndroidTestCase {
ipManagerCallback.assertNoProgramUpdate(); ipManagerCallback.assertNoProgramUpdate();
} }
@MediumTest @SmallTest
public void testApfFilterRa() throws Exception { public void testApfFilterRa() throws Exception {
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog); TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog);

View File

@@ -473,6 +473,7 @@ public class DhcpPacketTest extends TestCase {
assertEquals(Integer.toHexString(expected), Integer.toHexString(got)); assertEquals(Integer.toHexString(expected), Integer.toHexString(got));
} }
@SmallTest
public void testTruncatedOfferPackets() throws Exception { public void testTruncatedOfferPackets() throws Exception {
final byte[] packet = HexDump.hexStringToByteArray( final byte[] packet = HexDump.hexStringToByteArray(
// IP header. // IP header.
@@ -506,6 +507,7 @@ public class DhcpPacketTest extends TestCase {
} }
} }
@SmallTest
public void testRandomPackets() throws Exception { public void testRandomPackets() throws Exception {
final int maxRandomPacketSize = 512; final int maxRandomPacketSize = 512;
final Random r = new Random(); final Random r = new Random();

View File

@@ -24,6 +24,7 @@ import android.net.netlink.NetlinkConstants;
import android.net.netlink.NetlinkErrorMessage; import android.net.netlink.NetlinkErrorMessage;
import android.net.netlink.NetlinkMessage; import android.net.netlink.NetlinkMessage;
import android.net.netlink.StructNlMsgErr; import android.net.netlink.StructNlMsgErr;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log; import android.util.Log;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@@ -53,6 +54,7 @@ public class NetlinkErrorMessageTest extends TestCase {
public static final byte[] NLM_ERROR_OK = public static final byte[] NLM_ERROR_OK =
HexEncoding.decode(NLM_ERROR_OK_HEX.toCharArray(), false); HexEncoding.decode(NLM_ERROR_OK_HEX.toCharArray(), false);
@SmallTest
public void testParseNlmErrorOk() { public void testParseNlmErrorOk() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK); final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing. byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.

View File

@@ -20,6 +20,7 @@ import android.net.netlink.NetlinkSocket;
import android.net.netlink.RtNetlinkNeighborMessage; import android.net.netlink.RtNetlinkNeighborMessage;
import android.net.netlink.StructNdMsg; import android.net.netlink.StructNdMsg;
import android.net.netlink.StructNlMsgHdr; import android.net.netlink.StructNlMsgHdr;
import android.test.suitebuilder.annotation.SmallTest;
import android.system.ErrnoException; import android.system.ErrnoException;
import android.system.NetlinkSocketAddress; import android.system.NetlinkSocketAddress;
import android.system.OsConstants; import android.system.OsConstants;
@@ -33,6 +34,7 @@ import junit.framework.TestCase;
public class NetlinkSocketTest extends TestCase { public class NetlinkSocketTest extends TestCase {
private final String TAG = "NetlinkSocketTest"; private final String TAG = "NetlinkSocketTest";
@SmallTest
public void testBasicWorkingGetNeighborsQuery() throws Exception { public void testBasicWorkingGetNeighborsQuery() throws Exception {
NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE); NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE);
assertNotNull(s); assertNotNull(s);
@@ -91,6 +93,7 @@ public class NetlinkSocketTest extends TestCase {
s.close(); s.close();
} }
@SmallTest
public void testRepeatedCloseCallsAreQuiet() throws Exception { public void testRepeatedCloseCallsAreQuiet() throws Exception {
// Create a working NetlinkSocket. // Create a working NetlinkSocket.
NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE); NetlinkSocket s = new NetlinkSocket(OsConstants.NETLINK_ROUTE);

View File

@@ -21,12 +21,13 @@ import android.net.netlink.NetlinkMessage;
import android.net.netlink.RtNetlinkNeighborMessage; import android.net.netlink.RtNetlinkNeighborMessage;
import android.net.netlink.StructNdMsg; import android.net.netlink.StructNdMsg;
import android.net.netlink.StructNlMsgHdr; import android.net.netlink.StructNlMsgHdr;
import android.test.suitebuilder.annotation.SmallTest;
import android.system.OsConstants; import android.system.OsConstants;
import android.util.Log; import android.util.Log;
import libcore.util.HexEncoding; import libcore.util.HexEncoding;
import java.net.InetAddress;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@@ -135,6 +136,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
public static final byte[] RTM_GETNEIGH_RESPONSE = public static final byte[] RTM_GETNEIGH_RESPONSE =
HexEncoding.decode(RTM_GETNEIGH_RESPONSE_HEX.replaceAll(" ", "").toCharArray(), false); HexEncoding.decode(RTM_GETNEIGH_RESPONSE_HEX.replaceAll(" ", "").toCharArray(), false);
@SmallTest
public void testParseRtmDelNeigh() { public void testParseRtmDelNeigh() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_DELNEIGH); final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_DELNEIGH);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing. byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
@@ -161,6 +163,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
assertEquals(InetAddress.parseNumericAddress("192.168.159.254"), destination); assertEquals(InetAddress.parseNumericAddress("192.168.159.254"), destination);
} }
@SmallTest
public void testParseRtmNewNeigh() { public void testParseRtmNewNeigh() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_NEWNEIGH); final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_NEWNEIGH);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing. byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
@@ -187,6 +190,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
assertEquals(InetAddress.parseNumericAddress("fe80::86c9:b2ff:fe6a:ed4b"), destination); assertEquals(InetAddress.parseNumericAddress("fe80::86c9:b2ff:fe6a:ed4b"), destination);
} }
@SmallTest
public void testParseRtmGetNeighResponse() { public void testParseRtmGetNeighResponse() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_GETNEIGH_RESPONSE); final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_GETNEIGH_RESPONSE);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing. byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
@@ -211,6 +215,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
assertEquals(14, messageCount); assertEquals(14, messageCount);
} }
@SmallTest
public void testCreateRtmNewNeighMessage() { public void testCreateRtmNewNeighMessage() {
final int seqNo = 2635; final int seqNo = 2635;
final int ifIndex = 14; final int ifIndex = 14;

View File

@@ -70,7 +70,6 @@ import android.provider.Settings;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.test.FlakyTest; import android.test.FlakyTest;
import android.test.mock.MockContentResolver; import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log; import android.util.Log;
import android.util.LogPrinter; import android.util.LogPrinter;
@@ -196,6 +195,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
} }
// Tests that IdleableHandlerThread works as expected. // Tests that IdleableHandlerThread works as expected.
@SmallTest
public void testIdleableHandlerThread() { public void testIdleableHandlerThread() {
final int attempts = 50; // Causes the test to take about 200ms on bullhead-eng. final int attempts = 50; // Causes the test to take about 200ms on bullhead-eng.
@@ -220,6 +220,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
} }
} }
@SmallTest
@FlakyTest(tolerance = 3) @FlakyTest(tolerance = 3)
public void testNotWaitingForIdleCausesRaceConditions() { public void testNotWaitingForIdleCausesRaceConditions() {
// Bring up a network that we can use to send messages to ConnectivityService. // Bring up a network that we can use to send messages to ConnectivityService.
@@ -840,7 +841,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
return cv; return cv;
} }
@LargeTest @SmallTest
public void testLingering() throws Exception { public void testLingering() throws Exception {
verifyNoNetwork(); verifyNoNetwork();
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR); mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
@@ -880,7 +881,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyNoNetwork(); verifyNoNetwork();
} }
@LargeTest @SmallTest
public void testValidatedCellularOutscoresUnvalidatedWiFi() throws Exception { public void testValidatedCellularOutscoresUnvalidatedWiFi() throws Exception {
// Test bringing up unvalidated WiFi // Test bringing up unvalidated WiFi
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
@@ -915,7 +916,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyNoNetwork(); verifyNoNetwork();
} }
@LargeTest @SmallTest
public void testUnvalidatedWifiOutscoresUnvalidatedCellular() throws Exception { public void testUnvalidatedWifiOutscoresUnvalidatedCellular() throws Exception {
// Test bringing up unvalidated cellular. // Test bringing up unvalidated cellular.
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR); mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
@@ -941,7 +942,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyNoNetwork(); verifyNoNetwork();
} }
@LargeTest @SmallTest
public void testUnlingeringDoesNotValidate() throws Exception { public void testUnlingeringDoesNotValidate() throws Exception {
// Test bringing up unvalidated WiFi. // Test bringing up unvalidated WiFi.
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
@@ -969,7 +970,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
NET_CAPABILITY_VALIDATED)); NET_CAPABILITY_VALIDATED));
} }
@LargeTest @SmallTest
public void testCellularOutscoresWeakWifi() throws Exception { public void testCellularOutscoresWeakWifi() throws Exception {
// Test bringing up validated cellular. // Test bringing up validated cellular.
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR); mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
@@ -995,7 +996,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyActiveNetwork(TRANSPORT_WIFI); verifyActiveNetwork(TRANSPORT_WIFI);
} }
@LargeTest @SmallTest
public void testReapingNetwork() throws Exception { public void testReapingNetwork() throws Exception {
// Test bringing up WiFi without NET_CAPABILITY_INTERNET. // Test bringing up WiFi without NET_CAPABILITY_INTERNET.
// Expect it to be torn down immediately because it satisfies no requests. // Expect it to be torn down immediately because it satisfies no requests.
@@ -1028,7 +1029,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
waitFor(cv); waitFor(cv);
} }
@LargeTest @SmallTest
public void testCellularFallback() throws Exception { public void testCellularFallback() throws Exception {
// Test bringing up validated cellular. // Test bringing up validated cellular.
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR); mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
@@ -1066,7 +1067,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyActiveNetwork(TRANSPORT_WIFI); verifyActiveNetwork(TRANSPORT_WIFI);
} }
@LargeTest @SmallTest
public void testWiFiFallback() throws Exception { public void testWiFiFallback() throws Exception {
// Test bringing up unvalidated WiFi. // Test bringing up unvalidated WiFi.
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
@@ -1208,7 +1209,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
} }
} }
@LargeTest @SmallTest
public void testStateChangeNetworkCallbacks() throws Exception { public void testStateChangeNetworkCallbacks() throws Exception {
final TestNetworkCallback genericNetworkCallback = new TestNetworkCallback(); final TestNetworkCallback genericNetworkCallback = new TestNetworkCallback();
final TestNetworkCallback wifiNetworkCallback = new TestNetworkCallback(); final TestNetworkCallback wifiNetworkCallback = new TestNetworkCallback();
@@ -1591,7 +1592,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
handlerThread.quit(); handlerThread.quit();
} }
@LargeTest @SmallTest
public void testNetworkFactoryRequests() throws Exception { public void testNetworkFactoryRequests() throws Exception {
tryNetworkFactoryRequests(NET_CAPABILITY_MMS); tryNetworkFactoryRequests(NET_CAPABILITY_MMS);
tryNetworkFactoryRequests(NET_CAPABILITY_SUPL); tryNetworkFactoryRequests(NET_CAPABILITY_SUPL);
@@ -1611,7 +1612,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
// Skipping VALIDATED and CAPTIVE_PORTAL as they're disallowed. // Skipping VALIDATED and CAPTIVE_PORTAL as they're disallowed.
} }
@LargeTest @SmallTest
public void testNoMutableNetworkRequests() throws Exception { public void testNoMutableNetworkRequests() throws Exception {
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent("a"), 0); PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent("a"), 0);
NetworkRequest.Builder builder = new NetworkRequest.Builder(); NetworkRequest.Builder builder = new NetworkRequest.Builder();
@@ -1636,7 +1637,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
} catch (IllegalArgumentException expected) {} } catch (IllegalArgumentException expected) {}
} }
@LargeTest @SmallTest
public void testMMSonWiFi() throws Exception { public void testMMSonWiFi() throws Exception {
// Test bringing up cellular without MMS NetworkRequest gets reaped // Test bringing up cellular without MMS NetworkRequest gets reaped
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR); mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
@@ -1671,7 +1672,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyActiveNetwork(TRANSPORT_WIFI); verifyActiveNetwork(TRANSPORT_WIFI);
} }
@LargeTest @SmallTest
public void testMMSonCell() throws Exception { public void testMMSonCell() throws Exception {
// Test bringing up cellular without MMS // Test bringing up cellular without MMS
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR); mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
@@ -1697,7 +1698,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
verifyActiveNetwork(TRANSPORT_CELLULAR); verifyActiveNetwork(TRANSPORT_CELLULAR);
} }
@LargeTest @SmallTest
public void testCaptivePortal() { public void testCaptivePortal() {
final TestNetworkCallback captivePortalCallback = new TestNetworkCallback(); final TestNetworkCallback captivePortalCallback = new TestNetworkCallback();
final NetworkRequest captivePortalRequest = new NetworkRequest.Builder() final NetworkRequest captivePortalRequest = new NetworkRequest.Builder()
@@ -1746,7 +1747,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
validatedCallback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent); validatedCallback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent);
} }
@LargeTest @SmallTest
public void testAvoidOrIgnoreCaptivePortals() { public void testAvoidOrIgnoreCaptivePortals() {
final TestNetworkCallback captivePortalCallback = new TestNetworkCallback(); final TestNetworkCallback captivePortalCallback = new TestNetworkCallback();
final NetworkRequest captivePortalRequest = new NetworkRequest.Builder() final NetworkRequest captivePortalRequest = new NetworkRequest.Builder()
@@ -1817,7 +1818,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
execptionCalled); execptionCalled);
} }
@LargeTest @SmallTest
public void testRegisterDefaultNetworkCallback() throws Exception { public void testRegisterDefaultNetworkCallback() throws Exception {
final TestNetworkCallback defaultNetworkCallback = new TestNetworkCallback(); final TestNetworkCallback defaultNetworkCallback = new TestNetworkCallback();
mCm.registerDefaultNetworkCallback(defaultNetworkCallback); mCm.registerDefaultNetworkCallback(defaultNetworkCallback);
@@ -1878,7 +1879,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
} }
} }
@LargeTest @SmallTest
public void testRequestCallbackUpdates() throws Exception { public void testRequestCallbackUpdates() throws Exception {
// File a network request for mobile. // File a network request for mobile.
final TestNetworkCallback cellNetworkCallback = new TestRequestUpdateCallback(); final TestNetworkCallback cellNetworkCallback = new TestRequestUpdateCallback();
@@ -2519,6 +2520,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
return mWiFiNetworkAgent.getNetwork(); return mWiFiNetworkAgent.getNetwork();
} }
@SmallTest
public void testPacketKeepalives() throws Exception { public void testPacketKeepalives() throws Exception {
InetAddress myIPv4 = InetAddress.getByName("192.0.2.129"); InetAddress myIPv4 = InetAddress.getByName("192.0.2.129");
InetAddress notMyIPv4 = InetAddress.getByName("192.0.2.35"); InetAddress notMyIPv4 = InetAddress.getByName("192.0.2.35");

View File

@@ -24,6 +24,7 @@ import android.net.Network;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.NetworkMisc; import android.net.NetworkMisc;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import com.android.internal.R; import com.android.internal.R;
import com.android.server.ConnectivityService; import com.android.server.ConnectivityService;
@@ -70,6 +71,7 @@ public class LingerMonitorTest extends TestCase {
mMonitor = new TestableLingerMonitor(mCtx, mNotifier, HIGH_DAILY_LIMIT, HIGH_RATE_LIMIT); mMonitor = new TestableLingerMonitor(mCtx, mNotifier, HIGH_DAILY_LIMIT, HIGH_RATE_LIMIT);
} }
@SmallTest
public void testTransitions() { public void testTransitions() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
NetworkAgentInfo nai1 = wifiNai(100); NetworkAgentInfo nai1 = wifiNai(100);
@@ -79,6 +81,7 @@ public class LingerMonitorTest extends TestCase {
assertFalse(mMonitor.isNotificationEnabled(nai2, nai1)); assertFalse(mMonitor.isNotificationEnabled(nai2, nai1));
} }
@SmallTest
public void testNotificationOnLinger() { public void testNotificationOnLinger() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION); setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
@@ -89,6 +92,7 @@ public class LingerMonitorTest extends TestCase {
verifyNotification(from, to); verifyNotification(from, to);
} }
@SmallTest
public void testToastOnLinger() { public void testToastOnLinger() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST); setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
@@ -99,6 +103,7 @@ public class LingerMonitorTest extends TestCase {
verifyToast(from, to); verifyToast(from, to);
} }
@SmallTest
public void testNotificationClearedAfterDisconnect() { public void testNotificationClearedAfterDisconnect() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION); setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
@@ -112,6 +117,7 @@ public class LingerMonitorTest extends TestCase {
verify(mNotifier, times(1)).clearNotification(100); verify(mNotifier, times(1)).clearNotification(100);
} }
@SmallTest
public void testNotificationClearedAfterSwitchingBack() { public void testNotificationClearedAfterSwitchingBack() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION); setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
@@ -125,6 +131,7 @@ public class LingerMonitorTest extends TestCase {
verify(mNotifier, times(1)).clearNotification(100); verify(mNotifier, times(1)).clearNotification(100);
} }
@SmallTest
public void testUniqueToast() { public void testUniqueToast() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST); setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
@@ -142,6 +149,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testMultipleNotifications() { public void testMultipleNotifications() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION); setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
@@ -160,6 +168,7 @@ public class LingerMonitorTest extends TestCase {
verifyNotification(wifi2, cell); verifyNotification(wifi2, cell);
} }
@SmallTest
public void testRateLimiting() throws InterruptedException { public void testRateLimiting() throws InterruptedException {
mMonitor = new TestableLingerMonitor(mCtx, mNotifier, HIGH_DAILY_LIMIT, LOW_RATE_LIMIT); mMonitor = new TestableLingerMonitor(mCtx, mNotifier, HIGH_DAILY_LIMIT, LOW_RATE_LIMIT);
@@ -185,6 +194,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testDailyLimiting() throws InterruptedException { public void testDailyLimiting() throws InterruptedException {
mMonitor = new TestableLingerMonitor(mCtx, mNotifier, LOW_DAILY_LIMIT, HIGH_RATE_LIMIT); mMonitor = new TestableLingerMonitor(mCtx, mNotifier, LOW_DAILY_LIMIT, HIGH_RATE_LIMIT);
@@ -211,6 +221,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testUniqueNotification() { public void testUniqueNotification() {
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION); setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
@@ -227,6 +238,7 @@ public class LingerMonitorTest extends TestCase {
verifyNotification(from, to); verifyNotification(from, to);
} }
@SmallTest
public void testIgnoreNeverValidatedNetworks() { public void testIgnoreNeverValidatedNetworks() {
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST); setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
@@ -238,6 +250,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testIgnoreCurrentlyValidatedNetworks() { public void testIgnoreCurrentlyValidatedNetworks() {
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST); setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
@@ -249,6 +262,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testNoNotificationType() { public void testNoNotificationType() {
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST); setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
setNotificationSwitch(); setNotificationSwitch();
@@ -259,6 +273,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testNoTransitionToNotify() { public void testNoTransitionToNotify() {
setNotificationType(LingerMonitor.NOTIFY_TYPE_NONE); setNotificationType(LingerMonitor.NOTIFY_TYPE_NONE);
setNotificationSwitch(transition(WIFI, CELLULAR)); setNotificationSwitch(transition(WIFI, CELLULAR));
@@ -269,6 +284,7 @@ public class LingerMonitorTest extends TestCase {
verifyNoNotifications(); verifyNoNotifications();
} }
@SmallTest
public void testDifferentTransitionToNotify() { public void testDifferentTransitionToNotify() {
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST); setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
setNotificationSwitch(transition(CELLULAR, WIFI)); setNotificationSwitch(transition(CELLULAR, WIFI));

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.net.ConnectivityMetricsEvent; import android.net.ConnectivityMetricsEvent;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.test.suitebuilder.annotation.SmallTest;
import static android.net.ConnectivityMetricsEvent.Reference; import static android.net.ConnectivityMetricsEvent.Reference;
import junit.framework.TestCase; import junit.framework.TestCase;
@@ -67,12 +68,14 @@ public class MetricsLoggerServiceTest extends TestCase {
mService.onStart(); mService.onStart();
} }
@SmallTest
public void testGetNoEvents() throws Exception { public void testGetNoEvents() throws Exception {
Reference r = new Reference(0); Reference r = new Reference(0);
assertArrayEquals(NO_EVENTS, mService.mBinder.getEvents(r)); assertArrayEquals(NO_EVENTS, mService.mBinder.getEvents(r));
assertEquals(0, r.getValue()); assertEquals(0, r.getValue());
} }
@SmallTest
public void testLogAndGetEvents() throws Exception { public void testLogAndGetEvents() throws Exception {
mService.mBinder.logEvents(EVENTS); mService.mBinder.logEvents(EVENTS);
@@ -85,6 +88,7 @@ public class MetricsLoggerServiceTest extends TestCase {
assertEquals(N_EVENTS, r.getValue()); assertEquals(N_EVENTS, r.getValue());
} }
@SmallTest
public void testLogOneByOne() throws Exception { public void testLogOneByOne() throws Exception {
for (ConnectivityMetricsEvent ev : EVENTS) { for (ConnectivityMetricsEvent ev : EVENTS) {
mService.mBinder.logEvent(ev); mService.mBinder.logEvent(ev);
@@ -99,6 +103,7 @@ public class MetricsLoggerServiceTest extends TestCase {
assertEquals(N_EVENTS, r.getValue()); assertEquals(N_EVENTS, r.getValue());
} }
@SmallTest
public void testInterleavedLogAndGet() throws Exception { public void testInterleavedLogAndGet() throws Exception {
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 0, 3)); mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 0, 3));
@@ -117,6 +122,7 @@ public class MetricsLoggerServiceTest extends TestCase {
assertEquals(N_EVENTS, r.getValue()); assertEquals(N_EVENTS, r.getValue());
} }
@SmallTest
public void testMultipleGetAll() throws Exception { public void testMultipleGetAll() throws Exception {
mService.mBinder.logEvents(Arrays.copyOf(EVENTS, 3)); mService.mBinder.logEvents(Arrays.copyOf(EVENTS, 3));
@@ -131,6 +137,7 @@ public class MetricsLoggerServiceTest extends TestCase {
assertEquals(N_EVENTS, r2.getValue()); assertEquals(N_EVENTS, r2.getValue());
} }
@SmallTest
public void testLogAndDumpConcurrently() throws Exception { public void testLogAndDumpConcurrently() throws Exception {
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
mContext = null; mContext = null;