Skip to content

Commit cc05b85

Browse files
authored
Fix test failures with non-EEA debug tests on iOS. (#1500)
* Fix test failures with non-EEA debug tests on iOS. * Add testing::Eq to using statements. * Fix missing namespace. * Add flaky retry to OperationInProgress test. * Allow the NonEEA test to still require consent. * Update additional tests for new debug NonEEA semantics. * Format code.
1 parent cd5c493 commit cc05b85

File tree

1 file changed

+47
-17
lines changed

1 file changed

+47
-17
lines changed

gma/integration_test/src/integration_test.cc

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ using firebase_test_framework::FirebaseTest;
147147
using testing::AnyOf;
148148
using testing::Contains;
149149
using testing::ElementsAre;
150+
using testing::Eq;
150151
using testing::HasSubstr;
151152
using testing::Pair;
152153
using testing::Property;
@@ -2634,8 +2635,9 @@ TEST_F(FirebaseGmaUmpTest, TestUmpRequestConsentInfoUpdateDebugNonEEA) {
26342635

26352636
WaitForCompletion(future, "RequestConsentInfoUpdate");
26362637

2637-
EXPECT_EQ(consent_info_->GetConsentStatus(),
2638-
firebase::gma::ump::kConsentStatusNotRequired);
2638+
EXPECT_THAT(consent_info_->GetConsentStatus(),
2639+
AnyOf(Eq(firebase::gma::ump::kConsentStatusNotRequired),
2640+
Eq(firebase::gma::ump::kConsentStatusRequired)));
26392641
}
26402642

26412643
TEST_F(FirebaseGmaUmpTest, TestUmpLoadForm) {
@@ -2721,6 +2723,8 @@ TEST_F(FirebaseGmaUmpTest, TestUmpShowForm) {
27212723
}
27222724

27232725
TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDueToUnderAgeOfConsent) {
2726+
SKIP_TEST_ON_IOS_SIMULATOR;
2727+
27242728
using firebase::gma::ump::ConsentDebugSettings;
27252729
using firebase::gma::ump::ConsentFormStatus;
27262730
using firebase::gma::ump::ConsentRequestParameters;
@@ -2736,8 +2740,12 @@ TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDueToUnderAgeOfConsent) {
27362740
WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params),
27372741
"RequestConsentInfoUpdate");
27382742

2739-
WaitForCompletion(consent_info_->LoadConsentForm(), "LoadConsentForm",
2740-
firebase::gma::ump::kConsentFormErrorUnavailable);
2743+
firebase::Future<void> load_future = consent_info_->LoadConsentForm();
2744+
WaitForCompletionAnyResult(load_future, "LoadConsentForm");
2745+
2746+
EXPECT_THAT(load_future.error(),
2747+
AnyOf(Eq(firebase::gma::ump::kConsentFormErrorUnavailable),
2748+
Eq(firebase::gma::ump::kConsentFormErrorTimeout)));
27412749
}
27422750

27432751
TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDebugNonEEA) {
@@ -2756,8 +2764,11 @@ TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDebugNonEEA) {
27562764
WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params),
27572765
"RequestConsentInfoUpdate");
27582766

2759-
WaitForCompletion(consent_info_->LoadConsentForm(), "LoadConsentForm",
2760-
firebase::gma::ump::kConsentFormErrorUnavailable);
2767+
if (consent_info_->GetConsentStatus() !=
2768+
firebase::gma::ump::kConsentStatusRequired) {
2769+
WaitForCompletion(consent_info_->LoadConsentForm(), "LoadConsentForm",
2770+
firebase::gma::ump::kConsentFormErrorUnavailable);
2771+
}
27612772
}
27622773

27632774
TEST_F(FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugNonEEA) {
@@ -2775,17 +2786,25 @@ TEST_F(FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugNonEEA) {
27752786
WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params),
27762787
"RequestConsentInfoUpdate");
27772788

2778-
EXPECT_EQ(consent_info_->GetConsentStatus(),
2779-
firebase::gma::ump::kConsentStatusNotRequired);
2789+
EXPECT_THAT(consent_info_->GetConsentStatus(),
2790+
AnyOf(Eq(firebase::gma::ump::kConsentStatusNotRequired),
2791+
Eq(firebase::gma::ump::kConsentStatusRequired)));
27802792

2781-
firebase::Future<void> future =
2782-
consent_info_->LoadAndShowConsentFormIfRequired(
2783-
app_framework::GetWindowController());
2793+
if (consent_info_->GetConsentStatus() ==
2794+
firebase::gma::ump::kConsentStatusNotRequired ||
2795+
ShouldRunUITests()) {
2796+
// If ConsentStatus is Required, we only want to do this next part if UI
2797+
// interaction is allowed, as it will show a consent form which won't work
2798+
// in automated testing.
2799+
firebase::Future<void> future =
2800+
consent_info_->LoadAndShowConsentFormIfRequired(
2801+
app_framework::GetWindowController());
27842802

2785-
EXPECT_TRUE(future ==
2786-
consent_info_->LoadAndShowConsentFormIfRequiredLastResult());
2803+
EXPECT_TRUE(future ==
2804+
consent_info_->LoadAndShowConsentFormIfRequiredLastResult());
27872805

2788-
WaitForCompletion(future, "LoadAndShowConsentFormIfRequired");
2806+
WaitForCompletion(future, "LoadAndShowConsentFormIfRequired");
2807+
}
27892808
}
27902809

27912810
TEST_F(FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugEEA) {
@@ -2885,10 +2904,14 @@ TEST_F(FirebaseGmaUmpTest, TestCanRequestAdsNonEEA) {
28852904
WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params),
28862905
"RequestConsentInfoUpdate");
28872906

2888-
EXPECT_EQ(consent_info_->GetConsentStatus(),
2889-
firebase::gma::ump::kConsentStatusNotRequired);
2907+
EXPECT_THAT(consent_info_->GetConsentStatus(),
2908+
AnyOf(Eq(firebase::gma::ump::kConsentStatusNotRequired),
2909+
Eq(firebase::gma::ump::kConsentStatusRequired)));
28902910

2891-
EXPECT_TRUE(consent_info_->CanRequestAds());
2911+
if (consent_info_->GetConsentStatus() ==
2912+
firebase::gma::ump::kConsentStatusNotRequired) {
2913+
EXPECT_TRUE(consent_info_->CanRequestAds());
2914+
}
28922915
}
28932916

28942917
TEST_F(FirebaseGmaUmpTest, TestCanRequestAdsEEA) {
@@ -3042,6 +3065,9 @@ TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgress) {
30423065
// Check that all of the UMP operations properly return an OperationInProgress
30433066
// error if called more than once at the same time.
30443067

3068+
// This depends on timing, so it's inherently flaky.
3069+
FLAKY_TEST_SECTION_BEGIN();
3070+
30453071
ConsentRequestParameters params;
30463072
params.tag_for_under_age_of_consent = false;
30473073
params.debug_settings.debug_geography =
@@ -3057,6 +3083,10 @@ TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgress) {
30573083
future_request_2, "RequestConsentInfoUpdate second",
30583084
firebase::gma::ump::kConsentRequestErrorOperationInProgress);
30593085
WaitForCompletion(future_request_1, "RequestConsentInfoUpdate first");
3086+
3087+
consent_info_->Reset();
3088+
3089+
FLAKY_TEST_SECTION_END();
30603090
}
30613091

30623092
TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgressWithUI) {

0 commit comments

Comments
 (0)