feat(EDT): Update the preference interaction and visiblity logic
The EDT toggle will be an subsetting in the DarkTheme settings page - When the Dark Theme main toggle is on, we check the EDT setting to decide applying normal DarkTheme or EDT now. - The EDT preference is disabled when DarkTheme is off Bug: 368721320 Flag: android.view.accessibility.force_invert_color Test: atest ToggleForceInvertPreferenceControllerTest Change-Id: I97841c5b2f03c8c0fb37e0be309d15f312bfedbd
This commit is contained in:
@@ -23,13 +23,18 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -69,6 +74,30 @@ public class ToggleForceInvertPreferenceControllerTest {
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_darkModeOn_preferenceEnabled() {
|
||||
Configuration config = mContext.getResources().getConfiguration();
|
||||
config.uiMode = Configuration.UI_MODE_NIGHT_YES;
|
||||
mContext.getResources().updateConfiguration(config, null);
|
||||
|
||||
Preference preference = mock(Preference.class);
|
||||
mController.updateState(preference);
|
||||
|
||||
verify(preference).setEnabled(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_darkModeOff_preferenceDisabled() {
|
||||
Configuration config = mContext.getResources().getConfiguration();
|
||||
config.uiMode = Configuration.UI_MODE_NIGHT_NO;
|
||||
mContext.getResources().updateConfiguration(config, null);
|
||||
|
||||
Preference preference = mock(Preference.class);
|
||||
mController.updateState(preference);
|
||||
|
||||
verify(preference).setEnabled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void settingOff_reflectsCorrectValue() {
|
||||
setEnabled(false);
|
||||
|
Reference in New Issue
Block a user