Merge "Fix the link text "Learn more" in the accessibility pages with help links could not convey the link's purpose clearly" into sc-dev am: 58ed6a90fe
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14702759 Change-Id: I8bcf4f0e66af8513618609f83a9bcbb4761a1dde
This commit is contained in:
@@ -5335,8 +5335,8 @@
|
||||
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold.</string>
|
||||
<!-- Summary for software shortcut in accessibility edit shortcut dialog when user had enabled the accessibility floating button mode (Floating over other apps). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_shortcut_edit_dialog_summary_software_floating"><annotation id="link">Customize accessibility button</annotation></string>
|
||||
<!-- Summary for footer to show help link. [CHAR LIMIT=NONE] -->
|
||||
<string name="footer_learn_more"><annotation id="link">Learn more</annotation></string>
|
||||
<!-- Footer to show help link content description. [CHAR LIMIT=NONE] -->
|
||||
<string name="footer_learn_more_content_description">Learn more about <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
|
||||
<!-- Title for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
|
||||
<!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
|
||||
|
@@ -17,29 +17,19 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.utils.AnnotationSpan;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
/**
|
||||
* A custom preference acting as footer of a page. It has a field for icon and text. It is added
|
||||
* to screen as the last preference and groups of icon and text content in accessibility-focusable
|
||||
* {@link android.view.accessibility.AccessibilityNodeInfo} for TalkBack to use.
|
||||
* A custom preference acting as footer of a page. Disables the movement method by default.
|
||||
*/
|
||||
public final class AccessibilityFooterPreference extends FooterPreference {
|
||||
|
||||
private CharSequence mIconContentDescription;
|
||||
private boolean mLinkEnabled;
|
||||
|
||||
public AccessibilityFooterPreference(Context context, AttributeSet attrs) {
|
||||
@@ -65,33 +55,6 @@ public final class AccessibilityFooterPreference extends FooterPreference {
|
||||
} else {
|
||||
title.setMovementMethod(/* movement= */ null);
|
||||
}
|
||||
|
||||
final LinearLayout infoFrame = holder.itemView.findViewById(R.id.icon_frame);
|
||||
if (!TextUtils.isEmpty(mIconContentDescription)) {
|
||||
// Groups related content.
|
||||
infoFrame.setContentDescription(mIconContentDescription);
|
||||
title.setFocusable(false);
|
||||
} else {
|
||||
infoFrame.setContentDescription(null);
|
||||
title.setFocusable(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content description of the icon.
|
||||
*/
|
||||
public void setIconContentDescription(CharSequence iconContentDescription) {
|
||||
if (!TextUtils.equals(iconContentDescription, mIconContentDescription)) {
|
||||
mIconContentDescription = iconContentDescription;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content description of the icon.
|
||||
*/
|
||||
public CharSequence getIconContentDescription() {
|
||||
return mIconContentDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,23 +73,4 @@ public final class AccessibilityFooterPreference extends FooterPreference {
|
||||
public boolean isLinkEnabled() {
|
||||
return mLinkEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends {@link AnnotationSpan} with learn more link apart from the other text.
|
||||
*
|
||||
* @param helpLinkRes The Help Uri Resource key
|
||||
*/
|
||||
public void appendHelpLink(int helpLinkRes) {
|
||||
final SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
sb.append(getTitle()).append("\n\n").append(getLearnMoreLink(getContext(), helpLinkRes));
|
||||
setTitle(sb);
|
||||
}
|
||||
|
||||
private CharSequence getLearnMoreLink(Context context, int helpLinkRes) {
|
||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||
context, context.getString(helpLinkRes), context.getClass().getName());
|
||||
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
|
||||
context, AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, helpIntent);
|
||||
return AnnotationSpan.linkify(context.getText(R.string.footer_learn_more), linkInfo);
|
||||
}
|
||||
}
|
||||
|
@@ -17,11 +17,13 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
|
||||
/**
|
||||
* Base class for accessibility preference footer.
|
||||
@@ -59,13 +61,24 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
|
||||
protected abstract String getLabelName();
|
||||
|
||||
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title, getLabelName());
|
||||
footerPreference.setIconContentDescription(iconContentDescription);
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append(mContext.getString(
|
||||
R.string.accessibility_introduction_title, getLabelName()))
|
||||
.append("\n\n")
|
||||
.append(footerPreference.getTitle());
|
||||
footerPreference.setContentDescription(sb);
|
||||
|
||||
if (getHelpResource() != 0) {
|
||||
footerPreference.appendHelpLink(getHelpResource());
|
||||
footerPreference.setLinkEnabled(true);
|
||||
footerPreference.setLearnMoreAction(view -> {
|
||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||
mContext, mContext.getString(getHelpResource()),
|
||||
mContext.getClass().getName());
|
||||
view.startActivityForResult(helpIntent, 0);
|
||||
});
|
||||
|
||||
final String learnMoreContentDescription = mContext.getString(
|
||||
R.string.footer_learn_more_content_description, getLabelName());
|
||||
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -55,6 +55,7 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
import com.android.settings.utils.LocaleUtils;
|
||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||
|
||||
@@ -520,14 +521,25 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
new AccessibilityFooterPreference(screen.getContext());
|
||||
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
htmlFooterPreference.setSummary(htmlDescription);
|
||||
htmlFooterPreference.setContentDescription(
|
||||
generateFooterContentDescription(htmlDescription));
|
||||
|
||||
// Only framework tools support help link
|
||||
if (getHelpResource() != 0) {
|
||||
htmlFooterPreference.appendHelpLink(getHelpResource());
|
||||
htmlFooterPreference.setLearnMoreAction(view -> {
|
||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||
getContext(), getContext().getString(getHelpResource()),
|
||||
getContext().getClass().getName());
|
||||
view.startActivityForResult(helpIntent, 0);
|
||||
});
|
||||
|
||||
final String learnMoreContentDescription = getPrefContext().getString(
|
||||
R.string.footer_learn_more_content_description, mPackageName);
|
||||
htmlFooterPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||
htmlFooterPreference.setLinkEnabled(true);
|
||||
} else {
|
||||
htmlFooterPreference.setLinkEnabled(false);
|
||||
}
|
||||
htmlFooterPreference.setIconContentDescription(iconContentDescription);
|
||||
screen.addPreference(htmlFooterPreference);
|
||||
}
|
||||
|
||||
@@ -559,14 +571,33 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
new AccessibilityFooterPreference(screen.getContext());
|
||||
footerPreference.setSummary(summary);
|
||||
footerPreference.setIconContentDescription(iconContentDescription);
|
||||
footerPreference.setContentDescription(
|
||||
generateFooterContentDescription(summary));
|
||||
|
||||
// Only framework tools support help link
|
||||
if (getHelpResource() != 0) {
|
||||
footerPreference.appendHelpLink(getHelpResource());
|
||||
footerPreference.setLinkEnabled(true);
|
||||
footerPreference.setLearnMoreAction(view -> {
|
||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||
getContext(), getContext().getString(getHelpResource()),
|
||||
getContext().getClass().getName());
|
||||
view.startActivityForResult(helpIntent, 0);
|
||||
});
|
||||
|
||||
final String learnMoreContentDescription = getPrefContext().getString(
|
||||
R.string.footer_learn_more_content_description, mPackageName);
|
||||
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||
}
|
||||
screen.addPreference(footerPreference);
|
||||
}
|
||||
|
||||
private CharSequence generateFooterContentDescription(CharSequence footerContent) {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append(getPrefContext().getString(
|
||||
R.string.accessibility_introduction_title, mPackageName))
|
||||
.append("\n\n")
|
||||
.append(footerContent);
|
||||
return sb;
|
||||
}
|
||||
@VisibleForTesting
|
||||
void setupEditShortcutDialog(Dialog dialog) {
|
||||
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
|
||||
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityButtonFooterPreferenceControllerTest {
|
||||
|
||||
private static final String TEST_KEY = "test_key";
|
||||
private static final String TEST_TITLE = "test_title";
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private PreferenceScreen mScreen;
|
||||
private AccessibilityButtonFooterPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
new AccessibilityFooterPreference(mContext);
|
||||
footerPreference.setKey(TEST_KEY);
|
||||
footerPreference.setTitle(TEST_TITLE);
|
||||
mScreen.addPreference(footerPreference);
|
||||
mController = new AccessibilityButtonFooterPreferenceController(mContext, TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
|
||||
final String packageName = mContext.getString(R.string.accessibility_button_title);
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title,
|
||||
packageName);
|
||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link AccessibilityControlTimeoutFooterPreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityControlTimeoutFooterPreferenceControllerTest {
|
||||
|
||||
private static final String TEST_KEY = "test_key";
|
||||
private static final String TEST_TITLE = "test_title";
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private PreferenceScreen mScreen;
|
||||
private AccessibilityControlTimeoutFooterPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
new AccessibilityFooterPreference(mContext);
|
||||
footerPreference.setKey(TEST_KEY);
|
||||
footerPreference.setTitle(TEST_TITLE);
|
||||
mScreen.addPreference(footerPreference);
|
||||
mController = new AccessibilityControlTimeoutFooterPreferenceController(mContext, TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
mScreen.findPreference(TEST_KEY);
|
||||
final String packageName =
|
||||
mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title,
|
||||
packageName);
|
||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
||||
}
|
||||
}
|
@@ -19,13 +19,12 @@ package com.android.settings.accessibility;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.method.MovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
@@ -39,10 +38,6 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public final class AccessibilityFooterPreferenceTest {
|
||||
|
||||
private static final String DEFAULT_SUMMARY = "default summary";
|
||||
private static final String DEFAULT_DESCRIPTION = "default description";
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private AccessibilityFooterPreference mAccessibilityFooterPreference;
|
||||
private PreferenceViewHolder mPreferenceViewHolder;
|
||||
|
||||
@@ -58,41 +53,22 @@ public final class AccessibilityFooterPreferenceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_initTextConfig_parseTextAndFocusable() {
|
||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
||||
public void onBindViewHolder_LinkDisabledByDefault_notReturnLinkMovement() {
|
||||
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
|
||||
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
||||
android.R.id.title);
|
||||
assertThat(summaryView.getMovementMethod()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_setLinkEnabled_returnLinkMovement() {
|
||||
mAccessibilityFooterPreference.setLinkEnabled(true);
|
||||
|
||||
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
|
||||
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
||||
android.R.id.title);
|
||||
assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
|
||||
assertThat(summaryView.isFocusable()).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_initTextConfigAndAccessibleIcon_groupContentForAccessible() {
|
||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
||||
mAccessibilityFooterPreference.setIconContentDescription(DEFAULT_DESCRIPTION);
|
||||
|
||||
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
|
||||
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
||||
android.R.id.title);
|
||||
assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
|
||||
assertThat(summaryView.isFocusable()).isEqualTo(false);
|
||||
final LinearLayout infoFrame = (LinearLayout) mPreferenceViewHolder.findViewById(
|
||||
R.id.icon_frame);
|
||||
assertThat(infoFrame.getContentDescription()).isEqualTo(DEFAULT_DESCRIPTION);
|
||||
assertThat(infoFrame.isFocusable()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendHelpLink_timeoutHelpUri_updateSummary() {
|
||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
||||
|
||||
mAccessibilityFooterPreference.appendHelpLink(R.string.help_url_timeout);
|
||||
|
||||
final String title = mAccessibilityFooterPreference.getTitle().toString();
|
||||
assertThat(title.contains(mContext.getString(R.string.footer_learn_more))).isTrue();
|
||||
assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class);
|
||||
}
|
||||
}
|
||||
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link CaptionFooterPreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class CaptionFooterPreferenceControllerTest {
|
||||
|
||||
private static final String TEST_KEY = "test_key";
|
||||
private static final String TEST_TITLE = "test_title";
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private PreferenceScreen mScreen;
|
||||
private CaptionFooterPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
new AccessibilityFooterPreference(mContext);
|
||||
footerPreference.setKey(TEST_KEY);
|
||||
footerPreference.setTitle(TEST_TITLE);
|
||||
mScreen.addPreference(footerPreference);
|
||||
mController = new CaptionFooterPreferenceController(mContext, TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
|
||||
final String packageName = mContext.getString(R.string.accessibility_captioning_title);
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title,
|
||||
packageName);
|
||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link ToggleAutoclickFooterPreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ToggleAutoclickFooterPreferenceControllerTest {
|
||||
|
||||
private static final String TEST_KEY = "test_key";
|
||||
private static final String TEST_TITLE = "test_title";
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private PreferenceScreen mScreen;
|
||||
private ToggleAutoclickFooterPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
new AccessibilityFooterPreference(mContext);
|
||||
footerPreference.setKey(TEST_KEY);
|
||||
footerPreference.setTitle(TEST_TITLE);
|
||||
mScreen.addPreference(footerPreference);
|
||||
mController = new ToggleAutoclickFooterPreferenceController(mContext, TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
|
||||
final String packageName = mContext.getString(
|
||||
R.string.accessibility_autoclick_preference_title);
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title,
|
||||
packageName);
|
||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
||||
}
|
||||
}
|
@@ -215,8 +215,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
(AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference(
|
||||
mFragment.getPreferenceScreen().getPreferenceCount() - 1);
|
||||
assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY);
|
||||
assertThat(accessibilityFooterPreference.getIconContentDescription()).isEqualTo(
|
||||
DEFAULT_DESCRIPTION);
|
||||
assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true);
|
||||
assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user