[Flag cleanup] edit_shortcuts_in_full_screen is always on now
- Cleaned up the code that won't be executed when the flag is on - Remove unused resources Bug: 300302098 Test: Manually verify the user can change the shortcut type, and the changes are saved Test: atest com.android.settings.accessibility Flag: EXEMPT removing com.android.settings.accessibility.edit_shortcuts_in_full_screen Change-Id: I1e32b724ca3da909feda55e20fb1d51dc4680c09
This commit is contained in:
@@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -40,24 +39,6 @@ public class AccessibilityDialogUtilsTest {
|
||||
mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateShortcutInDialog_correctDialogType_success() {
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC, "Title",
|
||||
null);
|
||||
|
||||
assertThat(
|
||||
AccessibilityDialogUtils.updateShortcutInDialog(mContext, dialog)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateShortcutInDialog_useNotSupportedDialog_fail() {
|
||||
final AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle("Title").show();
|
||||
|
||||
assertThat(AccessibilityDialogUtils.updateShortcutInDialog(mContext,
|
||||
dialog)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showDialog_createCustomDialog_isShowing() {
|
||||
final Dialog dialog = AccessibilityDialogUtils.createCustomDialog(mContext,
|
||||
|
@@ -16,12 +16,10 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
|
||||
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;
|
||||
import static com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW;
|
||||
import static com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -37,7 +35,6 @@ import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.icu.text.CaseMap;
|
||||
import android.os.Bundle;
|
||||
@@ -52,7 +49,6 @@ import android.view.accessibility.Flags;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -159,71 +155,6 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
assertThat(expectedType).isEqualTo(HARDWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||
mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC,
|
||||
PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
mFragment.mShortcutPreference.setChecked(false);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
|
||||
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
|
||||
mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC,
|
||||
PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
final PreferredShortcut hardwareShortcut = new PreferredShortcut(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString(), HARDWARE);
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
PreferredShortcuts.saveUserShortcutType(mContext, hardwareShortcut);
|
||||
mFragment.mShortcutPreference.setChecked(true);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
|
||||
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(HARDWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_assignShortcutTypeToVariable() {
|
||||
mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC,
|
||||
PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
savedInstanceState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE,
|
||||
SOFTWARE | HARDWARE);
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(savedInstanceState);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
final int value = mFragment.getShortcutTypeCheckBoxValue();
|
||||
mFragment.saveNonEmptyUserShortcutType(value);
|
||||
|
||||
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
|
||||
mFragment.getComponentName().flattenToString());
|
||||
assertThat(expectedType).isEqualTo(SOFTWARE | HARDWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
@@ -268,8 +199,7 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN)
|
||||
public void onSettingsClicked_editShortcutsFullScreenFlagOn_showFullScreenEditShortcutScreen() {
|
||||
public void onSettingsClicked_showFullScreenEditShortcutScreen() {
|
||||
Activity activity = Robolectric.setupActivity(FragmentActivity.class);
|
||||
when(mFragment.getContext()).thenReturn(activity);
|
||||
Context context = mFragment.getContext();
|
||||
@@ -311,8 +241,6 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
assertThat(summary).isEqualTo(expected);
|
||||
}
|
||||
|
||||
private void callEmptyOnClicked(DialogInterface dialog, int which) {}
|
||||
|
||||
private void putStringIntoSettings(String key, String componentName) {
|
||||
Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
|
||||
}
|
||||
|
@@ -299,21 +299,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(
|
||||
com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN)
|
||||
public void clickShortcutSettingsPreference_warningNotRequired_dontShowWarning_showDialog()
|
||||
throws Throwable {
|
||||
setupServiceWarningRequired(false);
|
||||
mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null);
|
||||
|
||||
mFragment.onSettingsClicked(mFragment.mShortcutPreference);
|
||||
|
||||
assertThat(mFragment.mLastShownDialogId).isEqualTo(
|
||||
AccessibilityDialogUtils.DialogEnums.EDIT_SHORTCUT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN)
|
||||
public void clickShortcutSettingsPreference_warningNotRequired_dontShowWarning_launchActivity()
|
||||
throws Throwable {
|
||||
setupServiceWarningRequired(false);
|
||||
|
@@ -16,11 +16,9 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
|
||||
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;
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -36,7 +34,6 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.icu.text.CaseMap;
|
||||
@@ -48,10 +45,8 @@ import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -59,7 +54,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
@@ -79,7 +73,6 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.shadows.ShadowLooper;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -239,89 +232,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
assertThat(expectedType).isEqualTo(HARDWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogCheckboxClicked_hardwareType_skipTimeoutRestriction() {
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
mFragment::callOnAlertDialogCheckboxClicked);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
|
||||
final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
|
||||
final CheckBox hardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
|
||||
hardwareTypeCheckBox.setChecked(true);
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
|
||||
ShadowLooper.idleMainLooper();
|
||||
final boolean skipTimeoutRestriction = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, 0) != 0;
|
||||
|
||||
assertThat(skipTimeoutRestriction).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
mFragment.mShortcutPreference.setChecked(false);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
|
||||
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
final PreferredShortcut hardwareShortcut = new PreferredShortcut(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString(), HARDWARE);
|
||||
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
PreferredShortcuts.saveUserShortcutType(mContext, hardwareShortcut);
|
||||
mFragment.mShortcutPreference.setChecked(true);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
|
||||
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(HARDWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_assignShortcutTypeToVariable() {
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||
mFragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
savedInstanceState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE,
|
||||
SOFTWARE | HARDWARE);
|
||||
mFragment.onCreate(savedInstanceState);
|
||||
mFragment.setupEditShortcutDialog(dialog);
|
||||
final int value = mFragment.getShortcutTypeCheckBoxValue();
|
||||
mFragment.saveNonEmptyUserShortcutType(value);
|
||||
|
||||
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
|
||||
mFragment.mComponentName.flattenToString());
|
||||
assertThat(expectedType).isEqualTo(SOFTWARE | HARDWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnDisabledService_notShowTooltipView() {
|
||||
@@ -505,9 +415,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
PreferredShortcut shortcut) {
|
||||
PreferredShortcuts.saveUserShortcutType(context, shortcut);
|
||||
}
|
||||
|
||||
private void callEmptyOnClicked(DialogInterface dialog, int which) {}
|
||||
|
||||
private static PopupWindow getLatestPopupWindow() {
|
||||
final ShadowApplication shadowApplication =
|
||||
Shadow.extract(ApplicationProvider.getApplicationContext());
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
|
||||
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;
|
||||
@@ -25,7 +24,6 @@ import static com.android.internal.accessibility.common.ShortcutConstants.UserSh
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
import static com.android.settings.accessibility.MagnificationCapabilities.MagnificationMode;
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -42,7 +40,6 @@ import static org.mockito.Mockito.when;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.database.ContentObserver;
|
||||
@@ -57,7 +54,6 @@ import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -66,7 +62,6 @@ import com.android.server.accessibility.Flags;
|
||||
import com.android.settings.DialogCreatable;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
|
||||
import com.android.settings.testutils.AccessibilityTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||
import com.android.settings.testutils.shadow.ShadowStorageManager;
|
||||
@@ -735,105 +730,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
assertThat(expectedType).isEqualTo(TWOFINGER_DOUBLETAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||
mFragController.create(R.id.main_content, /* bundle= */
|
||||
null).start().resume().get();
|
||||
fragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null);
|
||||
|
||||
fragment.mShortcutPreference.setChecked(false);
|
||||
fragment.setupMagnificationEditShortcutDialog(
|
||||
createEditShortcutDialog(fragment.getActivity()));
|
||||
|
||||
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
|
||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||
mFragController.create(R.id.main_content, /* bundle= */
|
||||
null).start().resume().get();
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
final PreferredShortcut tripletapShortcut = new PreferredShortcut(
|
||||
MAGNIFICATION_CONTROLLER_NAME, TRIPLETAP);
|
||||
fragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
PreferredShortcuts.saveUserShortcutType(mContext, tripletapShortcut);
|
||||
fragment.mShortcutPreference.setChecked(true);
|
||||
fragment.setupMagnificationEditShortcutDialog(
|
||||
createEditShortcutDialog(fragment.getActivity()));
|
||||
|
||||
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(TRIPLETAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
|
||||
public void setupMagnificationEditShortcutDialog_twoFingerTripleTapOn_checkboxIsSavedValue() {
|
||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||
mFragController.create(R.id.main_content, /* bundle= */
|
||||
null).start().resume().get();
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
final PreferredShortcut twoFingerTripleTapShortcut = new PreferredShortcut(
|
||||
MAGNIFICATION_CONTROLLER_NAME, TWOFINGER_DOUBLETAP);
|
||||
fragment.mShortcutPreference = shortcutPreference;
|
||||
|
||||
PreferredShortcuts.saveUserShortcutType(mContext, twoFingerTripleTapShortcut);
|
||||
fragment.mShortcutPreference.setChecked(true);
|
||||
fragment.setupMagnificationEditShortcutDialog(
|
||||
createEditShortcutDialog(fragment.getActivity()));
|
||||
|
||||
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
|
||||
assertThat(checkboxValue).isEqualTo(TWOFINGER_DOUBLETAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restoreValueFromSavedInstanceState_assignToVariable() {
|
||||
final Bundle fragmentState = createFragmentSavedInstanceState(
|
||||
HARDWARE | TRIPLETAP);
|
||||
ToggleScreenMagnificationPreferenceFragment fragment = mFragController.get();
|
||||
// Had to use reflection to pass the savedInstanceState when launching the fragment
|
||||
ReflectionHelpers.setField(fragment, "mSavedFragmentState", fragmentState);
|
||||
|
||||
FragmentController.of(fragment, SettingsActivity.class).create(
|
||||
R.id.main_content, /* bundle= */ null).start().resume().get();
|
||||
fragment.setupMagnificationEditShortcutDialog(
|
||||
createEditShortcutDialog(fragment.getActivity()));
|
||||
final int value = fragment.getShortcutTypeCheckBoxValue();
|
||||
fragment.saveNonEmptyUserShortcutType(value);
|
||||
|
||||
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
|
||||
MAGNIFICATION_CONTROLLER_NAME);
|
||||
assertThat(value).isEqualTo(6);
|
||||
assertThat(expectedType).isEqualTo(HARDWARE | TRIPLETAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
|
||||
public void restoreValueFromSavedInstanceState_twoFingerTripleTap_assignToVariable() {
|
||||
final Bundle fragmentState =
|
||||
createFragmentSavedInstanceState(TWOFINGER_DOUBLETAP);
|
||||
ToggleScreenMagnificationPreferenceFragment fragment = mFragController.get();
|
||||
// Had to use reflection to pass the savedInstanceState when launching the fragment
|
||||
ReflectionHelpers.setField(fragment, "mSavedFragmentState", fragmentState);
|
||||
|
||||
FragmentController.of(fragment, SettingsActivity.class).create(
|
||||
R.id.main_content, /* bundle= */ null).start().resume().get();
|
||||
fragment.setupMagnificationEditShortcutDialog(
|
||||
createEditShortcutDialog(fragment.getActivity()));
|
||||
final int value = fragment.getShortcutTypeCheckBoxValue();
|
||||
fragment.saveNonEmptyUserShortcutType(value);
|
||||
|
||||
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
|
||||
MAGNIFICATION_CONTROLLER_NAME);
|
||||
assertThat(value).isEqualTo(TWOFINGER_DOUBLETAP);
|
||||
assertThat(expectedType).isEqualTo(TWOFINGER_DOUBLETAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCreateView_magnificationAreaNotSupported_settingsPreferenceIsNull() {
|
||||
setWindowMagnificationSupported(
|
||||
@@ -1167,9 +1063,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
== ON;
|
||||
}
|
||||
|
||||
private void callEmptyOnClicked(DialogInterface dialog, int which) {
|
||||
}
|
||||
|
||||
private void setWindowMagnificationSupported(boolean magnificationAreaSupported,
|
||||
boolean windowMagnificationSupported) {
|
||||
when(mSpyResources.getBoolean(
|
||||
@@ -1179,24 +1072,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
windowMagnificationSupported);
|
||||
}
|
||||
|
||||
private AlertDialog createEditShortcutDialog(Context context) {
|
||||
context.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
return AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
context,
|
||||
DialogType.EDIT_SHORTCUT_MAGNIFICATION, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
}
|
||||
|
||||
private Bundle createFragmentSavedInstanceState(int userShortcutType) {
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
savedInstanceState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE, userShortcutType);
|
||||
final Bundle fragmentState = new Bundle();
|
||||
fragmentState.putBundle(
|
||||
/* FragmentStateManager.SAVED_INSTANCE_STATE_KEY */ "savedInstanceState",
|
||||
savedInstanceState);
|
||||
return fragmentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* A test fragment that provides a way to change the context
|
||||
*/
|
||||
|
@@ -62,7 +62,7 @@ public class ShortcutOptionPreferenceTest {
|
||||
@Test
|
||||
public void bindViewHolder_imageResIdSet_shouldShowImageView() {
|
||||
mShortcutOptionPreference.setIntroImageResId(
|
||||
R.drawable.accessibility_shortcut_type_hardware);
|
||||
R.drawable.accessibility_shortcut_type_volume_keys);
|
||||
|
||||
mShortcutOptionPreference.onBindViewHolder(mViewHolder);
|
||||
|
||||
|
Reference in New Issue
Block a user