@@ -147,6 +147,7 @@ using firebase_test_framework::FirebaseTest;
147
147
using testing::AnyOf;
148
148
using testing::Contains;
149
149
using testing::ElementsAre;
150
+ using testing::Eq;
150
151
using testing::HasSubstr;
151
152
using testing::Pair;
152
153
using testing::Property;
@@ -2634,8 +2635,9 @@ TEST_F(FirebaseGmaUmpTest, TestUmpRequestConsentInfoUpdateDebugNonEEA) {
2634
2635
2635
2636
WaitForCompletion (future, " RequestConsentInfoUpdate" );
2636
2637
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 )));
2639
2641
}
2640
2642
2641
2643
TEST_F (FirebaseGmaUmpTest, TestUmpLoadForm) {
@@ -2721,6 +2723,8 @@ TEST_F(FirebaseGmaUmpTest, TestUmpShowForm) {
2721
2723
}
2722
2724
2723
2725
TEST_F (FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDueToUnderAgeOfConsent) {
2726
+ SKIP_TEST_ON_IOS_SIMULATOR;
2727
+
2724
2728
using firebase::gma::ump::ConsentDebugSettings;
2725
2729
using firebase::gma::ump::ConsentFormStatus;
2726
2730
using firebase::gma::ump::ConsentRequestParameters;
@@ -2736,8 +2740,12 @@ TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDueToUnderAgeOfConsent) {
2736
2740
WaitForCompletion (consent_info_->RequestConsentInfoUpdate (params),
2737
2741
" RequestConsentInfoUpdate" );
2738
2742
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 )));
2741
2749
}
2742
2750
2743
2751
TEST_F (FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDebugNonEEA) {
@@ -2756,8 +2764,11 @@ TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDebugNonEEA) {
2756
2764
WaitForCompletion (consent_info_->RequestConsentInfoUpdate (params),
2757
2765
" RequestConsentInfoUpdate" );
2758
2766
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
+ }
2761
2772
}
2762
2773
2763
2774
TEST_F (FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugNonEEA) {
@@ -2775,17 +2786,25 @@ TEST_F(FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugNonEEA) {
2775
2786
WaitForCompletion (consent_info_->RequestConsentInfoUpdate (params),
2776
2787
" RequestConsentInfoUpdate" );
2777
2788
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 )));
2780
2792
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 ());
2784
2802
2785
- EXPECT_TRUE (future ==
2786
- consent_info_->LoadAndShowConsentFormIfRequiredLastResult ());
2803
+ EXPECT_TRUE (future ==
2804
+ consent_info_->LoadAndShowConsentFormIfRequiredLastResult ());
2787
2805
2788
- WaitForCompletion (future, " LoadAndShowConsentFormIfRequired" );
2806
+ WaitForCompletion (future, " LoadAndShowConsentFormIfRequired" );
2807
+ }
2789
2808
}
2790
2809
2791
2810
TEST_F (FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugEEA) {
@@ -2885,10 +2904,14 @@ TEST_F(FirebaseGmaUmpTest, TestCanRequestAdsNonEEA) {
2885
2904
WaitForCompletion (consent_info_->RequestConsentInfoUpdate (params),
2886
2905
" RequestConsentInfoUpdate" );
2887
2906
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 )));
2890
2910
2891
- EXPECT_TRUE (consent_info_->CanRequestAds ());
2911
+ if (consent_info_->GetConsentStatus () ==
2912
+ firebase::gma::ump::kConsentStatusNotRequired ) {
2913
+ EXPECT_TRUE (consent_info_->CanRequestAds ());
2914
+ }
2892
2915
}
2893
2916
2894
2917
TEST_F (FirebaseGmaUmpTest, TestCanRequestAdsEEA) {
@@ -3042,6 +3065,9 @@ TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgress) {
3042
3065
// Check that all of the UMP operations properly return an OperationInProgress
3043
3066
// error if called more than once at the same time.
3044
3067
3068
+ // This depends on timing, so it's inherently flaky.
3069
+ FLAKY_TEST_SECTION_BEGIN ();
3070
+
3045
3071
ConsentRequestParameters params;
3046
3072
params.tag_for_under_age_of_consent = false ;
3047
3073
params.debug_settings .debug_geography =
@@ -3057,6 +3083,10 @@ TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgress) {
3057
3083
future_request_2, " RequestConsentInfoUpdate second" ,
3058
3084
firebase::gma::ump::kConsentRequestErrorOperationInProgress );
3059
3085
WaitForCompletion (future_request_1, " RequestConsentInfoUpdate first" );
3086
+
3087
+ consent_info_->Reset ();
3088
+
3089
+ FLAKY_TEST_SECTION_END ();
3060
3090
}
3061
3091
3062
3092
TEST_F (FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgressWithUI) {
0 commit comments