Search in sources :

Example 46 with TestController

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

the class RouterTests method testSetNewRoot.

@Test
public void testSetNewRoot() {
    String oldRootTag = "oldRoot";
    String newRootTag = "newRoot";
    Controller oldRootController = new TestController();
    Controller newRootController = new TestController();
    router.setRoot(RouterTransaction.with(oldRootController).tag(oldRootTag));
    router.setRoot(RouterTransaction.with(newRootController).tag(newRootTag));
    assertNull(router.getControllerWithTag(oldRootTag));
    assertEquals(newRootController, router.getControllerWithTag(newRootTag));
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 47 with TestController

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

the class RouterTests method testReplaceTopControllerWithNoRemoveViewOnPush.

@Test
public void testReplaceTopControllerWithNoRemoveViewOnPush() {
    RouterTransaction rootTransaction = RouterTransaction.with(new TestController());
    RouterTransaction topTransaction = RouterTransaction.with(new TestController()).pushChangeHandler(MockChangeHandler.noRemoveViewOnPushHandler());
    List<RouterTransaction> backstack = Arrays.asList(rootTransaction, topTransaction);
    router.setBackstack(backstack, null);
    assertEquals(2, router.getBackstackSize());
    assertTrue(rootTransaction.controller.isAttached());
    assertTrue(topTransaction.controller.isAttached());
    List<RouterTransaction> fetchedBackstack = router.getBackstack();
    assertEquals(rootTransaction, fetchedBackstack.get(0));
    assertEquals(topTransaction, fetchedBackstack.get(1));
    RouterTransaction newTopTransaction = RouterTransaction.with(new TestController()).pushChangeHandler(MockChangeHandler.noRemoveViewOnPushHandler());
    router.replaceTopController(newTopTransaction);
    newTopTransaction.pushChangeHandler().completeImmediately();
    assertEquals(2, router.getBackstackSize());
    fetchedBackstack = router.getBackstack();
    assertEquals(rootTransaction, fetchedBackstack.get(0));
    assertEquals(newTopTransaction, fetchedBackstack.get(1));
    assertTrue(rootTransaction.controller.isAttached());
    assertFalse(topTransaction.controller.isAttached());
    assertTrue(newTopTransaction.controller.isAttached());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 48 with TestController

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

the class RouterTests method testRearrangeTransactionBackstack.

@Test
public void testRearrangeTransactionBackstack() {
    RouterTransaction transaction1 = RouterTransaction.with(new TestController());
    RouterTransaction transaction2 = RouterTransaction.with(new TestController());
    List<RouterTransaction> backstack = Arrays.asList(transaction1, transaction2);
    router.setBackstack(backstack, null);
    assertEquals(1, transaction1.transactionIndex);
    assertEquals(2, transaction2.transactionIndex);
    backstack = Arrays.asList(transaction2, transaction1);
    router.setBackstack(backstack, null);
    assertEquals(1, transaction2.transactionIndex);
    assertEquals(2, transaction1.transactionIndex);
    router.handleBack();
    assertEquals(1, router.getBackstackSize());
    assertEquals(transaction2, router.getBackstack().get(0));
    router.handleBack();
    assertEquals(0, router.getBackstackSize());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 49 with TestController

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

the class RouterTests method testSetRoot.

@Test
public void testSetRoot() {
    String rootTag = "root";
    Controller rootController = new TestController();
    assertFalse(router.hasRootController());
    router.setRoot(RouterTransaction.with(rootController).tag(rootTag));
    assertTrue(router.hasRootController());
    assertEquals(rootController, router.getControllerWithTag(rootTag));
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 50 with TestController

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

the class RouterTests method testRemovesAllViewsOnDestroy.

@Test
public void testRemovesAllViewsOnDestroy() {
    Controller controller1 = new TestController();
    Controller controller2 = new TestController();
    router.setRoot(RouterTransaction.with(controller1));
    router.pushController(RouterTransaction.with(controller2).pushChangeHandler(new FadeChangeHandler(false)));
    assertEquals(2, router.container.getChildCount());
    router.destroy(true);
    assertEquals(0, router.container.getChildCount());
}
Also used : FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) 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