Search in sources :

Example 86 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class RationalTest method testValueConversions.

@SmallTest
public void testValueConversions() {
    // Unit, simple case
    assertValueEquals(UNIT, 1.0f);
    assertValueEquals(UNIT, 1.0);
    assertValueEquals(UNIT, 1L);
    assertValueEquals(UNIT, 1);
    assertValueEquals(UNIT, (short) 1);
    // Zero, simple case
    assertValueEquals(ZERO, 0.0f);
    assertValueEquals(ZERO, 0.0);
    assertValueEquals(ZERO, 0L);
    assertValueEquals(ZERO, 0);
    assertValueEquals(ZERO, (short) 0);
    // NaN is 0 for integers, not-a-number for floating point
    assertValueEquals(NaN, Float.NaN);
    assertValueEquals(NaN, Double.NaN);
    assertValueEquals(NaN, 0L);
    assertValueEquals(NaN, 0);
    assertValueEquals(NaN, (short) 0);
    // Positive infinity, saturates upwards for integers
    assertValueEquals(POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
    assertValueEquals(POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    assertValueEquals(POSITIVE_INFINITY, Long.MAX_VALUE);
    assertValueEquals(POSITIVE_INFINITY, Integer.MAX_VALUE);
    assertValueEquals(POSITIVE_INFINITY, (short) -1);
    // Negative infinity, saturates downwards for integers
    assertValueEquals(NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
    assertValueEquals(NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
    assertValueEquals(NEGATIVE_INFINITY, Long.MIN_VALUE);
    assertValueEquals(NEGATIVE_INFINITY, Integer.MIN_VALUE);
    assertValueEquals(NEGATIVE_INFINITY, (short) 0);
    // Normal finite values, round down for integers
    final Rational oneQuarter = new Rational(1, 4);
    assertValueEquals(oneQuarter, 1.0f / 4.0f);
    assertValueEquals(oneQuarter, 1.0 / 4.0);
    assertValueEquals(oneQuarter, 0L);
    assertValueEquals(oneQuarter, 0);
    assertValueEquals(oneQuarter, (short) 0);
    final Rational nineFifths = new Rational(9, 5);
    assertValueEquals(nineFifths, 9.0f / 5.0f);
    assertValueEquals(nineFifths, 9.0 / 5.0);
    assertValueEquals(nineFifths, 1L);
    assertValueEquals(nineFifths, 1);
    assertValueEquals(nineFifths, (short) 1);
    final Rational negativeHundred = new Rational(-1000, 10);
    assertValueEquals(negativeHundred, -100.f / 1.f);
    assertValueEquals(negativeHundred, -100.0 / 1.0);
    assertValueEquals(negativeHundred, -100L);
    assertValueEquals(negativeHundred, -100);
    assertValueEquals(negativeHundred, (short) -100);
    // Short truncates if the result is too large
    assertValueEquals(new Rational(Integer.MAX_VALUE, 1), (short) Integer.MAX_VALUE);
    assertValueEquals(new Rational(0x00FFFFFF, 1), (short) 0x00FFFFFF);
    assertValueEquals(new Rational(0x00FF00FF, 1), (short) 0x00FF00FF);
}
Also used : Rational(android.util.Rational) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 87 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class NetdEventListenerServiceTest method testOneDnsBatch.

@SmallTest
public void testOneDnsBatch() throws Exception {
    log(105, LATENCIES);
    // one lookup short of a batch event
    log(106, Arrays.copyOf(LATENCIES, BATCH_SIZE - 1));
    verifyLoggedDnsEvents(new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES));
    log(106, Arrays.copyOfRange(LATENCIES, BATCH_SIZE - 1, BATCH_SIZE));
    // reset argument captor
    mDnsEvCaptor = ArgumentCaptor.forClass(DnsEvent.class);
    verifyLoggedDnsEvents(new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(106, EVENT_TYPES, RETURN_CODES, LATENCIES));
}
Also used : DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 88 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class NetdEventListenerServiceTest method testConnectLogging.

@SmallTest
public void testConnectLogging() throws Exception {
    final int OK = 0;
    Thread[] logActions = { // ignored
    connectEventAction(OsConstants.EALREADY, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EALREADY, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.EINPROGRESS, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EINPROGRESS, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.EINPROGRESS, 0, EXAMPLE_IPV6), // valid latencies
    connectEventAction(OK, 110, EXAMPLE_IPV4), connectEventAction(OK, 23, EXAMPLE_IPV4), connectEventAction(OK, 45, EXAMPLE_IPV4), connectEventAction(OK, 56, EXAMPLE_IPV4), connectEventAction(OK, 523, EXAMPLE_IPV6), connectEventAction(OK, 214, EXAMPLE_IPV6), connectEventAction(OK, 67, EXAMPLE_IPV6), // errors
    connectEventAction(OsConstants.EPERM, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EPERM, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EAGAIN, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EACCES, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EACCES, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EACCES, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.EADDRINUSE, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.ETIMEDOUT, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.ETIMEDOUT, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.ETIMEDOUT, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.ECONNREFUSED, 0, EXAMPLE_IPV4) };
    for (Thread t : logActions) {
        t.start();
    }
    for (Thread t : logActions) {
        t.join();
    }
    List<IpConnectivityEvent> events = new ArrayList<>();
    mNetdEventListenerService.flushStatistics(events);
    IpConnectivityEvent got = events.get(0);
    String want = joinLines("time_ms: 0", "transport: 0", "connect_statistics <", "  connect_count: 12", "  errnos_counters <", "    key: 1", "    value: 2", "  >", "  errnos_counters <", "    key: 11", "    value: 1", "  >", "  errnos_counters <", "    key: 13", "    value: 3", "  >", "  errnos_counters <", "    key: 98", "    value: 1", "  >", "  errnos_counters <", "    key: 110", "    value: 3", "  >", "  errnos_counters <", "    key: 111", "    value: 1", "  >", "  ipv6_addr_count: 6", "  latencies_ms: 23", "  latencies_ms: 45", "  latencies_ms: 56", "  latencies_ms: 67", "  latencies_ms: 110", "  latencies_ms: 214", "  latencies_ms: 523");
    verifyConnectEvent(want, got);
}
Also used : IpConnectivityEvent(com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent) ArrayList(java.util.ArrayList) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 89 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class NetworkNotificationManagerTest method testNotificationsNotShownIfNoInternetCapability.

@SmallTest
public void testNotificationsNotShownIfNoInternetCapability() {
    mWifiNai.networkCapabilities = new NetworkCapabilities();
    mWifiNai.networkCapabilities.addTransportType(NetworkCapabilities.TRANSPORT_WIFI);
    mManager.showNotification(102, NO_INTERNET, mWifiNai, mCellNai, null, false);
    mManager.showNotification(103, LOST_INTERNET, mWifiNai, mCellNai, null, false);
    mManager.showNotification(104, NETWORK_SWITCH, mWifiNai, mCellNai, null, false);
    verify(mNotificationManager, never()).notifyAsUser(any(), anyInt(), any(), any());
}
Also used : NetworkCapabilities(android.net.NetworkCapabilities) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 90 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class IpConnectivityMetricsTest method testEndToEndLogging.

@SmallTest
public void testEndToEndLogging() {
    IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
    Parcelable[] events = { new IpReachabilityEvent("wlan0", IpReachabilityEvent.NUD_FAILED), new DhcpClientEvent("wlan0", "SomeState", 192), new DefaultNetworkEvent(102, new int[] { 1, 2, 3 }, 101, true, false), new IpManagerEvent("wlan0", IpManagerEvent.PROVISIONING_OK, 5678), new ValidationProbeEvent(120, 40730, ValidationProbeEvent.PROBE_HTTP, 204), new ApfStats(45000, 10, 2, 2, 1, 2, 4, 2048), new RaEvent(2000, 400, 300, -1, 1000, -1) };
    for (int i = 0; i < events.length; i++) {
        logger.log(100 * (i + 1), events[i]);
    }
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 100", "  transport: 0", "  ip_reachability_event <", "    event_type: 512", "    if_name: \"wlan0\"", "  >", ">", "events <", "  time_ms: 200", "  transport: 0", "  dhcp_event <", "    duration_ms: 192", "    if_name: \"wlan0\"", "    state_transition: \"SomeState\"", "  >", ">", "events <", "  time_ms: 300", "  transport: 0", "  default_network_event <", "    network_id <", "      network_id: 102", "    >", "    previous_network_id <", "      network_id: 101", "    >", "    previous_network_ip_support: 1", "    transport_types: 1", "    transport_types: 2", "    transport_types: 3", "  >", ">", "events <", "  time_ms: 400", "  transport: 0", "  ip_provisioning_event <", "    event_type: 1", "    if_name: \"wlan0\"", "    latency_ms: 5678", "  >", ">", "events <", "  time_ms: 500", "  transport: 0", "  validation_probe_event <", "    latency_ms: 40730", "    network_id <", "      network_id: 120", "    >", "    probe_result: 204", "    probe_type: 1", "  >", ">", "events <", "  time_ms: 600", "  transport: 0", "  apf_statistics <", "    dropped_ras: 2", "    duration_ms: 45000", "    matching_ras: 2", "    max_program_size: 2048", "    parse_errors: 2", "    program_updates: 4", "    received_ras: 10", "    zero_lifetime_ras: 1", "  >", ">", "events <", "  time_ms: 700", "  transport: 0", "  ra_event <", "    dnssl_lifetime: -1", "    prefix_preferred_lifetime: 300", "    prefix_valid_lifetime: 400", "    rdnss_lifetime: 1000", "    route_info_lifetime: -1", "    router_lifetime: 2000", "  >", ">", "version: 2");
    verifySerialization(want, getdump("flush"));
}
Also used : DefaultNetworkEvent(android.net.metrics.DefaultNetworkEvent) RaEvent(android.net.metrics.RaEvent) ApfStats(android.net.metrics.ApfStats) IpConnectivityLog(android.net.metrics.IpConnectivityLog) DhcpClientEvent(android.net.metrics.DhcpClientEvent) IpManagerEvent(android.net.metrics.IpManagerEvent) ValidationProbeEvent(android.net.metrics.ValidationProbeEvent) Parcelable(android.os.Parcelable) IpReachabilityEvent(android.net.metrics.IpReachabilityEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SmallTest (android.test.suitebuilder.annotation.SmallTest)2108 Test (org.junit.Test)235 Parcel (android.os.Parcel)153 ArrayList (java.util.ArrayList)104 Time (android.text.format.Time)97 Rect (android.graphics.Rect)94 TelephonyTest (com.android.internal.telephony.TelephonyTest)84 Bundle (android.os.Bundle)77 ByteBuffer (java.nio.ByteBuffer)71 Intent (android.content.Intent)69 LinkProperties (android.net.LinkProperties)68 SpannableString (android.text.SpannableString)61 FlakyTest (android.support.test.filters.FlakyTest)58 DhcpPacket (android.net.dhcp.DhcpPacket)52 Rational (android.util.Rational)50 NetworkRequest (android.net.NetworkRequest)48 File (java.io.File)47 RouteInfo (android.net.RouteInfo)45 BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)45 ParcelUuid (android.os.ParcelUuid)43