Search in sources :

Example 1 with SimpleViewController

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

the class ParentControllerTest method findControllerById_Recursive.

@Test
public void findControllerById_Recursive() {
    StackController stackController = TestUtils.newStackController(activity).build();
    stackController.ensureViewIsCreated();
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    SimpleViewController child2 = new SimpleViewController(activity, childRegistry, "child2", new Options());
    stackController.push(child1, new CommandListenerAdapter());
    stackController.push(child2, new CommandListenerAdapter());
    children.add(stackController);
    assertThat(uut.findController("child2")).isEqualTo(child2);
}
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 2 with SimpleViewController

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

the class BackButtonHelperTest method beforeEach.

@Override
public void beforeEach() {
    uut = new BackButtonHelper();
    Activity activity = newActivity();
    ChildControllersRegistry childRegistry = new ChildControllersRegistry();
    stack = TestUtils.newStackController(activity).setChildRegistry(childRegistry).setBackButtonHelper(uut).build();
    child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
    child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
    stack.ensureViewIsCreated();
}
Also used : Options(com.reactnativenavigation.options.Options) BackButtonHelper(com.reactnativenavigation.viewcontrollers.stack.topbar.button.BackButtonHelper) Activity(android.app.Activity) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 3 with SimpleViewController

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

the class TopTabsViewControllerTest method applyOptions_tabsAreRemovedAfterViewDisappears.

@Test
public void applyOptions_tabsAreRemovedAfterViewDisappears() {
    StackController stackController = TestUtils.newStackController(activity).build();
    stackController.ensureViewIsCreated();
    ViewController<?> first = new SimpleViewController(activity, childRegistry, "first", Options.EMPTY);
    disablePushAnimation(first, uut);
    stackController.push(first, new CommandListenerAdapter());
    stackController.push(uut, new CommandListenerAdapter());
    uut.onViewWillAppear();
    assertThat(ViewHelper.isVisible(stackController.getTopBar().getTopTabs())).isTrue();
    disablePopAnimation(uut);
    stackController.pop(Options.EMPTY, new CommandListenerAdapter());
    first.onViewWillAppear();
    assertThat(ViewHelper.isVisible(stackController.getTopBar().getTopTabs())).isFalse();
}
Also used : 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 4 with SimpleViewController

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

the class NavigatorTest method shouldCallOverlaysOnHostResumeWhenHostResumes.

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

Example 5 with SimpleViewController

use of com.reactnativenavigation.mocks.SimpleViewController 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)

Aggregations

SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)42 BaseTest (com.reactnativenavigation.BaseTest)31 Test (org.junit.Test)31 Options (com.reactnativenavigation.options.Options)27 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)21 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)8 Activity (android.app.Activity)4 ModalOptions (com.reactnativenavigation.options.ModalOptions)4 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)4 FrameLayout (android.widget.FrameLayout)3 View (android.view.View)2 CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)2 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)2 Text (com.reactnativenavigation.options.params.Text)2 EventEmitter (com.reactnativenavigation.react.events.EventEmitter)2 ViewParent (android.view.ViewParent)1 ReactInstanceManager (com.facebook.react.ReactInstanceManager)1 TestActivity (com.reactnativenavigation.TestActivity)1 TypefaceLoaderMock (com.reactnativenavigation.mocks.TypefaceLoaderMock)1 FabOptions (com.reactnativenavigation.options.FabOptions)1