urbanairship-core/src/test/java/com/urbanairship/ChannelCaptureTest.java
@Test
    public void testForegroundClipboardWithTokenNoUrl() {
        when(mockPushManager.getChannelId()).thenReturn("channel ID");

        // Set the token without a Url
        clipboardManager.setPrimaryClip(ClipData.newPlainText("Channel", generateToken(null)));

        activityMonitor.startActivity();

        Intent intent = shadowOf(RuntimeEnvironment.application).getNextStartedActivity();

        // Verify the intent
        assertNotNull(intent);
        assertEquals(intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK, Intent.FLAG_ACTIVITY_NEW_TASK);
        assertEquals(intent.getComponent().getClassName(), "com.urbanairship.ChannelCaptureActivity");
        assertEquals("channel ID", intent.getExtras().getString(ChannelCapture.CHANNEL));
        assertEquals(null, intent.getExtras().getString(ChannelCapture.URL));
    }
/**
     * Test app foreground when the clipboard contains the expected token without a URL.
     */
Test app foreground when the clipboard contains the expected token without a URL.
Test app foreground when the clipboard contains the expected token without a URL .
@Test
    public void testForegroundClipboardWithTokenNoUrl() {
        when(mockPushManager.getChannelId()).thenReturn("channel ID");
        clipboardManager.setPrimaryClip(ClipData.newPlainText("Channel", generateToken(null)));
        activityMonitor.startActivity();
        Intent intent = shadowOf(RuntimeEnvironment.application).getNextStartedActivity();
        assertNotNull(intent);
        assertEquals(intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK, Intent.FLAG_ACTIVITY_NEW_TASK);
        assertEquals(intent.getComponent().getClassName(), "com.urbanairship.ChannelCaptureActivity");
        assertEquals("channel ID", intent.getExtras().getString(ChannelCapture.CHANNEL));
        assertEquals(null, intent.getExtras().getString(ChannelCapture.URL));
    }
@ Test public void testForegroundClipboardWithTokenNoUrl ( ) { when ( mockPushManager . getChannelId ( ) ) . thenReturn ( "channel ID" ) ; clipboardManager . setPrimaryClip ( ClipData . newPlainText ( "Channel" , generateToken ( null ) ) ) ; activityMonitor . startActivity ( ) ; Intent intent = shadowOf ( RuntimeEnvironment . application ) . getNextStartedActivity ( ) ; assertNotNull ( intent ) ; assertEquals ( intent . getFlags ( ) & Intent . FLAG_ACTIVITY_NEW_TASK , Intent . FLAG_ACTIVITY_NEW_TASK ) ; assertEquals ( intent . getComponent ( ) . getClassName ( ) , "com.urbanairship.ChannelCaptureActivity" ) ; assertEquals ( "channel ID" , intent . getExtras ( ) . getString ( ChannelCapture . CHANNEL ) ) ; assertEquals ( null , intent . getExtras ( ) . getString ( ChannelCapture . URL ) ) ; }
Test app foreground when the clipboard contains the expected token without a URL.
Test app foreground when the clipboard contains the expected token without a URL .
// Set the token without a Url // Verify the intent