diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-07-14 20:37:37 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-07-14 20:43:27 -0700 |
commit | 4e814c348ce205fcc1a273427f95ef1d100ed60c (patch) | |
tree | 6464b7f58b1177ce8a1ffb0d8f8e9298ca861e84 /services/tests | |
parent | 4a8df318b06a85a90309149ebcbff3b25077de15 (diff) | |
download | frameworks_base-4e814c348ce205fcc1a273427f95ef1d100ed60c.zip frameworks_base-4e814c348ce205fcc1a273427f95ef1d100ed60c.tar.gz frameworks_base-4e814c348ce205fcc1a273427f95ef1d100ed60c.tar.bz2 |
Hide NetworkTemplate details, buffered stats I/O.
Move template matching to builder methods instead of exposing the
internal constants. Also rule to match Ethernet usage. Buffer
reading and writing of network stats, making operations 5x faster.
Change-Id: Iedb2d0ab3b26a976811c050f84a164e909eb74b6
Diffstat (limited to 'services/tests')
-rw-r--r-- | services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java | 3 | ||||
-rw-r--r-- | services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java | 14 |
2 files changed, 8 insertions, 9 deletions
diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java index 33fd355..504ba42 100644 --- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java @@ -27,7 +27,6 @@ import static android.net.NetworkPolicyManager.RULE_REJECT_METERED; import static android.net.NetworkPolicyManager.computeLastCycleBoundary; import static android.net.NetworkStats.TAG_NONE; import static android.net.NetworkStats.UID_ALL; -import static android.net.NetworkTemplate.MATCH_WIFI; import static org.easymock.EasyMock.anyInt; import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.capture; @@ -88,7 +87,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { private static final long TEST_START = 1194220800000L; private static final String TEST_IFACE = "test0"; - private static NetworkTemplate sTemplateWifi = new NetworkTemplate(MATCH_WIFI, null); + private static NetworkTemplate sTemplateWifi = NetworkTemplate.buildTemplateWifi(); private BroadcastInterceptingContext mServiceContext; private File mPolicyDir; diff --git a/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java index ac74063..bd80af9 100644 --- a/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java @@ -25,8 +25,8 @@ import static android.net.ConnectivityManager.TYPE_WIMAX; import static android.net.NetworkStats.IFACE_ALL; import static android.net.NetworkStats.TAG_NONE; import static android.net.NetworkStats.UID_ALL; -import static android.net.NetworkTemplate.MATCH_MOBILE_ALL; -import static android.net.NetworkTemplate.MATCH_WIFI; +import static android.net.NetworkTemplate.buildTemplateMobileAll; +import static android.net.NetworkTemplate.buildTemplateWifi; import static android.net.TrafficStats.UID_REMOVED; import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.text.format.DateUtils.HOUR_IN_MILLIS; @@ -81,9 +81,9 @@ public class NetworkStatsServiceTest extends AndroidTestCase { private static final String IMSI_1 = "310004"; private static final String IMSI_2 = "310260"; - private static NetworkTemplate sTemplateWifi = new NetworkTemplate(MATCH_WIFI, null); - private static NetworkTemplate sTemplateImsi1 = new NetworkTemplate(MATCH_MOBILE_ALL, IMSI_1); - private static NetworkTemplate sTemplateImsi2 = new NetworkTemplate(MATCH_MOBILE_ALL, IMSI_2); + private static NetworkTemplate sTemplateWifi = buildTemplateWifi(); + private static NetworkTemplate sTemplateImsi1 = buildTemplateMobileAll(IMSI_1); + private static NetworkTemplate sTemplateImsi2 = buildTemplateMobileAll(IMSI_2); private static final int UID_RED = 1001; private static final int UID_BLUE = 1002; @@ -290,7 +290,7 @@ public class NetworkStatsServiceTest extends AndroidTestCase { mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL)); // verify service recorded history - history = mService.getHistoryForNetwork(new NetworkTemplate(MATCH_WIFI, null)); + history = mService.getHistoryForNetwork(sTemplateWifi); assertValues(history, Long.MIN_VALUE, Long.MAX_VALUE, 512L, 512L); assertEquals(HOUR_IN_MILLIS, history.getBucketDuration()); assertEquals(2, history.size()); @@ -307,7 +307,7 @@ public class NetworkStatsServiceTest extends AndroidTestCase { mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL)); // verify identical stats, but spread across 4 buckets now - history = mService.getHistoryForNetwork(new NetworkTemplate(MATCH_WIFI, null)); + history = mService.getHistoryForNetwork(sTemplateWifi); assertValues(history, Long.MIN_VALUE, Long.MAX_VALUE, 512L, 512L); assertEquals(30 * MINUTE_IN_MILLIS, history.getBucketDuration()); assertEquals(4, history.size()); |