Search in sources :

Example 16 with FragmentManager

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();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Test(org.junit.Test)

Example 17 with FragmentManager

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);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) MenuInflater(android.view.MenuInflater) Bundle(android.os.Bundle) RoboMenu(org.robolectric.fakes.RoboMenu) Before(org.junit.Before)

Example 18 with FragmentManager

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();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) Test(org.junit.Test)

Example 19 with FragmentManager

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);
    });
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Instrumentation(android.app.Instrumentation) Test(org.junit.Test)

Example 20 with FragmentManager

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();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment) Test(org.junit.Test)

Aggregations

FragmentManager (androidx.fragment.app.FragmentManager)170 FragmentTransaction (androidx.fragment.app.FragmentTransaction)55 Fragment (androidx.fragment.app.Fragment)42 Bundle (android.os.Bundle)28 Test (org.junit.Test)15 Intent (android.content.Intent)13 FragmentActivity (androidx.fragment.app.FragmentActivity)10 Activity (android.app.Activity)6 View (android.view.View)6 DialogFragment (androidx.fragment.app.DialogFragment)6 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)5 ArrayList (java.util.ArrayList)5 Context (android.content.Context)4 DialogInterface (android.content.DialogInterface)3 LayoutInflater (android.view.LayoutInflater)3 MenuInflater (android.view.MenuInflater)3 Window (android.view.Window)3 TextView (android.widget.TextView)3 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3 SslUntrustedCertDialog (com.owncloud.android.ui.dialog.SslUntrustedCertDialog)3