Search in sources :

Example 6 with TestController

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

the class ViewLeakTests method testActivityStopWhenPushNeverCompleted.

@Test
public void testActivityStopWhenPushNeverCompleted() {
    Controller controller = new TestController();
    router.pushController(RouterTransaction.with(controller).pushChangeHandler(new NeverCompleteChangeHandler()));
    assertNotNull(controller.getView());
    activityProxy.stop(true);
    assertNull(controller.getView());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 7 with TestController

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

the class ViewLeakTests method testActivityStop.

@Test
public void testActivityStop() {
    Controller controller = new TestController();
    router.pushController(RouterTransaction.with(controller));
    assertNotNull(controller.getView());
    activityProxy.stop(true);
    assertNull(controller.getView());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 8 with TestController

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

the class ViewLeakTests method testPop.

@Test
public void testPop() {
    Controller controller = new TestController();
    router.pushController(RouterTransaction.with(controller));
    assertNotNull(controller.getView());
    router.popCurrentController();
    assertNull(controller.getView());
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Example 9 with TestController

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

the class ControllerTests method testOptionsMenu.

@Test
public void testOptionsMenu() {
    TestController controller = new TestController();
    CallState expectedCallState = new CallState(true);
    router.pushController(RouterTransaction.with(controller));
    // Ensure that calling onCreateOptionsMenu w/o declaring that we have one doesn't do anything
    router.onCreateOptionsMenu(null, null);
    assertCalls(expectedCallState, controller);
    // Ensure calling onCreateOptionsMenu with a menu works
    controller.setHasOptionsMenu(true);
    // Ensure it'll still get called back next time onCreateOptionsMenu is called
    router.onCreateOptionsMenu(null, null);
    expectedCallState.createOptionsMenuCalls++;
    assertCalls(expectedCallState, controller);
    // Ensure we stop getting them when we hide it
    controller.setOptionsMenuHidden(true);
    router.onCreateOptionsMenu(null, null);
    assertCalls(expectedCallState, controller);
    // Ensure we get the callback them when we un-hide it
    controller.setOptionsMenuHidden(false);
    router.onCreateOptionsMenu(null, null);
    expectedCallState.createOptionsMenuCalls++;
    assertCalls(expectedCallState, controller);
    // Ensure we don't get the callback when we no longer have a menu
    controller.setHasOptionsMenu(false);
    router.onCreateOptionsMenu(null, null);
    assertCalls(expectedCallState, controller);
}
Also used : TestController(com.bluelinelabs.conductor.util.TestController) CallState(com.bluelinelabs.conductor.util.CallState) Test(org.junit.Test)

Example 10 with TestController

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

the class ReattachCaseTests method testChildHandleBackOnOrientation.

@Test
public void testChildHandleBackOnOrientation() {
    final TestController controllerA = new TestController();
    final TestController controllerB = new TestController();
    final TestController childController = new TestController();
    router.pushController(RouterTransaction.with(controllerA).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    assertTrue(controllerA.isAttached());
    assertFalse(controllerB.isAttached());
    assertFalse(childController.isAttached());
    router.pushController(RouterTransaction.with(controllerB).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    Router childRouter = controllerB.getChildRouter((ViewGroup) controllerB.getView().findViewById(TestController.VIEW_ID));
    childRouter.setPopsLastView(true);
    childRouter.pushController(RouterTransaction.with(childController).pushChangeHandler(MockChangeHandler.defaultHandler()).popChangeHandler(MockChangeHandler.defaultHandler()));
    assertFalse(controllerA.isAttached());
    assertTrue(controllerB.isAttached());
    assertTrue(childController.isAttached());
    activityProxy.rotate();
    router.rebindIfNeeded();
    assertFalse(controllerA.isAttached());
    assertTrue(controllerB.isAttached());
    assertTrue(childController.isAttached());
    router.handleBack();
    assertFalse(controllerA.isAttached());
    assertTrue(controllerB.isAttached());
    assertFalse(childController.isAttached());
    router.handleBack();
    assertTrue(controllerA.isAttached());
    assertFalse(controllerB.isAttached());
    assertFalse(childController.isAttached());
}
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