Merge changes I97841c5b,I64e47f92 into main

* changes:
  feat(EDT): Update the preference interaction and visiblity logic
  feat(EDT): Migrate entry into Display Settings
This commit is contained in:
Menghan Li
2024-12-23 22:00:42 -08:00
committed by Android (Google) Code Review
8 changed files with 175 additions and 68 deletions

View File

@@ -16,14 +16,10 @@
package com.android.settings.accessibility;
import static android.view.accessibility.Flags.FLAG_FORCE_INVERT_COLOR;
import static com.google.common.truth.Truth.assertThat;
import android.app.settings.SettingsEnums;
import android.content.Context;
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;
@@ -73,20 +69,6 @@ public class ColorAndMotionFragmentTest {
}
@Test
@RequiresFlagsEnabled(FLAG_FORCE_INVERT_COLOR)
public void forceInvertEnabled_getNonIndexableKeys_existInXmlLayout() {
final List<String> niks = ColorAndMotionFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext);
final List<String> keys =
XmlTestUtils.getKeysFromPreferenceXml(mContext,
R.xml.accessibility_color_and_motion);
assertThat(niks).doesNotContain(ColorAndMotionFragment.TOGGLE_FORCE_INVERT);
assertThat(keys).containsAtLeastElementsIn(niks);
}
@Test
@RequiresFlagsDisabled(FLAG_FORCE_INVERT_COLOR)
public void getNonIndexableKeys_existInXmlLayout() {
final List<String> niks = ColorAndMotionFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext);
@@ -94,7 +76,6 @@ public class ColorAndMotionFragmentTest {
XmlTestUtils.getKeysFromPreferenceXml(mContext,
R.xml.accessibility_color_and_motion);
assertThat(niks).contains(ColorAndMotionFragment.TOGGLE_FORCE_INVERT);
assertThat(keys).containsAtLeastElementsIn(niks);
}
}

View File

@@ -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;
@@ -52,10 +57,7 @@ public class ToggleForceInvertPreferenceControllerTest {
@Before
public void setUp() {
mController = new ToggleForceInvertPreferenceController(
mContext,
ColorAndMotionFragment.TOGGLE_FORCE_INVERT
);
mController = new ToggleForceInvertPreferenceController(mContext, "toggle_force_invert");
}
@Test
@@ -72,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);