Add SearchIndexable to improve search coverage
- Add searachIndex test - Increase accessibility framework feature fragment coverage Bug: 197695932 Test: make RunSettingsRoboTests Change-Id: Icb7e2cf70bb0443304af7866efd48bed1d9af5bf
This commit is contained in:
@@ -34,12 +34,15 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** Settings page for color inversion. */
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
|
||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
||||
@@ -173,4 +176,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
}
|
||||
mToggleServiceSwitchPreference.setChecked(checked);
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings);
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
@@ -70,6 +71,17 @@ public class AccessibilityButtonFragmentTest {
|
||||
when(mFragment.getActivity()).thenReturn(Robolectric.setupActivity(FragmentActivity.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_BUTTON_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("AccessibilityButtonFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCreate_navigationGestureEnabled_setCorrectTitle() {
|
||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||
|
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -60,6 +61,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** Tests for {@link AccessibilityDetailsSettingsFragment}. */
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityDetailsSettingsFragmentTest {
|
||||
@@ -169,6 +171,12 @@ public class AccessibilityDetailsSettingsFragmentTest {
|
||||
AccessibilityButtonFragment.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_DETAILS_SETTINGS);
|
||||
}
|
||||
|
||||
private AccessibilityServiceInfo getMockAccessibilityServiceInfo() {
|
||||
final ApplicationInfo applicationInfo = new ApplicationInfo();
|
||||
final ServiceInfo serviceInfo = new ServiceInfo();
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,6 +26,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -35,7 +37,30 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AudioAdjustmentFragmentTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private AudioAdjustmentFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new AudioAdjustmentFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_AUDIO_ADJUSTMENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_audio_adjustment);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("AudioAdjustmentFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,6 +26,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -35,7 +37,30 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class CaptionMoreOptionsFragmentTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private CaptionMoreOptionsFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new CaptionMoreOptionsFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_CAPTION_MORE_OPTIONS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.captioning_more_options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("CaptionMoreOptionsFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,6 +26,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -36,6 +38,29 @@ import java.util.List;
|
||||
public class CaptionPropertiesFragmentTest {
|
||||
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private CaptionPropertiesFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new CaptionPropertiesFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_CAPTION_PROPERTIES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.captioning_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("CaptionPropertiesFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,16 +26,41 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Tests for {@link ColorAndMotionFragment}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ColorAndMotionFragmentTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private ColorAndMotionFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new ColorAndMotionFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_COLOR_AND_MOTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_color_and_motion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("ColorAndMotionFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -44,7 +45,7 @@ import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
|
||||
/** Tests for {@link HearingAidDialogFragment}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowAlertDialogCompat.class)
|
||||
public class HearingAidDialogFragmentTest {
|
||||
@@ -90,4 +91,10 @@ public class HearingAidDialogFragmentTest {
|
||||
|
||||
assertThat(dialog.isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.DIALOG_ACCESSIBILITY_HEARINGAID);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -102,4 +103,10 @@ public class HearingAidPairingDialogFragmentTest {
|
||||
|
||||
assertThat(dialog.isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.DIALOG_ACCESSIBILITY_HEARING_AID_PAIR_ANOTHER);
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -67,7 +68,6 @@ public class MagnificationSettingsFragmentTest {
|
||||
doReturn(mScreen).when(mFragment).getPreferenceScreen();
|
||||
doReturn(mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS)).when(
|
||||
mFragment).getChildFragmentManager();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,6 +91,23 @@ public class MagnificationSettingsFragmentTest {
|
||||
verify(dialogDelegate).getDialogMetricsCategory(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_MAGNIFICATION_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_magnification_service_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("MagnificationSettingsFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
final List<String> niks =
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,6 +26,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -35,7 +37,30 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ShortcutsSettingsFragmentTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private ShortcutsSettingsFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new ShortcutsSettingsFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_SHORTCUTS_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_shortcuts_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("ShortcutsSettingsFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,6 +26,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -35,7 +37,30 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SystemControlsFragmentTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private SystemControlsFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new SystemControlsFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_SYSTEM_CONTROLS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_system_controls);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("SystemControlsFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -25,6 +26,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -35,7 +37,30 @@ import java.util.List;
|
||||
/** Tests for {@link TapAssistanceFragment}. */
|
||||
public class TapAssistanceFragmentTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private TapAssistanceFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new TapAssistanceFragment();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_TAP_ASSISTANCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_tap_assistance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("TapAssistanceFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
|
@@ -18,10 +18,13 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.TextReadingPreferenceFragment.RESET_KEY;
|
||||
|
||||
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.verify;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -32,27 +35,29 @@ import com.android.settingslib.widget.LayoutPreference;
|
||||
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Tests for {@link TextReadingPreferenceFragmentForSetupWizard}.
|
||||
*/
|
||||
/** Tests for {@link TextReadingPreferenceFragmentForSetupWizard}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TextReadingPreferenceFragmentForSetupWizardTest {
|
||||
|
||||
private final Context mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
@Rule
|
||||
public final MockitoRule mMockito = MockitoJUnit.rule();
|
||||
@Mock
|
||||
private GlifPreferenceLayout mGlifLayoutView;
|
||||
@Spy
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private TextReadingPreferenceFragmentForSetupWizard mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mFragment = spy(new TextReadingPreferenceFragmentForSetupWizard());
|
||||
final LayoutPreference resetPreference =
|
||||
new LayoutPreference(mContext, R.layout.accessibility_text_reading_reset_button);
|
||||
@@ -70,4 +75,15 @@ public class TextReadingPreferenceFragmentForSetupWizardTest {
|
||||
|
||||
verify(mGlifLayoutView).setHeaderText(title);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.SUW_ACCESSIBILITY_TEXT_READING_OPTIONS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHelpResource_shouldNotHaveHelpResource() {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.provider.Settings;
|
||||
@@ -38,33 +39,37 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
|
||||
import com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
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.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.shadows.ShadowToast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tests for {@link TextReadingPreferenceFragment}.
|
||||
*/
|
||||
/** Tests for {@link TextReadingPreferenceFragment}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TextReadingPreferenceFragmentTest {
|
||||
private TextReadingPreferenceFragment mFragment;
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mMockito = MockitoJUnit.rule();
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private PreferenceManager mPreferenceManager;
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private TextReadingPreferenceFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
|
||||
mFragment = spy(new TextReadingPreferenceFragment());
|
||||
@@ -119,4 +124,32 @@ public class TextReadingPreferenceFragmentTest {
|
||||
assertThat(ShadowToast.getTextOfLatestToast())
|
||||
.isEqualTo(mContext.getString(R.string.accessibility_text_reading_reset_message));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_TEXT_READING_OPTIONS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_text_reading_options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogTag_returnsCorrectTag() {
|
||||
assertThat(mFragment.getLogTag()).isEqualTo("TextReadingPreferenceFragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
final List<String> niks = TextReadingPreferenceFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(mContext);
|
||||
final List<String> keys =
|
||||
XmlTestUtils.getKeysFromPreferenceXml(mContext,
|
||||
R.xml.accessibility_text_reading_options);
|
||||
|
||||
assertThat(keys).containsAtLeastElementsIn(niks);
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -41,7 +42,9 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
|
||||
@@ -56,6 +59,8 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Tests for {@link ToggleColorInversionPreferenceFragment} */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
@@ -159,6 +164,34 @@ public class ToggleColorInversionPreferenceFragmentTest {
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_COLOR_INVERSION_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_color_inversion_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHelpResource_returnsCorrectHelpResource() {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(R.string.help_url_color_inversion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
final List<String> niks = ToggleColorInversionPreferenceFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(mContext);
|
||||
final List<String> keys =
|
||||
XmlTestUtils.getKeysFromPreferenceXml(mContext,
|
||||
R.xml.accessibility_color_inversion_settings);
|
||||
|
||||
assertThat(keys).containsAtLeastElementsIn(niks);
|
||||
}
|
||||
|
||||
private static PopupWindow getLatestPopupWindow() {
|
||||
final ShadowApplication shadowApplication =
|
||||
Shadow.extract(ApplicationProvider.getApplicationContext());
|
||||
|
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -45,7 +46,9 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.widget.SelectorWithWidgetPreference;
|
||||
@@ -61,6 +64,8 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Tests for {@link ToggleDaltonizerPreferenceFragment} */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
@@ -182,6 +187,34 @@ public class ToggleDaltonizerPreferenceFragmentTest {
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId_returnsCorrectXml() {
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(
|
||||
R.xml.accessibility_daltonizer_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHelpResource_returnsCorrectHelpResource() {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(R.string.help_url_color_correction);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
final List<String> niks = ToggleDaltonizerPreferenceFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(mContext);
|
||||
final List<String> keys =
|
||||
XmlTestUtils.getKeysFromPreferenceXml(mContext,
|
||||
R.xml.accessibility_daltonizer_settings);
|
||||
|
||||
assertThat(keys).containsAtLeastElementsIn(niks);
|
||||
}
|
||||
|
||||
private static PopupWindow getLatestPopupWindow() {
|
||||
final ShadowApplication shadowApplication =
|
||||
Shadow.extract(ApplicationProvider.getApplicationContext());
|
||||
|
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -49,9 +50,7 @@ import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
/**
|
||||
* Tests for {@link ToggleScreenMagnificationPreferenceFragmentForSetupWizard}.
|
||||
*/
|
||||
/** Tests for {@link ToggleScreenMagnificationPreferenceFragmentForSetupWizard}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowSettingsPreferenceFragment.class})
|
||||
public class ToggleScreenMagnificationPreferenceFragmentForSetupWizardTest {
|
||||
@@ -89,6 +88,17 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizardTest {
|
||||
assertThat(mFragment.mFollowingTypingSwitchPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHelpResource_shouldNotHaveHelpResource() {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private static class TestToggleScreenMagnificationPreferenceFragmentForSetupWizard
|
||||
extends ToggleScreenMagnificationPreferenceFragmentForSetupWizard {
|
||||
|
||||
|
@@ -70,6 +70,7 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
/** Tests for {@link ToggleScreenMagnificationPreferenceFragment}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowSettingsPreferenceFragment.class})
|
||||
public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
@@ -389,6 +390,16 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
verify(dialogDelegate).getDialogMetricsCategory(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_shouldNotHaveMetricsCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHelpResource_returnsCorrectHelpResource() {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(R.string.help_url_magnification);
|
||||
}
|
||||
|
||||
private void putStringIntoSettings(String key, String componentName) {
|
||||
Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -47,9 +48,7 @@ import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/**
|
||||
* Tests for {@link ToggleScreenReaderPreferenceFragmentForSetupWizard}.
|
||||
*/
|
||||
/** Tests for {@link ToggleScreenReaderPreferenceFragmentForSetupWizard}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ToggleScreenReaderPreferenceFragmentForSetupWizardTest {
|
||||
|
||||
@@ -83,6 +82,12 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizardTest {
|
||||
assertThat(mFragment.mTopIntroPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER);
|
||||
}
|
||||
|
||||
private static class TestToggleScreenReaderPreferenceFragmentForSetupWizard
|
||||
extends ToggleScreenReaderPreferenceFragmentForSetupWizard {
|
||||
|
||||
|
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -47,9 +48,7 @@ import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/**
|
||||
* Tests for {@link ToggleSelectToSpeakPreferenceFragmentForSetupWizard}.
|
||||
*/
|
||||
/** Tests for {@link ToggleSelectToSpeakPreferenceFragmentForSetupWizard}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ToggleSelectToSpeakPreferenceFragmentForSetupWizardTest {
|
||||
|
||||
@@ -83,6 +82,12 @@ public class ToggleSelectToSpeakPreferenceFragmentForSetupWizardTest {
|
||||
assertThat(mFragment.mTopIntroPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricsCategory_returnsCorrectCategory() {
|
||||
assertThat(mFragment.getMetricsCategory()).isEqualTo(
|
||||
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK);
|
||||
}
|
||||
|
||||
private static class TestToggleSelectToSpeakPreferenceFragmentForSetupWizard
|
||||
extends ToggleSelectToSpeakPreferenceFragmentForSetupWizard {
|
||||
|
||||
|
Reference in New Issue
Block a user