Search in sources :

Example 16 with SimpleViewController

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

the class ViewControllerTest method onDestroy_destroysViewEvenIfHidden.

@Test
public void onDestroy_destroysViewEvenIfHidden() {
    final SimpleViewController.SimpleView[] spy = new SimpleViewController.SimpleView[1];
    ViewController uut = new SimpleViewController(activity, childRegistry, "uut", new Options()) {

        @Override
        public SimpleView createView() {
            SimpleView view = spy(super.createView());
            spy[0] = view;
            return view;
        }
    };
    assertThat(uut.isViewShown()).isFalse();
    uut.destroy();
    verify(spy[0], times(1)).destroy();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 17 with SimpleViewController

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

the class FloatingActionButtonTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    stackController = TestUtils.newStackController(activity).setFabPresenter(createFabPresenter()).build();
    stackController.ensureViewIsCreated();
    Options options = getOptionsWithFab();
    childFab = new SimpleViewController(activity, childRegistry, "child1", options);
    childNoFab = new SimpleViewController(activity, childRegistry, "child2", new Options());
}
Also used : FabOptions(com.reactnativenavigation.options.FabOptions) Options(com.reactnativenavigation.options.Options) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 18 with SimpleViewController

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

the class BottomTabPresenterTest method createBottomTabs.

private void createBottomTabs(Options tab1Options, Options tab2Options, Options tab3Options) {
    childRegistry = new ChildControllersRegistry();
    bottomTabs = Mockito.mock(BottomTabs.class);
    child1 = spy(new SimpleViewController(activity, childRegistry, "child1", tab1Options));
    child2 = spy(new SimpleViewController(activity, childRegistry, "child2", tab2Options));
    child3 = spy(new SimpleViewController(activity, childRegistry, "child2", tab3Options));
    tabs = Arrays.asList(child1, child2, child3);
    uut = new BottomTabPresenter(activity, tabs, ImageLoaderMock.mock(), new TypefaceLoaderMock(), new Options());
    uut.bindView(bottomTabs);
    uut.setDefaultOptions(new Options());
}
Also used : BottomTabs(com.reactnativenavigation.views.bottomtabs.BottomTabs) Options(com.reactnativenavigation.options.Options) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) TypefaceLoaderMock(com.reactnativenavigation.mocks.TypefaceLoaderMock)

Example 19 with SimpleViewController

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

the class ParentControllerTest method mergeOptions_optionsAreMergedWhenChildAppears.

@Test
public void mergeOptions_optionsAreMergedWhenChildAppears() {
    Options options = new Options();
    options.topBar.title.text = new Text("new title");
    ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
    children.add(child1);
    uut.ensureViewIsCreated();
    child1.ensureViewIsCreated();
    child1.onViewWillAppear();
    ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
    verify(uut, times(1)).clearOptions();
    verify(uut, times(1)).applyChildOptions(optionsCaptor.capture(), eq(child1));
    assertThat(optionsCaptor.getValue().topBar.title.text.get()).isEqualTo("new title");
}
Also used : Options(com.reactnativenavigation.options.Options) Text(com.reactnativenavigation.options.params.Text) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 20 with SimpleViewController

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

the class ParentControllerTest method destroy_DestroysChildren.

@Test
public void destroy_DestroysChildren() {
    ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
    children.add(child1);
    verify(child1, times(0)).destroy();
    uut.destroy();
    verify(child1, times(1)).destroy();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) 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