Loading services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java +13 −0 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,7 @@ import static com.android.server.net.NetworkPolicyManagerService.TYPE_LIMIT; import static com.android.server.net.NetworkPolicyManagerService.TYPE_LIMIT_SNOOZED; import static com.android.server.net.NetworkPolicyManagerService.TYPE_LIMIT_SNOOZED; import static com.android.server.net.NetworkPolicyManagerService.TYPE_WARNING; import static com.android.server.net.NetworkPolicyManagerService.TYPE_WARNING; import static org.easymock.EasyMock.anyInt; import static org.easymock.EasyMock.anyInt; import static org.easymock.EasyMock.anyLong; import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.capture; import static org.easymock.EasyMock.capture; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.createMock; Loading Loading @@ -229,6 +230,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { // expect to answer screen status during systemReady() // expect to answer screen status during systemReady() expect(mPowerManager.isScreenOn()).andReturn(true).atLeastOnce(); expect(mPowerManager.isScreenOn()).andReturn(true).atLeastOnce(); expect(mNetworkManager.isBandwidthControlEnabled()).andReturn(true).atLeastOnce(); expectCurrentTime(); expectCurrentTime(); replay(); replay(); Loading Loading @@ -613,6 +615,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce(); expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce(); expectCurrentTime(); expectCurrentTime(); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(); future = expectMeteredIfacesChanged(); replay(); replay(); Loading @@ -637,6 +640,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectSetInterfaceQuota(TEST_IFACE, (2 * MB_IN_BYTES) - 512); expectSetInterfaceQuota(TEST_IFACE, (2 * MB_IN_BYTES) - 512); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(TEST_IFACE); future = expectMeteredIfacesChanged(TEST_IFACE); replay(); replay(); Loading Loading @@ -704,6 +708,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectPolicyDataEnable(TYPE_WIFI, true); expectPolicyDataEnable(TYPE_WIFI, true); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(); future = expectMeteredIfacesChanged(); replay(); replay(); Loading @@ -730,6 +735,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectSetInterfaceQuota(TEST_IFACE, 2 * MB_IN_BYTES); expectSetInterfaceQuota(TEST_IFACE, 2 * MB_IN_BYTES); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(TEST_IFACE); future = expectMeteredIfacesChanged(TEST_IFACE); replay(); replay(); Loading Loading @@ -794,6 +800,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { // still restricted. // still restricted. expectRemoveInterfaceQuota(TEST_IFACE); expectRemoveInterfaceQuota(TEST_IFACE); expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectAdvisePersistThreshold(); expectMeteredIfacesChanged(TEST_IFACE); expectMeteredIfacesChanged(TEST_IFACE); future = expectClearNotifications(); future = expectClearNotifications(); Loading Loading @@ -835,6 +842,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(TEST_IFACE); future = expectMeteredIfacesChanged(TEST_IFACE); replay(); replay(); Loading Loading @@ -943,6 +951,11 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { return future; return future; } } private void expectAdvisePersistThreshold() throws Exception { mStatsService.advisePersistThreshold(anyLong()); expectLastCall().anyTimes(); } private static class TestAbstractFuture<T> extends AbstractFuture<T> { private static class TestAbstractFuture<T> extends AbstractFuture<T> { @Override @Override public T get() throws InterruptedException, ExecutionException { public T get() throws InterruptedException, ExecutionException { Loading services/tests/servicestests/src/com/android/server/net/NetworkStatsCollectionTest.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // verify that history read correctly // verify that history read correctly assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 636014522L, 709291L, 88037144L, 518820L); 636016770L, 709306L, 88038768L, 518836L); // now export into a unified format // now export into a unified format final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); Loading @@ -70,7 +70,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // and read back into structure, verifying that totals are same // and read back into structure, verifying that totals are same collection.read(new ByteArrayInputStream(bos.toByteArray())); collection.read(new ByteArrayInputStream(bos.toByteArray())); assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 636014522L, 709291L, 88037144L, 518820L); 636016770L, 709306L, 88038768L, 518836L); } } public void testReadLegacyUid() throws Exception { public void testReadLegacyUid() throws Exception { Loading @@ -82,7 +82,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // verify that history read correctly // verify that history read correctly assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 637073904L, 711398L, 88342093L, 521006L); 637076152L, 711413L, 88343717L, 521022L); // now export into a unified format // now export into a unified format final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); Loading @@ -96,7 +96,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // and read back into structure, verifying that totals are same // and read back into structure, verifying that totals are same collection.read(new ByteArrayInputStream(bos.toByteArray())); collection.read(new ByteArrayInputStream(bos.toByteArray())); assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 637073904L, 711398L, 88342093L, 521006L); 637076152L, 711413L, 88343717L, 521022L); } } public void testReadLegacyUidTags() throws Exception { public void testReadLegacyUidTags() throws Exception { Loading Loading
services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java +13 −0 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,7 @@ import static com.android.server.net.NetworkPolicyManagerService.TYPE_LIMIT; import static com.android.server.net.NetworkPolicyManagerService.TYPE_LIMIT_SNOOZED; import static com.android.server.net.NetworkPolicyManagerService.TYPE_LIMIT_SNOOZED; import static com.android.server.net.NetworkPolicyManagerService.TYPE_WARNING; import static com.android.server.net.NetworkPolicyManagerService.TYPE_WARNING; import static org.easymock.EasyMock.anyInt; import static org.easymock.EasyMock.anyInt; import static org.easymock.EasyMock.anyLong; import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.capture; import static org.easymock.EasyMock.capture; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.createMock; Loading Loading @@ -229,6 +230,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { // expect to answer screen status during systemReady() // expect to answer screen status during systemReady() expect(mPowerManager.isScreenOn()).andReturn(true).atLeastOnce(); expect(mPowerManager.isScreenOn()).andReturn(true).atLeastOnce(); expect(mNetworkManager.isBandwidthControlEnabled()).andReturn(true).atLeastOnce(); expectCurrentTime(); expectCurrentTime(); replay(); replay(); Loading Loading @@ -613,6 +615,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce(); expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce(); expectCurrentTime(); expectCurrentTime(); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(); future = expectMeteredIfacesChanged(); replay(); replay(); Loading @@ -637,6 +640,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectSetInterfaceQuota(TEST_IFACE, (2 * MB_IN_BYTES) - 512); expectSetInterfaceQuota(TEST_IFACE, (2 * MB_IN_BYTES) - 512); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(TEST_IFACE); future = expectMeteredIfacesChanged(TEST_IFACE); replay(); replay(); Loading Loading @@ -704,6 +708,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectPolicyDataEnable(TYPE_WIFI, true); expectPolicyDataEnable(TYPE_WIFI, true); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(); future = expectMeteredIfacesChanged(); replay(); replay(); Loading @@ -730,6 +735,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectSetInterfaceQuota(TEST_IFACE, 2 * MB_IN_BYTES); expectSetInterfaceQuota(TEST_IFACE, 2 * MB_IN_BYTES); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(TEST_IFACE); future = expectMeteredIfacesChanged(TEST_IFACE); replay(); replay(); Loading Loading @@ -794,6 +800,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { // still restricted. // still restricted. expectRemoveInterfaceQuota(TEST_IFACE); expectRemoveInterfaceQuota(TEST_IFACE); expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectAdvisePersistThreshold(); expectMeteredIfacesChanged(TEST_IFACE); expectMeteredIfacesChanged(TEST_IFACE); future = expectClearNotifications(); future = expectClearNotifications(); Loading Loading @@ -835,6 +842,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE); expectClearNotifications(); expectClearNotifications(); expectAdvisePersistThreshold(); future = expectMeteredIfacesChanged(TEST_IFACE); future = expectMeteredIfacesChanged(TEST_IFACE); replay(); replay(); Loading Loading @@ -943,6 +951,11 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { return future; return future; } } private void expectAdvisePersistThreshold() throws Exception { mStatsService.advisePersistThreshold(anyLong()); expectLastCall().anyTimes(); } private static class TestAbstractFuture<T> extends AbstractFuture<T> { private static class TestAbstractFuture<T> extends AbstractFuture<T> { @Override @Override public T get() throws InterruptedException, ExecutionException { public T get() throws InterruptedException, ExecutionException { Loading
services/tests/servicestests/src/com/android/server/net/NetworkStatsCollectionTest.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // verify that history read correctly // verify that history read correctly assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 636014522L, 709291L, 88037144L, 518820L); 636016770L, 709306L, 88038768L, 518836L); // now export into a unified format // now export into a unified format final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); Loading @@ -70,7 +70,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // and read back into structure, verifying that totals are same // and read back into structure, verifying that totals are same collection.read(new ByteArrayInputStream(bos.toByteArray())); collection.read(new ByteArrayInputStream(bos.toByteArray())); assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 636014522L, 709291L, 88037144L, 518820L); 636016770L, 709306L, 88038768L, 518836L); } } public void testReadLegacyUid() throws Exception { public void testReadLegacyUid() throws Exception { Loading @@ -82,7 +82,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // verify that history read correctly // verify that history read correctly assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 637073904L, 711398L, 88342093L, 521006L); 637076152L, 711413L, 88343717L, 521022L); // now export into a unified format // now export into a unified format final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); Loading @@ -96,7 +96,7 @@ public class NetworkStatsCollectionTest extends AndroidTestCase { // and read back into structure, verifying that totals are same // and read back into structure, verifying that totals are same collection.read(new ByteArrayInputStream(bos.toByteArray())); collection.read(new ByteArrayInputStream(bos.toByteArray())); assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), 637073904L, 711398L, 88342093L, 521006L); 637076152L, 711413L, 88343717L, 521022L); } } public void testReadLegacyUidTags() throws Exception { public void testReadLegacyUidTags() throws Exception { Loading