Search in sources :

Example 51 with TestController

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

the class RouterTests method testPopNonCurrent.

@Test
public void testPopNonCurrent() {
    String controller1Tag = "controller1";
    String controller2Tag = "controller2";
    String controller3Tag = "controller3";
    Controller controller1 = new TestController();
    Controller controller2 = new TestController();
    Controller controller3 = new TestController();
    router.pushController(RouterTransaction.with(controller1).tag(controller1Tag));
    router.pushController(RouterTransaction.with(controller2).tag(controller2Tag));
    router.pushController(RouterTransaction.with(controller3).tag(controller3Tag));
    router.popController(controller2);
    assertEquals(2, router.getBackstackSize());
    assertEquals(controller1, router.getControllerWithTag(controller1Tag));
    assertNull(router.getControllerWithTag(controller2Tag));
    assertEquals(controller3, router.getControllerWithTag(controller3Tag));
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 52 with TestController

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

the class RouterTests method testPopToRootWithNoRemoveViewOnPush.

@Test
public void testPopToRootWithNoRemoveViewOnPush() {
    RouterTransaction rootTransaction = RouterTransaction.with(new TestController()).pushChangeHandler(new HorizontalChangeHandler(false));
    RouterTransaction transaction1 = RouterTransaction.with(new TestController()).pushChangeHandler(new HorizontalChangeHandler(false));
    RouterTransaction transaction2 = RouterTransaction.with(new TestController()).pushChangeHandler(new HorizontalChangeHandler(false));
    List<RouterTransaction> backstack = Arrays.asList(rootTransaction, transaction1, transaction2);
    router.setBackstack(backstack, null);
    assertEquals(3, router.getBackstackSize());
    router.popToRoot();
    assertEquals(1, router.getBackstackSize());
    assertEquals(rootTransaction, router.getBackstack().get(0));
    assertTrue(rootTransaction.controller.isAttached());
    assertFalse(transaction1.controller.isAttached());
    assertFalse(transaction2.controller.isAttached());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) Test(org.junit.Test)

Example 53 with TestController

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

the class TargetControllerTests method testParentChildTarget.

@Test
public void testParentChildTarget() {
    final TestController controllerA = new TestController();
    final TestController controllerB = new TestController();
    assertNull(controllerA.getTargetController());
    assertNull(controllerB.getTargetController());
    router.pushController(RouterTransaction.with(controllerA).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    controllerB.setTargetController(controllerA);
    Router childRouter = controllerA.getChildRouter((ViewGroup) controllerA.getView().findViewById(TestController.VIEW_ID));
    childRouter.pushController(RouterTransaction.with(controllerB).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    assertNull(controllerA.getTargetController());
    assertEquals(controllerA, controllerB.getTargetController());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 54 with TestController

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

the class ControllerLifecycleCallbacksTests method testNormalLifecycle.

@Test
public void testNormalLifecycle() {
    TestController controller = new TestController();
    attachLifecycleListener(controller);
    CallState expectedCallState = new CallState();
    assertCalls(expectedCallState, controller);
    router.pushController(RouterTransaction.with(controller).pushChangeHandler(getPushHandler(expectedCallState, controller)).popChangeHandler(getPopHandler(expectedCallState, controller)));
    assertCalls(expectedCallState, controller);
    router.popCurrentController();
    assertNull(controller.getView());
    assertCalls(expectedCallState, controller);
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) CallState(com.bluelinelabs.conductor.util.CallState) Test(org.junit.Test)

Example 55 with TestController

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

the class ControllerLifecycleCallbacksTests method testLifecycleWithActivityStop.

@Test
public void testLifecycleWithActivityStop() {
    TestController controller = new TestController();
    attachLifecycleListener(controller);
    CallState expectedCallState = new CallState();
    assertCalls(expectedCallState, controller);
    router.pushController(RouterTransaction.with(controller).pushChangeHandler(getPushHandler(expectedCallState, controller)));
    assertCalls(expectedCallState, controller);
    activityProxy.getActivity().isDestroying = true;
    activityProxy.pause();
    assertCalls(expectedCallState, controller);
    activityProxy.stop(false);
    expectedCallState.detachCalls++;
    assertCalls(expectedCallState, controller);
    assertNotNull(controller.getView());
    ViewUtils.reportAttached(controller.getView(), false);
    expectedCallState.saveViewStateCalls++;
    expectedCallState.destroyViewCalls++;
    assertCalls(expectedCallState, controller);
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) CallState(com.bluelinelabs.conductor.util.CallState) 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