1package com.xtremelabs.robolectric.shadows;
2
3import static junit.framework.Assert.assertFalse;
4import static junit.framework.Assert.assertTrue;
5import static org.hamcrest.CoreMatchers.*;
6import static org.junit.Assert.assertThat;
7
8import com.xtremelabs.robolectric.WithTestDefaultsRunner;
9import org.junit.Test;
10import org.junit.runner.RunWith;
11
12import android.content.SyncResult;
13
14
15@RunWith(WithTestDefaultsRunner.class)
16public class SyncResultTest {
17
18    @Test
19    public void testConstructor() throws Exception {
20        SyncResult result = new SyncResult();
21        assertThat(result.stats, not(nullValue()));
22    }
23
24    @Test
25    public void hasSoftError() throws Exception {
26        SyncResult result = new SyncResult();
27        assertFalse(result.hasSoftError());
28        result.stats.numIoExceptions++;
29        assertTrue(result.hasSoftError());
30        assertTrue(result.hasError());
31    }
32
33    @Test
34    public void hasHardError() throws Exception {
35        SyncResult result = new SyncResult();
36        assertFalse(result.hasHardError());
37        result.stats.numAuthExceptions++;
38        assertTrue(result.hasHardError());
39        assertTrue(result.hasError());
40    }
41
42    @Test
43    public void testMadeSomeProgress() throws Exception {
44        SyncResult result = new SyncResult();
45        assertFalse(result.madeSomeProgress());
46        result.stats.numInserts++;
47        assertTrue(result.madeSomeProgress());
48    }
49
50    @Test
51    public void testClear() throws Exception {
52        SyncResult result = new SyncResult();
53        result.moreRecordsToGet = true;
54        result.stats.numInserts++;
55        result.clear();
56        assertFalse(result.moreRecordsToGet);
57        assertThat(result.stats.numInserts, is(0L));
58    }
59}
60