Search in sources :

Example 6 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method pop_FromCorrectStackByFindingChildId_Promise.

@Test
public void pop_FromCorrectStackByFindingChildId_Promise() {
    disablePushAnimation(child4);
    StackController stack1 = newStack(child1);
    final StackController stack2 = newStack(child2, child3);
    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.pop("child4", Options.EMPTY, new CommandListenerAdapter());
            assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
        }
    });
    stack2.push(child4, listener);
    verify(listener).onSuccess(child4.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 7 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method popToRoot.

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

        @Override
        public void onSuccess(String childId) {
            uut.popToRoot(child3.getId(), Options.EMPTY, new CommandListenerAdapter());
            assertThat(stack2.getChildControllers()).containsOnly(child2);
        }
    });
}
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 8 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method newStack.

@NonNull
private StackController newStack(ViewController<?>... children) {
    StackController stack = TestUtils.newStackController(activity).setChildren(children).setChildRegistry(childRegistry).setId("stack" + CompatUtils.generateViewId()).setInitialOptions(tabOptions).build();
    stack.ensureViewIsCreated();
    return stack;
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) NonNull(androidx.annotation.NonNull)

Example 9 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method push_promise.

@Test
public void push_promise() {
    final StackController stackController = newStack();
    stackController.push(child1, new CommandListenerAdapter());
    uut.setRoot(stackController, new CommandListenerAdapter(), reactInstanceManager);
    assertIsChild(uut.getView(), stackController.getView());
    assertIsChild(stackController.getView(), child1.getView());
    uut.push(child1.getId(), child2, new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            assertIsChild(uut.getView(), stackController.getView());
            assertIsChild(stackController.getView(), child2.getView());
        }
    });
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 10 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method pushIntoModal.

@Test
public void pushIntoModal() {
    uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
    StackController stackController = newStack();
    stackController.push(child1, new CommandListenerAdapter());
    uut.showModal(stackController, new CommandListenerAdapter());
    uut.push(stackController.getId(), child2, new CommandListenerAdapter());
    assertIsChild(stackController.getView(), child2.getView());
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)20 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)19 BaseTest (com.reactnativenavigation.BaseTest)18 Test (org.junit.Test)18 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)5 BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)5 Bool (com.reactnativenavigation.options.params.Bool)3 Options (com.reactnativenavigation.options.Options)2 ViewGroup (android.view.ViewGroup)1 NonNull (androidx.annotation.NonNull)1 BottomTabOptions (com.reactnativenavigation.options.BottomTabOptions)1 Text (com.reactnativenavigation.options.params.Text)1