diff --git a/auth/tests/desktop/test_utils.cc b/auth/tests/desktop/test_utils.cc index de86beed5a..510629b1b0 100644 --- a/auth/tests/desktop/test_utils.cc +++ b/auth/tests/desktop/test_utils.cc @@ -28,13 +28,29 @@ void ListenerChangeCounter::ExpectChanges(const int num) { expected_changes_ = num; } void ListenerChangeCounter::VerifyAndReset() { - Verify(); + int timeout_value = -1; +#ifdef __APPLE__ + timeout_value = 10000; +#endif + Verify(timeout_value); expected_changes_ = -1; actual_changes_ = 0; } -void ListenerChangeCounter::Verify() { +void ListenerChangeCounter::Verify(int timeout) { if (expected_changes_ != -1) { + if (timeout >= 0 && expected_changes_ != actual_changes_) { + int elapsed_time = 0; + while( elapsed_time <= timeout ) { + printf("."); + firebase::internal::Sleep(100); + elapsed_time += 100; // only estimating elapsed time to simplfy portability. + if(expected_changes_ == actual_changes_) { + break; + } + } + printf("\n"); + } EXPECT_EQ(expected_changes_, actual_changes_); } } diff --git a/auth/tests/desktop/test_utils.h b/auth/tests/desktop/test_utils.h index 97d0379de2..afb8962bba 100644 --- a/auth/tests/desktop/test_utils.h +++ b/auth/tests/desktop/test_utils.h @@ -45,9 +45,9 @@ class ListenerChangeCounter { int actual_changes_; private: - void Verify(); + void Verify(int timeout = -1); - int expected_changes_; + volatile int expected_changes_; }; } // namespace detail