Fix WifiTetherSSIDPreferenceControllerTest failed

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

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

Bug: 183922071
Test: manual test
make RunSettingsRoboTests
ROBOTEST_FILTER=WifiTetherSSIDPreferenceControllerTest

Change-Id: I68955d83693dda787132e2a951e8d034e57090ce
This commit is contained in:
Weng Su
2021-03-30 03:42:10 +08:00
parent fe042ac08e
commit 6f2379bb44

View File

@@ -19,6 +19,7 @@ package com.android.settings.wifi.tether;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -67,8 +68,8 @@ public class WifiTetherSSIDPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mPreference = new WifiTetherSsidPreference(RuntimeEnvironment.application);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
when(mScreen.findPreference(anyString())).thenReturn(mPreference);