urbanairship-core/src/test/java/com/urbanairship/UAirshipTest.java
@Test
    public void testAsyncTakeOff() {
        final TestCallback testCallback = new TestCallback();
        UAirship.shared(testCallback);

        TestCallback cancelCallback = new TestCallback();
        Cancelable cancelable = UAirship.shared(cancelCallback);
        cancelable.cancel();

        TestCallback takeOffCallback = new TestCallback() {
            @Override
            public void onAirshipReady(UAirship airship) {
                super.onAirshipReady(airship);
                assertFalse("Take off callback should be called first", testCallback.onReadyCalled);
            }
        };

        UAirship.takeOff(application, configOptions, takeOffCallback);

        // Block until its ready
        UAirship.shared();
        looper.runToEndOfTasks();

        assertTrue(testCallback.onReadyCalled);
        assertTrue(takeOffCallback.onReadyCalled);
        assertFalse(cancelCallback.onReadyCalled);

        // Verify the airship ready intent was fired
        List<Intent> intents = ShadowApplication.getInstance().getBroadcastIntents();
        assertEquals(intents.size(), 1);
        assertEquals(intents.get(0).getAction(), UAirship.ACTION_AIRSHIP_READY);
    }
/**
     * Test takeOff with valid application and config options calls the correct callbacks.
     */
Test takeOff with valid application and config options calls the correct callbacks.
Test takeOff with valid application and config options calls the correct callbacks .
@Test
    public void testAsyncTakeOff() {
        final TestCallback testCallback = new TestCallback();
        UAirship.shared(testCallback);
        TestCallback cancelCallback = new TestCallback();
        Cancelable cancelable = UAirship.shared(cancelCallback);
        cancelable.cancel();
        TestCallback takeOffCallback = new TestCallback() {
            @Override
            public void onAirshipReady(UAirship airship) {
                super.onAirshipReady(airship);
                assertFalse("Take off callback should be called first", testCallback.onReadyCalled);
            }
        };
        UAirship.takeOff(application, configOptions, takeOffCallback);
        UAirship.shared();
        looper.runToEndOfTasks();
        assertTrue(testCallback.onReadyCalled);
        assertTrue(takeOffCallback.onReadyCalled);
        assertFalse(cancelCallback.onReadyCalled);
        List<Intent> intents = ShadowApplication.getInstance().getBroadcastIntents();
        assertEquals(intents.size(), 1);
        assertEquals(intents.get(0).getAction(), UAirship.ACTION_AIRSHIP_READY);
    }
@ Test public void testAsyncTakeOff ( ) { final TestCallback testCallback = new TestCallback ( ) ; UAirship . shared ( testCallback ) ; TestCallback cancelCallback = new TestCallback ( ) ; Cancelable cancelable = UAirship . shared ( cancelCallback ) ; cancelable . cancel ( ) ; TestCallback takeOffCallback = new TestCallback ( ) { @ Override public void onAirshipReady ( UAirship airship ) { super . onAirshipReady ( airship ) ; assertFalse ( "Take off callback should be called first" , testCallback . onReadyCalled ) ; } } ; UAirship . takeOff ( application , configOptions , takeOffCallback ) ; UAirship . shared ( ) ; looper . runToEndOfTasks ( ) ; assertTrue ( testCallback . onReadyCalled ) ; assertTrue ( takeOffCallback . onReadyCalled ) ; assertFalse ( cancelCallback . onReadyCalled ) ; List < Intent > intents = ShadowApplication . getInstance ( ) . getBroadcastIntents ( ) ; assertEquals ( intents . size ( ) , 1 ) ; assertEquals ( intents . get ( 0 ) . getAction ( ) , UAirship . ACTION_AIRSHIP_READY ) ; }
Test takeOff with valid application and config options calls the correct callbacks.
Test takeOff with valid application and config options calls the correct callbacks .
// Block until its ready // Verify the airship ready intent was fired