Skip to content

Clean up integration test for GetSessionId. #1188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions analytics/integration_test/src/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,31 @@ TEST_F(FirebaseAnalyticsTest, TestGetSessionID) {
#if defined(__ANDROID__)
if (did_test_setconsent_) {
LogInfo(
"Skipping TestGetSessionID after TestSetConsent, as it will fail until "
"the app is restarted.");
"Skipping TestGetSessionID after TestSetConsent, as GetSessionId() "
"will fail until the app is restarted.");
GTEST_SKIP();
return;
}
#endif
firebase::Future<int64_t> future;

// It can take Analytics a moment to initialize on iOS.
// So on iOS/tvOS, retry this test if GetSessionId returns an
// error.
#if TARGET_OS_IPHONE
// Give Analytics a moment to initialize and create a session.
ProcessEvents(1000);

// It can take Analytics even more time to initialize and create a session, so
// retry GetSessionId() if it returns an error.
FLAKY_TEST_SECTION_BEGIN();
#endif // TARGET_OS_IPHONE

future = firebase::analytics::GetSessionId();
WaitForCompletion(future, "GetSessionId");

#if TARGET_OS_IPHONE
FLAKY_TEST_SECTION_END();
#endif // TARGET_OS_IPHONE

EXPECT_TRUE(future.result() != nullptr);
EXPECT_NE(*future.result(), static_cast<int64_t>(0L));
LogInfo("Got session ID: %" PRId64, *future.result());
if (future.result() != nullptr) {
LogInfo("Got session ID: %" PRId64, *future.result());
}
}

TEST_F(FirebaseAnalyticsTest, TestSetConsent) {
Expand Down