Skip to content

Commit 9c494f7

Browse files
authored
Clean up integration test for GetSessionId. (#1188)
* Clean up integration test for GetSessionId. * Don't output a bad session ID. * Change retry to all platforms.
1 parent 6d8c0aa commit 9c494f7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

analytics/integration_test/src/integration_test.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

143143
TEST_F(FirebaseAnalyticsTest, TestSetConsent) {

0 commit comments

Comments
 (0)