Search in sources :

Example 71 with CommandListenerAdapter

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

the class NavigatorTest method push.

@Test
public void push() {
    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());
    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 72 with CommandListenerAdapter

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

the class NavigatorTest method shouldCallOnViewDidAppearWhenHostResumes.

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

Example 73 with CommandListenerAdapter

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

the class ParentControllerTest method optionsAreClearedWhenChildIsAppeared.

@Test
public void optionsAreClearedWhenChildIsAppeared() {
    StackController stackController = spy(TestUtils.newStackController(activity).build());
    stackController.ensureViewIsCreated();
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    stackController.push(child1, new CommandListenerAdapter());
    child1.onViewWillAppear();
    verify(stackController, times(1)).clearOptions();
}
Also used : Options(com.reactnativenavigation.options.Options) 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 74 with CommandListenerAdapter

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

the class Navigator method setRoot.

public void setRoot(final ViewController<?> appearing, CommandListener commandListener, ReactInstanceManager reactInstanceManager) {
    previousRoot = root;
    modalStack.destroy();
    final boolean removeSplashView = isRootNotCreated();
    if (isRootNotCreated())
        getView();
    final ViewController<?> disappearing = previousRoot;
    root = appearing;
    root.setOverlay(new RootOverlay(getActivity(), contentLayout));
    root.setParentController(this);
    rootPresenter.setRoot(appearing, disappearing, defaultOptions, new CommandListenerAdapter(commandListener) {

        @Override
        public void onSuccess(String childId) {
            root.onViewDidAppear();
            if (removeSplashView)
                contentLayout.removeViewAt(0);
            destroyPreviousRoot();
            super.onSuccess(childId);
        }
    }, reactInstanceManager);
}
Also used : RootOverlay(com.reactnativenavigation.viewcontrollers.viewcontroller.overlay.RootOverlay) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter)

Example 75 with CommandListenerAdapter

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

the class SideMenuControllerTest method handleBack_closesLeftMenu.

@Test
public void handleBack_closesLeftMenu() {
    uut.setLeftController(left);
    assertThat(uut.handleBack(new CommandListenerAdapter())).isFalse();
    verify(center, times(1)).handleBack(any());
    openLeftMenu();
    assertThat(uut.handleBack(new CommandListenerAdapter())).isTrue();
    verify(center, times(1)).handleBack(any());
}
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