Search in sources :

Example 81 with CommandListenerAdapter

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

the class ModalPresenterTest method dismissModal_successIsReportedBeforeViewIsDestroyed.

@Test
public void dismissModal_successIsReportedBeforeViewIsDestroyed() {
    disableModalAnimations(modal1);
    CommandListenerAdapter listener = Mockito.mock(CommandListenerAdapter.class);
    ViewController<?> modal = spy(modal1);
    InOrder inOrder = inOrder(listener, modal);
    uut.showModal(modal, root, new CommandListenerAdapter());
    uut.dismissModal(modal, root, root, listener);
    inOrder.verify(listener).onSuccess(modal.getId());
    inOrder.verify(modal).destroy();
}
Also used : InOrder(org.mockito.InOrder) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 82 with CommandListenerAdapter

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

the class ModalPresenterTest method showModal_waitForRender.

@Test
public void showModal_waitForRender() {
    modal1.options.animations.showModal.setWaitForRender(new Bool(true));
    uut.showModal(modal1, root, new CommandListenerAdapter());
    verify(modal1).addOnAppearedListener(any());
    verifyNoInteractions(animator);
}
Also used : Bool(com.reactnativenavigation.options.params.Bool) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 83 with CommandListenerAdapter

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

the class NavigatorTest method setRoot_withWaitForRender.

@Test
public void setRoot_withWaitForRender() {
    ViewController<?> initialRoot = spy(child2);
    uut.setRoot(initialRoot, new CommandListenerAdapter(), reactInstanceManager);
    child3.options.animations.setRoot.getEnter().waitForRender = new Bool(true);
    ViewController<?> secondRoot = spy(child3);
    CommandListenerAdapter listener = spy(new CommandListenerAdapter());
    uut.setRoot(secondRoot, listener, reactInstanceManager);
    verify(secondRoot).addOnAppearedListener(any());
    // make isRendered return true and trigger onViewAppeared
    secondRoot.getView().addView(new View(activity));
    idleMainLooper();
    assertThat(initialRoot.isDestroyed()).isTrue();
    assertThat(secondRoot.isViewShown()).isEqualTo(true);
}
Also used : Bool(com.reactnativenavigation.options.params.Bool) View(android.view.View) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 84 with CommandListenerAdapter

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

the class NavigatorTest method shouldCallModalOnViewDisappearWhenModalDisplayedOverContextUnderneath.

@Test
public void shouldCallModalOnViewDisappearWhenModalDisplayedOverContextUnderneath() {
    SimpleViewController child1 = spy(this.child1);
    ViewController<?> child2 = spy(this.child2);
    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.showModal(child2, new CommandListenerAdapter());
    uut.onHostPause();
    verify(child2, times(1)).onViewDisappear();
    verify(overContextModal, never()).onViewDisappear();
}
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 85 with CommandListenerAdapter

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

the class NavigatorTest method shouldCallOverlaysAndModalsChildrenOnViewDidAppearOnHostResume.

@Test
public void shouldCallOverlaysAndModalsChildrenOnViewDidAppearOnHostResume() {
    SimpleViewController child1 = spy(this.child1);
    ViewController<?> child2 = spy(this.child2);
    ViewController<?> child3 = spy(this.child3);
    ViewController<?> child4 = spy(this.child4);
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.showModal(child2, new CommandListenerAdapter());
    uut.showOverlay(child3, new CommandListenerAdapter());
    uut.showOverlay(child4, new CommandListenerAdapter());
    verify(child1, times(1)).onViewDidAppear();
    uut.onHostResume();
    verify(overlayManager).onHostResume();
    verify(child1, times(1)).onViewDidAppear();
    verify(child2).onViewDidAppear();
    verify(child3).onViewDidAppear();
    verify(child4).onViewDidAppear();
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) 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