Fix fail of AutomaticStorageManagerSwitchBarControllerTest

initializingSwitchDoesNotTriggerView initializes mController
with a mSwitchBar which has already addOnSwitchChangeListener,
it will trigger onSwitchChangedon (and a dialog breaks the test)
of a mController initialized at setUp().

This change initializes a new mSwitchBar for the test.

Bug: 214907475
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AutomaticStorageManagerSwitchBarControllerTest
Change-Id: Iefe56387c56ca6b1c2520c050467d130182ccfdc
This commit is contained in:
Arc Wang
2022-01-19 10:35:46 +08:00
parent 13f22fd6c5
commit aaa4c7c951

View File

@@ -38,7 +38,6 @@ import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -138,13 +137,13 @@ public class AutomaticStorageManagerSwitchBarControllerTest {
}
@Test
@Ignore
public void initializingSwitchDoesNotTriggerView() {
Settings.Secure.putInt(
mContext.getContentResolver(),
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED,
1);
mSwitchBar = new SettingsMainSwitchBar(mContext);
mController =
new AutomaticStorageManagerSwitchBarController(
mContext,