From 7b4a4cbdd417d2eecd298ea7dde6225ba92036d8 Mon Sep 17 00:00:00 2001 From: Aaron Huang Date: Fri, 10 Sep 2021 16:18:21 +0800 Subject: [PATCH] Remove ForceAllNetworkTypes from test Before sForceAllNetworkTypes is removed, the network type and meteredness will be ignored when matchesMobile or matchesMobileWildcard is called. After sForceAllNetworkTypes is removed, the matches method should check the network type and the meteredness. Thus, if the test data contains different type or it's not metered should not be counted. Bug: 183776809 Test: FrameworksNetTests Change-Id: Ie7194495d26c0f5ef7a247733f43c64688626c67 --- .../server/net/NetworkStatsCollectionTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/unit/java/com/android/server/net/NetworkStatsCollectionTest.java b/tests/unit/java/com/android/server/net/NetworkStatsCollectionTest.java index e771558a20..6b4ead5b9b 100644 --- a/tests/unit/java/com/android/server/net/NetworkStatsCollectionTest.java +++ b/tests/unit/java/com/android/server/net/NetworkStatsCollectionTest.java @@ -98,14 +98,11 @@ public class NetworkStatsCollectionTest { @Before public void setUp() throws Exception { sOriginalClock = RecurrenceRule.sClock; - // ignore any device overlay while testing - NetworkTemplate.forceAllNetworkTypes(); } @After public void tearDown() throws Exception { RecurrenceRule.sClock = sOriginalClock; - NetworkTemplate.resetForceAllNetworkTypes(); } private void setClock(Instant instant) { @@ -123,7 +120,7 @@ public class NetworkStatsCollectionTest { // verify that history read correctly assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), - 636016770L, 709306L, 88038768L, 518836L, NetworkStatsAccess.Level.DEVICE); + 636014522L, 709291L, 88037144L, 518820L, NetworkStatsAccess.Level.DEVICE); // now export into a unified format final ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -137,7 +134,7 @@ public class NetworkStatsCollectionTest { // and read back into structure, verifying that totals are same collection.read(new ByteArrayInputStream(bos.toByteArray())); assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), - 636016770L, 709306L, 88038768L, 518836L, NetworkStatsAccess.Level.DEVICE); + 636014522L, 709291L, 88037144L, 518820L, NetworkStatsAccess.Level.DEVICE); } @Test @@ -151,7 +148,7 @@ public class NetworkStatsCollectionTest { // verify that history read correctly assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), - 637076152L, 711413L, 88343717L, 521022L, NetworkStatsAccess.Level.DEVICE); + 637073904L, 711398L, 88342093L, 521006L, NetworkStatsAccess.Level.DEVICE); // now export into a unified format final ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -165,7 +162,7 @@ public class NetworkStatsCollectionTest { // and read back into structure, verifying that totals are same collection.read(new ByteArrayInputStream(bos.toByteArray())); assertSummaryTotal(collection, buildTemplateMobileAll(TEST_IMSI), - 637076152L, 711413L, 88343717L, 521022L, NetworkStatsAccess.Level.DEVICE); + 637073904L, 711398L, 88342093L, 521006L, NetworkStatsAccess.Level.DEVICE); } @Test