Skip to content

Commit ba0b681

Browse files
authored
UMP iOS: Add extra locks around async operations. (#1517)
* Add extra locks around async operations. * Change test to be more correct. * Updated code format.
1 parent 4894109 commit ba0b681

File tree

2 files changed

+231
-262
lines changed

2 files changed

+231
-262
lines changed

gma/integration_test/src/integration_test.cc

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,7 @@ TEST_F(FirebaseGmaUmpTest, TestUmpCleanupRaceCondition) {
30113011

30123012
TEST_F(FirebaseGmaUmpTest, TestUmpCallbacksOnWrongInstance) {
30133013
// Ensure that if ConsentInfo is deleted and then recreated, stale
3014-
// callbacks don't call into the new instance.
3014+
// callbacks don't call into the new instance and cause crashes.
30153015
using firebase::gma::ump::ConsentFormStatus;
30163016
using firebase::gma::ump::ConsentRequestParameters;
30173017
using firebase::gma::ump::ConsentStatus;
@@ -3023,33 +3023,21 @@ TEST_F(FirebaseGmaUmpTest, TestUmpCallbacksOnWrongInstance) {
30233023
params.debug_settings.debug_device_ids = kTestDeviceIDs;
30243024
params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId());
30253025

3026-
firebase::Future<void> future_request =
3027-
consent_info_->RequestConsentInfoUpdate(params);
3028-
firebase::Future<void> future_load = consent_info_->LoadConsentForm();
3029-
firebase::Future<void> future_show =
3030-
consent_info_->ShowConsentForm(app_framework::GetWindowController());
3031-
firebase::Future<void> future_load_and_show =
3032-
consent_info_->LoadAndShowConsentFormIfRequired(
3033-
app_framework::GetWindowController());
3034-
firebase::Future<void> future_privacy = consent_info_->ShowPrivacyOptionsForm(
3035-
app_framework::GetWindowController());
3026+
consent_info_->RequestConsentInfoUpdate(params);
3027+
consent_info_->LoadConsentForm();
3028+
// In automated tests, only check RequestConsentInfoUpdate and LoadConsentForm
3029+
// as the rest may show UI.
3030+
if (ShouldRunUITests()) {
3031+
consent_info_->ShowConsentForm(app_framework::GetWindowController());
3032+
consent_info_->LoadAndShowConsentFormIfRequired(
3033+
app_framework::GetWindowController());
3034+
consent_info_->ShowPrivacyOptionsForm(app_framework::GetWindowController());
3035+
}
30363036

30373037
TerminateUmp(kNoReset);
30383038

3039-
EXPECT_EQ(future_request.status(), firebase::kFutureStatusInvalid);
3040-
EXPECT_EQ(future_load.status(), firebase::kFutureStatusInvalid);
3041-
EXPECT_EQ(future_show.status(), firebase::kFutureStatusInvalid);
3042-
EXPECT_EQ(future_load_and_show.status(), firebase::kFutureStatusInvalid);
3043-
EXPECT_EQ(future_privacy.status(), firebase::kFutureStatusInvalid);
3044-
30453039
InitializeUmp(kNoReset);
30463040

3047-
EXPECT_EQ(future_request.status(), firebase::kFutureStatusInvalid);
3048-
EXPECT_EQ(future_load.status(), firebase::kFutureStatusInvalid);
3049-
EXPECT_EQ(future_show.status(), firebase::kFutureStatusInvalid);
3050-
EXPECT_EQ(future_load_and_show.status(), firebase::kFutureStatusInvalid);
3051-
EXPECT_EQ(future_privacy.status(), firebase::kFutureStatusInvalid);
3052-
30533041
// Give the operations time to complete.
30543042
ProcessEvents(5000);
30553043
}

0 commit comments

Comments
 (0)