Search in sources :

Example 16 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class ViewControllerTest method holdsAReferenceToStackControllerOrNull.

@SuppressWarnings("ConstantConditions")
@Test
public void holdsAReferenceToStackControllerOrNull() {
    uut.setParentController(null);
    assertThat(uut.getParentController()).isNull();
    StackController nav = TestUtils.newStackController(activity).build();
    nav.ensureViewIsCreated();
    nav.push(uut, new CommandListenerAdapter());
    assertThat(uut.getParentController()).isEqualTo(nav);
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 17 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController 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 18 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController 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 19 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method popTo_FromCorrectStackUpToChild.

@Test
public void popTo_FromCorrectStackUpToChild() {
    disablePushAnimation(child5);
    StackController stack1 = newStack(child1);
    StackController stack2 = newStack(child2, child3, child4);
    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.popTo(child2.getId(), Options.EMPTY, new CommandListenerAdapter());
            assertThat(stack2.getChildControllers()).containsOnly(child2);
        }
    });
    stack2.push(child5, listener);
    verify(listener).onSuccess(child5.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 20 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class OptionsApplyingTest method initialOptionsAppliedOnAppear.

@Test
public void initialOptionsAppliedOnAppear() {
    uut.options.topBar.title.text = new Text("the title");
    StackController stackController = TestUtils.newStackController(activity).build();
    stackController.ensureViewIsCreated();
    stackController.push(uut, new CommandListenerAdapter());
    assertThat(stackController.getTopBar().getTitle()).isEmpty();
    uut.onViewWillAppear();
    assertThat(stackController.getTopBar().getTitle()).isEqualTo("the title");
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) Text(com.reactnativenavigation.options.params.Text) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)20 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)19 BaseTest (com.reactnativenavigation.BaseTest)18 Test (org.junit.Test)18 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)5 BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)5 Bool (com.reactnativenavigation.options.params.Bool)3 Options (com.reactnativenavigation.options.Options)2 ViewGroup (android.view.ViewGroup)1 NonNull (androidx.annotation.NonNull)1 BottomTabOptions (com.reactnativenavigation.options.BottomTabOptions)1 Text (com.reactnativenavigation.options.params.Text)1