Fix ToggleScreenMagnificationPreferenceFragmentTest
**Root cause** ShadowFragment makes the test using an empty implementation of onCreate, hence the test execution throws SuperNotCalledException. ShadowFragment was accidentally added to this test when migrate to the latest Robolectric. Removing ShadowFragment in the config fixes the test. Fix: 300158627 Test: atest ToggleScreenMagnificationPreferenceFragmentTest Change-Id: I8782ac11a93c5f89b781dcca1713968ed18802cf
This commit is contained in:
@@ -57,7 +57,6 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|||||||
import com.google.common.truth.Correspondence;
|
import com.google.common.truth.Correspondence;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
@@ -78,7 +77,6 @@ import java.util.List;
|
|||||||
ShadowUserManager.class,
|
ShadowUserManager.class,
|
||||||
ShadowStorageManager.class,
|
ShadowStorageManager.class,
|
||||||
ShadowSettings.ShadowSecure.class,
|
ShadowSettings.ShadowSecure.class,
|
||||||
com.android.settings.testutils.shadow.ShadowFragment.class,
|
|
||||||
})
|
})
|
||||||
public class ToggleScreenMagnificationPreferenceFragmentTest {
|
public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||||
|
|
||||||
@@ -101,7 +99,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
|
|
||||||
private static final String KEY_FOLLOW_TYPING =
|
private static final String KEY_FOLLOW_TYPING =
|
||||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED;
|
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED;
|
||||||
|
|
||||||
private FragmentController<ToggleScreenMagnificationPreferenceFragment> mFragController;
|
private FragmentController<ToggleScreenMagnificationPreferenceFragment> mFragController;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Resources mSpyResources;
|
private Resources mSpyResources;
|
||||||
@@ -109,6 +106,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpTestFragment() {
|
public void setUpTestFragment() {
|
||||||
|
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
// Set up the fragment that support window magnification feature
|
// Set up the fragment that support window magnification feature
|
||||||
@@ -130,7 +128,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onResume_defaultStateForFollowingTyping_switchPreferenceShouldReturnTrue() {
|
public void onResume_defaultStateForFollowingTyping_switchPreferenceShouldReturnTrue() {
|
||||||
setKeyFollowTypingEnabled(true);
|
setKeyFollowTypingEnabled(true);
|
||||||
|
|
||||||
@@ -144,7 +141,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onResume_disableFollowingTyping_switchPreferenceShouldReturnFalse() {
|
public void onResume_disableFollowingTyping_switchPreferenceShouldReturnFalse() {
|
||||||
setKeyFollowTypingEnabled(false);
|
setKeyFollowTypingEnabled(false);
|
||||||
|
|
||||||
@@ -158,7 +154,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onResume_haveRegisterToSpecificUris() {
|
public void onResume_haveRegisterToSpecificUris() {
|
||||||
ShadowContentResolver shadowContentResolver = Shadows.shadowOf(
|
ShadowContentResolver shadowContentResolver = Shadows.shadowOf(
|
||||||
mContext.getContentResolver());
|
mContext.getContentResolver());
|
||||||
@@ -187,7 +182,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void hasValueInSettings_putValue_hasValue() {
|
public void hasValueInSettings_putValue_hasValue() {
|
||||||
setMagnificationTripleTapEnabled(/* enabled= */ true);
|
setMagnificationTripleTapEnabled(/* enabled= */ true);
|
||||||
|
|
||||||
@@ -196,7 +190,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optInAllValuesToSettings_optInValue_haveMatchString() {
|
public void optInAllValuesToSettings_optInValue_haveMatchString() {
|
||||||
int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP;
|
int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP;
|
||||||
|
|
||||||
@@ -210,7 +203,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optInAllValuesToSettings_existOtherValue_optInValue_haveMatchString() {
|
public void optInAllValuesToSettings_existOtherValue_optInValue_haveMatchString() {
|
||||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, PLACEHOLDER_COMPONENT_NAME.flattenToString());
|
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, PLACEHOLDER_COMPONENT_NAME.flattenToString());
|
||||||
|
|
||||||
@@ -222,7 +214,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optInAllValuesToSettings_software_sizeValueIsNull_putLargeSizeValue() {
|
public void optInAllValuesToSettings_software_sizeValueIsNull_putLargeSizeValue() {
|
||||||
ShadowSettings.ShadowSecure.reset();
|
ShadowSettings.ShadowSecure.reset();
|
||||||
|
|
||||||
@@ -236,7 +227,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
|
public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
|
||||||
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.LARGE,
|
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.LARGE,
|
||||||
FloatingMenuSizePreferenceController.Size.SMALL}) {
|
FloatingMenuSizePreferenceController.Size.SMALL}) {
|
||||||
@@ -255,7 +245,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optInAllValuesToSettings_hardware_sizeValueIsNotChanged() {
|
public void optInAllValuesToSettings_hardware_sizeValueIsNotChanged() {
|
||||||
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
|
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
|
||||||
FloatingMenuSizePreferenceController.Size.LARGE,
|
FloatingMenuSizePreferenceController.Size.LARGE,
|
||||||
@@ -274,7 +263,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optInAllValuesToSettings_tripletap_sizeValueIsNotChanged() {
|
public void optInAllValuesToSettings_tripletap_sizeValueIsNotChanged() {
|
||||||
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
|
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
|
||||||
FloatingMenuSizePreferenceController.Size.LARGE,
|
FloatingMenuSizePreferenceController.Size.LARGE,
|
||||||
@@ -293,7 +281,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optOutAllValuesToSettings_optOutValue_emptyString() {
|
public void optOutAllValuesToSettings_optOutValue_emptyString() {
|
||||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
||||||
putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
||||||
@@ -310,7 +297,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() {
|
public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() {
|
||||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY,
|
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY,
|
||||||
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
|
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
|
||||||
@@ -328,7 +314,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
|
public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
|
||||||
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
|
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
|
||||||
|
|
||||||
@@ -341,7 +326,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void updateShortcutPreferenceData_hasValueInSettings_assignToVariable() {
|
public void updateShortcutPreferenceData_hasValueInSettings_assignToVariable() {
|
||||||
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
|
||||||
setMagnificationTripleTapEnabled(/* enabled= */ true);
|
setMagnificationTripleTapEnabled(/* enabled= */ true);
|
||||||
@@ -355,7 +339,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void updateShortcutPreferenceData_hasValueInSharedPreference_assignToVariable() {
|
public void updateShortcutPreferenceData_hasValueInSharedPreference_assignToVariable() {
|
||||||
final PreferredShortcut tripleTapShortcut = new PreferredShortcut(
|
final PreferredShortcut tripleTapShortcut = new PreferredShortcut(
|
||||||
MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TRIPLETAP);
|
MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TRIPLETAP);
|
||||||
@@ -370,7 +353,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||||
mFragController.create(R.id.main_content, /* bundle= */
|
mFragController.create(R.id.main_content, /* bundle= */
|
||||||
@@ -386,7 +368,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
|
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
|
||||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||||
mFragController.create(R.id.main_content, /* bundle= */
|
mFragController.create(R.id.main_content, /* bundle= */
|
||||||
@@ -407,7 +388,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void restoreValueFromSavedInstanceState_assignToVariable() {
|
public void restoreValueFromSavedInstanceState_assignToVariable() {
|
||||||
final Bundle fragmentState = createFragmentSavedInstanceState(
|
final Bundle fragmentState = createFragmentSavedInstanceState(
|
||||||
UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
|
UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
|
||||||
@@ -429,7 +409,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onCreateView_magnificationAreaNotSupported_settingsPreferenceIsNull() {
|
public void onCreateView_magnificationAreaNotSupported_settingsPreferenceIsNull() {
|
||||||
setWindowMagnificationSupported(
|
setWindowMagnificationSupported(
|
||||||
/* magnificationAreaSupported= */ false,
|
/* magnificationAreaSupported= */ false,
|
||||||
@@ -441,7 +420,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onCreateView_windowMagnificationNotSupported_settingsPreferenceIsNull() {
|
public void onCreateView_windowMagnificationNotSupported_settingsPreferenceIsNull() {
|
||||||
setWindowMagnificationSupported(
|
setWindowMagnificationSupported(
|
||||||
/* magnificationAreaSupported= */ true,
|
/* magnificationAreaSupported= */ true,
|
||||||
@@ -453,7 +431,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onCreateView_setDialogDelegateAndAddTheControllerToLifeCycleObserver() {
|
public void onCreateView_setDialogDelegateAndAddTheControllerToLifeCycleObserver() {
|
||||||
Correspondence instanceOf = Correspondence.transforming(
|
Correspondence instanceOf = Correspondence.transforming(
|
||||||
observer -> (observer instanceof MagnificationModePreferenceController),
|
observer -> (observer instanceof MagnificationModePreferenceController),
|
||||||
@@ -471,7 +448,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onCreateDialog_setDialogDelegate_invokeDialogDelegate() {
|
public void onCreateDialog_setDialogDelegate_invokeDialogDelegate() {
|
||||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||||
mFragController.create(
|
mFragController.create(
|
||||||
@@ -488,7 +464,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getMetricsCategory_returnsCorrectCategory() {
|
public void getMetricsCategory_returnsCorrectCategory() {
|
||||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||||
mFragController.create(
|
mFragController.create(
|
||||||
@@ -499,7 +474,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getHelpResource_returnsCorrectHelpResource() {
|
public void getHelpResource_returnsCorrectHelpResource() {
|
||||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||||
mFragController.create(
|
mFragController.create(
|
||||||
@@ -509,7 +483,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onProcessArguments_defaultArgumentUnavailable_shouldSetDefaultArguments() {
|
public void onProcessArguments_defaultArgumentUnavailable_shouldSetDefaultArguments() {
|
||||||
ToggleScreenMagnificationPreferenceFragment fragment =
|
ToggleScreenMagnificationPreferenceFragment fragment =
|
||||||
mFragController.create(
|
mFragController.create(
|
||||||
@@ -524,7 +497,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getSummary_magnificationEnabled_returnShortcutOnWithSummary() {
|
public void getSummary_magnificationEnabled_returnShortcutOnWithSummary() {
|
||||||
setMagnificationTripleTapEnabled(true);
|
setMagnificationTripleTapEnabled(true);
|
||||||
|
|
||||||
@@ -535,7 +507,6 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getSummary_magnificationDisabled_returnShortcutOffWithSummary() {
|
public void getSummary_magnificationDisabled_returnShortcutOffWithSummary() {
|
||||||
setMagnificationTripleTapEnabled(false);
|
setMagnificationTripleTapEnabled(false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user