Search in sources :

Example 36 with CommandListenerAdapter

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

the class ModalPresenterTest method showModal_rejectIfContentIsNull.

@Test
public void showModal_rejectIfContentIsNull() {
    uut.setModalsLayout(null);
    CommandListenerAdapter listener = Mockito.mock(CommandListenerAdapter.class);
    uut.showModal(modal1, modal2, listener);
    verify(listener).onError(any());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 37 with CommandListenerAdapter

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

the class ModalPresenterTest method dismissModal_animatesByDefault.

@Test
public void dismissModal_animatesByDefault() {
    disableShowModalAnimation(modal1);
    uut.showModal(modal1, root, new CommandListenerAdapter());
    uut.dismissModal(modal1, root, root, new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            post(() -> {
                verify(modal1).onViewDisappear();
                verify(modal1).destroy();
            });
        }
    });
    verify(animator).dismiss(eq(root), eq(modal1), any(), any());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 38 with CommandListenerAdapter

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

the class ModalPresenterTest method dismissModal_previousControllerIsNotAddedIfDismissedModalIsNotTop.

@Test
public void dismissModal_previousControllerIsNotAddedIfDismissedModalIsNotTop() {
    disableShowModalAnimation(modal1, modal2);
    disableDismissModalAnimation(modal1, modal2);
    uut.showModal(modal1, root, new CommandListenerAdapter());
    uut.showModal(modal2, modal1, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(modal1.getView().getParent()).isNull();
    assertThat(root.getView().getParent()).isNull();
    uut.dismissModal(modal1, null, root, new CommandListenerAdapter());
    assertThat(root.getView().getParent()).isNull();
    uut.dismissModal(modal2, root, root, new CommandListenerAdapter());
    assertThat(root.getView().getParent()).isNotNull();
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 39 with CommandListenerAdapter

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

the class ModalPresenterTest method dismissModal_previousModalIsAddedBackToHierarchy.

@Test
public void dismissModal_previousModalIsAddedBackToHierarchy() {
    disableShowModalAnimation(modal1, modal2);
    uut.showModal(modal1, root, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(modal1.getView().getParent()).isNotNull();
    verify(modal1).onViewWillAppear();
    uut.showModal(modal2, modal1, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(modal1.getView().getParent()).isNull();
    Shadows.shadowOf(Looper.getMainLooper()).idle();
    uut.dismissModal(modal2, modal1, root, new CommandListenerAdapter());
    assertThat(modal1.getView().getParent()).isNotNull();
    idleMainLooper();
    verify(modal1, times(2)).onViewWillAppear();
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 40 with CommandListenerAdapter

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

the class ModalPresenterTest method showModal_onViewDidAppearIsInvokedBeforeViewDisappear.

@Test
public void showModal_onViewDidAppearIsInvokedBeforeViewDisappear() {
    disableShowModalAnimation(modal1);
    root.onViewWillAppear();
    uut.showModal(modal1, root, new CommandListenerAdapter());
    idleMainLooper();
    InOrder inOrder = inOrder(modal1, root);
    inOrder.verify(modal1).onViewDidAppear();
    inOrder.verify(root).onViewDisappear();
}
Also used : InOrder(org.mockito.InOrder) 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