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();
}
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();
}
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());
}
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);
}
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);
}
Aggregations