Search in sources :

Example 41 with SimpleViewController

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

the class ChildControllerTest method beforeEach.

@Override
public void beforeEach() {
    childRegistry = spy(new ChildControllersRegistry());
    presenter = Mockito.mock(Presenter.class);
    uut = new SimpleViewController(newActivity(), childRegistry, "childId", presenter, new Options()) {

        @Override
        public Options resolveCurrentOptions() {
            return resolvedOptions;
        }
    };
    ParentController<?> parent = Mockito.mock(ParentController.class);
    Mockito.when(parent.resolveChildOptions(uut)).thenReturn(Options.EMPTY);
    uut.setParentController(parent);
}
Also used : Options(com.reactnativenavigation.options.Options) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 42 with SimpleViewController

use of com.reactnativenavigation.mocks.SimpleViewController 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)

Aggregations

SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)42 BaseTest (com.reactnativenavigation.BaseTest)31 Test (org.junit.Test)31 Options (com.reactnativenavigation.options.Options)27 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)21 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)8 Activity (android.app.Activity)4 ModalOptions (com.reactnativenavigation.options.ModalOptions)4 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)4 FrameLayout (android.widget.FrameLayout)3 View (android.view.View)2 CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)2 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)2 Text (com.reactnativenavigation.options.params.Text)2 EventEmitter (com.reactnativenavigation.react.events.EventEmitter)2 ViewParent (android.view.ViewParent)1 ReactInstanceManager (com.facebook.react.ReactInstanceManager)1 TestActivity (com.reactnativenavigation.TestActivity)1 TypefaceLoaderMock (com.reactnativenavigation.mocks.TypefaceLoaderMock)1 FabOptions (com.reactnativenavigation.options.FabOptions)1