use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.
the class WifiSettingsTest method setUpForOnCreate.
private void setUpForOnCreate() {
final FragmentActivity activity = mock(FragmentActivity.class);
when(mWifiSettings.getActivity()).thenReturn(activity);
final Resources.Theme theme = mContext.getTheme();
when(activity.getTheme()).thenReturn(theme);
UserManager userManager = mock(UserManager.class);
when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(userManager);
when(mWifiSettings.findPreference(WifiSettings.PREF_KEY_DATA_USAGE)).thenReturn(mDataUsagePreference);
}
use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.
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 android_packages_apps_Settings by omnirom.
the class SurveyMixinTest method onPause_removesReceiverIfPreviouslySet.
@Test
public void onPause_removesReceiverIfPreviouslySet() {
// Pretend there is a survey in memory
when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(-1L);
// Pretend we are an activity that starts and stops
FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(temp);
when(mProvider.createAndRegisterReceiver(any())).thenReturn(mReceiver);
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(temp);
SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
mixin.onResume();
manager.registerReceiver(mReceiver, new IntentFilter());
mixin.onPause();
// Verify we remove the receiver
HashMap<BroadcastReceiver, ArrayList<IntentFilter>> map = ReflectionHelpers.getField(manager, "mReceivers");
assertThat(map.containsKey(mReceiver)).isFalse();
}
use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.
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 ActivityTile(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.bindPreferenceToTileAndGetObservers(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
final ShadowActivity.IntentForResult launchIntent = Shadows.shadowOf(activity).getNextStartedActivityForResult();
assertThat(launchIntent).isNull();
}
use of androidx.fragment.app.FragmentActivity in project android_packages_apps_Settings by omnirom.
the class EntityHeaderControllerTest method bindButton_hasAppInfo_shouldAttachClickListener.
@Test
public void bindButton_hasAppInfo_shouldAttachClickListener() {
final View appLinks = mLayoutInflater.inflate(R.layout.settings_entity_header, null);
final FragmentActivity activity = mock(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(activity);
when(mContext.getString(eq(R.string.application_info_label))).thenReturn("App Info");
mController = EntityHeaderController.newInstance(mActivity, mFragment, appLinks);
mController.setPackageName("123").setUid(123321).setHasAppInfoLink(true).setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE, EntityHeaderController.ActionType.ACTION_NONE);
mController.done(mActivity);
appLinks.findViewById(R.id.entity_header_content).performClick();
verify(activity).startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
Aggregations