Search in sources :

Example 1 with TestController

use of com.bluelinelabs.conductor.util.TestController in project Conductor by bluelinelabs.

the class BackstackTests method testPeek.

@Test
public void testPeek() {
    RouterTransaction transaction1 = RouterTransaction.with(new TestController());
    RouterTransaction transaction2 = RouterTransaction.with(new TestController());
    backstack.push(transaction1);
    assertEquals(transaction1, backstack.peek());
    backstack.push(transaction2);
    assertEquals(transaction2, backstack.peek());
    backstack.pop();
    assertEquals(transaction1, backstack.peek());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 2 with TestController

use of com.bluelinelabs.conductor.util.TestController in project Conductor by bluelinelabs.

the class ControllerChangeHandlerTests method testSaveRestore.

@Test
public void testSaveRestore() {
    HorizontalChangeHandler horizontalChangeHandler = new HorizontalChangeHandler();
    FadeChangeHandler fadeChangeHandler = new FadeChangeHandler(120, false);
    RouterTransaction transaction = RouterTransaction.with(new TestController()).pushChangeHandler(horizontalChangeHandler).popChangeHandler(fadeChangeHandler);
    RouterTransaction restoredTransaction = new RouterTransaction(transaction.saveInstanceState());
    ControllerChangeHandler restoredHorizontal = restoredTransaction.pushChangeHandler();
    ControllerChangeHandler restoredFade = restoredTransaction.popChangeHandler();
    assertEquals(horizontalChangeHandler.getClass(), restoredHorizontal.getClass());
    assertEquals(fadeChangeHandler.getClass(), restoredFade.getClass());
    HorizontalChangeHandler restoredHorizontalCast = (HorizontalChangeHandler) restoredHorizontal;
    FadeChangeHandler restoredFadeCast = (FadeChangeHandler) restoredFade;
    assertEquals(horizontalChangeHandler.getAnimationDuration(), restoredHorizontalCast.getAnimationDuration());
    assertEquals(horizontalChangeHandler.removesFromViewOnPush(), restoredHorizontalCast.removesFromViewOnPush());
    assertEquals(fadeChangeHandler.getAnimationDuration(), restoredFadeCast.getAnimationDuration());
    assertEquals(fadeChangeHandler.removesFromViewOnPush(), restoredFadeCast.removesFromViewOnPush());
}
Also used : FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) TestController(com.bluelinelabs.conductor.util.TestController) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) Test(org.junit.Test)

Example 3 with TestController

use of com.bluelinelabs.conductor.util.TestController in project Conductor by bluelinelabs.

the class ControllerLifecycleActivityReferenceTests method testChildControllerActivityOnDestroy.

@Test
public void testChildControllerActivityOnDestroy() {
    Controller parent = new TestController();
    router.pushController(RouterTransaction.with(parent).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    TestController child = new TestController();
    ActivityReferencingLifecycleListener listener = new ActivityReferencingLifecycleListener();
    child.addLifecycleListener(listener);
    Router childRouter = parent.getChildRouter((ViewGroup) parent.getView().findViewById(TestController.VIEW_ID));
    childRouter.setPopsLastView(true);
    childRouter.pushController(RouterTransaction.with(child).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    activityProxy.pause().stop(false).destroy();
    assertEquals(Collections.singletonList(true), listener.changeEndReferences);
    assertEquals(Collections.singletonList(true), listener.postCreateViewReferences);
    assertEquals(Collections.singletonList(true), listener.postAttachReferences);
    assertEquals(Collections.singletonList(true), listener.postDetachReferences);
    assertEquals(Collections.singletonList(true), listener.postDestroyViewReferences);
    assertEquals(Collections.singletonList(true), listener.postDestroyReferences);
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 4 with TestController

use of com.bluelinelabs.conductor.util.TestController in project Conductor by bluelinelabs.

the class ControllerLifecycleActivityReferenceTests method testChildControllerActivityOnPush.

@Test
public void testChildControllerActivityOnPush() {
    Controller parent = new TestController();
    router.pushController(RouterTransaction.with(parent).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    TestController child = new TestController();
    assertNull(child.getActivity());
    ActivityReferencingLifecycleListener listener = new ActivityReferencingLifecycleListener();
    child.addLifecycleListener(listener);
    Router childRouter = parent.getChildRouter((ViewGroup) parent.getView().findViewById(TestController.VIEW_ID));
    childRouter.pushController(RouterTransaction.with(child).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    assertEquals(Collections.singletonList(true), listener.changeEndReferences);
    assertEquals(Collections.singletonList(true), listener.postCreateViewReferences);
    assertEquals(Collections.singletonList(true), listener.postAttachReferences);
    assertEquals(Collections.emptyList(), listener.postDetachReferences);
    assertEquals(Collections.emptyList(), listener.postDestroyViewReferences);
    assertEquals(Collections.emptyList(), listener.postDestroyReferences);
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 5 with TestController

use of com.bluelinelabs.conductor.util.TestController in project Conductor by bluelinelabs.

the class ControllerLifecycleActivityReferenceTests method testChildControllerActivityOnParentPop.

@Test
public void testChildControllerActivityOnParentPop() {
    Controller parent = new TestController();
    router.pushController(RouterTransaction.with(parent).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    TestController child = new TestController();
    ActivityReferencingLifecycleListener listener = new ActivityReferencingLifecycleListener();
    child.addLifecycleListener(listener);
    Router childRouter = parent.getChildRouter((ViewGroup) parent.getView().findViewById(TestController.VIEW_ID));
    childRouter.setPopsLastView(true);
    childRouter.pushController(RouterTransaction.with(child).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    router.popCurrentController();
    assertEquals(Collections.singletonList(true), listener.changeEndReferences);
    assertEquals(Collections.singletonList(true), listener.postCreateViewReferences);
    assertEquals(Collections.singletonList(true), listener.postAttachReferences);
    assertEquals(Collections.singletonList(true), listener.postDetachReferences);
    assertEquals(Collections.singletonList(true), listener.postDestroyViewReferences);
    assertEquals(Collections.singletonList(true), listener.postDestroyReferences);
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Aggregations

TestController (com.bluelinelabs.conductor.util.TestController)65 Test (org.junit.Test)64 CallState (com.bluelinelabs.conductor.util.CallState)14 View (android.view.View)6 ViewGroup (android.view.ViewGroup)5 MockChangeHandler (com.bluelinelabs.conductor.util.MockChangeHandler)5 Bundle (android.os.Bundle)4 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)3 Intent (android.content.Intent)2 FadeChangeHandler (com.bluelinelabs.conductor.changehandler.FadeChangeHandler)2 LifecycleListener (com.bluelinelabs.conductor.Controller.LifecycleListener)1 VerticalChangeHandler (com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)1 ActivityProxy (com.bluelinelabs.conductor.util.ActivityProxy)1