Search in sources :

Example 31 with SimpleViewController

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

the class ChildControllersRegistryTest method beforeEach.

@Override
public void beforeEach() {
    Activity activity = newActivity();
    uut = new ChildControllersRegistry();
    child1 = spy(new SimpleViewController(activity, uut, "child1", new Options()));
    child2 = spy(new SimpleViewController(activity, uut, "child2", new Options()));
}
Also used : Options(com.reactnativenavigation.options.Options) Activity(android.app.Activity) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 32 with SimpleViewController

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

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

Example 34 with SimpleViewController

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

the class NavigatorTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    childRegistry = new ChildControllersRegistry();
    eventEmitter = Mockito.mock(EventEmitter.class);
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    overlayManager = spy(new OverlayManager());
    imageLoaderMock = ImageLoaderMock.mock();
    activityController = newActivityController(TestActivity.class);
    activity = activityController.create().get();
    modalStack = spy(new ModalStack(activity));
    rootPresenter = spy(new RootPresenter());
    modalStack.setEventEmitter(Mockito.mock(EventEmitter.class));
    uut = new Navigator(activity, childRegistry, modalStack, overlayManager, rootPresenter);
    activity.setNavigator(uut);
    ViewController<?> initialChild = new SimpleViewController(activity, childRegistry, "initialChild", Options.EMPTY);
    parentController = newStack(initialChild);
    parentVisibilityListener = spy(new ViewController.ViewVisibilityListener() {

        @Override
        public boolean onViewAppeared(View view) {
            return false;
        }

        @Override
        public boolean onViewDisappear(View view) {
            return false;
        }
    });
    parentController.setViewVisibilityListener(parentVisibilityListener);
    child1 = new SimpleViewController(activity, childRegistry, "child1", tabOptions);
    child2 = new SimpleViewController(activity, childRegistry, "child2", tabOptions);
    child3 = new SimpleViewController(activity, childRegistry, "child3", tabOptions);
    child4 = new SimpleViewController(activity, childRegistry, "child4", tabOptions);
    child5 = new SimpleViewController(activity, childRegistry, "child5", tabOptions);
    uut.bindViews();
    activityController.visible();
    activityController.postCreate(Bundle.EMPTY);
    idleMainLooper();
}
Also used : OverlayManager(com.reactnativenavigation.viewcontrollers.overlay.OverlayManager) ModalStack(com.reactnativenavigation.viewcontrollers.modal.ModalStack) ReactInstanceManager(com.facebook.react.ReactInstanceManager) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) TestActivity(com.reactnativenavigation.TestActivity) RootPresenter(com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) View(android.view.View)

Example 35 with SimpleViewController

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

the class NavigatorTest method shouldCallRootOnViewDisappearWhenModalDisplayedOverContext.

@Test
public void shouldCallRootOnViewDisappearWhenModalDisplayedOverContext() {
    SimpleViewController child1 = spy(this.child1);
    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.onHostPause();
    verify(child1, times(1)).onViewDisappear();
    verify(overContextModal, times(1)).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)

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