Search in sources :

Example 31 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter 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 32 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter 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)

Example 33 with CommandListenerAdapter

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

the class NavigatorTest method push_InvalidPushWithoutAStack_DoesNothing.

@Test
public void push_InvalidPushWithoutAStack_DoesNothing() {
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.push(child1.getId(), child2, new CommandListenerAdapter());
    assertIsChild(uut.getView(), child1.getView());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 34 with CommandListenerAdapter

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

the class NavigatorTest method setRoot_ReplacesExistingChildControllerViews.

@Test
public void setRoot_ReplacesExistingChildControllerViews() {
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.setRoot(child2, new CommandListenerAdapter(), reactInstanceManager);
    assertIsChild(uut.getRootLayout(), child2.getView());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 35 with CommandListenerAdapter

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

the class ModalPresenterTest method showModal_animatesByDefault.

@Test
public void showModal_animatesByDefault() {
    uut.showModal(modal1, root, new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            verify(animator).show(eq(modal1), eq(root), any(), any());
            assertThat(animator.isRunning()).isFalse();
        }
    });
    assertThat(animator.isRunning()).isTrue();
}
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