@@ -146,8 +146,8 @@ private void notifyLocalViewChanges(LocalViewChanges changes) {
146
146
localStore .notifyLocalViewChanges (asList (changes ));
147
147
}
148
148
149
- private void udpateViews (int targetId ) {
150
- notifyLocalViewChanges (viewChanges (targetId , asList (), asList ()));
149
+ private void udpateViews (int targetId , boolean synced ) {
150
+ notifyLocalViewChanges (viewChanges (targetId , synced , asList (), asList ()));
151
151
}
152
152
153
153
private void acknowledgeMutation (long documentVersion , @ Nullable Object transformResult ) {
@@ -311,7 +311,7 @@ public void testHandlesSetMutationThenAckThenRelease() {
311
311
allocateQuery (query );
312
312
313
313
writeMutation (setMutation ("foo/bar" , map ("foo" , "bar" )));
314
- notifyLocalViewChanges (viewChanges (2 , asList ("foo/bar" ), emptyList ()));
314
+ notifyLocalViewChanges (viewChanges (2 , /* synced= */ false , asList ("foo/bar" ), emptyList ()));
315
315
316
316
assertChanged (doc ("foo/bar" , 0 , map ("foo" , "bar" ), Document .DocumentState .LOCAL_MUTATIONS ));
317
317
assertContains (doc ("foo/bar" , 0 , map ("foo" , "bar" ), Document .DocumentState .LOCAL_MUTATIONS ));
@@ -831,14 +831,16 @@ public void testPinsDocumentsInTheLocalView() {
831
831
assertContains (doc ("foo/bar" , 1 , map ("foo" , "bar" )));
832
832
assertContains (doc ("foo/baz" , 0 , map ("foo" , "baz" ), Document .DocumentState .LOCAL_MUTATIONS ));
833
833
834
- notifyLocalViewChanges (viewChanges (2 , asList ("foo/bar" , "foo/baz" ), emptyList ()));
834
+ notifyLocalViewChanges (
835
+ viewChanges (2 , /* synced= */ false , asList ("foo/bar" , "foo/baz" ), emptyList ()));
835
836
applyRemoteEvent (updateRemoteEvent (doc ("foo/bar" , 1 , map ("foo" , "bar" )), none , two ));
836
837
applyRemoteEvent (updateRemoteEvent (doc ("foo/baz" , 2 , map ("foo" , "baz" )), two , none ));
837
838
acknowledgeMutation (2 );
838
839
assertContains (doc ("foo/bar" , 1 , map ("foo" , "bar" )));
839
840
assertContains (doc ("foo/baz" , 2 , map ("foo" , "baz" )));
840
841
841
- notifyLocalViewChanges (viewChanges (2 , emptyList (), asList ("foo/bar" , "foo/baz" )));
842
+ notifyLocalViewChanges (
843
+ viewChanges (2 , /* synced= */ false , emptyList (), asList ("foo/bar" , "foo/baz" )));
842
844
releaseQuery (query );
843
845
844
846
assertNotContains ("foo/bar" );
@@ -1057,7 +1059,7 @@ public void testUsesTargetMappingToExecuteQueries() {
1057
1059
asList (targetId ),
1058
1060
emptyList ()));
1059
1061
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1060
- udpateViews (targetId );
1062
+ udpateViews (targetId , /* synced= */ true );
1061
1063
1062
1064
// Execute the query again, this time verifying that we only read the two documents that match
1063
1065
// the query.
@@ -1092,9 +1094,14 @@ public void testLastLimboFreeSnapshotIsAdvancedDuringViewProcessing() {
1092
1094
// At this point, we have not yet confirmed that the query is limbo free.
1093
1095
Assert .assertEquals (
1094
1096
SnapshotVersion .NONE , localStore .getQueryData (query ).getLastLimboFreeSnapshotVersion ());
1095
- udpateViews (targetId );
1096
1097
1097
- // The query is marked limbo-free during the view computation.
1098
+ // Update the view, but don't mark the view synced.
1099
+ Assert .assertEquals (
1100
+ SnapshotVersion .NONE , localStore .getQueryData (query ).getLastLimboFreeSnapshotVersion ());
1101
+ udpateViews (targetId , /* synced=*/ true );
1102
+
1103
+ // The query is marked limbo-free only when we mark the view synced.
1104
+ udpateViews (targetId , /* synced=*/ true );
1098
1105
Assert .assertNotEquals (
1099
1106
SnapshotVersion .NONE , localStore .getQueryData (query ).getLastLimboFreeSnapshotVersion ());
1100
1107
@@ -1124,7 +1131,7 @@ public void testQueriesIncludeLocallyModifiedDocuments() {
1124
1131
asList (targetId ),
1125
1132
emptyList ()));
1126
1133
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1127
- udpateViews (targetId );
1134
+ udpateViews (targetId , /* synced= */ true );
1128
1135
1129
1136
// Execute the query based on the RemoteEvent.
1130
1137
executeQuery (query );
@@ -1161,7 +1168,7 @@ public void testQueriesIncludeDocumentsFromOtherQueries() {
1161
1168
asList (targetId ),
1162
1169
emptyList ()));
1163
1170
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1164
- udpateViews (targetId );
1171
+ udpateViews (targetId , /* synced=*/ true );
1165
1172
releaseQuery (filteredQuery );
1166
1173
1167
1174
// Start another query and add more matching documents to the collection.
@@ -1203,7 +1210,7 @@ public void testQueriesFilterDocumentsThatNoLongerMatch() {
1203
1210
asList (targetId ),
1204
1211
emptyList ()));
1205
1212
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1206
- udpateViews (targetId );
1213
+ udpateViews (targetId , /* synced=*/ true );
1207
1214
releaseQuery (filteredQuery );
1208
1215
1209
1216
// Modify one of the documents to no longer match while the filtered query is inactive.
0 commit comments