Search in sources :

Example 66 with Options

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

the class ParentControllerTest method findControllerById_ChildById.

@Test
public void findControllerById_ChildById() {
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    SimpleViewController child2 = new SimpleViewController(activity, childRegistry, "child2", new Options());
    children.add(child1);
    children.add(child2);
    assertThat(uut.findController("uut")).isEqualTo(uut);
    assertThat(uut.findController("child1")).isEqualTo(child1);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 67 with Options

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

the class BackButtonHelperTest method addToChild_addsIfStackContainsMoreThenOneChild.

@Test
public void addToChild_addsIfStackContainsMoreThenOneChild() {
    disablePushAnimation(child1, child2);
    stack.push(child1, new CommandListenerAdapter());
    stack.push(child2, new CommandListenerAdapter());
    ArgumentCaptor<Options> optionWithBackButton = ArgumentCaptor.forClass(Options.class);
    verify(child2, times(1)).mergeOptions(optionWithBackButton.capture());
    assertThat(optionWithBackButton.getValue().topBar.buttons.back.visible.get()).isTrue();
}
Also used : Options(com.reactnativenavigation.options.Options) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 68 with Options

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

the class TopTabsViewControllerTest method createOptions.

@NonNull
private ArrayList<Options> createOptions() {
    ArrayList<Options> result = new ArrayList<>();
    for (int i = 0; i < SIZE; i++) {
        final Options options = new Options();
        options.topTabOptions.title = new Text("Tab " + i);
        options.topBar.title.text = new Text(createTabTopBarTitle(i));
        result.add(options);
    }
    return result;
}
Also used : Options(com.reactnativenavigation.options.Options) ArrayList(java.util.ArrayList) Text(com.reactnativenavigation.options.params.Text) NonNull(androidx.annotation.NonNull)

Example 69 with Options

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

the class NavigatorTest method shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext.

@Test
public void shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext() {
    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.onHostResume();
    verify(child1, times(2)).onViewDidAppear();
    verify(overContextModal, times(1)).onViewDidAppear();
}
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)

Example 70 with Options

use of com.reactnativenavigation.options.Options 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)

Aggregations

Options (com.reactnativenavigation.options.Options)110 BaseTest (com.reactnativenavigation.BaseTest)57 Test (org.junit.Test)57 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)32 SideMenuOptions (com.reactnativenavigation.options.SideMenuOptions)19 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)18 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)16 Bool (com.reactnativenavigation.options.params.Bool)15 Text (com.reactnativenavigation.options.params.Text)15 OrientationOptions (com.reactnativenavigation.options.OrientationOptions)10 AnimationOptions (com.reactnativenavigation.options.AnimationOptions)9 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)9 FrameLayout (android.widget.FrameLayout)8 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)8 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)8 ComponentOptions (com.reactnativenavigation.options.ComponentOptions)6 TopBarOptions (com.reactnativenavigation.options.TopBarOptions)6 TopTabOptions (com.reactnativenavigation.options.TopTabOptions)6 TopTabsOptions (com.reactnativenavigation.options.TopTabsOptions)6 Activity (android.app.Activity)5