Add switch bar to enable/disable dev settings in new page.
Bug: 65522852 Test: make RunSettingsRoboTests -j40 ROBOTEST_FILTER=Development Change-Id: I0958950dc6aaee24d8d5e0be58d7564d108bc72e
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.development;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -45,6 +46,8 @@ public class DevelopmentSwitchBarControllerTest {
|
||||
|
||||
@Mock
|
||||
private DevelopmentSettings mSettings;
|
||||
@Mock
|
||||
private DevelopmentSettingsDashboardFragment mNewSettings;
|
||||
private Lifecycle mLifecycle;
|
||||
private SwitchBar mSwitchBar;
|
||||
private DevelopmentSwitchBarController mController;
|
||||
@@ -76,6 +79,21 @@ public class DevelopmentSwitchBarControllerTest {
|
||||
assertThat(listeners).doesNotContain(mSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runThroughLifecycle_v2_isMonkeyRun_shouldNotRegisterListener() {
|
||||
ShadowUtils.setIsUserAMonkey(true);
|
||||
mController = new DevelopmentSwitchBarController(mNewSettings, mSwitchBar,
|
||||
true /* isAvailable */, mLifecycle);
|
||||
final ArrayList<SwitchBar.OnSwitchChangeListener> listeners =
|
||||
ReflectionHelpers.getField(mSwitchBar, "mSwitchChangeListeners");
|
||||
|
||||
mLifecycle.onStart();
|
||||
assertThat(listeners).doesNotContain(mNewSettings);
|
||||
|
||||
mLifecycle.onStop();
|
||||
assertThat(listeners).doesNotContain(mNewSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runThroughLifecycle_isNotMonkeyRun_shouldRegisterAndRemoveListener() {
|
||||
ShadowUtils.setIsUserAMonkey(false);
|
||||
@@ -91,6 +109,22 @@ public class DevelopmentSwitchBarControllerTest {
|
||||
assertThat(listeners).doesNotContain(mSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runThroughLifecycle_v2_isNotMonkeyRun_shouldRegisterAndRemoveListener() {
|
||||
when(mNewSettings.getContext()).thenReturn(RuntimeEnvironment.application);
|
||||
ShadowUtils.setIsUserAMonkey(false);
|
||||
mController = new DevelopmentSwitchBarController(mNewSettings, mSwitchBar,
|
||||
true /* isAvailable */, mLifecycle);
|
||||
final ArrayList<SwitchBar.OnSwitchChangeListener> listeners =
|
||||
ReflectionHelpers.getField(mSwitchBar, "mSwitchChangeListeners");
|
||||
|
||||
mLifecycle.onStart();
|
||||
assertThat(listeners).contains(mNewSettings);
|
||||
|
||||
mLifecycle.onStop();
|
||||
assertThat(listeners).doesNotContain(mNewSettings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildController_unavailable_shouldDisableSwitchBar() {
|
||||
ShadowUtils.setIsUserAMonkey(false);
|
||||
|
Reference in New Issue
Block a user