diff options
| author | 2019-03-08 14:34:19 +0800 | |
|---|---|---|
| committer | 2019-03-08 14:34:19 +0800 | |
| commit | e43f162371d6b649e5ceec479179a80a047d24fe (patch) | |
| tree | ae3ebe94cf80251fa19f65a7382ee14f1e69b761 | |
| parent | c8dfb728917c68d9cf4638fb05e4ddbe5ae8f80c (diff) | |
Not to use any() to verify DataStallDetectionStats
Build a empty DataStallDetectionStats object instead of use
any() to do the verification to prevent NPE while trying to
write the metrics.
Bug: 120452078
Test: atest NetworkStackTests
Change-Id: Ib9f3e56195a539a5ca4826b4aad0e38945a9a3a7
| -rw-r--r-- | packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java index ee2baf20bb8e..34ca6ac2ac20 100644 --- a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java +++ b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java @@ -525,7 +525,7 @@ public class NetworkMonitorTest { wrappedMonitor.setLastProbeTime(SystemClock.elapsedRealtime() - 1000); makeDnsTimeoutEvent(wrappedMonitor, 5); assertTrue(wrappedMonitor.isDataStall()); - verify(mDataStallStatsUtils, times(1)).write(any(), any()); + verify(mDataStallStatsUtils, times(1)).write(makeEmptyDataStallDetectionStats(), any()); } @Test @@ -534,7 +534,7 @@ public class NetworkMonitorTest { wrappedMonitor.setLastProbeTime(SystemClock.elapsedRealtime() - 1000); makeDnsTimeoutEvent(wrappedMonitor, 3); assertFalse(wrappedMonitor.isDataStall()); - verify(mDataStallStatsUtils, never()).write(any(), any()); + verify(mDataStallStatsUtils, never()).write(makeEmptyDataStallDetectionStats(), any()); } @Test @@ -586,6 +586,10 @@ public class NetworkMonitorTest { } } + private DataStallDetectionStats makeEmptyDataStallDetectionStats() { + return new DataStallDetectionStats.Builder().build(); + } + private void setDataStallEvaluationType(int type) { when(mDependencies.getSetting(any(), eq(Settings.Global.DATA_STALL_EVALUATION_TYPE), anyInt())).thenReturn(type); |