Search in sources :

Example 61 with Options

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

the class ParentControllerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    children = new ArrayList<>();
    Options initialOptions = new Options();
    initialOptions.topBar.title.text = new Text(INITIAL_TITLE);
    presenter = spy(new Presenter(activity, new Options()));
    uut = spy(new ParentController<ViewGroup>(activity, childRegistry, "uut", presenter, initialOptions) {

        @Override
        public ViewController<?> getCurrentChild() {
            return children.get(0);
        }

        @NonNull
        @Override
        public ViewGroup createView() {
            FrameLayout layout = new FrameLayout(activity);
            for (ViewController<?> child : children) {
                child.setParentController(this);
                layout.addView(child.getView());
            }
            return layout;
        }

        @Override
        public void sendOnNavigationButtonPressed(String buttonId) {
        }

        @NonNull
        @Override
        public Collection<ViewController<?>> getChildControllers() {
            return children;
        }
    });
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) FrameLayout(android.widget.FrameLayout) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) Text(com.reactnativenavigation.options.params.Text)

Example 62 with Options

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

Example 63 with Options

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

the class ParentControllerTest method onViewDidAppearShouldCallCurrentChildDidAppear.

@Test
public void onViewDidAppearShouldCallCurrentChildDidAppear() {
    SimpleViewController child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
    SimpleViewController child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
    children.add(child1);
    children.add(child2);
    uut.onViewDidAppear();
    verify(child1).onViewDidAppear();
    verify(child2, never()).onViewDidAppear();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 64 with Options

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

the class ParentControllerTest method onConfigurationChange_shouldCallConfigurationChangeForPresenterAndChildren.

@Test
public void onConfigurationChange_shouldCallConfigurationChangeForPresenterAndChildren() {
    children.add(spy(new SimpleViewController(activity, childRegistry, "child1", new Options())));
    children.add(spy(new SimpleViewController(activity, childRegistry, "child2", new Options())));
    ParentController<?> spyUUT = spy(uut);
    spyUUT.onConfigurationChanged(mockConfiguration);
    verify(presenter).onConfigurationChanged(any(), any());
    for (ViewController<?> controller : children) {
        verify(controller).onConfigurationChanged(any());
    }
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 65 with Options

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

the class ParentControllerTest method onViewDisappearShouldCallCurrentChildDisAppear.

@Test
public void onViewDisappearShouldCallCurrentChildDisAppear() {
    SimpleViewController child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
    SimpleViewController child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
    children.add(child1);
    children.add(child2);
    uut.onViewDisappear();
    verify(child1).onViewDisappear();
    verify(child2, never()).onViewDisappear();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) 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