Fix WifiTetherFooterPreferenceControllerTest failed

- Use the same service name(WifiManager.class) to mock
WifiManager.class

- Use the same service name(TetheringManager.class) to mock
TetheringManager.class

Bug: 183921868
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherFooterPreferenceControllerTest

Change-Id: I904c463f555c3c3c2a85272505215cf993474a7a
This commit is contained in:
Weng Su
2021-03-30 03:17:52 +08:00
parent fe042ac08e
commit 98746308cc

View File

@@ -17,6 +17,7 @@
package com.android.settings.wifi.tether;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -57,7 +58,8 @@ public class WifiTetherFooterPreferenceControllerTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
mController = new WifiTetherFooterPreferenceController(mContext);