Search in sources :

Example 31 with TestController

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

the class RouterTests method testPopToTag.

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

Example 32 with TestController

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

the class TargetControllerTests method testSiblingTarget.

@Test
public void testSiblingTarget() {
    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.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 33 with TestController

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

the class TargetControllerTests method testChildParentTarget.

@Test
public void testChildParentTarget() {
    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()));
    controllerA.setTargetController(controllerB);
    Router childRouter = controllerA.getChildRouter((ViewGroup) controllerA.getView().findViewById(TestController.VIEW_ID));
    childRouter.pushController(RouterTransaction.with(controllerB).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    assertNull(controllerB.getTargetController());
    assertEquals(controllerB, controllerA.getTargetController());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 34 with TestController

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

the class TargetControllerTests method createActivityController.

public void createActivityController(Bundle savedInstanceState) {
    ActivityProxy activityProxy = new ActivityProxy().create(savedInstanceState).start().resume();
    router = Conductor.attachRouter(activityProxy.getActivity(), activityProxy.getView(), savedInstanceState);
    if (!router.hasRootController()) {
        router.setRoot(RouterTransaction.with(new TestController()));
    }
}
Also used : ActivityProxy(com.bluelinelabs.conductor.util.ActivityProxy) TestController(com.bluelinelabs.conductor.util.TestController)

Example 35 with TestController

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

the class BackstackTests method testPopTo.

@Test
public void testPopTo() {
    RouterTransaction transaction1 = RouterTransaction.with(new TestController());
    RouterTransaction transaction2 = RouterTransaction.with(new TestController());
    RouterTransaction transaction3 = RouterTransaction.with(new TestController());
    backstack.push(transaction1);
    backstack.push(transaction2);
    backstack.push(transaction3);
    assertEquals(3, backstack.size());
    backstack.popTo(transaction1);
    assertEquals(1, backstack.size());
    assertEquals(transaction1, backstack.peek());
}
Also used : 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