Search in sources :

Example 91 with CommandListenerAdapter

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

the class NavigatorTest method popTo_FromCorrectStackUpToChild.

@Test
public void popTo_FromCorrectStackUpToChild() {
    disablePushAnimation(child5);
    StackController stack1 = newStack(child1);
    StackController stack2 = newStack(child2, child3, child4);
    BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
    uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
    idleMainLooper();
    CommandListenerAdapter listener = spy(new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            uut.popTo(child2.getId(), Options.EMPTY, new CommandListenerAdapter());
            assertThat(stack2.getChildControllers()).containsOnly(child2);
        }
    });
    stack2.push(child5, listener);
    verify(listener).onSuccess(child5.getId());
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 92 with CommandListenerAdapter

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

the class NavigatorTest method findController_root.

@Test
public void findController_root() {
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    assertThat(uut.findController(child1.getId())).isEqualTo(child1);
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 93 with CommandListenerAdapter

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

the class NavigatorTest method setDefaultOptions.

@Test
public void setDefaultOptions() {
    uut.setDefaultOptions(new Options());
    SimpleViewController spy = spy(child1);
    uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
    Options defaultOptions = new Options();
    uut.setDefaultOptions(defaultOptions);
    verify(spy).setDefaultOptions(defaultOptions);
    verify(modalStack).setDefaultOptions(defaultOptions);
}
Also used : ModalOptions(com.reactnativenavigation.options.ModalOptions) Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 94 with CommandListenerAdapter

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

the class NavigatorTest method shouldNotCallModalOnHostPauseWhenHostPausesAndNoModals.

@Test
public void shouldNotCallModalOnHostPauseWhenHostPausesAndNoModals() {
    SimpleViewController child1 = spy(this.child1);
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.onHostPause();
    verify(modalStack, never()).onHostPause();
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 95 with CommandListenerAdapter

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

the class NavigatorTest method handleBack_DelegatesToRoot.

@Test
public void handleBack_DelegatesToRoot() {
    assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
    ViewController<?> root = spy(child1);
    uut.setRoot(root, new CommandListenerAdapter(), reactInstanceManager);
    when(root.handleBack(any(CommandListener.class))).thenReturn(true);
    assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
    verify(root, times(1)).handleBack(any());
}
Also used : CommandListener(com.reactnativenavigation.react.CommandListener) 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