|
32 | 32 | import static org.junit.Assert.assertNull;
|
33 | 33 | import static org.junit.Assert.assertTrue;
|
34 | 34 |
|
35 |
| -import android.os.SystemClock; |
36 |
| -import androidx.annotation.Nullable; |
37 | 35 | import androidx.test.ext.junit.runners.AndroidJUnit4;
|
38 | 36 | import com.google.android.gms.tasks.Task;
|
39 | 37 | import com.google.common.collect.Lists;
|
@@ -1089,8 +1087,9 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
|
1089 | 1087 | QuerySnapshot snapshot2;
|
1090 | 1088 | WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo
|
1091 | 1089 | existenceFilterMismatchInfo;
|
1092 |
| - ExistenceFilterMismatchAccumulator existenceFilterMismatchAccumulator = |
1093 |
| - new ExistenceFilterMismatchAccumulator(); |
| 1090 | + WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchAccumulator |
| 1091 | + existenceFilterMismatchAccumulator = |
| 1092 | + new WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchAccumulator(); |
1094 | 1093 | existenceFilterMismatchAccumulator.register();
|
1095 | 1094 | try {
|
1096 | 1095 | snapshot2 = waitFor(collection.get());
|
@@ -1183,76 +1182,6 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
|
1183 | 1182 | }
|
1184 | 1183 | }
|
1185 | 1184 |
|
1186 |
| - private static final class ExistenceFilterMismatchAccumulator { |
1187 |
| - |
1188 |
| - private final ExistenceFilterMismatchListenerImpl listener = |
1189 |
| - new ExistenceFilterMismatchListenerImpl(); |
1190 |
| - private ListenerRegistration listenerRegistration = null; |
1191 |
| - |
1192 |
| - void register() { |
1193 |
| - if (listenerRegistration != null) { |
1194 |
| - throw new IllegalStateException("already registered"); |
1195 |
| - } |
1196 |
| - listenerRegistration = |
1197 |
| - WatchChangeAggregatorTestingHooksAccessor.addExistenceFilterMismatchListener(listener); |
1198 |
| - } |
1199 |
| - |
1200 |
| - void unregister() { |
1201 |
| - if (listenerRegistration == null) { |
1202 |
| - return; |
1203 |
| - } |
1204 |
| - listenerRegistration.remove(); |
1205 |
| - listenerRegistration = null; |
1206 |
| - } |
1207 |
| - |
1208 |
| - @Nullable |
1209 |
| - WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo |
1210 |
| - waitForExistenceFilterMismatch(long timeoutMillis) throws InterruptedException { |
1211 |
| - if (listenerRegistration == null) { |
1212 |
| - throw new IllegalStateException( |
1213 |
| - "must be registered before waiting for an existence filter mismatch"); |
1214 |
| - } |
1215 |
| - return listener.waitForExistenceFilterMismatch(timeoutMillis); |
1216 |
| - } |
1217 |
| - |
1218 |
| - private final class ExistenceFilterMismatchListenerImpl |
1219 |
| - implements WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchListener { |
1220 |
| - |
1221 |
| - private final ArrayList<WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo> |
1222 |
| - existenceFilterMismatches = new ArrayList<>(); |
1223 |
| - |
1224 |
| - @Override |
1225 |
| - public void onExistenceFilterMismatch( |
1226 |
| - WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo info) { |
1227 |
| - synchronized (existenceFilterMismatches) { |
1228 |
| - existenceFilterMismatches.add(info); |
1229 |
| - existenceFilterMismatches.notifyAll(); |
1230 |
| - } |
1231 |
| - } |
1232 |
| - |
1233 |
| - @Nullable |
1234 |
| - WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterMismatchInfo |
1235 |
| - waitForExistenceFilterMismatch(long timeoutMillis) throws InterruptedException { |
1236 |
| - if (timeoutMillis <= 0) { |
1237 |
| - throw new IllegalArgumentException("invalid timeout: " + timeoutMillis); |
1238 |
| - } |
1239 |
| - synchronized (existenceFilterMismatches) { |
1240 |
| - long endTimeMillis = SystemClock.uptimeMillis() + timeoutMillis; |
1241 |
| - while (true) { |
1242 |
| - if (existenceFilterMismatches.size() > 0) { |
1243 |
| - return existenceFilterMismatches.remove(0); |
1244 |
| - } |
1245 |
| - long currentWaitMillis = endTimeMillis - SystemClock.uptimeMillis(); |
1246 |
| - if (currentWaitMillis <= 0) { |
1247 |
| - return null; |
1248 |
| - } |
1249 |
| - existenceFilterMismatches.wait(currentWaitMillis); |
1250 |
| - } |
1251 |
| - } |
1252 |
| - } |
1253 |
| - } |
1254 |
| - } |
1255 |
| - |
1256 | 1185 | // TODO(orquery): Enable this test when prod supports OR queries.
|
1257 | 1186 | @Ignore
|
1258 | 1187 | @Test
|
|
0 commit comments