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: I7b0706a7e3368f971d508388e8ad4afc5de9d646
This commit is contained in:
committed by
Lorenzo Colitti
parent
5d0f28c7fd
commit
cfcc1cb7bf
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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",
|
||||
@@ -725,7 +724,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);
|
||||
@@ -780,7 +779,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);
|
||||
@@ -812,7 +811,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};
|
||||
@@ -922,7 +921,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);
|
||||
@@ -1041,7 +1040,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);
|
||||
|
||||
@@ -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.
|
||||
@@ -506,6 +507,7 @@ public class DhcpPacketTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testRandomPackets() throws Exception {
|
||||
final int maxRandomPacketSize = 512;
|
||||
final Random r = new Random();
|
||||
|
||||
@@ -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;
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -21,12 +21,13 @@ import android.net.netlink.NetlinkMessage;
|
||||
import android.net.netlink.RtNetlinkNeighborMessage;
|
||||
import android.net.netlink.StructNdMsg;
|
||||
import android.net.netlink.StructNlMsgHdr;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.system.OsConstants;
|
||||
import android.util.Log;
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
@@ -135,6 +136,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
|
||||
public static final byte[] RTM_GETNEIGH_RESPONSE =
|
||||
HexEncoding.decode(RTM_GETNEIGH_RESPONSE_HEX.replaceAll(" ", "").toCharArray(), false);
|
||||
|
||||
@SmallTest
|
||||
public void testParseRtmDelNeigh() {
|
||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_DELNEIGH);
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
|
||||
@@ -161,6 +163,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
|
||||
assertEquals(InetAddress.parseNumericAddress("192.168.159.254"), destination);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testParseRtmNewNeigh() {
|
||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_NEWNEIGH);
|
||||
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);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testParseRtmGetNeighResponse() {
|
||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_GETNEIGH_RESPONSE);
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
|
||||
@@ -211,6 +215,7 @@ public class RtNetlinkNeighborMessageTest extends TestCase {
|
||||
assertEquals(14, messageCount);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testCreateRtmNewNeighMessage() {
|
||||
final int seqNo = 2635;
|
||||
final int ifIndex = 14;
|
||||
|
||||
@@ -70,7 +70,6 @@ import android.provider.Settings;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.FlakyTest;
|
||||
import android.test.mock.MockContentResolver;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.util.Log;
|
||||
import android.util.LogPrinter;
|
||||
@@ -196,6 +195,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
// Tests that IdleableHandlerThread works as expected.
|
||||
@SmallTest
|
||||
public void testIdleableHandlerThread() {
|
||||
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)
|
||||
public void testNotWaitingForIdleCausesRaceConditions() {
|
||||
// Bring up a network that we can use to send messages to ConnectivityService.
|
||||
@@ -840,7 +841,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
return cv;
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testLingering() throws Exception {
|
||||
verifyNoNetwork();
|
||||
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
|
||||
@@ -880,7 +881,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyNoNetwork();
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testValidatedCellularOutscoresUnvalidatedWiFi() throws Exception {
|
||||
// Test bringing up unvalidated WiFi
|
||||
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
|
||||
@@ -915,7 +916,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyNoNetwork();
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testUnvalidatedWifiOutscoresUnvalidatedCellular() throws Exception {
|
||||
// Test bringing up unvalidated cellular.
|
||||
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
|
||||
@@ -941,7 +942,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyNoNetwork();
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testUnlingeringDoesNotValidate() throws Exception {
|
||||
// Test bringing up unvalidated WiFi.
|
||||
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
|
||||
@@ -969,7 +970,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
NET_CAPABILITY_VALIDATED));
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testCellularOutscoresWeakWifi() throws Exception {
|
||||
// Test bringing up validated cellular.
|
||||
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
|
||||
@@ -995,7 +996,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyActiveNetwork(TRANSPORT_WIFI);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testReapingNetwork() throws Exception {
|
||||
// Test bringing up WiFi without NET_CAPABILITY_INTERNET.
|
||||
// Expect it to be torn down immediately because it satisfies no requests.
|
||||
@@ -1028,7 +1029,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
waitFor(cv);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testCellularFallback() throws Exception {
|
||||
// Test bringing up validated cellular.
|
||||
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
|
||||
@@ -1066,7 +1067,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyActiveNetwork(TRANSPORT_WIFI);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testWiFiFallback() throws Exception {
|
||||
// Test bringing up unvalidated WiFi.
|
||||
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
|
||||
@@ -1193,7 +1194,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testStateChangeNetworkCallbacks() throws Exception {
|
||||
final TestNetworkCallback genericNetworkCallback = new TestNetworkCallback();
|
||||
final TestNetworkCallback wifiNetworkCallback = new TestNetworkCallback();
|
||||
@@ -1576,7 +1577,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
handlerThread.quit();
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testNetworkFactoryRequests() throws Exception {
|
||||
tryNetworkFactoryRequests(NET_CAPABILITY_MMS);
|
||||
tryNetworkFactoryRequests(NET_CAPABILITY_SUPL);
|
||||
@@ -1596,7 +1597,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
// Skipping VALIDATED and CAPTIVE_PORTAL as they're disallowed.
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testNoMutableNetworkRequests() throws Exception {
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent("a"), 0);
|
||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||
@@ -1621,7 +1622,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
} catch (IllegalArgumentException expected) {}
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testMMSonWiFi() throws Exception {
|
||||
// Test bringing up cellular without MMS NetworkRequest gets reaped
|
||||
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
|
||||
@@ -1656,7 +1657,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyActiveNetwork(TRANSPORT_WIFI);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testMMSonCell() throws Exception {
|
||||
// Test bringing up cellular without MMS
|
||||
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
|
||||
@@ -1682,7 +1683,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
verifyActiveNetwork(TRANSPORT_CELLULAR);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testCaptivePortal() {
|
||||
final TestNetworkCallback captivePortalCallback = new TestNetworkCallback();
|
||||
final NetworkRequest captivePortalRequest = new NetworkRequest.Builder()
|
||||
@@ -1731,7 +1732,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
validatedCallback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testAvoidOrIgnoreCaptivePortals() {
|
||||
final TestNetworkCallback captivePortalCallback = new TestNetworkCallback();
|
||||
final NetworkRequest captivePortalRequest = new NetworkRequest.Builder()
|
||||
@@ -1802,7 +1803,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
execptionCalled);
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testRegisterDefaultNetworkCallback() throws Exception {
|
||||
final TestNetworkCallback defaultNetworkCallback = new TestNetworkCallback();
|
||||
mCm.registerDefaultNetworkCallback(defaultNetworkCallback);
|
||||
@@ -1863,7 +1864,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
@SmallTest
|
||||
public void testRequestCallbackUpdates() throws Exception {
|
||||
// File a network request for mobile.
|
||||
final TestNetworkCallback cellNetworkCallback = new TestRequestUpdateCallback();
|
||||
@@ -2504,6 +2505,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
||||
return mWiFiNetworkAgent.getNetwork();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testPacketKeepalives() throws Exception {
|
||||
InetAddress myIPv4 = InetAddress.getByName("192.0.2.129");
|
||||
InetAddress notMyIPv4 = InetAddress.getByName("192.0.2.35");
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkMisc;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.text.format.DateUtils;
|
||||
import com.android.internal.R;
|
||||
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);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testTransitions() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
NetworkAgentInfo nai1 = wifiNai(100);
|
||||
@@ -79,6 +81,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
assertFalse(mMonitor.isNotificationEnabled(nai2, nai1));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testNotificationOnLinger() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
|
||||
@@ -89,6 +92,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNotification(from, to);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testToastOnLinger() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
|
||||
@@ -99,6 +103,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyToast(from, to);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testNotificationClearedAfterDisconnect() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
|
||||
@@ -112,6 +117,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verify(mNotifier, times(1)).clearNotification(100);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testNotificationClearedAfterSwitchingBack() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
|
||||
@@ -125,6 +131,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verify(mNotifier, times(1)).clearNotification(100);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testUniqueToast() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
|
||||
@@ -142,6 +149,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testMultipleNotifications() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
|
||||
@@ -160,6 +168,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNotification(wifi2, cell);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testRateLimiting() throws InterruptedException {
|
||||
mMonitor = new TestableLingerMonitor(mCtx, mNotifier, HIGH_DAILY_LIMIT, LOW_RATE_LIMIT);
|
||||
|
||||
@@ -185,6 +194,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testDailyLimiting() throws InterruptedException {
|
||||
mMonitor = new TestableLingerMonitor(mCtx, mNotifier, LOW_DAILY_LIMIT, HIGH_RATE_LIMIT);
|
||||
|
||||
@@ -211,6 +221,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testUniqueNotification() {
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_NOTIFICATION);
|
||||
@@ -227,6 +238,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNotification(from, to);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIgnoreNeverValidatedNetworks() {
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
@@ -238,6 +250,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIgnoreCurrentlyValidatedNetworks() {
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
@@ -249,6 +262,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testNoNotificationType() {
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
|
||||
setNotificationSwitch();
|
||||
@@ -259,6 +273,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testNoTransitionToNotify() {
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_NONE);
|
||||
setNotificationSwitch(transition(WIFI, CELLULAR));
|
||||
@@ -269,6 +284,7 @@ public class LingerMonitorTest extends TestCase {
|
||||
verifyNoNotifications();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testDifferentTransitionToNotify() {
|
||||
setNotificationType(LingerMonitor.NOTIFY_TYPE_TOAST);
|
||||
setNotificationSwitch(transition(CELLULAR, WIFI));
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.net.ConnectivityMetricsEvent;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import static android.net.ConnectivityMetricsEvent.Reference;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -67,12 +68,14 @@ public class MetricsLoggerServiceTest extends TestCase {
|
||||
mService.onStart();
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testGetNoEvents() throws Exception {
|
||||
Reference r = new Reference(0);
|
||||
assertArrayEquals(NO_EVENTS, mService.mBinder.getEvents(r));
|
||||
assertEquals(0, r.getValue());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testLogAndGetEvents() throws Exception {
|
||||
mService.mBinder.logEvents(EVENTS);
|
||||
|
||||
@@ -85,6 +88,7 @@ public class MetricsLoggerServiceTest extends TestCase {
|
||||
assertEquals(N_EVENTS, r.getValue());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testLogOneByOne() throws Exception {
|
||||
for (ConnectivityMetricsEvent ev : EVENTS) {
|
||||
mService.mBinder.logEvent(ev);
|
||||
@@ -99,6 +103,7 @@ public class MetricsLoggerServiceTest extends TestCase {
|
||||
assertEquals(N_EVENTS, r.getValue());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testInterleavedLogAndGet() throws Exception {
|
||||
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 0, 3));
|
||||
|
||||
@@ -117,6 +122,7 @@ public class MetricsLoggerServiceTest extends TestCase {
|
||||
assertEquals(N_EVENTS, r.getValue());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testMultipleGetAll() throws Exception {
|
||||
mService.mBinder.logEvents(Arrays.copyOf(EVENTS, 3));
|
||||
|
||||
@@ -131,6 +137,7 @@ public class MetricsLoggerServiceTest extends TestCase {
|
||||
assertEquals(N_EVENTS, r2.getValue());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testLogAndDumpConcurrently() throws Exception {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
mContext = null;
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.net.metrics.DnsEvent;
|
||||
import android.net.metrics.INetdEventListener;
|
||||
import android.net.metrics.IpConnectivityLog;
|
||||
import android.os.RemoteException;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
@@ -83,6 +84,7 @@ public class NetdEventListenerServiceTest extends TestCase {
|
||||
verify(mCm, times(1)).registerNetworkCallback(any(), mCallbackCaptor.capture());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testOneBatch() throws Exception {
|
||||
log(105, LATENCIES);
|
||||
log(106, Arrays.copyOf(LATENCIES, BATCH_SIZE - 1)); // one lookup short of a batch event
|
||||
@@ -97,6 +99,7 @@ public class NetdEventListenerServiceTest extends TestCase {
|
||||
new DnsEvent(106, EVENT_TYPES, RETURN_CODES, LATENCIES));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testSeveralBatches() throws Exception {
|
||||
log(105, LATENCIES);
|
||||
log(106, LATENCIES);
|
||||
@@ -110,6 +113,7 @@ public class NetdEventListenerServiceTest extends TestCase {
|
||||
new DnsEvent(107, EVENT_TYPES, RETURN_CODES, LATENCIES));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testBatchAndNetworkLost() throws Exception {
|
||||
byte[] eventTypes = Arrays.copyOf(EVENT_TYPES, 20);
|
||||
byte[] returnCodes = Arrays.copyOf(RETURN_CODES, 20);
|
||||
@@ -126,6 +130,7 @@ public class NetdEventListenerServiceTest extends TestCase {
|
||||
new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testConcurrentBatchesAndDumps() throws Exception {
|
||||
final long stop = System.currentTimeMillis() + 100;
|
||||
final PrintWriter pw = new PrintWriter(new FileOutputStream("/dev/null"));
|
||||
@@ -147,6 +152,7 @@ public class NetdEventListenerServiceTest extends TestCase {
|
||||
new DnsEvent(107, EVENT_TYPES, RETURN_CODES, LATENCIES));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testConcurrentBatchesAndNetworkLoss() throws Exception {
|
||||
logAsync(105, LATENCIES);
|
||||
Thread.sleep(10L);
|
||||
|
||||
Reference in New Issue
Block a user