use of com.android.settings.widget.MasterSwitchPreference in project platform_packages_apps_Settings by BlissRoms.
the class BluetoothEnablerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
mSwitch = new Switch(mContext);
mMasterSwitchPreference = new MasterSwitchPreference(mContext);
mMasterSwitchController = spy(new MasterSwitchController(mMasterSwitchPreference));
mBluetoothEnabler = new BluetoothEnabler(mContext, mMasterSwitchController, mMetricsFeatureProvider, mBluetoothManager, 123, mRestrictionUtils);
PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
when(holder.findViewById(R.id.switchWidget)).thenReturn(mSwitch);
mMasterSwitchPreference.onBindViewHolder(holder);
}
use of com.android.settings.widget.MasterSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiTetherPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
FakeFeatureFactory.setupForTest();
mPreference = new MasterSwitchPreference(RuntimeEnvironment.application);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mWifiManager.getWifiApConfiguration()).thenReturn(mWifiConfiguration);
mWifiConfiguration.SSID = SSID;
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
mController = new WifiTetherPreferenceController(mContext, mLifecycle, false);
mController.displayPreference(mScreen);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by LineageOS.
the class BluetoothEnablerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
mSwitch = new Switch(mContext);
mMasterSwitchPreference = new MasterSwitchPreference(mContext);
mMasterSwitchController = spy(new MasterSwitchController(mMasterSwitchPreference));
mBluetoothEnabler = new BluetoothEnabler(mContext, mMasterSwitchController, mMetricsFeatureProvider, mBluetoothManager, 123, mRestrictionUtils);
PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
when(holder.findViewById(R.id.switchWidget)).thenReturn(mSwitch);
mMasterSwitchPreference.onBindViewHolder(holder);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by omnirom.
the class WifiTetherPreferenceControllerTest method start_wifiApOff_shouldSetInitialStateToOff.
@Test
public void start_wifiApOff_shouldSetInitialStateToOff() {
when(mWifiManager.getWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_DISABLED);
final BroadcastReceiver receiver = ReflectionHelpers.getField(mController, "mReceiver");
final MasterSwitchPreference pref = mock(MasterSwitchPreference.class);
when(mScreen.findPreference(anyString())).thenReturn(pref);
mController.displayPreference(mScreen);
mLifecycle.onStart();
assertThat(ShadowWifiTetherSwitchBarController.onStartCalled).isTrue();
verify(mContext).registerReceiver(eq(receiver), any(IntentFilter.class));
verify(pref).setChecked(false);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by omnirom.
the class WifiTetherPreferenceControllerTest method start_wifiApOn_shouldSetInitialStateToOn.
@Test
public void start_wifiApOn_shouldSetInitialStateToOn() {
when(mWifiManager.getWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_ENABLED);
final BroadcastReceiver receiver = ReflectionHelpers.getField(mController, "mReceiver");
final MasterSwitchPreference pref = mock(MasterSwitchPreference.class);
when(mScreen.findPreference(anyString())).thenReturn(pref);
mController.displayPreference(mScreen);
mLifecycle.onStart();
assertThat(ShadowWifiTetherSwitchBarController.onStartCalled).isTrue();
verify(mContext).registerReceiver(eq(receiver), any(IntentFilter.class));
verify(pref).setChecked(true);
}
Aggregations