Search in sources :

Example 11 with CommandListenerAdapter

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

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

the class NavigatorTest method showModal_onViewDisappearIsInvokedOnRoot.

@Test
public void showModal_onViewDisappearIsInvokedOnRoot() {
    uut.setRoot(parentController, new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            idleMainLooper();
            verify(parentVisibilityListener).onViewAppeared(parentController.getView());
            uut.showModal(child1, new CommandListenerAdapter() {

                @Override
                public void onSuccess(String childId) {
                    assertThat(parentController.getView().getParent()).isNull();
                    idleMainLooper();
                    verify(parentVisibilityListener).onViewDisappear(parentController.getView());
                }
            });
        }
    }, reactInstanceManager);
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 13 with CommandListenerAdapter

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

the class NavigatorTest method onConfigurationChange_shouldCallOnConfigurationChangedForOverlays.

@Test
public void onConfigurationChange_shouldCallOnConfigurationChangedForOverlays() {
    Navigator spyUUT = spy(uut);
    SimpleViewController spyChild1 = spy(child1);
    ViewController<?> spyChild2 = spy(child2);
    ViewController<?> spyChild3 = spy(child3);
    spyUUT.setRoot(spyChild1, new CommandListenerAdapter(), reactInstanceManager);
    spyUUT.showOverlay(spyChild2, new CommandListenerAdapter());
    spyUUT.showOverlay(spyChild3, new CommandListenerAdapter());
    spyUUT.onConfigurationChanged(mockConfiguration);
    verify(spyChild2).onConfigurationChanged(any());
    verify(spyChild3).onConfigurationChanged(any());
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 14 with CommandListenerAdapter

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

the class NavigatorTest method shouldCallOnViewDisappearWhenHostPauses.

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

Example 15 with CommandListenerAdapter

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

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