Search in sources :

Example 1 with SyncResult

use of android.content.SyncResult in project iosched by google.

the class ForceSyncNowAction method run.

@Override
public void run(final Context context, final Callback callback) {
    ConferenceDataHandler.resetDataTimestamp(context);
    final Bundle bundle = new Bundle();
    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
    new AsyncTask<Context, Void, Void>() {

        @Override
        protected Void doInBackground(Context... contexts) {
            Account account = AccountUtils.getActiveAccount(context);
            if (account == null) {
                callback.done(false, "Cannot sync if there is no active account.");
            } else {
                new SyncHelper(contexts[0]).performSync(new SyncResult(), bundle);
            }
            return null;
        }
    }.execute(context);
}
Also used : Context(android.content.Context) Account(android.accounts.Account) Bundle(android.os.Bundle) SyncHelper(com.google.samples.apps.iosched.sync.SyncHelper) SyncResult(android.content.SyncResult)

Example 2 with SyncResult

use of android.content.SyncResult in project robolectric by robolectric.

the class ShadowSyncResultTest method testConstructor.

@Test
public void testConstructor() throws Exception {
    SyncResult result = new SyncResult();
    assertThat(result.stats).isNotNull();
}
Also used : SyncResult(android.content.SyncResult) Test(org.junit.Test)

Example 3 with SyncResult

use of android.content.SyncResult in project robolectric by robolectric.

the class ShadowSyncResultTest method hasSoftError.

@Test
public void hasSoftError() throws Exception {
    SyncResult result = new SyncResult();
    assertFalse(result.hasSoftError());
    result.stats.numIoExceptions++;
    assertTrue(result.hasSoftError());
    assertTrue(result.hasError());
}
Also used : SyncResult(android.content.SyncResult) Test(org.junit.Test)

Example 4 with SyncResult

use of android.content.SyncResult in project robolectric by robolectric.

the class ShadowSyncResultTest method testMadeSomeProgress.

@Test
public void testMadeSomeProgress() throws Exception {
    SyncResult result = new SyncResult();
    assertFalse(result.madeSomeProgress());
    result.stats.numInserts++;
    assertTrue(result.madeSomeProgress());
}
Also used : SyncResult(android.content.SyncResult) Test(org.junit.Test)

Example 5 with SyncResult

use of android.content.SyncResult in project robolectric by robolectric.

the class ShadowSyncResultTest method testClear.

@Test
public void testClear() throws Exception {
    SyncResult result = new SyncResult();
    result.moreRecordsToGet = true;
    result.stats.numInserts++;
    result.clear();
    assertFalse(result.moreRecordsToGet);
    assertThat(result.stats.numInserts).isEqualTo(0L);
}
Also used : SyncResult(android.content.SyncResult) Test(org.junit.Test)

Aggregations

SyncResult (android.content.SyncResult)8 Test (org.junit.Test)7 SyncStats (android.content.SyncStats)2 Field (java.lang.reflect.Field)2 Account (android.accounts.Account)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 SyncHelper (com.google.samples.apps.iosched.sync.SyncHelper)1