diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-06-11 22:16:55 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-06-11 22:17:17 -0700 |
commit | 4a97122ebf4d92a3f94402041729d77905e6c0c0 (patch) | |
tree | 2dce98de643ebbfe98c06c70b54d743362a900d2 /services/tests | |
parent | 39ebc2195ed16b9e955dd57f5c95212bb7b934b6 (diff) | |
download | frameworks_base-4a97122ebf4d92a3f94402041729d77905e6c0c0.zip frameworks_base-4a97122ebf4d92a3f94402041729d77905e6c0c0.tar.gz frameworks_base-4a97122ebf4d92a3f94402041729d77905e6c0c0.tar.bz2 |
Growable NetworkStats object instead of builder.
NetworkStats now grows in place with arraycopy() instead of callers
needing to know record count a priori. Better growth calculation for
both NetworkStats and NetworkStatsHistory; 50% each time. Better
estimates of buckets needed in calling services.
Change-Id: I3adbffa0b7407612cc6349d9135a8b4eb63cd440
Diffstat (limited to 'services/tests')
3 files changed, 15 insertions, 16 deletions
diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java index 1eeb56b..f831ca3 100644 --- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java @@ -357,8 +357,8 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectTime(TIME_MAR_10 + elapsedRealtime); // pretend that 512 bytes total have happened - stats = new NetworkStats.Builder(elapsedRealtime, 1).addEntry( - TEST_IFACE, UID_ALL, 256L, 256L).build(); + stats = new NetworkStats(elapsedRealtime, 1) + .addEntry(TEST_IFACE, UID_ALL, 256L, 256L); expect(mStatsService.getSummaryForNetwork(TIME_FEB_15, TIME_MAR_10, TEMPLATE_WIFI, null)) .andReturn(stats).atLeastOnce(); diff --git a/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java index d6e4b8b..2457ff3 100644 --- a/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java @@ -145,8 +145,8 @@ public class NetworkStatsServiceTest extends AndroidTestCase { elapsedRealtime += HOUR_IN_MILLIS; expectTime(TEST_START + elapsedRealtime); expectDefaultSettings(); - expectNetworkStatsSummary(new NetworkStats.Builder(elapsedRealtime, 1) - .addEntry(TEST_IFACE, UID_ALL, 1024L, 2048L).build()); + expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1) + .addEntry(TEST_IFACE, UID_ALL, 1024L, 2048L)); expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime)); replay(); @@ -161,8 +161,8 @@ public class NetworkStatsServiceTest extends AndroidTestCase { elapsedRealtime += DAY_IN_MILLIS; expectTime(TEST_START + elapsedRealtime); expectDefaultSettings(); - expectNetworkStatsSummary(new NetworkStats.Builder(elapsedRealtime, 1) - .addEntry(TEST_IFACE, UID_ALL, 4096L, 8192L).build()); + expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1) + .addEntry(TEST_IFACE, UID_ALL, 4096L, 8192L)); expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime)); replay(); @@ -196,12 +196,12 @@ public class NetworkStatsServiceTest extends AndroidTestCase { elapsedRealtime += HOUR_IN_MILLIS; expectTime(TEST_START + elapsedRealtime); expectDefaultSettings(); - expectNetworkStatsSummary(new NetworkStats.Builder(elapsedRealtime, 1) - .addEntry(TEST_IFACE, UID_ALL, 1024L, 2048L).build()); + expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1) + .addEntry(TEST_IFACE, UID_ALL, 1024L, 2048L)); // TODO: switch these stats to specific iface - expectNetworkStatsDetail(new NetworkStats.Builder(elapsedRealtime, 2) + expectNetworkStatsDetail(new NetworkStats(elapsedRealtime, 2) .addEntry(IFACE_ALL, TEST_UID_1, 512L, 256L) - .addEntry(IFACE_ALL, TEST_UID_2, 128L, 128L).build()); + .addEntry(IFACE_ALL, TEST_UID_2, 128L, 128L)); replay(); mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL)); @@ -262,8 +262,8 @@ public class NetworkStatsServiceTest extends AndroidTestCase { elapsedRealtime += 2 * HOUR_IN_MILLIS; expectTime(TEST_START + elapsedRealtime); expectSettings(0L, HOUR_IN_MILLIS, WEEK_IN_MILLIS); - expectNetworkStatsSummary(new NetworkStats.Builder(elapsedRealtime, 1) - .addEntry(TEST_IFACE, UID_ALL, 512L, 512L).build()); + expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1) + .addEntry(TEST_IFACE, UID_ALL, 512L, 512L)); expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime)); replay(); @@ -378,7 +378,7 @@ public class NetworkStatsServiceTest extends AndroidTestCase { } private static NetworkStats buildEmptyStats(long elapsedRealtime) { - return new NetworkStats.Builder(elapsedRealtime, 0).build(); + return new NetworkStats(elapsedRealtime, 0); } private void replay() { diff --git a/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java b/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java index d1ee4f6..30afdd8 100644 --- a/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java @@ -288,11 +288,10 @@ public class ThrottleServiceTest extends AndroidTestCase { */ public void expectGetInterfaceCounter(long rx, long tx) throws Exception { // TODO: provide elapsedRealtime mock to match TimeAuthority - final NetworkStats.Builder stats = new NetworkStats.Builder( - SystemClock.elapsedRealtime(), 1); + final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1); stats.addEntry(TEST_IFACE, NetworkStats.UID_ALL, rx, tx); - expect(mMockNMService.getNetworkStatsSummary()).andReturn(stats.build()).atLeastOnce(); + expect(mMockNMService.getNetworkStatsSummary()).andReturn(stats).atLeastOnce(); } /** |