From 3b6ee54cf6e8001c131d2d8ac15f35a22ab2071b Mon Sep 17 00:00:00 2001 From: Quang Anh Luong Date: Thu, 13 Mar 2025 18:34:34 +0900 Subject: [PATCH] Fix TetheringTest.failureEnablingIpForwarding verification count failureEnablingIpForwarding verifies that TetheringMetrics sends one more error report than it should. This extra verification is caused by any(class) being passed into the mock WifiManager.startTetheredHotspot, which does not match null even though the actual code passes in a null. This results in an extra failure that causes the extra error report call. Fix this by replacing any(class) with null, and removing the extra error verification. Bug: 216524590 Test: atest TetheringTest Change-Id: I93986a999d573a186696e54793563e2be8405f39 --- .../com/android/networkstack/tethering/TetheringTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java index 2a22c6d998..fe3b201585 100644 --- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java +++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java @@ -2030,7 +2030,7 @@ public class TetheringTest { @Test public void failureEnablingIpForwarding() throws Exception { initTetheringOnTestThread(); - when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true); + when(mWifiManager.startTetheredHotspot(null)).thenReturn(true); doThrow(new RemoteException()).when(mNetd).ipfwdEnableForwarding(TETHERING_NAME); // Emulate pressing the WiFi tethering button. @@ -2080,9 +2080,9 @@ public class TetheringTest { TEST_WLAN_IFNAME, WifiManager.IFACE_IP_MODE_CONFIGURATION_ERROR); verify(mTetheringMetrics, times(0)).maybeUpdateUpstreamType(any()); - verify(mTetheringMetrics, times(2)).updateErrorCode(eq(TETHERING_WIFI), + verify(mTetheringMetrics, times(1)).updateErrorCode(eq(TETHERING_WIFI), eq(TETHER_ERROR_INTERNAL_ERROR)); - verify(mTetheringMetrics, times(2)).sendReport(eq(TETHERING_WIFI)); + verify(mTetheringMetrics, times(1)).sendReport(eq(TETHERING_WIFI)); verifyNoMoreInteractions(mWifiManager); verifyNoMoreInteractions(mNetd);