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