diff options
| author | junyulai <junyulai@google.com> | 2022-02-08 16:52:45 +0800 |
|---|---|---|
| committer | junyulai <junyulai@google.com> | 2022-02-09 17:18:19 +0800 |
| commit | 86fd7ea63662fbd00f7d1b393d435a1e0e365b87 (patch) | |
| tree | 2e295370b905f6e3bfc183d142a0cfb2d04d1c7f /tests/unit/java/android/net/NetworkStatsCollectionTest.java | |
| parent | cc7f866d95b14f0d4c297a9be77f3ded9b3a15aa (diff) | |
[MS83] Add Cts for NetworkStatsCollection/History builders
Test: 1. atest CtsNetTestCases:android.net.netstats.NetworkStatsHistoryTest
2. atest CtsNetTestCases:android.net.netstats.NetworkStatsCollectionTest
3. atest FrameworksNetTests
Ignore-AOSP-First: Required API is not in downstream yet
Bug: 218441356
Change-Id: If3d45325623cad987aab35f89c55f84042271adf
Diffstat (limited to 'tests/unit/java/android/net/NetworkStatsCollectionTest.java')
| -rw-r--r-- | tests/unit/java/android/net/NetworkStatsCollectionTest.java | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/tests/unit/java/android/net/NetworkStatsCollectionTest.java b/tests/unit/java/android/net/NetworkStatsCollectionTest.java index c27ee931eb..bc2b53228a 100644 --- a/tests/unit/java/android/net/NetworkStatsCollectionTest.java +++ b/tests/unit/java/android/net/NetworkStatsCollectionTest.java @@ -38,13 +38,11 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import android.content.res.Resources; -import android.net.NetworkStatsCollection.Key; import android.os.Process; import android.os.UserHandle; import android.telephony.SubscriptionPlan; import android.telephony.TelephonyManager; import android.text.format.DateUtils; -import android.util.ArrayMap; import android.util.RecurrenceRule; import androidx.test.InstrumentationRegistry; @@ -75,7 +73,6 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * Tests for {@link NetworkStatsCollection}. @@ -533,52 +530,6 @@ public class NetworkStatsCollectionTest { assertThrows(ArithmeticException.class, () -> multiplySafeByRational(30, 3, 0)); } - @Test - public void testBuilder() { - final Map<Key, NetworkStatsHistory> expectedEntries = new ArrayMap<>(); - final NetworkStats.Entry entry = new NetworkStats.Entry(); - final NetworkIdentitySet ident = new NetworkIdentitySet(); - final Key key1 = new Key(ident, 0, 0, 0); - final Key key2 = new Key(ident, 1, 0, 0); - final long bucketDuration = 10; - - final NetworkStatsHistory.Entry entry1 = new NetworkStatsHistory.Entry(10, 10, 40, - 4, 50, 5, 60); - final NetworkStatsHistory.Entry entry2 = new NetworkStatsHistory.Entry(30, 10, 3, - 41, 7, 1, 0); - - NetworkStatsHistory history1 = new NetworkStatsHistory.Builder(10, 5) - .addEntry(entry1) - .addEntry(entry2) - .build(); - - NetworkStatsHistory history2 = new NetworkStatsHistory(10, 5); - - NetworkStatsCollection actualCollection = new NetworkStatsCollection.Builder(bucketDuration) - .addEntry(key1, history1) - .addEntry(key2, history2) - .build(); - - // The builder will omit any entry with empty history. Thus, history2 - // is not expected in the result collection. - expectedEntries.put(key1, history1); - - final Map<Key, NetworkStatsHistory> actualEntries = actualCollection.getEntries(); - - assertEquals(expectedEntries.size(), actualEntries.size()); - for (Key expectedKey : expectedEntries.keySet()) { - final NetworkStatsHistory expectedHistory = expectedEntries.get(expectedKey); - - final NetworkStatsHistory actualHistory = actualEntries.get(expectedKey); - assertNotNull(actualHistory); - - assertEquals(expectedHistory.getEntries(), actualHistory.getEntries()); - - actualEntries.remove(expectedKey); - } - assertEquals(0, actualEntries.size()); - } - /** * Copy a {@link Resources#openRawResource(int)} into {@link File} for * testing purposes. |
