Search in sources :

Example 86 with CommandListenerAdapter

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

the class NavigatorTest method handleBack_modalTakePrecedenceOverRoot.

@Test
public void handleBack_modalTakePrecedenceOverRoot() {
    ViewController<?> root = spy(child1);
    uut.setRoot(root, new CommandListenerAdapter(), reactInstanceManager);
    uut.showModal(child2, new CommandListenerAdapter());
    verify(root, times(0)).handleBack(new CommandListenerAdapter());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 87 with CommandListenerAdapter

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

the class NavigatorTest method mergeOptions_CallsApplyNavigationOptions.

@Test
public void mergeOptions_CallsApplyNavigationOptions() {
    ComponentViewController componentVc = new SimpleComponentViewController(activity, childRegistry, "theId", new Options());
    componentVc.setParentController(parentController);
    assertThat(componentVc.options.topBar.title.text.get("")).isEmpty();
    uut.setRoot(componentVc, new CommandListenerAdapter(), reactInstanceManager);
    Options options = new Options();
    options.topBar.title.text = new Text("new title");
    uut.mergeOptions("theId", options);
    assertThat(componentVc.options.topBar.title.text.get()).isEqualTo("new title");
}
Also used : ModalOptions(com.reactnativenavigation.options.ModalOptions) Options(com.reactnativenavigation.options.Options) SimpleComponentViewController(com.reactnativenavigation.mocks.SimpleComponentViewController) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) Text(com.reactnativenavigation.options.params.Text) SimpleComponentViewController(com.reactnativenavigation.mocks.SimpleComponentViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 88 with CommandListenerAdapter

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

the class NavigatorTest method pop_InvalidDoesNothing.

@Test
public void pop_InvalidDoesNothing() {
    uut.pop("123", Options.EMPTY, new CommandListenerAdapter());
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.pop(child1.getId(), Options.EMPTY, new CommandListenerAdapter());
    assertThat(uut.getChildControllers()).hasSize(1);
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 89 with CommandListenerAdapter

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

the class NavigatorTest method setRoot_destroysModals.

@Test
public void setRoot_destroysModals() {
    uut.showModal(child1, new CommandListenerAdapter());
    uut.setRoot(child2, new CommandListenerAdapter(), reactInstanceManager);
    assertTrue(child1.isDestroyed());
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 90 with CommandListenerAdapter

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

the class NavigatorTest method shouldCallRootOnViewDisappearWhenModalDisplayedOverContext.

@Test
public void shouldCallRootOnViewDisappearWhenModalDisplayedOverContext() {
    SimpleViewController child1 = spy(this.child1);
    final Options overContextOptions = tabOptions.copy();
    overContextOptions.modal = new ModalOptions();
    overContextOptions.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
    ViewController<?> overContextModal = spy(new SimpleViewController(activity, childRegistry, "overContextModal", overContextOptions));
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.showModal(overContextModal, new CommandListenerAdapter());
    uut.onHostPause();
    verify(child1, times(1)).onViewDisappear();
    verify(overContextModal, times(1)).onViewDisappear();
}
Also used : ModalOptions(com.reactnativenavigation.options.ModalOptions) Options(com.reactnativenavigation.options.Options) ModalOptions(com.reactnativenavigation.options.ModalOptions) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) 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