urbanairship-core/src/test/java/com/urbanairship/analytics/AnalyticsTest.java
@Test
    public void testAdIdTrackingOnForeground() {
        // Test the preference settings.
        analytics.setAutoTrackAdvertisingIdEnabled(false);
        assertFalse(analytics.isAutoTrackAdvertisingIdEnabled());

        analytics.setAutoTrackAdvertisingIdEnabled(true);
        assertTrue(analytics.isAutoTrackAdvertisingIdEnabled());

        // Start analytics in the background.
        analytics.onForeground(0);

        // Verify a job was dispatched fot update the advertising ID
        verify(mockJobDispatcher, times(2)).dispatch(Mockito.argThat(new ArgumentMatcher<JobInfo>() {
            @Override
            public boolean matches(JobInfo jobInfo) {
                return jobInfo.getAction().equals(Analytics.ACTION_UPDATE_ADVERTISING_ID);
            }
        }));
    }
/**
     * Test that foregrounding the app with advertising ID tracking enabled dispatches a job to update
     * the advertising ID.
     */
Test that foregrounding the app with advertising ID tracking enabled dispatches a job to update
the advertising ID.
Test that foregrounding the app with advertising ID tracking enabled dispatches a job to update the advertising ID .
@Test
    public void testAdIdTrackingOnForeground() {
        analytics.setAutoTrackAdvertisingIdEnabled(false);
        assertFalse(analytics.isAutoTrackAdvertisingIdEnabled());
        analytics.setAutoTrackAdvertisingIdEnabled(true);
        assertTrue(analytics.isAutoTrackAdvertisingIdEnabled());
        analytics.onForeground(0);
        verify(mockJobDispatcher, times(2)).dispatch(Mockito.argThat(new ArgumentMatcher<JobInfo>() {
            @Override
            public boolean matches(JobInfo jobInfo) {
                return jobInfo.getAction().equals(Analytics.ACTION_UPDATE_ADVERTISING_ID);
            }
        }));
    }
@ Test public void testAdIdTrackingOnForeground ( ) { analytics . setAutoTrackAdvertisingIdEnabled ( false ) ; assertFalse ( analytics . isAutoTrackAdvertisingIdEnabled ( ) ) ; analytics . setAutoTrackAdvertisingIdEnabled ( true ) ; assertTrue ( analytics . isAutoTrackAdvertisingIdEnabled ( ) ) ; analytics . onForeground ( 0 ) ; verify ( mockJobDispatcher , times ( 2 ) ) . dispatch ( Mockito . argThat ( new ArgumentMatcher < JobInfo > ( ) { @ Override public boolean matches ( JobInfo jobInfo ) { return jobInfo . getAction ( ) . equals ( Analytics . ACTION_UPDATE_ADVERTISING_ID ) ; } } ) ) ; }
Test that foregrounding the app with advertising ID tracking enabled dispatches a job to update
 the advertising ID.
Test that foregrounding the app with advertising ID tracking enabled dispatches a job to update the advertising ID .
// Test the preference settings. // Start analytics in the background. // Verify a job was dispatched fot update the advertising ID