|
22 | 22 | import android.database.sqlite.SQLiteException; |
23 | 23 | import android.support.test.InstrumentationRegistry; |
24 | 24 | import android.support.test.runner.AndroidJUnit4; |
25 | | -import com.google.common.collect.Range; |
26 | 25 | import com.squareup.sqlbrite.BriteDatabase.Transaction; |
27 | 26 | import com.squareup.sqlbrite.TestDb.Employee; |
28 | 27 | import java.io.Closeable; |
|
31 | 30 | import java.util.Arrays; |
32 | 31 | import java.util.List; |
33 | 32 | import java.util.concurrent.CountDownLatch; |
34 | | -import java.util.concurrent.TimeUnit; |
35 | 33 | import org.junit.After; |
36 | 34 | import org.junit.Before; |
37 | 35 | import org.junit.Test; |
|
59 | 57 | @RunWith(AndroidJUnit4.class) |
60 | 58 | public final class BriteDatabaseTest { |
61 | 59 | private final List<String> logs = new ArrayList<>(); |
62 | | - private RecordingObserver o = new RecordingObserver(); |
| 60 | + private final RecordingObserver o = new RecordingObserver(); |
63 | 61 |
|
64 | 62 | private TestDb helper; |
65 | 63 | private SQLiteDatabase real; |
@@ -164,46 +162,6 @@ public final class BriteDatabaseTest { |
164 | 162 | .isExhausted(); |
165 | 163 | } |
166 | 164 |
|
167 | | - @Test public void queryObservesInsertDebounced() { |
168 | | - o = new BlockingRecordingObserver(); |
169 | | - |
170 | | - db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES) |
171 | | - .debounce(500, MILLISECONDS) |
172 | | - .subscribe(o); |
173 | | - o.assertCursor() |
174 | | - .hasRow("alice", "Alice Allison") |
175 | | - .hasRow("bob", "Bob Bobberson") |
176 | | - .hasRow("eve", "Eve Evenson") |
177 | | - .isExhausted(); |
178 | | - |
179 | | - long startNs = System.nanoTime(); |
180 | | - |
181 | | - // Shotgun 10 inserts which will cause 10 triggers. DO NOT DO THIS IRL! Use a transaction! |
182 | | - for (int i = 0; i < 10; i++) { |
183 | | - db.insert(TABLE_EMPLOYEE, employee("john" + i, "John Johnson " + i)); |
184 | | - } |
185 | | - |
186 | | - // Only one trigger should have been observed. |
187 | | - o.assertCursor() |
188 | | - .hasRow("alice", "Alice Allison") |
189 | | - .hasRow("bob", "Bob Bobberson") |
190 | | - .hasRow("eve", "Eve Evenson") |
191 | | - .hasRow("john0", "John Johnson 0") |
192 | | - .hasRow("john1", "John Johnson 1") |
193 | | - .hasRow("john2", "John Johnson 2") |
194 | | - .hasRow("john3", "John Johnson 3") |
195 | | - .hasRow("john4", "John Johnson 4") |
196 | | - .hasRow("john5", "John Johnson 5") |
197 | | - .hasRow("john6", "John Johnson 6") |
198 | | - .hasRow("john7", "John Johnson 7") |
199 | | - .hasRow("john8", "John Johnson 8") |
200 | | - .hasRow("john9", "John Johnson 9") |
201 | | - .isExhausted(); |
202 | | - |
203 | | - long tookNs = System.nanoTime() - startNs; |
204 | | - assertThat(TimeUnit.NANOSECONDS.toMillis(tookNs)).isIn(Range.atLeast(500L)); |
205 | | - } |
206 | | - |
207 | 165 | @Test public void queryNotNotifiedWhenInsertFails() { |
208 | 166 | db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o); |
209 | 167 | o.assertCursor() |
|
0 commit comments