Refactoring A11y shortcut functions in Settings to use GESTURE
Properly integrating GESTURE into Settings, so that text pertaining to the gesture shortcut are displayed when appropriate. Heavy refactoring has been done to allow for easier cleanup and expansion Demo video: https://x20web.corp.google.com/users/jo/jonesriley/splitShortcut/a11ySettingsGestureCompat.mp4 NO_IFTTT=changes do not alter the order of the shortcuts. Bug: 365570709 Test: atest com.android.settings.accessibility Flag: android.provider.a11y_standalone_gesture_enabled Change-Id: If90719763a48e3b8bc35988a1de9a352a766953b
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE;
|
||||
import static android.provider.Settings.Secure.NAVIGATION_MODE;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
|
||||
@@ -26,11 +28,17 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.icu.text.MessageFormat;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Flags;
|
||||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.accessibility.util.ShortcutUtils;
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -47,6 +55,8 @@ import org.robolectric.RobolectricTestRunner;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityButtonFooterPreferenceControllerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mCheckFlagsRule = new SetFlagsRule();
|
||||
@Rule
|
||||
public final MockitoRule mockito = MockitoJUnit.rule();
|
||||
@Spy
|
||||
@@ -69,9 +79,12 @@ public class AccessibilityButtonFooterPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void displayPreference_navigationGestureEnabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
ShortcutUtils.setButtonMode(
|
||||
mContext, ACCESSIBILITY_BUTTON_MODE_GESTURE, mContext.getUserId());
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -82,11 +95,26 @@ public class AccessibilityButtonFooterPreferenceControllerTest {
|
||||
Html.FROM_HTML_MODE_COMPACT).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void displayPreference_navigationGestureEnabled_flag_setCorrectTitle() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
assertThat(AccessibilityUtil.isGestureNavigateEnabled(mContext)).isTrue();
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mPreference.getTitle().toString()).isEqualTo(
|
||||
Html.fromHtml(
|
||||
MessageFormat.format(mContext.getString(
|
||||
R.string.accessibility_button_description), 1, 2, 3),
|
||||
Html.FROM_HTML_MODE_COMPACT).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_navigationGestureDisabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(
|
||||
com.android.internal.R.integer.config_navBarInteractionMode)).thenReturn(
|
||||
NAV_BAR_MODE_2BUTTON);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_2BUTTON, mContext.getUserId());
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
|
@@ -32,6 +32,7 @@ import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Flags;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -92,8 +93,9 @@ public class AccessibilityButtonFragmentTest {
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void onCreate_navigationGestureEnabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putIntForUser(
|
||||
mContext.getContentResolver(), Settings.Secure.NAVIGATION_MODE,
|
||||
NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(Bundle.EMPTY);
|
||||
@@ -104,9 +106,10 @@ public class AccessibilityButtonFragmentTest {
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void onCreate_navigationGestureEnabled_gestureFlag_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
public void onCreate_navigationGestureEnabled_flag_setCorrectTitle() {
|
||||
Settings.Secure.putIntForUser(
|
||||
mContext.getContentResolver(), Settings.Secure.NAVIGATION_MODE,
|
||||
NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(Bundle.EMPTY);
|
||||
@@ -117,8 +120,9 @@ public class AccessibilityButtonFragmentTest {
|
||||
|
||||
@Test
|
||||
public void onCreate_navigationBarEnabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_2BUTTON);
|
||||
Settings.Secure.putIntForUser(
|
||||
mContext.getContentResolver(), Settings.Secure.NAVIGATION_MODE,
|
||||
NAV_BAR_MODE_2BUTTON, mContext.getUserId());
|
||||
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(Bundle.EMPTY);
|
||||
|
@@ -75,26 +75,25 @@ public class AccessibilityButtonGesturePreferenceControllerTest {
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void getAvailabilityStatus_navigationGestureEnabled_returnAvailable() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void
|
||||
getAvailabilityStatus_navigationGestureEnabled_gestureFlag_conditionallyUnavailable() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
public void getAvailabilityStatus_navigationGestureEnabled_returnConditionallyUnavailable() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_navigationGestureDisabled_returnConditionallyUnavailable() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_2BUTTON);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_2BUTTON, mContext.getUserId());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
@@ -69,16 +69,16 @@ public class AccessibilityButtonLocationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_navigationGestureEnabled_returnConditionallyUnavailable() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_navigationGestureDisabled_returnAvailable() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_2BUTTON);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_2BUTTON, mContext.getUserId());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static android.provider.Settings.Secure.NAVIGATION_MODE;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
|
||||
@@ -25,6 +26,11 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Flags;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -50,6 +56,8 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityButtonPreferenceControllerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Rule
|
||||
public final MockitoRule mockito = MockitoJUnit.rule();
|
||||
@Spy
|
||||
@@ -72,9 +80,10 @@ public class AccessibilityButtonPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void displayPreference_navigationGestureEnabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -83,9 +92,10 @@ public class AccessibilityButtonPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_navigationGestureDisabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_2BUTTON);
|
||||
@EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void displayPreference_navigationGestureEnabled_flag_setCorrectTitle() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -94,9 +104,21 @@ public class AccessibilityButtonPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_navigationGestureDisabled_setCorrectTitle() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_2BUTTON, mContext.getUserId());
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mPreference.getTitle()).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_button_title));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void updateDynamicRawDataToIndex_navigationGestureEnabled_setCorrectIndex() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
List<SearchIndexableRaw> rawDataList = new ArrayList<>();
|
||||
|
||||
mController.updateDynamicRawDataToIndex(rawDataList);
|
||||
@@ -109,10 +131,27 @@ public class AccessibilityButtonPreferenceControllerTest {
|
||||
mResources.getString(R.string.accessibility_shortcuts_settings_title));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void updateDynamicRawDataToIndex_navigationGestureEnabled_flag_setCorrectIndex() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, mContext.getUserId());
|
||||
List<SearchIndexableRaw> rawDataList = new ArrayList<>();
|
||||
|
||||
mController.updateDynamicRawDataToIndex(rawDataList);
|
||||
|
||||
assertThat(rawDataList).hasSize(1);
|
||||
SearchIndexableRaw raw = rawDataList.get(0);
|
||||
assertThat(raw.title).isEqualTo(
|
||||
mResources.getString(R.string.accessibility_button_title));
|
||||
assertThat(raw.screenTitle).isEqualTo(
|
||||
mResources.getString(R.string.accessibility_shortcuts_settings_title));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDynamicRawDataToIndex_navigationGestureDisabled_setCorrectIndex() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
.thenReturn(NAV_BAR_MODE_2BUTTON);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
NAVIGATION_MODE, NAV_BAR_MODE_2BUTTON, mContext.getUserId());
|
||||
List<SearchIndexableRaw> rawDataList = new ArrayList<>();
|
||||
|
||||
mController.updateDynamicRawDataToIndex(rawDataList);
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
|
||||
@@ -36,6 +37,7 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@@ -479,9 +481,37 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void createAccessibilityTutorialDialog_gestureShortcut_talkbackOn_verifyText() {
|
||||
mShortcutTypes |= SOFTWARE;
|
||||
setTouchExplorationEnabled(true);
|
||||
AccessibilityTestUtils.setSoftwareShortcutMode(
|
||||
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
|
||||
|
||||
final String expectedTitle = mContext.getString(
|
||||
R.string.accessibility_tutorial_dialog_title_gesture);
|
||||
final String expectedInstruction = StringUtil.getIcuPluralsString(
|
||||
mContext,
|
||||
/* count= */ 3,
|
||||
R.string.accessibility_tutorial_dialog_gesture_shortcut_instruction);
|
||||
|
||||
final AlertDialog alertDialog =
|
||||
createAccessibilityTutorialDialog(
|
||||
mContext, mShortcutTypes, FAKE_FEATURE_NAME);
|
||||
alertDialog.show();
|
||||
ShadowLooper.idleMainLooper();
|
||||
|
||||
verifyTutorialTitleAndInstruction(
|
||||
alertDialog,
|
||||
expectedTitle,
|
||||
expectedInstruction);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void createAccessibilityTutorialDialog_gestureShortcut_talkbackOn_flag_verifyText() {
|
||||
mShortcutTypes |= GESTURE;
|
||||
setTouchExplorationEnabled(true);
|
||||
AccessibilityTestUtils.setSoftwareShortcutMode(
|
||||
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
|
||||
final String expectedTitle = mContext.getString(
|
||||
@@ -504,6 +534,7 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void createAccessibilityTutorialDialog_gestureShortcut_talkbackOff_verifyText() {
|
||||
mShortcutTypes |= SOFTWARE;
|
||||
setTouchExplorationEnabled(false);
|
||||
@@ -528,6 +559,32 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
expectedInstruction);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void createAccessibilityTutorialDialog_gestureShortcut_talkbackOff_flag_verifyText() {
|
||||
mShortcutTypes |= GESTURE;
|
||||
setTouchExplorationEnabled(false);
|
||||
AccessibilityTestUtils.setSoftwareShortcutMode(
|
||||
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
|
||||
final String expectedTitle = mContext.getString(
|
||||
R.string.accessibility_tutorial_dialog_title_gesture);
|
||||
final String expectedInstruction = StringUtil.getIcuPluralsString(
|
||||
mContext,
|
||||
/* count= */ 2,
|
||||
R.string.accessibility_tutorial_dialog_gesture_shortcut_instruction);
|
||||
|
||||
final AlertDialog alertDialog =
|
||||
createAccessibilityTutorialDialog(
|
||||
mContext, mShortcutTypes, FAKE_FEATURE_NAME);
|
||||
alertDialog.show();
|
||||
ShadowLooper.idleMainLooper();
|
||||
|
||||
verifyTutorialTitleAndInstruction(
|
||||
alertDialog,
|
||||
expectedTitle,
|
||||
expectedInstruction);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void performClickOnPositiveButton_turnOnSoftwareShortcut_dismiss() {
|
||||
mShortcutTypes |= SOFTWARE;
|
||||
|
@@ -16,6 +16,11 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
|
||||
@@ -398,6 +403,49 @@ public final class AccessibilityUtilTest {
|
||||
.isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void getSoftwareShortcutSummary_returnsSoftwareSummary() {
|
||||
assertThat(AccessibilityUtil.getSoftwareShortcutSummary(mContext)).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_shortcut_edit_summary_software));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void getSoftwareShortcutSummary_gestureMode_floatingButton_returnsSoftwareSummary() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_MODE,
|
||||
ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU);
|
||||
|
||||
assertThat(AccessibilityUtil.getSoftwareShortcutSummary(mContext)).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_shortcut_edit_summary_software));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void getSoftwareShortcutSummary_gestureMode_gesture_returnsGestureSummary() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_MODE,
|
||||
ACCESSIBILITY_BUTTON_MODE_GESTURE);
|
||||
|
||||
assertThat(AccessibilityUtil.getSoftwareShortcutSummary(mContext)).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_shortcut_edit_summary_software_gesture));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
|
||||
public void getSoftwareShortcutSummary_navBarMode_returnsSoftwareSummary() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON);
|
||||
|
||||
assertThat(AccessibilityUtil.getSoftwareShortcutSummary(mContext)).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_shortcut_edit_summary_software));
|
||||
}
|
||||
|
||||
private AccessibilityServiceInfo getMockAccessibilityServiceInfo() {
|
||||
final ApplicationInfo applicationInfo = new ApplicationInfo();
|
||||
final ServiceInfo serviceInfo = new ServiceInfo();
|
||||
|
@@ -17,11 +17,11 @@
|
||||
package com.android.settings.testutils;
|
||||
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -35,8 +35,6 @@ import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -48,15 +46,18 @@ public class AccessibilityTestUtils {
|
||||
|
||||
public static void setSoftwareShortcutMode(
|
||||
Context context, boolean gestureNavEnabled, boolean floatingButtonEnabled) {
|
||||
int buttonMode = floatingButtonEnabled ? ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU : -1;
|
||||
int buttonMode = ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR;
|
||||
if (floatingButtonEnabled) {
|
||||
buttonMode = ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU;
|
||||
} else if (gestureNavEnabled) {
|
||||
buttonMode = ACCESSIBILITY_BUTTON_MODE_GESTURE;
|
||||
}
|
||||
int navMode = gestureNavEnabled ? NAV_BAR_MODE_GESTURAL : NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_MODE, buttonMode);
|
||||
SettingsShadowResources.overrideResource(
|
||||
com.android.internal.R.integer.config_navBarInteractionMode, navMode);
|
||||
assertThat(context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_navBarInteractionMode)).isEqualTo(navMode);
|
||||
Settings.Secure.putIntForUser(context.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_MODE, buttonMode, context.getUserId());
|
||||
Settings.Secure.putIntForUser(context.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, navMode, context.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user