Reset allow background activity to default on

Change-Id: Ifeda9bb431b8f0c3bbefb41fb13fa70e15952cce
Fixes: 123029532
Test: robotests
This commit is contained in:
Fan Zhang
2019-01-18 16:10:20 -08:00
parent 31b210017b
commit fb90429930
2 changed files with 7 additions and 11 deletions

View File

@@ -62,7 +62,7 @@ public class AllowBackgroundActivityStartsPreferenceController
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled(); super.onDeveloperOptionsSwitchDisabled();
writeSetting(false); writeSetting(true);
((SwitchPreference) mPreference).setChecked(false); ((SwitchPreference) mPreference).setChecked(true);
} }
} }

View File

@@ -24,6 +24,9 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.provider.Settings; import android.provider.Settings;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -32,9 +35,6 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class AllowBackgroundActivityStartsPreferenceControllerTest { public class AllowBackgroundActivityStartsPreferenceControllerTest {
@@ -98,11 +98,7 @@ public class AllowBackgroundActivityStartsPreferenceControllerTest {
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() { public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
final int mode = Settings.Global.getInt(mContext.getContentResolver(), verify(mPreference).setChecked(true);
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1 /* default */);
assertThat(mode).isEqualTo(0);
verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
} }