Physical keyboard related options shouldn't be searchable when invisible
Physical keyboard options category is hidden when there is no hardware keyboard. It's related preferences are hidden in this case. Hence those preferences shouldn't be searchable. Bug: 351047456 Test: manually search "bounce keys", "sticky keys" and "slow keys", they're not searchable when invisible on Accessibility page Test: atest Flag: com.android.settings.accessibility.fix_a11y_settings_search Change-Id: I1eb465dd34e59d856bb1fa7c06bc253971a8c8d0
This commit is contained in:
@@ -25,6 +25,8 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -34,19 +36,24 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class KeyboardBounceKeyPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_ACCESSIBILITY_BOUNCE_KEYS =
|
||||
Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS;
|
||||
private static final int UNKNOWN = -1;
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagRule = new SetFlagsRule();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final SwitchPreference mSwitchPreference = spy(new SwitchPreference(mContext));
|
||||
private final KeyboardBounceKeyPreferenceController mController =
|
||||
@@ -131,4 +138,26 @@ public class KeyboardBounceKeyPreferenceControllerTest {
|
||||
mContext.getContentResolver(), KEY_ACCESSIBILITY_BOUNCE_KEYS,
|
||||
UNKNOWN)).isNotEqualTo(OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||
public void updateNonIndexableKeys_physicalKeyboardExists_returnEmptyList() {
|
||||
Assume.assumeTrue(AccessibilitySettings.isAnyHardKeyboardsExist());
|
||||
|
||||
List<String> nonIndexableKeys = new ArrayList<>();
|
||||
mController.updateNonIndexableKeys(nonIndexableKeys);
|
||||
|
||||
assertThat(nonIndexableKeys).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||
public void updateNonIndexableKeys_noPhysicalKeyboard_returnPreKey() {
|
||||
Assume.assumeFalse(AccessibilitySettings.isAnyHardKeyboardsExist());
|
||||
|
||||
List<String> nonIndexableKeys = new ArrayList<>();
|
||||
mController.updateNonIndexableKeys(nonIndexableKeys);
|
||||
|
||||
assertThat(nonIndexableKeys).contains(mController.getPreferenceKey());
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,8 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -34,19 +36,24 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class KeyboardSlowKeyPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_ACCESSIBILITY_SLOW_KEYS =
|
||||
Settings.Secure.ACCESSIBILITY_SLOW_KEYS;
|
||||
private static final int UNKNOWN = -1;
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagRule = new SetFlagsRule();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final SwitchPreference mSwitchPreference = spy(new SwitchPreference(mContext));
|
||||
private final KeyboardSlowKeyPreferenceController mController =
|
||||
@@ -131,4 +138,26 @@ public class KeyboardSlowKeyPreferenceControllerTest {
|
||||
mContext.getContentResolver(), KEY_ACCESSIBILITY_SLOW_KEYS, UNKNOWN)).isNotEqualTo(
|
||||
OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||
public void updateNonIndexableKeys_physicalKeyboardExists_returnEmptyList() {
|
||||
Assume.assumeTrue(AccessibilitySettings.isAnyHardKeyboardsExist());
|
||||
|
||||
List<String> nonIndexableKeys = new ArrayList<>();
|
||||
mController.updateNonIndexableKeys(nonIndexableKeys);
|
||||
|
||||
assertThat(nonIndexableKeys).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||
public void updateNonIndexableKeys_noPhysicalKeyboard_returnPreKey() {
|
||||
Assume.assumeFalse(AccessibilitySettings.isAnyHardKeyboardsExist());
|
||||
|
||||
List<String> nonIndexableKeys = new ArrayList<>();
|
||||
mController.updateNonIndexableKeys(nonIndexableKeys);
|
||||
|
||||
assertThat(nonIndexableKeys).contains(mController.getPreferenceKey());
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,8 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -34,19 +36,24 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class KeyboardStickyKeyPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_ACCESSIBILITY_STICKY_KEYS =
|
||||
Settings.Secure.ACCESSIBILITY_STICKY_KEYS;
|
||||
private static final int UNKNOWN = -1;
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagRule = new SetFlagsRule();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final SwitchPreference mSwitchPreference = spy(new SwitchPreference(mContext));
|
||||
private final KeyboardStickyKeyPreferenceController mController =
|
||||
@@ -129,4 +136,26 @@ public class KeyboardStickyKeyPreferenceControllerTest {
|
||||
assertThat(Settings.Secure.getInt(
|
||||
mContext.getContentResolver(), KEY_ACCESSIBILITY_STICKY_KEYS, UNKNOWN)).isEqualTo(ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||
public void updateNonIndexableKeys_physicalKeyboardExists_returnEmptyList() {
|
||||
Assume.assumeTrue(AccessibilitySettings.isAnyHardKeyboardsExist());
|
||||
|
||||
List<String> nonIndexableKeys = new ArrayList<>();
|
||||
mController.updateNonIndexableKeys(nonIndexableKeys);
|
||||
|
||||
assertThat(nonIndexableKeys).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||
public void updateNonIndexableKeys_noPhysicalKeyboard_returnPreKey() {
|
||||
Assume.assumeFalse(AccessibilitySettings.isAnyHardKeyboardsExist());
|
||||
|
||||
List<String> nonIndexableKeys = new ArrayList<>();
|
||||
mController.updateNonIndexableKeys(nonIndexableKeys);
|
||||
|
||||
assertThat(nonIndexableKeys).contains(mController.getPreferenceKey());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user