use of androidx.fragment.app.FragmentManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDetailsButtonsControllerTest method forgetDialog.
@Test
public void forgetDialog() {
showScreen(mController);
FragmentManager fragmentManager = mock(FragmentManager.class);
when(mFragment.getFragmentManager()).thenReturn(fragmentManager);
FragmentTransaction ft = mock(FragmentTransaction.class);
when(fragmentManager.beginTransaction()).thenReturn(ft);
mForgetButton.callOnClick();
ArgumentCaptor<ForgetDeviceDialogFragment> dialogCaptor = ArgumentCaptor.forClass(ForgetDeviceDialogFragment.class);
verify(ft).add(dialogCaptor.capture(), anyString());
ForgetDeviceDialogFragment dialogFragment = dialogCaptor.getValue();
assertThat(dialogFragment).isNotNull();
}
use of androidx.fragment.app.FragmentManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDeviceDetailsFragmentTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
FakeFeatureFactory.setupForTest();
mFragment = spy(BluetoothDeviceDetailsFragment.newInstance(TEST_ADDRESS));
doReturn(mLocalManager).when(mFragment).getLocalBluetoothManager(any());
doReturn(mCachedDevice).when(mFragment).getCachedDevice(any());
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
FragmentManager fragmentManager = mock(FragmentManager.class);
when(mFragment.getFragmentManager()).thenReturn(fragmentManager);
mFragmentTransaction = mock(FragmentTransaction.class);
when(fragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
when(mCachedDevice.getAddress()).thenReturn(TEST_ADDRESS);
Bundle args = new Bundle();
args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS, TEST_ADDRESS);
mFragment.setArguments(args);
mFragment.onAttach(mContext);
mMenu = new RoboMenu(mContext);
mInflater = new MenuInflater(mContext);
}
use of androidx.fragment.app.FragmentManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfirmCredentialTest method testLastTryDialogShownExactlyOnce.
@Test
public void testLastTryDialogShownExactlyOnce() {
FragmentManager fm = Robolectric.buildActivity(FragmentActivity.class).setup().get().getSupportFragmentManager();
// Launch only one instance at a time.
assertThat(LastTryDialog.show(fm, "title", android.R.string.yes, android.R.string.ok, false)).isTrue();
assertThat(LastTryDialog.show(fm, "title", android.R.string.yes, android.R.string.ok, false)).isFalse();
// After cancelling, the dialog should be re-shown when asked for.
LastTryDialog.hide(fm);
assertThat(LastTryDialog.show(fm, "title", android.R.string.yes, android.R.string.ok, false)).isTrue();
}
use of androidx.fragment.app.FragmentManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiDppQrCodeScannerFragmentTest method onPause_shouldNotDecodeQrCode.
@Test
public void onPause_shouldNotDecodeQrCode() {
final WifiDppConfiguratorActivity hostActivity = (WifiDppConfiguratorActivity) mActivityRule.getActivity();
final FragmentManager fragmentManager = hostActivity.getSupportFragmentManager();
final WifiDppQrCodeScannerFragment scannerFragment = (WifiDppQrCodeScannerFragment) fragmentManager.findFragmentByTag(TAG_FRAGMENT_QR_CODE_SCANNER);
final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
instrumentation.runOnMainSync(() -> {
instrumentation.callActivityOnPause(hostActivity);
assertThat(scannerFragment.isDecodeTaskAlive()).isEqualTo(false);
});
}
use of androidx.fragment.app.FragmentManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsActivityTest method onActivityResult_shouldDelegateToListener.
@Test
public void onActivityResult_shouldDelegateToListener() {
final List<Fragment> fragments = new ArrayList<>();
fragments.add(new Fragment());
fragments.add(new ListenerFragment());
final FragmentManager manager = mock(FragmentManager.class);
when(mActivity.getSupportFragmentManager()).thenReturn(manager);
when(manager.getFragments()).thenReturn(fragments);
mActivity.onActivityResult(0, 0, new Intent());
assertThat(((ListenerFragment) fragments.get(1)).mOnActivityResultCalled).isTrue();
}
Aggregations