Search in sources :

Example 11 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController 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 12 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController 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 13 with StackController

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

the class NavigatorTest method setStackRoot.

@Test
public void setStackRoot() {
    disablePushAnimation(child1, child2, child3);
    StackController stack = newStack(child1, child2);
    uut.setRoot(stack, new CommandListenerAdapter(), reactInstanceManager);
    stack.setRoot(Collections.singletonList(child3), new CommandListenerAdapter());
    assertThat(stack.getChildControllers()).containsOnly(child3);
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 14 with StackController

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

the class NavigatorTest method pop_FromCorrectStackByFindingChildId.

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

        @Override
        public void onSuccess(String childId) {
            stack2.push(child4, new CommandListenerAdapter() {

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

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

the class NavigatorTest method push_OnCorrectStackByFindingChildId.

@Test
public void push_OnCorrectStackByFindingChildId() {
    StackController stack1 = newStack();
    stack1.ensureViewIsCreated();
    StackController stack2 = newStack();
    stack2.ensureViewIsCreated();
    stack1.push(child1, new CommandListenerAdapter());
    stack2.push(child2, new CommandListenerAdapter());
    BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
    uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
    SimpleViewController newChild = new SimpleViewController(activity, childRegistry, "new child", tabOptions);
    uut.push(child2.getId(), newChild, new CommandListenerAdapter());
    assertThat(stack1.getChildControllers()).doesNotContain(newChild);
    assertThat(stack2.getChildControllers()).contains(newChild);
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) 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