Search in sources :

Example 21 with CommandListenerAdapter

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

the class NavigatorTest method shouldCallOverlaysChildrenOnViewDidAppearOnHostResume.

@Test
public void shouldCallOverlaysChildrenOnViewDidAppearOnHostResume() {
    SimpleViewController child1 = spy(this.child1);
    ViewController<?> child2 = spy(this.child2);
    ViewController<?> child3 = spy(this.child3);
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.showOverlay(child2, new CommandListenerAdapter());
    uut.showOverlay(child3, new CommandListenerAdapter());
    verify(child1, times(1)).onViewDidAppear();
    uut.onHostResume();
    verify(overlayManager).onHostResume();
    verify(child1, times(2)).onViewDidAppear();
    verify(child2).onViewDidAppear();
    verify(child3).onViewDidAppear();
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 22 with CommandListenerAdapter

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

the class NavigatorTest method destroy_shouldNotChangeViewIds.

@Test
public void destroy_shouldNotChangeViewIds() {
    disablePushAnimation(child1);
    disableShowModalAnimation(child1, child2, child3);
    StackController spy = spy(parentController);
    SimpleViewController.SimpleView view = child1.getView();
    ViewGroup view1 = child2.getView();
    view.setId(10);
    view1.setId(11);
    spy.options.animations.setRoot.getEnter().enabled = new Bool(false);
    uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
    spy.push(child1, new CommandListenerAdapter());
    uut.showModal(child2, new CommandListenerAdapter());
    activityController.destroy();
    assertThat(view.getId()).isEqualTo(10);
    assertThat(view1.getId()).isEqualTo(11);
    verify(spy, times(1)).destroy();
}
Also used : Bool(com.reactnativenavigation.options.params.Bool) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) ViewGroup(android.view.ViewGroup) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 23 with CommandListenerAdapter

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

the class NavigatorTest method handleBack_onViewAppearedInvokedOnRoot.

@Test
public void handleBack_onViewAppearedInvokedOnRoot() {
    disableModalAnimations(child1);
    disablePushAnimation(child2);
    parentController.push(child2, new CommandListenerAdapter());
    uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
    idleMainLooper();
    verify(parentVisibilityListener).onViewAppeared(parentController.getView());
    uut.showModal(child1, new CommandListenerAdapter());
    idleMainLooper();
    assertThat(parentController.getView().getParent()).isNull();
    verify(parentVisibilityListener).onViewDisappear(parentController.getView());
    uut.handleBack(new CommandListenerAdapter());
    idleMainLooper();
    assertThat(parentController.getView().getParent()).isNotNull();
    verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 24 with CommandListenerAdapter

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

the class NavigatorTest method pushedStackCanBePopped.

@Test
public void pushedStackCanBePopped() {
    StackController spy = spy(parentController);
    disablePushAnimation(spy, child2);
    spy.push(child2, new CommandListenerAdapter());
    StackController parent = newStack(spy);
    parent.options.animations.setRoot.getEnter().enabled = new Bool(false);
    uut.setRoot(parent, new CommandListenerAdapter(), reactInstanceManager);
    CommandListenerAdapter listener = new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            assertThat(spy.getChildControllers().size()).isEqualTo(1);
        }
    };
    disablePopAnimation(child2);
    uut.pop("child2", Options.EMPTY, listener);
    verify(spy, times(1)).pop(Options.EMPTY, listener);
}
Also used : Bool(com.reactnativenavigation.options.params.Bool) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 25 with CommandListenerAdapter

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

the class NavigatorTest method findController_modal.

@Test
public void findController_modal() {
    uut.showModal(child1, new CommandListenerAdapter());
    assertThat(uut.findController(child1.getId())).isEqualTo(child1);
}
Also used : 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