@@ -137,6 +137,8 @@ class FirebaseDatabaseTest : public FirebaseTest {
137
137
// Sign in an anonymous user.
138
138
static void SignIn ();
139
139
// Sign out the current user, if applicable.
140
+ // If this is an anonymous user, deletes the user instead,
141
+ // to avoid polluting the user list.
140
142
static void SignOut ();
141
143
142
144
// Initialize Firebase Database.
@@ -341,12 +343,19 @@ void FirebaseDatabaseTest::SignOut() {
341
343
// Already signed out.
342
344
return ;
343
345
}
344
-
345
- shared_auth_->SignOut ();
346
-
347
- // Wait for the sign-out to finish.
348
- while (shared_auth_->current_user () != nullptr ) {
349
- if (ProcessEvents (100 )) break ;
346
+ if (shared_auth_->current_user ()->is_anonymous ()) {
347
+ // If signed in anonymously, delete the anonymous user.
348
+ WaitForCompletion (shared_auth_->current_user ()->Delete (), " DeleteAnonymousUser" );
349
+ }
350
+ else {
351
+ // If not signed in anonymously (e.g. if the tests were modified to sign in
352
+ // as an actual user), just sign out normally.
353
+ shared_auth_->SignOut ();
354
+
355
+ // Wait for the sign-out to finish.
356
+ while (shared_auth_->current_user () != nullptr ) {
357
+ if (ProcessEvents (100 )) break ;
358
+ }
350
359
}
351
360
EXPECT_EQ (shared_auth_->current_user (), nullptr );
352
361
}
@@ -1180,16 +1189,22 @@ TEST_F(FirebaseDatabaseTest, TestInfoConnected) {
1180
1189
}
1181
1190
LogDebug (" Disconnecting..." );
1182
1191
database_->GoOffline ();
1192
+ // Pause a moment to give the SDK time to realize we are disconnected.
1193
+ ProcessEvents (1000 );
1183
1194
{
1184
1195
auto disconnected = info.GetValue ();
1185
1196
WaitForCompletion (disconnected, " GetValue 3" );
1186
1197
EXPECT_EQ (disconnected.result ()->value (), false );
1187
1198
}
1188
1199
LogDebug (" Reconnecting..." );
1189
1200
database_->GoOnline ();
1201
+ // Pause a moment to give the SDK time to realize we are reconnected.
1190
1202
ProcessEvents (1000 );
1191
1203
// Force getting a value so that we reconnect to the database.
1192
1204
WaitForCompletion (ref.GetValue (), " GetValue 4 [ignored]" );
1205
+ // Pause another moment to REALLY give the SDK time to realize we are
1206
+ // reconnected.
1207
+ ProcessEvents (1000 );
1193
1208
{
1194
1209
auto reconnected = info.GetValue ();
1195
1210
WaitForCompletion (reconnected, " GetValue 5" );
0 commit comments