Search in sources :

Example 61 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class BackButtonHelperTest method addToChild_addsIfStackContainsMoreThenOneChild.

@Test
public void addToChild_addsIfStackContainsMoreThenOneChild() {
    disablePushAnimation(child1, child2);
    stack.push(child1, new CommandListenerAdapter());
    stack.push(child2, new CommandListenerAdapter());
    ArgumentCaptor<Options> optionWithBackButton = ArgumentCaptor.forClass(Options.class);
    verify(child2, times(1)).mergeOptions(optionWithBackButton.capture());
    assertThat(optionWithBackButton.getValue().topBar.buttons.back.visible.get()).isTrue();
}
Also used : Options(com.reactnativenavigation.options.Options) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 62 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class NavigatorTest method shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext.

@Test
public void shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext() {
    SimpleViewController child1 = spy(this.child1);
    final Options overContextOptions = tabOptions.copy();
    overContextOptions.modal = new ModalOptions();
    overContextOptions.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
    ViewController<?> overContextModal = spy(new SimpleViewController(activity, childRegistry, "overContextModal", overContextOptions));
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.showModal(overContextModal, new CommandListenerAdapter());
    uut.onHostResume();
    verify(child1, times(2)).onViewDidAppear();
    verify(overContextModal, times(1)).onViewDidAppear();
}
Also used : ModalOptions(com.reactnativenavigation.options.ModalOptions) Options(com.reactnativenavigation.options.Options) ModalOptions(com.reactnativenavigation.options.ModalOptions) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 63 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class NavigatorTest method setRoot_clearsSplashLayout.

@Test
public void setRoot_clearsSplashLayout() {
    FrameLayout content = activity.findViewById(android.R.id.content);
    // 3 frame layouts (root, modal and overlay containers) and the default splash layout
    assertThat(content.getChildCount()).isEqualTo(4);
    uut.setRoot(child2, new CommandListenerAdapter(), reactInstanceManager);
    assertThat(content.getChildCount()).isEqualTo(3);
}
Also used : FrameLayout(android.widget.FrameLayout) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 64 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class NavigatorTest method dismissAllModals_onViewAppearedInvokedOnRoot.

@Test
public void dismissAllModals_onViewAppearedInvokedOnRoot() {
    disableModalAnimations(child1);
    disablePushAnimation(child2);
    parentController.push(child2, new CommandListenerAdapter());
    uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
    idleMainLooper();
    verify(parentVisibilityListener).onViewAppeared(parentController.getView());
    uut.showModal(child1, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(parentController.getView().getParent()).isNull();
    verify(parentVisibilityListener).onViewDisappear(parentController.getView());
    uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(parentController.getView().getParent()).isNotNull();
    verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 65 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class NavigatorTest method dismissModal_onViewAppearedInvokedOnRoot.

@Test
public void dismissModal_onViewAppearedInvokedOnRoot() {
    disableModalAnimations(child1);
    disablePushAnimation(child2);
    parentController.push(child2, new CommandListenerAdapter());
    uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
    idleMainLooper();
    verify(parentVisibilityListener).onViewAppeared(parentController.getView());
    uut.showModal(child1, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(parentController.getView().getParent()).isNull();
    verify(parentVisibilityListener).onViewDisappear(parentController.getView());
    uut.dismissModal(child1.getId(), new CommandListenerAdapter());
    idleMainLooper();
    assertThat(parentController.getView().getParent()).isNotNull();
    verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)121 BaseTest (com.reactnativenavigation.BaseTest)115 Test (org.junit.Test)115 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)22 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)19 Options (com.reactnativenavigation.options.Options)17 CommandListener (com.reactnativenavigation.react.CommandListener)16 Bool (com.reactnativenavigation.options.params.Bool)7 ModalOptions (com.reactnativenavigation.options.ModalOptions)5 BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)5 Text (com.reactnativenavigation.options.params.Text)4 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)3 FrameLayout (android.widget.FrameLayout)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 InOrder (org.mockito.InOrder)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Nullable (androidx.annotation.Nullable)1 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)1