Search in sources :

Example 11 with CommandListener

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

the class ModalStackTest method showModal_DidAppearEventShouldBeCallled.

@Test
public void showModal_DidAppearEventShouldBeCallled() {
    CommandListener listener = spy(new CommandListenerAdapter());
    uut.showModal(modal1, root, listener);
    verify(listener).onSuccess(modal1.getId());
    idleMainLooper();
    verify(modal1).onViewDidAppear();
}
Also used : CommandListener(com.reactnativenavigation.react.CommandListener) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 12 with CommandListener

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

the class ModalStackTest method handleBack_ViewControllerTakesPrecedenceOverModal.

@Test
public void handleBack_ViewControllerTakesPrecedenceOverModal() {
    ViewController<?> backHandlingModal = spy(new SimpleViewController(activity, childRegistry, "stack", new Options()) {

        @Override
        public boolean handleBack(CommandListener listener) {
            return true;
        }
    });
    uut.showModal(backHandlingModal, root, new CommandListenerAdapter());
    root.getView().getViewTreeObserver().dispatchOnGlobalLayout();
    assertThat(uut.handleBack(new CommandListenerAdapter(), any())).isTrue();
    verify(backHandlingModal, times(1)).handleBack(any());
    verify(backHandlingModal, times(0)).onViewDisappear();
}
Also used : TransitionAnimationOptions(com.reactnativenavigation.options.TransitionAnimationOptions) Options(com.reactnativenavigation.options.Options) CommandListener(com.reactnativenavigation.react.CommandListener) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 13 with CommandListener

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

the class ModalStackTest method dismissAllModals_resolveSuccessfullyIfEmpty.

@Test
public void dismissAllModals_resolveSuccessfullyIfEmpty() {
    CommandListener spy = spy(new CommandListenerAdapter());
    uut.dismissAllModals(root, Options.EMPTY, spy);
    verify(spy, times(1)).onSuccess(root.getId());
}
Also used : CommandListener(com.reactnativenavigation.react.CommandListener) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 14 with CommandListener

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

the class ModalStackTest method dismissAllModals_onlyTopModalIsAnimated.

@Test
public void dismissAllModals_onlyTopModalIsAnimated() {
    modal2 = spy(modal2);
    Options defaultOptions = new Options();
    uut.setDefaultOptions(defaultOptions);
    Options resolvedOptions = new Options();
    when(modal2.resolveCurrentOptions(defaultOptions)).then(invocation -> resolvedOptions);
    uut.showModal(modal1, root, new CommandListenerAdapter());
    uut.showModal(modal2, root, new CommandListenerAdapter());
    CommandListener listener = spy(new CommandListenerAdapter());
    uut.dismissAllModals(root, Options.EMPTY, listener);
    verify(presenter).dismissModal(eq(modal2), eq(root), eq(root), any());
    verify(listener).onSuccess(modal2.getId());
    verify(animator, never()).dismiss(eq(modal1), eq(modal2), eq(modal1.options.animations.dismissModal), any());
    verify(animator).dismiss(eq(root), eq(modal2), eq(resolvedOptions.animations.dismissModal), any());
    assertThat(uut.size()).isEqualTo(0);
}
Also used : TransitionAnimationOptions(com.reactnativenavigation.options.TransitionAnimationOptions) Options(com.reactnativenavigation.options.Options) CommandListener(com.reactnativenavigation.react.CommandListener) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 15 with CommandListener

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

the class ModalStackTest method dismissAllModals.

@Test
public void dismissAllModals() {
    uut.showModal(modal1, root, new CommandListenerAdapter());
    uut.showModal(modal2, root, new CommandListenerAdapter());
    CommandListener listener = spy(new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            assertThat(findModal(modal1.getId())).isNull();
            assertThat(findModal(modal2.getId())).isNull();
            assertThat(uut.isEmpty()).isTrue();
        }
    });
    uut.dismissAllModals(root, Options.EMPTY, listener);
    verify(listener, times(1)).onSuccess(anyString());
    verifyNoMoreInteractions(listener);
}
Also used : CommandListener(com.reactnativenavigation.react.CommandListener) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

CommandListener (com.reactnativenavigation.react.CommandListener)16 BaseTest (com.reactnativenavigation.BaseTest)15 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)15 Test (org.junit.Test)15 Options (com.reactnativenavigation.options.Options)3 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)2 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)1 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)1 StackAnimationOptions (com.reactnativenavigation.options.StackAnimationOptions)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1