Cleaning up quick settings flag in Settings app
Removes all instances of a11y_qs_enabled. Any code that would be nontrivial to remove has been deprecated for later cleanup. Test: atest com.android.settings.accessibility Flag: EXEMPT flag cleanup Bug: 367414968 Change-Id: I81f3c9cee377535eaa552a170d58ec1a79d1da65
This commit is contained in:
@@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
import com.android.settingslib.PrimarySwitchPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Tests for {@link AccessibilityQuickSettingsPrimarySwitchPreferenceController}.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest {
|
||||
|
||||
private static final String PLACEHOLDER_PACKAGE_NAME = "com.placeholder.example";
|
||||
private static final String PLACEHOLDER_TILE_CLASS_NAME =
|
||||
PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
|
||||
private static final ComponentName PLACEHOLDER_TILE_COMPONENT_NAME = new ComponentName(
|
||||
PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME);
|
||||
private static final CharSequence PLACEHOLDER_TILE_CONTENT =
|
||||
PLACEHOLDER_TILE_CLASS_NAME + ".tile.content";
|
||||
private static final String TEST_KEY = "test_pref_key";
|
||||
private static final String TEST_TITLE = "test_title";
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mockito = MockitoJUnit.rule();
|
||||
|
||||
@Spy
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
|
||||
private TestAccessibilityQuickSettingsPrimarySwitchPreferenceController mController;
|
||||
private PrimarySwitchPreference mPreference;
|
||||
private TestFragment mFragment;
|
||||
private PreferenceScreen mScreen;
|
||||
private PreferenceViewHolder mHolder;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private PreferenceManager mPreferenceManager;
|
||||
|
||||
private static PopupWindow getLatestPopupWindow() {
|
||||
final ShadowApplication shadowApplication =
|
||||
Shadow.extract(ApplicationProvider.getApplicationContext());
|
||||
return shadowApplication.getLatestPopupWindow();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
mFragment = spy(new TestFragment());
|
||||
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
|
||||
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||
when(mFragment.getContext()).thenReturn(mContext);
|
||||
mScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null));
|
||||
when(mScreen.getPreferenceManager()).thenReturn(mPreferenceManager);
|
||||
doReturn(mScreen).when(mFragment).getPreferenceScreen();
|
||||
|
||||
mPreference = new PrimarySwitchPreference(mContext);
|
||||
mPreference.setKey(TEST_KEY);
|
||||
mPreference.setTitle(TEST_TITLE);
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
mHolder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(
|
||||
com.android.settingslib.widget.preference.twotarget.R.layout.preference_two_target, null));
|
||||
LinearLayout mWidgetView = mHolder.itemView.findViewById(android.R.id.widget_frame);
|
||||
inflater.inflate(R.layout.preference_widget_primary_switch, mWidgetView, true);
|
||||
mPreference.onBindViewHolder(mHolder);
|
||||
|
||||
mController = new TestAccessibilityQuickSettingsPrimarySwitchPreferenceController(mContext,
|
||||
TEST_KEY);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_showTooltipView() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.setChecked(true);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_notCallDisplayPreference_notShowTooltipView() {
|
||||
// Simulates the slice highlight menu that does not call {@link #displayPreference} before
|
||||
// {@link #setChecked} called.
|
||||
mController.setChecked(true);
|
||||
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_tooltipViewShown_notShowTooltipView() {
|
||||
mController.displayPreference(mScreen);
|
||||
mController.setChecked(true);
|
||||
getLatestPopupWindow().dismiss();
|
||||
mController.setChecked(false);
|
||||
|
||||
mController.setChecked(true);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_showTooltipView() {
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
|
||||
mController.onCreate(savedInstanceState);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
ShadowLooper.idleMainLooper();
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
public static class TestAccessibilityQuickSettingsPrimarySwitchPreferenceController
|
||||
extends AccessibilityQuickSettingsPrimarySwitchPreferenceController {
|
||||
|
||||
public TestAccessibilityQuickSettingsPrimarySwitchPreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
ComponentName getTileComponentName() {
|
||||
return PLACEHOLDER_TILE_COMPONENT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileTooltipContent() {
|
||||
return PLACEHOLDER_TILE_CONTENT;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestFragment extends SettingsPreferenceFragment {
|
||||
|
||||
@Override
|
||||
protected boolean shouldSkipForInitialSUW() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -376,21 +376,7 @@ public class AccessibilitySettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onCreate_flagDisabled_haveRegisterToSpecificUrisAndActions() {
|
||||
setupFragment();
|
||||
|
||||
assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS,
|
||||
AccessibilitySettingsContentObserver.class).isTrue();
|
||||
assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
|
||||
AccessibilitySettingsContentObserver.class).isTrue();
|
||||
assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_QS_TARGETS,
|
||||
AccessibilitySettingsContentObserver.class).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onCreate_flagEnabled_haveRegisterToSpecificUrisAndActions() {
|
||||
public void onCreate_haveRegisterToSpecificUrisAndActions() {
|
||||
setupFragment();
|
||||
|
||||
assertUriObserversContainsClazz(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS,
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.accessibility;
|
||||
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.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -38,14 +37,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.icu.text.CaseMap;
|
||||
import android.os.Bundle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.Flags;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -156,25 +152,6 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_showTooltipView() {
|
||||
mContext.setTheme(androidx.appcompat.R.style.Theme_AppCompat);
|
||||
mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(savedInstanceState);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
|
||||
mFragment.onViewCreated(mFragment.getView(), savedInstanceState);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() {
|
||||
mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
@@ -219,7 +196,6 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
|
||||
final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString(),
|
||||
|
@@ -133,7 +133,6 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void createTutorialPages_turnOnQuickSettingShortcut_hasOnePage() {
|
||||
mShortcutTypes |= QUICK_SETTINGS;
|
||||
|
||||
@@ -260,7 +259,6 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOn_verifyText() {
|
||||
mShortcutTypes |= QUICK_SETTINGS;
|
||||
setTouchExplorationEnabled(true);
|
||||
@@ -292,7 +290,6 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOn_verifyText() {
|
||||
mShortcutTypes |= QUICK_SETTINGS;
|
||||
setTouchExplorationEnabled(true);
|
||||
@@ -318,7 +315,6 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOff_verifyText() {
|
||||
mShortcutTypes |= QUICK_SETTINGS;
|
||||
setTouchExplorationEnabled(false);
|
||||
@@ -349,7 +345,6 @@ public final class AccessibilityShortcutsTutorialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOff_verifyText() {
|
||||
mShortcutTypes |= QUICK_SETTINGS;
|
||||
setTouchExplorationEnabled(false);
|
||||
|
@@ -46,7 +46,6 @@ import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
@@ -203,7 +202,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getUserShortcutTypeFromSettings_threeShortcutTypesChosen() {
|
||||
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
@@ -220,22 +218,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_optInValue_haveMatchString() {
|
||||
clearShortcuts();
|
||||
int shortcutTypes = SOFTWARE | HARDWARE;
|
||||
|
||||
AccessibilityUtil.optInAllValuesToSettings(mContext, shortcutTypes, MOCK_COMPONENT_NAME);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
MOCK_COMPONENT_NAME.flattenToString());
|
||||
assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
MOCK_COMPONENT_NAME.flattenToString());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_optInValue_callsA11yManager() {
|
||||
AccessibilityManager a11yManager =
|
||||
AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
|
||||
@@ -252,20 +234,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInValueToSettings_optInValue_haveMatchString() {
|
||||
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
|
||||
AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE,
|
||||
MOCK_COMPONENT_NAME2);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
MOCK_COMPONENT_NAME.flattenToString() + ":"
|
||||
+ MOCK_COMPONENT_NAME2.flattenToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInValueToSettings_optInValue_callsA11yManager() {
|
||||
AccessibilityManager a11yManager =
|
||||
AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
|
||||
@@ -281,37 +249,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInValueToSettings_optInTwoValues_haveMatchString() {
|
||||
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
|
||||
AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE,
|
||||
MOCK_COMPONENT_NAME2);
|
||||
AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE,
|
||||
MOCK_COMPONENT_NAME2);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
MOCK_COMPONENT_NAME.flattenToString() + ":"
|
||||
+ MOCK_COMPONENT_NAME2.flattenToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutAllValuesToSettings_optOutValue_emptyString() {
|
||||
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
int shortcutTypes =
|
||||
SOFTWARE | HARDWARE | TRIPLETAP;
|
||||
|
||||
AccessibilityUtil.optOutAllValuesFromSettings(mContext, shortcutTypes,
|
||||
MOCK_COMPONENT_NAME);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty();
|
||||
assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutAllValuesToSettings_optOutValue_callsA1yManager() {
|
||||
AccessibilityManager a11yManager =
|
||||
AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
|
||||
@@ -331,31 +268,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutValueFromSettings_optOutValue_emptyString() {
|
||||
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
|
||||
|
||||
AccessibilityUtil.optOutValueFromSettings(mContext, SOFTWARE,
|
||||
MOCK_COMPONENT_NAME);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutValueFromSettings_optOutValue_haveMatchString() {
|
||||
setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString(),
|
||||
MOCK_COMPONENT_NAME2.flattenToString());
|
||||
|
||||
AccessibilityUtil.optOutValueFromSettings(mContext, SOFTWARE,
|
||||
MOCK_COMPONENT_NAME2);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
MOCK_COMPONENT_NAME.flattenToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutValueFromSettings_optOutValue_callsA11yManager() {
|
||||
AccessibilityManager a11yManager =
|
||||
AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
|
||||
@@ -389,7 +301,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void convertKeyFromSettings_shortcutTypeMultiFingersMultiTap() {
|
||||
assertThat(AccessibilityUtil.convertKeyFromSettings(TWOFINGER_DOUBLETAP))
|
||||
.isEqualTo(
|
||||
@@ -397,7 +308,6 @@ public final class AccessibilityUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void convertKeyFromSettings_shortcutTypeQuickSettings() {
|
||||
assertThat(AccessibilityUtil.convertKeyFromSettings(QUICK_SETTINGS))
|
||||
.isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
|
||||
|
@@ -22,7 +22,6 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.content.Context;
|
||||
|
@@ -26,8 +26,8 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
|
@@ -30,10 +30,10 @@ import android.provider.Settings;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
|
||||
import com.android.settings.widget.SeekBarPreference;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
|
@@ -31,9 +31,9 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -42,8 +42,8 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
/** Test for {@link MediaVibrationIntensityPreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
|
@@ -34,13 +34,8 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Bundle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.service.quicksettings.TileService;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -55,7 +50,6 @@ import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragm
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
@@ -75,8 +69,6 @@ import java.util.Set;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
|
||||
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
private static final String PLACEHOLDER_PACKAGE_NAME = "com.placeholder.example";
|
||||
private static final String PLACEHOLDER_PACKAGE_NAME2 = "com.placeholder.example2";
|
||||
private static final String PLACEHOLDER_SERVICE_CLASS_NAME = "a11yservice1";
|
||||
@@ -314,30 +306,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getDefaultShortcutTypes_noAssociatedTile_softwareTypeIsDefault() throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
setupAccessibilityServiceInfoForFragment(
|
||||
/* isAccessibilityTool= */ true,
|
||||
/* tileService= */ null
|
||||
/* warningRequired= */);
|
||||
|
||||
assertThat(mFragment.getDefaultShortcutTypes())
|
||||
.isEqualTo(ShortcutConstants.UserShortcutType.SOFTWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getDefaultShortcutTypes_hasAssociatedTile_softwareTypeIsDefault() {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
when(mFragment.getTileComponentName()).thenReturn(PLACEHOLDER_TILE_COMPONENT_NAME);
|
||||
|
||||
assertThat(mFragment.getDefaultShortcutTypes())
|
||||
.isEqualTo(ShortcutConstants.UserShortcutType.SOFTWARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getDefaultShortcutTypes_isAccessibilityTool_hasAssociatedTile_qsTypeIsDefault()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
@@ -351,7 +319,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getDefaultShortcutTypes_isNotAccessibilityTool_hasAssociatedTile_softwareTypeIsDefault()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
@@ -365,7 +332,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getDefaultShortcutTypes_isAccessibilityTool_noAssociatedTile_softwareTypeIsDefault()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
@@ -379,7 +345,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getDefaultShortcutTypes_isNotAccessibilityTool_noAssociatedTile_softwareTypeIsDefault()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
@@ -393,7 +358,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_enableQsShortcut()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
@@ -413,7 +377,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_enableSoftwareShortcut()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
@@ -433,47 +396,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_flagOff_enableSoftwareShortcut()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
setupAccessibilityServiceInfoForFragment(
|
||||
/* isAccessibilityTool= */ true,
|
||||
/* tileService= */ PLACEHOLDER_TILE_COMPONENT_NAME
|
||||
/* warningRequired= */);
|
||||
mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null);
|
||||
|
||||
mFragment.mShortcutPreference.setChecked(true);
|
||||
mFragment.onToggleClicked(mFragment.mShortcutPreference);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getString(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS))
|
||||
.contains(mFragment.mComponentName.flattenToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_flagOff_enableSoftwareShortcut()
|
||||
throws Throwable {
|
||||
PreferredShortcuts.clearPreferredShortcuts(mContext);
|
||||
setupAccessibilityServiceInfoForFragment(
|
||||
/* isAccessibilityTool= */ true,
|
||||
/* tileService= */ null
|
||||
/* warningRequired= */);
|
||||
mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */ null);
|
||||
|
||||
mFragment.mShortcutPreference.setChecked(true);
|
||||
mFragment.onToggleClicked(mFragment.mShortcutPreference);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getString(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS))
|
||||
.contains(mFragment.mComponentName.flattenToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void toggleShortcutPreference_userPreferVolumeKeysShortcut_noQsTile_enableVolumeKeysShortcut()
|
||||
throws Throwable {
|
||||
setupAccessibilityServiceInfoForFragment(
|
||||
@@ -498,7 +420,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void toggleShortcutPreference_userPreferVolumeKeysShortcut_hasQsTile_enableVolumeKeysShortcut()
|
||||
throws Throwable {
|
||||
setupAccessibilityServiceInfoForFragment(
|
||||
|
@@ -139,25 +139,6 @@ public class ToggleColorInversionPreferenceFragmentTest {
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onPreferenceToggled_colorCorrectDisabled_shouldReturnTrueAndShowTooltipView() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF);
|
||||
mSwitchPreference.setChecked(false);
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
|
||||
mFragment.onViewCreated(mFragment.getView(), Bundle.EMPTY);
|
||||
|
||||
mFragment.onPreferenceToggled(mSwitchPreference.getKey(), true);
|
||||
|
||||
final boolean isEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF) == ON;
|
||||
assertThat(isEnabled).isTrue();
|
||||
assertThat(getLatestPopupWindow()).isNotNull();
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
|
@@ -106,23 +106,6 @@ public class ToggleDaltonizerPreferenceFragmentTest {
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onPreferenceToggled_colorCorrectDisabled_shouldReturnTrueAndShowTooltipView() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, OFF);
|
||||
ToggleDaltonizerPreferenceFragment fragment = getFragmentInResumedState();
|
||||
SettingsMainSwitchPreference switchPreference = getMainFeatureToggle(fragment);
|
||||
|
||||
fragment.onPreferenceToggled(switchPreference.getKey(), true);
|
||||
|
||||
final boolean isEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, OFF) == ON;
|
||||
assertThat(isEnabled).isTrue();
|
||||
assertThat(getLatestPopupWindow()).isNotNull();
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceToggled_colorCorrectEnabled_shouldReturnFalseAndNotShowTooltipView() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
|
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -38,7 +37,6 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.icu.text.CaseMap;
|
||||
import android.os.Bundle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
@@ -142,7 +140,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = {ShadowFragment.class})
|
||||
public void onResume_flagEnabled_haveRegisterToSpecificUris() {
|
||||
mFragment.onAttach(mContext);
|
||||
@@ -166,31 +163,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
any(AccessibilitySettingsContentObserver.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = {ShadowFragment.class})
|
||||
public void onResume_flagDisabled_haveRegisterToSpecificUris() {
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(Bundle.EMPTY);
|
||||
|
||||
mFragment.onResume();
|
||||
|
||||
verify(mContentResolver).registerContentObserver(
|
||||
eq(Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS)),
|
||||
eq(false),
|
||||
any(AccessibilitySettingsContentObserver.class));
|
||||
verify(mContentResolver).registerContentObserver(
|
||||
eq(Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE)),
|
||||
eq(false),
|
||||
any(AccessibilitySettingsContentObserver.class));
|
||||
verify(mContentResolver, never()).registerContentObserver(
|
||||
eq(Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_QS_TARGETS)),
|
||||
eq(false),
|
||||
any(AccessibilitySettingsContentObserver.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
|
||||
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||
@@ -240,15 +212,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnEnabledService_showTooltipView() {
|
||||
mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnEnabledService_inSuw_toolTipViewShouldNotShow() {
|
||||
@@ -261,18 +224,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnEnabledService_tooltipViewShown_notShowTooltipView() {
|
||||
mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
|
||||
getLatestPopupWindow().dismiss();
|
||||
|
||||
mFragment.onPreferenceToggled(mFragment.getUseServicePreferenceKey(), /* enabled= */ true);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initTopIntroPreference_hasTopIntroTitle_shouldSetAsExpectedValue() {
|
||||
mFragment.mTopIntroTitle = DEFAULT_TOP_INTRO;
|
||||
@@ -365,7 +316,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void showQuickSettingsTooltipIfNeeded_qsFlagOn_dontShowTooltipView() {
|
||||
mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
@@ -374,7 +324,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
|
||||
final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString(),
|
||||
|
@@ -337,8 +337,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onResume_flagEnabled_haveRegisterToSpecificUris() {
|
||||
public void onResume_haveRegisterToSpecificUris() {
|
||||
ShadowContentResolver shadowContentResolver = Shadows.shadowOf(
|
||||
mContext.getContentResolver());
|
||||
Uri[] observedUri = new Uri[]{
|
||||
@@ -367,38 +366,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onResume_flagDisabled_haveRegisterToSpecificUris() {
|
||||
ShadowContentResolver shadowContentResolver = Shadows.shadowOf(
|
||||
mContext.getContentResolver());
|
||||
Uri[] observedUri = new Uri[]{
|
||||
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS),
|
||||
Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE),
|
||||
Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED),
|
||||
Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED)
|
||||
};
|
||||
for (Uri uri : observedUri) {
|
||||
// verify no observer registered before launching the fragment
|
||||
assertThat(shadowContentResolver.getContentObservers(uri)).isEmpty();
|
||||
}
|
||||
|
||||
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
|
||||
|
||||
for (Uri uri : observedUri) {
|
||||
Collection<ContentObserver> observers = shadowContentResolver.getContentObservers(uri);
|
||||
assertThat(observers.size()).isEqualTo(1);
|
||||
assertThat(observers.stream().findFirst().get()).isInstanceOf(
|
||||
AccessibilitySettingsContentObserver.class);
|
||||
}
|
||||
assertThat(shadowContentResolver.getContentObservers(
|
||||
Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_QS_TARGETS))).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE)
|
||||
public void onResume_oneFingerPanningFlagOn_registerToSpecificUri() {
|
||||
@@ -462,20 +429,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_optInValue_haveMatchString() {
|
||||
int shortcutTypes = SOFTWARE | TRIPLETAP;
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
|
||||
shortcutTypes);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
MAGNIFICATION_CONTROLLER_NAME);
|
||||
assertThat(getMagnificationTripleTapStatus()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_optInValue_callA11yManager() {
|
||||
int shortcutTypes =
|
||||
SOFTWARE | TRIPLETAP | HARDWARE
|
||||
@@ -500,45 +453,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
verifyNoMoreInteractions(mAccessibilityManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_twoFingerTripleTap_haveMatchString() {
|
||||
int shortcutTypes = TWOFINGER_DOUBLETAP;
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
|
||||
shortcutTypes);
|
||||
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF)).isEqualTo(ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_existOtherValue_optInValue_haveMatchString() {
|
||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, PLACEHOLDER_COMPONENT_NAME.flattenToString());
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
|
||||
SOFTWARE);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optInAllValuesToSettings_software_sizeValueIsNull_putLargeSizeValue() {
|
||||
ShadowSettings.ShadowSecure.reset();
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
|
||||
SOFTWARE);
|
||||
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
|
||||
FloatingMenuSizePreferenceController.Size.UNKNOWN)).isEqualTo(
|
||||
FloatingMenuSizePreferenceController.Size.LARGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
|
||||
for (int size : new int[]{FloatingMenuSizePreferenceController.Size.LARGE,
|
||||
@@ -594,24 +508,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutAllValuesToSettings_optOutValue_emptyString() {
|
||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
||||
putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
||||
setMagnificationTripleTapEnabled(/* enabled= */ true);
|
||||
int shortcutTypes =
|
||||
SOFTWARE | HARDWARE | TRIPLETAP;
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
|
||||
mContext, shortcutTypes);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty();
|
||||
assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEmpty();
|
||||
assertThat(getMagnificationTripleTapStatus()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutAllValuesToSettings_optOutValue_callA11yManager() {
|
||||
Set<String> shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME);
|
||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
||||
@@ -635,38 +531,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
verifyNoMoreInteractions(mAccessibilityManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutAllValuesToSettings_twoFingerTripleTap_settingsValueIsOff() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
|
||||
mContext, TWOFINGER_DOUBLETAP);
|
||||
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON)).isEqualTo(OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() {
|
||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY,
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
|
||||
putStringIntoSettings(HARDWARE_SHORTCUT_KEY,
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
|
||||
int shortcutTypes = SOFTWARE | HARDWARE;
|
||||
|
||||
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
|
||||
mContext, shortcutTypes);
|
||||
|
||||
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString());
|
||||
assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEqualTo(
|
||||
PLACEHOLDER_COMPONENT_NAME.flattenToString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
|
||||
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
|
||||
@@ -979,7 +843,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
|
||||
final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
|
||||
MAGNIFICATION_CONTROLLER_NAME,
|
||||
|
@@ -46,7 +46,6 @@ import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.util.Pair;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -466,7 +465,6 @@ public class EditShortcutsPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void fragmentResumed_enableTouchExploration_qsShortcutOptionSummaryUpdated() {
|
||||
String expectedSummary = StringUtil.getIcuPluralsString(mContext, 2,
|
||||
R.string.accessibility_shortcut_edit_dialog_summary_quick_settings);
|
||||
@@ -486,7 +484,6 @@ public class EditShortcutsPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void fragmentPaused_enableTouchExploration_qsShortcutOptionSummaryNotUpdated() {
|
||||
String expectedSummary = StringUtil.getIcuPluralsString(mContext, 1,
|
||||
R.string.accessibility_shortcut_edit_dialog_summary_quick_settings);
|
||||
@@ -644,7 +641,6 @@ public class EditShortcutsPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void onQuickSettingsShortcutSettingChanged_preferredShortcutsUpdated() {
|
||||
final String target = TARGET_FAKE_COMPONENT.flattenToString();
|
||||
mFragmentScenario = createFragScenario(
|
||||
|
@@ -27,11 +27,7 @@ import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -45,7 +41,6 @@ import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -67,8 +62,6 @@ public class QuickSettingsShortcutOptionControllerTest {
|
||||
private static final String TARGET_FLATTEN = TARGET.flattenToString();
|
||||
private static final ComponentName TARGET_TILE =
|
||||
new ComponentName("FakePackage", "FakeTileClass");
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
private final Context mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
private QuickSettingsShortcutOptionController mController;
|
||||
@@ -149,13 +142,6 @@ public class QuickSettingsShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void isShortcutAvailable_a11yQsShortcutFlagDisabled_returnsFalse() {
|
||||
assertThat(mController.isShortcutAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void isShortcutAvailable_qsNotSupported_returnsFalse() {
|
||||
SettingsShadowResources.overrideResource(
|
||||
com.android.internal.R.bool.config_quickSettingsSupported, false);
|
||||
@@ -164,7 +150,6 @@ public class QuickSettingsShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void isShortcutAvailable_qsTileProvided_returnsTrue() {
|
||||
when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId()))
|
||||
.thenReturn(Map.of(TARGET, TARGET_TILE));
|
||||
@@ -173,7 +158,6 @@ public class QuickSettingsShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void isShortcutAvailable_qsTileNotProvided_returnsFalse() {
|
||||
when(mAccessibilityManager.getA11yFeatureToTileMap(UserHandle.myUserId()))
|
||||
.thenReturn(Collections.emptyMap());
|
||||
@@ -182,7 +166,6 @@ public class QuickSettingsShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void isShortcutAvailable_qsTileProvided_invalidUseCase_returnFalse() {
|
||||
AccessibilityServiceInfo mockStandardA11yService =
|
||||
AccessibilityTestUtils.createAccessibilityServiceInfo(
|
||||
@@ -197,7 +180,6 @@ public class QuickSettingsShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void isShortcutAvailable_qsTileProvided_validUseCase_returnTrue() {
|
||||
AccessibilityServiceInfo mockAlwaysOnA11yService =
|
||||
AccessibilityTestUtils.createAccessibilityServiceInfo(
|
||||
|
@@ -33,14 +33,11 @@ import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
@@ -50,10 +47,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settings.accessibility.AccessibilityButtonFragment;
|
||||
import com.android.settings.accessibility.FloatingMenuSizePreferenceController;
|
||||
import com.android.settings.testutils.AccessibilityTestUtils;
|
||||
import com.android.settings.utils.AnnotationSpan;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -178,23 +173,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcut_shortcutTurnedOn() {
|
||||
String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString();
|
||||
mController.setShortcutTargets(Set.of(target));
|
||||
assertThat(ShortcutUtils.isComponentIdExistingInSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target
|
||||
)).isFalse();
|
||||
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(ShortcutUtils.isComponentIdExistingInSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target
|
||||
)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcut_callA11yManager() {
|
||||
String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString();
|
||||
mController.setShortcutTargets(Set.of(target));
|
||||
@@ -214,25 +192,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableShortcut_shortcutTurnedOff() {
|
||||
String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString();
|
||||
ShortcutUtils.optInValueToSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target);
|
||||
assertThat(ShortcutUtils.isComponentIdExistingInSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target
|
||||
)).isTrue();
|
||||
mController.setShortcutTargets(Set.of(target));
|
||||
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
assertThat(ShortcutUtils.isComponentIdExistingInSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.SOFTWARE, target
|
||||
)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableShortcut_callA11yManager() {
|
||||
String target = TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString();
|
||||
ShortcutUtils.optInValueToSettings(
|
||||
@@ -253,89 +212,6 @@ public class SoftwareShortcutOptionPreferenceControllerTest {
|
||||
verifyNoMoreInteractions(mAccessibilityManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcutWithMagnification_menuSizeIncreased() {
|
||||
mController.setShortcutTargets(Set.of(TARGET_MAGNIFICATION));
|
||||
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
|
||||
FloatingMenuSizePreferenceController.Size.UNKNOWN))
|
||||
.isEqualTo(FloatingMenuSizePreferenceController.Size.LARGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcutWithMagnification_userConfigureSmallMenuSize_menuSizeNotChanged() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
|
||||
FloatingMenuSizePreferenceController.Size.SMALL);
|
||||
mController.setShortcutTargets(Set.of(TARGET_MAGNIFICATION));
|
||||
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
|
||||
FloatingMenuSizePreferenceController.Size.UNKNOWN))
|
||||
.isEqualTo(FloatingMenuSizePreferenceController.Size.SMALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableAlwaysOnServiceShortcut_turnsOnAlwaysOnService() {
|
||||
mController.setShortcutTargets(
|
||||
Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()));
|
||||
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext))
|
||||
.contains(TARGET_ALWAYS_ON_A11Y_SERVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableAlwaysOnServiceShortcut_turnsOffAlwaysOnService() {
|
||||
mController.setShortcutTargets(
|
||||
Set.of(TARGET_ALWAYS_ON_A11Y_SERVICE.flattenToString()));
|
||||
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext))
|
||||
.doesNotContain(TARGET_ALWAYS_ON_A11Y_SERVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableStandardServiceShortcut_wontTurnOnService() {
|
||||
mController.setShortcutTargets(
|
||||
Set.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString()));
|
||||
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext))
|
||||
.doesNotContain(TARGET_STANDARD_A11Y_SERVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableStandardServiceShortcutWithServiceOn_wontTurnOffService() {
|
||||
mController.setShortcutTargets(
|
||||
Set.of(TARGET_STANDARD_A11Y_SERVICE.flattenToString()));
|
||||
AccessibilityUtils.setAccessibilityServiceState(
|
||||
mContext, TARGET_STANDARD_A11Y_SERVICE, /* enabled= */ true);
|
||||
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
assertThat(AccessibilityUtils.getEnabledServicesFromSettings(mContext))
|
||||
.contains(TARGET_STANDARD_A11Y_SERVICE);
|
||||
}
|
||||
|
||||
private void assertLaunchSettingsPage(String page) {
|
||||
ContextWrapper applicationContext = (Application) mContext.getApplicationContext();
|
||||
final Intent intent = Shadows.shadowOf(applicationContext).getNextStartedActivity();
|
||||
|
@@ -28,12 +28,9 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -182,20 +179,6 @@ public class TripleTapShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcut_settingUpdated() {
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
|
||||
AccessibilityUtil.State.OFF)
|
||||
).isEqualTo(AccessibilityUtil.State.ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcut_callA11yManager() {
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
@@ -209,20 +192,6 @@ public class TripleTapShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableShortcut_settingUpdated() {
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
|
||||
AccessibilityUtil.State.OFF)
|
||||
).isEqualTo(AccessibilityUtil.State.OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableShortcut_callA11yManager() {
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
|
@@ -143,20 +143,6 @@ public class TwoFingerDoubleTapShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcut_settingUpdated() {
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
|
||||
AccessibilityUtil.State.OFF)
|
||||
).isEqualTo(AccessibilityUtil.State.ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableShortcut_callA11yManager() {
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
@@ -170,20 +156,6 @@ public class TwoFingerDoubleTapShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableShortcut_settingUpdated() {
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
assertThat(
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
|
||||
AccessibilityUtil.State.OFF)
|
||||
).isEqualTo(AccessibilityUtil.State.OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableShortcut_callA11yManager() {
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
|
@@ -25,11 +25,8 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -111,17 +108,6 @@ public class VolumeKeysShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableVolumeKeysShortcut_shortcutSet() {
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
assertThat(
|
||||
ShortcutUtils.isComponentIdExistingInSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.HARDWARE, TARGET)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_enableVolumeKeysShortcut_callA11yManager() {
|
||||
mController.enableShortcutForTargets(true);
|
||||
|
||||
@@ -135,17 +121,6 @@ public class VolumeKeysShortcutOptionControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableVolumeKeysShortcut_shortcutNotSet() {
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
assertThat(
|
||||
ShortcutUtils.isComponentIdExistingInSettings(
|
||||
mContext, ShortcutConstants.UserShortcutType.HARDWARE, TARGET)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
|
||||
public void enableShortcutForTargets_disableVolumeKeysShortcut_callA11yManager() {
|
||||
mController.enableShortcutForTargets(false);
|
||||
|
||||
|
Reference in New Issue
Block a user