Loading tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java +35 −16 Original line number Diff line number Diff line Loading @@ -39,13 +39,13 @@ import android.net.metrics.IpReachabilityEvent; import android.net.metrics.NetworkEvent; import android.net.metrics.RaEvent; import android.net.metrics.ValidationProbeEvent; import junit.framework.TestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.Arrays; import junit.framework.TestCase; public class IpConnectivityEventBuilderTest extends TestCase { @SmallTest public void testDefaultNetworkEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DefaultNetworkEvent.class), Loading @@ -58,6 +58,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " default_network_event <", " network_id <", " network_id: 102", Loading @@ -70,13 +72,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " transport_types: 2", " transport_types: 3", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testDhcpClientEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DhcpClientEvent.class), Loading @@ -87,19 +89,20 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dhcp_event <", " duration_ms: 192", " error_code: 0", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testDhcpErrorEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DhcpErrorEvent.class), Loading @@ -109,19 +112,20 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dhcp_event <", " duration_ms: 0", " error_code: 50397184", " if_name: \"wlan0\"", " state_transition: \"\"", " error_code: 50397184", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testDnsEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DnsEvent.class), Loading @@ -133,6 +137,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dns_lookup_batch <", " event_types: 1", " event_types: 1", Loading Loading @@ -162,13 +168,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " return_codes: 200", " return_codes: 178", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testIpManagerEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(IpManagerEvent.class), Loading @@ -179,18 +185,20 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testIpReachabilityEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(IpReachabilityEvent.class), Loading @@ -200,17 +208,19 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testNetworkEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(NetworkEvent.class), Loading @@ -221,6 +231,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " network_event <", " event_type: 5", " latency_ms: 20410", Loading @@ -228,13 +240,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " network_id: 100", " >", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testValidationProbeEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(ValidationProbeEvent.class), Loading @@ -247,6 +259,7 @@ public class IpConnectivityEventBuilderTest extends TestCase { "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", Loading @@ -261,6 +274,7 @@ public class IpConnectivityEventBuilderTest extends TestCase { verifySerialization(want, ev); } @SmallTest public void testApfProgramEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(ApfProgramEvent.class), Loading @@ -273,6 +287,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " apf_program_event <", " current_ras: 9", " drop_multicast: true", Loading @@ -281,13 +297,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " lifetime: 200", " program_length: 2048", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testApfStatsSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(ApfStats.class), Loading @@ -303,6 +319,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", Loading @@ -313,13 +331,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " received_ras: 10", " zero_lifetime_ras: 1", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testRaEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(RaEvent.class), Loading @@ -333,6 +351,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", Loading @@ -341,7 +361,6 @@ public class IpConnectivityEventBuilderTest extends TestCase { " route_info_lifetime: -1", " router_lifetime: 2000", " >", " time_ms: 1", ">", "version: 2"); Loading tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java +23 −15 Original line number Diff line number Diff line Loading @@ -32,22 +32,19 @@ import android.net.metrics.IpReachabilityEvent; import android.net.metrics.RaEvent; import android.net.metrics.ValidationProbeEvent; import android.os.Parcelable; import android.test.suitebuilder.annotation.SmallTest; import android.util.Base64; import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass; import junit.framework.TestCase; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import junit.framework.TestCase; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; public class IpConnectivityMetricsTest extends TestCase { static final IpReachabilityEvent FAKE_EV = Loading @@ -63,6 +60,7 @@ public class IpConnectivityMetricsTest extends TestCase { mService = new IpConnectivityMetrics(mCtx, (ctx) -> 2000); } @SmallTest public void testLoggingEvents() throws Exception { IpConnectivityLog logger = new IpConnectivityLog(mMockService); Loading @@ -76,6 +74,7 @@ public class IpConnectivityMetricsTest extends TestCase { assertEventsEqual(expectedEvent(3), got.get(2)); } @SmallTest public void testLoggingEventsWithMultipleCallers() throws Exception { IpConnectivityLog logger = new IpConnectivityLog(mMockService); Loading Loading @@ -103,6 +102,7 @@ public class IpConnectivityMetricsTest extends TestCase { } } @SmallTest public void testBufferFlushing() { String output1 = getdump("flush"); assertEquals("", output1); Loading @@ -115,6 +115,7 @@ public class IpConnectivityMetricsTest extends TestCase { assertEquals("", output3); } @SmallTest public void testRateLimiting() { final IpConnectivityLog logger = new IpConnectivityLog(mService.impl); final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0); Loading @@ -136,6 +137,7 @@ public class IpConnectivityMetricsTest extends TestCase { assertEquals("", output2); } @SmallTest public void testEndToEndLogging() { IpConnectivityLog logger = new IpConnectivityLog(mService.impl); Loading @@ -156,22 +158,25 @@ public class IpConnectivityMetricsTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 100", " transport: 0", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", " time_ms: 100", ">", "events <", " time_ms: 200", " transport: 0", " dhcp_event <", " duration_ms: 192", " error_code: 0", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", " time_ms: 200", ">", "events <", " time_ms: 300", " transport: 0", " default_network_event <", " network_id <", " network_id: 102", Loading @@ -184,18 +189,19 @@ public class IpConnectivityMetricsTest extends TestCase { " transport_types: 2", " transport_types: 3", " >", " time_ms: 300", ">", "events <", " time_ms: 400", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", " time_ms: 400", ">", "events <", " time_ms: 500", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", Loading @@ -206,6 +212,8 @@ public class IpConnectivityMetricsTest extends TestCase { " >", ">", "events <", " time_ms: 600", " transport: 0", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", Loading @@ -216,9 +224,10 @@ public class IpConnectivityMetricsTest extends TestCase { " received_ras: 10", " zero_lifetime_ras: 1", " >", " time_ms: 600", ">", "events <", " time_ms: 700", " transport: 0", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", Loading @@ -227,7 +236,6 @@ public class IpConnectivityMetricsTest extends TestCase { " route_info_lifetime: -1", " router_lifetime: 2000", " >", " time_ms: 700", ">", "version: 2"); Loading Loading
tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java +35 −16 Original line number Diff line number Diff line Loading @@ -39,13 +39,13 @@ import android.net.metrics.IpReachabilityEvent; import android.net.metrics.NetworkEvent; import android.net.metrics.RaEvent; import android.net.metrics.ValidationProbeEvent; import junit.framework.TestCase; import android.test.suitebuilder.annotation.SmallTest; import java.util.Arrays; import junit.framework.TestCase; public class IpConnectivityEventBuilderTest extends TestCase { @SmallTest public void testDefaultNetworkEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DefaultNetworkEvent.class), Loading @@ -58,6 +58,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " default_network_event <", " network_id <", " network_id: 102", Loading @@ -70,13 +72,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " transport_types: 2", " transport_types: 3", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testDhcpClientEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DhcpClientEvent.class), Loading @@ -87,19 +89,20 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dhcp_event <", " duration_ms: 192", " error_code: 0", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testDhcpErrorEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DhcpErrorEvent.class), Loading @@ -109,19 +112,20 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dhcp_event <", " duration_ms: 0", " error_code: 50397184", " if_name: \"wlan0\"", " state_transition: \"\"", " error_code: 50397184", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testDnsEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(DnsEvent.class), Loading @@ -133,6 +137,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dns_lookup_batch <", " event_types: 1", " event_types: 1", Loading Loading @@ -162,13 +168,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " return_codes: 200", " return_codes: 178", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testIpManagerEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(IpManagerEvent.class), Loading @@ -179,18 +185,20 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testIpReachabilityEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(IpReachabilityEvent.class), Loading @@ -200,17 +208,19 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testNetworkEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(NetworkEvent.class), Loading @@ -221,6 +231,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " network_event <", " event_type: 5", " latency_ms: 20410", Loading @@ -228,13 +240,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " network_id: 100", " >", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testValidationProbeEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(ValidationProbeEvent.class), Loading @@ -247,6 +259,7 @@ public class IpConnectivityEventBuilderTest extends TestCase { "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", Loading @@ -261,6 +274,7 @@ public class IpConnectivityEventBuilderTest extends TestCase { verifySerialization(want, ev); } @SmallTest public void testApfProgramEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(ApfProgramEvent.class), Loading @@ -273,6 +287,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " apf_program_event <", " current_ras: 9", " drop_multicast: true", Loading @@ -281,13 +297,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " lifetime: 200", " program_length: 2048", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testApfStatsSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(ApfStats.class), Loading @@ -303,6 +319,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", Loading @@ -313,13 +331,13 @@ public class IpConnectivityEventBuilderTest extends TestCase { " received_ras: 10", " zero_lifetime_ras: 1", " >", " time_ms: 1", ">", "version: 2"); verifySerialization(want, ev); } @SmallTest public void testRaEventSerialization() { ConnectivityMetricsEvent ev = describeIpEvent( aType(RaEvent.class), Loading @@ -333,6 +351,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", Loading @@ -341,7 +361,6 @@ public class IpConnectivityEventBuilderTest extends TestCase { " route_info_lifetime: -1", " router_lifetime: 2000", " >", " time_ms: 1", ">", "version: 2"); Loading
tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java +23 −15 Original line number Diff line number Diff line Loading @@ -32,22 +32,19 @@ import android.net.metrics.IpReachabilityEvent; import android.net.metrics.RaEvent; import android.net.metrics.ValidationProbeEvent; import android.os.Parcelable; import android.test.suitebuilder.annotation.SmallTest; import android.util.Base64; import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass; import junit.framework.TestCase; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import junit.framework.TestCase; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; public class IpConnectivityMetricsTest extends TestCase { static final IpReachabilityEvent FAKE_EV = Loading @@ -63,6 +60,7 @@ public class IpConnectivityMetricsTest extends TestCase { mService = new IpConnectivityMetrics(mCtx, (ctx) -> 2000); } @SmallTest public void testLoggingEvents() throws Exception { IpConnectivityLog logger = new IpConnectivityLog(mMockService); Loading @@ -76,6 +74,7 @@ public class IpConnectivityMetricsTest extends TestCase { assertEventsEqual(expectedEvent(3), got.get(2)); } @SmallTest public void testLoggingEventsWithMultipleCallers() throws Exception { IpConnectivityLog logger = new IpConnectivityLog(mMockService); Loading Loading @@ -103,6 +102,7 @@ public class IpConnectivityMetricsTest extends TestCase { } } @SmallTest public void testBufferFlushing() { String output1 = getdump("flush"); assertEquals("", output1); Loading @@ -115,6 +115,7 @@ public class IpConnectivityMetricsTest extends TestCase { assertEquals("", output3); } @SmallTest public void testRateLimiting() { final IpConnectivityLog logger = new IpConnectivityLog(mService.impl); final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0); Loading @@ -136,6 +137,7 @@ public class IpConnectivityMetricsTest extends TestCase { assertEquals("", output2); } @SmallTest public void testEndToEndLogging() { IpConnectivityLog logger = new IpConnectivityLog(mService.impl); Loading @@ -156,22 +158,25 @@ public class IpConnectivityMetricsTest extends TestCase { String want = joinLines( "dropped_events: 0", "events <", " time_ms: 100", " transport: 0", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", " time_ms: 100", ">", "events <", " time_ms: 200", " transport: 0", " dhcp_event <", " duration_ms: 192", " error_code: 0", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", " time_ms: 200", ">", "events <", " time_ms: 300", " transport: 0", " default_network_event <", " network_id <", " network_id: 102", Loading @@ -184,18 +189,19 @@ public class IpConnectivityMetricsTest extends TestCase { " transport_types: 2", " transport_types: 3", " >", " time_ms: 300", ">", "events <", " time_ms: 400", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", " time_ms: 400", ">", "events <", " time_ms: 500", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", Loading @@ -206,6 +212,8 @@ public class IpConnectivityMetricsTest extends TestCase { " >", ">", "events <", " time_ms: 600", " transport: 0", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", Loading @@ -216,9 +224,10 @@ public class IpConnectivityMetricsTest extends TestCase { " received_ras: 10", " zero_lifetime_ras: 1", " >", " time_ms: 600", ">", "events <", " time_ms: 700", " transport: 0", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", Loading @@ -227,7 +236,6 @@ public class IpConnectivityMetricsTest extends TestCase { " route_info_lifetime: -1", " router_lifetime: 2000", " >", " time_ms: 700", ">", "version: 2"); Loading