Merge "Add lost prefController to WifiTetherSettings"

This commit is contained in:
Lei Yu
2019-01-02 23:07:08 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 3 deletions

View File

@@ -178,6 +178,8 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
controllers.add(new WifiTetherSecurityPreferenceController(context, listener)); controllers.add(new WifiTetherSecurityPreferenceController(context, listener));
controllers.add(new WifiTetherPasswordPreferenceController(context, listener)); controllers.add(new WifiTetherPasswordPreferenceController(context, listener));
controllers.add(new WifiTetherApBandPreferenceController(context, listener)); controllers.add(new WifiTetherApBandPreferenceController(context, listener));
controllers.add(
new WifiTetherAutoOffPreferenceController(context, KEY_WIFI_TETHER_AUTO_OFF));
return controllers; return controllers;
} }

View File

@@ -35,6 +35,9 @@ import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.widget.TextView; import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceScreen;
import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowWifiManager; import com.android.settings.testutils.shadow.ShadowWifiManager;
@@ -51,15 +54,13 @@ import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceScreen;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowWifiManager.class}) @Config(shadows = {ShadowWifiManager.class})
public class WifiTetherSettingsTest { public class WifiTetherSettingsTest {
private static final String[] WIFI_REGEXS = {"wifi_regexs"}; private static final String[] WIFI_REGEXS = {"wifi_regexs"};
private Context mContext; private Context mContext;
private WifiTetherSettings mWifiTetherSettings;
@Mock @Mock
private ConnectivityManager mConnectivityManager; private ConnectivityManager mConnectivityManager;
@@ -75,6 +76,8 @@ public class WifiTetherSettingsTest {
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE); .when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
doReturn(WIFI_REGEXS).when(mConnectivityManager).getTetherableWifiRegexs(); doReturn(WIFI_REGEXS).when(mConnectivityManager).getTetherableWifiRegexs();
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE); doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
mWifiTetherSettings = new WifiTetherSettings();
} }
@Test @Test
@@ -136,6 +139,15 @@ public class WifiTetherSettingsTest {
verify(screen).removeAll(); verify(screen).removeAll();
} }
@Test
public void createPreferenceControllers_hasAutoOffPreference() {
assertThat(mWifiTetherSettings.createPreferenceControllers(mContext)
.stream()
.filter(controller -> controller instanceof WifiTetherAutoOffPreferenceController)
.count())
.isEqualTo(1);
}
private void setupIsTetherAvailable(boolean returnValue) { private void setupIsTetherAvailable(boolean returnValue) {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true); when(mConnectivityManager.isTetheringSupported()).thenReturn(true);