use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppNotificationPreferenceControllerTest method getArguments_containsChannelId.
@Test
public void getArguments_containsChannelId() {
FragmentActivity activity = mock(FragmentActivity.class);
Intent intent = new Intent();
intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, "test");
when(mFragment.getActivity()).thenReturn(activity);
when(activity.getIntent()).thenReturn(intent);
AppNotificationPreferenceController controller = new AppNotificationPreferenceController(mContext, "test");
controller.setParentFragment(mFragment);
assertThat(controller.getArguments().containsKey(EXTRA_FRAGMENT_ARG_KEY)).isTrue();
assertThat(controller.getArguments().getString(EXTRA_FRAGMENT_ARG_KEY)).isEqualTo("test");
}
use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InstantAppButtonDialogFragmentTest method setUp.
@Before
public void setUp() {
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
mContext = spy(RuntimeEnvironment.application);
mFragment = spy(InstantAppButtonDialogFragment.newInstance(TEST_PACKAGE));
mFragment.show(activity.getSupportFragmentManager(), "InstantAppButtonDialogFragment");
doReturn(mContext).when(mFragment).getContext();
}
use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BillingCycleSettingsTest method onCreate_emptyArguments_shouldSetDefaultNetworkTemplate.
@Test
public void onCreate_emptyArguments_shouldSetDefaultNetworkTemplate() {
final BillingCycleSettings billingCycleSettings = spy(new BillingCycleSettings());
when(billingCycleSettings.getContext()).thenReturn(mContext);
when(billingCycleSettings.getArguments()).thenReturn(Bundle.EMPTY);
final FragmentActivity activity = mock(FragmentActivity.class);
when(billingCycleSettings.getActivity()).thenReturn(activity);
final Resources.Theme theme = mContext.getTheme();
when(activity.getTheme()).thenReturn(theme);
doNothing().when(billingCycleSettings).onCreatePreferences(any(Bundle.class), nullable(String.class));
when(mContext.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(mNetworkPolicyManager);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
when(mConnectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
final SwitchPreference preference = mock(SwitchPreference.class);
when(billingCycleSettings.findPreference(anyString())).thenReturn(preference);
final FooterPreferenceMixinCompat footer = mock(FooterPreferenceMixinCompat.class);
ReflectionHelpers.setField(billingCycleSettings, "mFooterPreferenceMixin", footer);
when(footer.createFooterPreference()).thenReturn(mock(FooterPreference.class));
billingCycleSettings.onCreate(Bundle.EMPTY);
assertThat(billingCycleSettings.mNetworkTemplate).isNotNull();
}
use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method bindPreference_withIntentActionMetadata_shouldSetLaunchAction.
@Test
public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent;
assertThat(launchIntent.getAction()).isEqualTo("TestAction");
assertThat(launchIntent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, 0)).isEqualTo(MetricsEvent.SETTINGS_GESTURES);
}
use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method clickPreference_withUnresolvableIntent_shouldNotLaunchAnything.
@Test
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
ReflectionHelpers.setField(mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager());
FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
final ShadowActivity.IntentForResult launchIntent = Shadows.shadowOf(activity).getNextStartedActivityForResult();
assertThat(launchIntent).isNull();
}
Aggregations