Skip to content

Commit

Permalink
Idle main looper after each SupportFragmentTestUtil call when looper …
Browse files Browse the repository at this point in the history
…mode is PAUSED.

PiperOrigin-RevId: 241555325
  • Loading branch information
brettchabot authored and copybara-robolectric committed Apr 2, 2019
1 parent f4a5d49 commit 78d27a9
Showing 1 changed file with 6 additions and 0 deletions.
@@ -1,5 +1,7 @@
package org.robolectric.shadows.support.v4;

import static org.robolectric.shadows.ShadowBaseLooper.shadowMainLooper;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
Expand All @@ -19,21 +21,25 @@ public class SupportFragmentTestUtil {
public static void startFragment(Fragment fragment) {
buildSupportFragmentManager(FragmentUtilActivity.class)
.beginTransaction().add(fragment, null).commitNow();
shadowMainLooper().idleIfPaused();
}

public static void startFragment(Fragment fragment, Class<? extends FragmentActivity> fragmentActivityClass) {
buildSupportFragmentManager(fragmentActivityClass)
.beginTransaction().add(fragment, null).commitNow();
shadowMainLooper().idleIfPaused();
}

public static void startVisibleFragment(Fragment fragment) {
buildSupportFragmentManager(FragmentUtilActivity.class)
.beginTransaction().add(1, fragment, null).commitNow();
shadowMainLooper().idleIfPaused();
}

public static void startVisibleFragment(Fragment fragment, Class<? extends FragmentActivity> fragmentActivityClass, int containerViewId) {
buildSupportFragmentManager(fragmentActivityClass)
.beginTransaction().add(containerViewId, fragment, null).commitNow();
shadowMainLooper().idle();
}

private static FragmentManager buildSupportFragmentManager(Class<? extends FragmentActivity> fragmentActivityClass) {
Expand Down

0 comments on commit 78d27a9

Please sign in to comment.