BaseFragment extends Fragment implements BackPressWatcher, ViewClickWatcher { @Nullable protected Transition inflateTransition(@TransitionRes int resource) { final Context context = getActivity(); return context == null ? null : FragmentUtils.inflateTransition(context, resource); } BaseFragment(); @SuppressWarnings("TryWithIdenticalCatches") @Nullable static F newInstanceWithArguments(@NonNull final Class<F> classOfFragment, @Nullable final Bundle args); @SuppressWarnings("deprecation") @Override void onAttach(@NonNull final Activity activity); final boolean isAttached(); final boolean runOnUiThread(@NonNull final Runnable action); @Override void onCreate(@Nullable final Bundle savedInstanceState); final boolean isCreated(); @Override void onStart(); final boolean isStarted(); @Override View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState); @Override void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState); final boolean isViewCreated(); @Override void onResume(); boolean invalidateOptionsMenu(); @Override boolean dispatchViewClick(@NonNull final View view); @Override void onPause(); final boolean isPaused(); @Override void onStop(); final boolean isStopped(); @Override @CheckResult boolean dispatchBackPress(); @Override void onDestroy(); final boolean isDestroyed(); @Override void onDetach();  }
@Test public void testInflateTransitionWhenNotAttached() { final TestFragment fragment = new TestFragment(); assertThat(fragment.inflateTransition(1), is(nullValue())); }
@Config(sdk = Build.VERSION_CODES.JELLY_BEAN) @Test public void testInflateTransitionOnJellyBeanApiLevel() { final FragmentActivity activity = Robolectric.buildActivity(TestCompatActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getSupportFragmentManager(); final BaseFragment fragment = new TestFragment(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); assertThat(fragment.inflateTransition(1), is(nullValue())); }
@Config(sdk = Build.VERSION_CODES.LOLLIPOP) @Test public void testInflateTransitionOnLollipopApiLevel() { final FragmentActivity activity = Robolectric.buildActivity(TestCompatActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getSupportFragmentManager(); final BaseFragment fragment = new TestFragment(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); assertThat( fragment.inflateTransition(android.R.transition.fade), is(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? notNullValue() : nullValue()) ); }