@@ -113,31 +113,31 @@ TEST_F(FirebaseAnalyticsTest, TestGetSessionID) {
113113#if defined(__ANDROID__)
114114 if (did_test_setconsent_) {
115115 LogInfo (
116- " Skipping TestGetSessionID after TestSetConsent, as it will fail until "
117- " the app is restarted." );
116+ " Skipping TestGetSessionID after TestSetConsent, as GetSessionId() "
117+ " will fail until the app is restarted." );
118118 GTEST_SKIP ();
119119 return ;
120120 }
121121#endif
122122 firebase::Future<int64_t > future;
123123
124- // It can take Analytics a moment to initialize on iOS.
125- // So on iOS/tvOS, retry this test if GetSessionId returns an
126- // error.
127- #if TARGET_OS_IPHONE
124+ // Give Analytics a moment to initialize and create a session.
125+ ProcessEvents (1000 );
126+
127+ // It can take Analytics even more time to initialize and create a session, so
128+ // retry GetSessionId() if it returns an error.
128129 FLAKY_TEST_SECTION_BEGIN ();
129- #endif // TARGET_OS_IPHONE
130130
131131 future = firebase::analytics::GetSessionId ();
132132 WaitForCompletion (future, " GetSessionId" );
133133
134- #if TARGET_OS_IPHONE
135134 FLAKY_TEST_SECTION_END ();
136- #endif // TARGET_OS_IPHONE
137135
138136 EXPECT_TRUE (future.result () != nullptr );
139137 EXPECT_NE (*future.result (), static_cast <int64_t >(0L ));
140- LogInfo (" Got session ID: %" PRId64, *future.result ());
138+ if (future.result () != nullptr ) {
139+ LogInfo (" Got session ID: %" PRId64, *future.result ());
140+ }
141141}
142142
143143TEST_F (FirebaseAnalyticsTest, TestSetConsent) {
0 commit comments