@@ -778,19 +778,13 @@ TEST_F(FirebaseGmaTest, TestAdViewLoadAd) {
778
778
firebase::Future<firebase::gma::AdResult> load_ad_future;
779
779
const firebase::gma::AdResult* result_ptr = nullptr ;
780
780
781
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
782
- // return NoFill for valid ad requests if there aren't any ads to serve.
783
- FLAKY_TEST_SECTION_BEGIN ();
784
-
785
781
load_ad_future = ad_view->LoadAd (GetAdRequest ());
786
782
WaitForCompletion (load_ad_future, " LoadAd" );
787
783
788
784
result_ptr = load_ad_future.result ();
789
785
ASSERT_NE (result_ptr, nullptr );
790
786
EXPECT_TRUE (result_ptr->is_successful ());
791
787
792
- FLAKY_TEST_SECTION_END ();
793
-
794
788
ASSERT_NE (result_ptr, nullptr );
795
789
EXPECT_FALSE (result_ptr->response_info ().adapter_responses ().empty ());
796
790
EXPECT_FALSE (
@@ -811,10 +805,6 @@ TEST_F(FirebaseGmaTest, TestInterstitialAdLoad) {
811
805
SKIP_TEST_ON_DESKTOP;
812
806
SKIP_TEST_ON_SIMULATOR;
813
807
814
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
815
- // return NoFill for valid ad requests if there aren't any ads to serve.
816
- FLAKY_TEST_SECTION_BEGIN ();
817
-
818
808
firebase::gma::InterstitialAd* interstitial =
819
809
new firebase::gma::InterstitialAd ();
820
810
@@ -837,17 +827,14 @@ TEST_F(FirebaseGmaTest, TestInterstitialAdLoad) {
837
827
838
828
load_ad_future.Release ();
839
829
delete interstitial;
840
-
841
- FLAKY_TEST_SECTION_END ();
842
830
}
843
831
844
832
TEST_F (FirebaseGmaTest, TestRewardedAdLoad) {
845
833
SKIP_TEST_ON_DESKTOP;
846
834
SKIP_TEST_ON_SIMULATOR;
847
835
848
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
849
- // return NoFill for valid ad requests if there aren't any ads to serve.
850
- FLAKY_TEST_SECTION_BEGIN ();
836
+ // TODO(@drsanta): remove when GMA whitelists CI devices.
837
+ TEST_REQUIRES_USER_INTERACTION_ON_IOS;
851
838
852
839
firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd ();
853
840
@@ -870,8 +857,6 @@ TEST_F(FirebaseGmaTest, TestRewardedAdLoad) {
870
857
871
858
load_ad_future.Release ();
872
859
delete rewarded;
873
-
874
- FLAKY_TEST_SECTION_END ();
875
860
}
876
861
877
862
// Interactive test section. These have been placed up front so that the
@@ -1011,6 +996,9 @@ TEST_F(FirebaseGmaUITest, TestRewardedAdLoadAndShow) {
1011
996
SKIP_TEST_ON_DESKTOP;
1012
997
SKIP_TEST_ON_SIMULATOR;
1013
998
999
+ // TODO(@drsanta): remove when GMA whitelists CI devices.
1000
+ TEST_REQUIRES_USER_INTERACTION_ON_IOS;
1001
+
1014
1002
firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd ();
1015
1003
1016
1004
WaitForCompletion (rewarded->Initialize (app_framework::GetWindowContext ()),
@@ -1093,18 +1081,12 @@ TEST_F(FirebaseGmaTest, TestAdViewLoadAdEmptyAdRequest) {
1093
1081
firebase::Future<firebase::gma::AdResult> load_ad_future;
1094
1082
const firebase::gma::AdResult* result_ptr = nullptr ;
1095
1083
1096
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1097
- // return NoFill for valid ad requests if there aren't any ads to serve.
1098
- FLAKY_TEST_SECTION_BEGIN ();
1099
-
1100
1084
load_ad_future = ad_view->LoadAd (request);
1101
1085
WaitForCompletion (load_ad_future, " LoadAd" );
1102
1086
result_ptr = load_ad_future.result ();
1103
1087
ASSERT_NE (result_ptr, nullptr );
1104
1088
EXPECT_TRUE (result_ptr->is_successful ());
1105
1089
1106
- FLAKY_TEST_SECTION_END ();
1107
-
1108
1090
EXPECT_FALSE (result_ptr->response_info ().adapter_responses ().empty ());
1109
1091
EXPECT_FALSE (
1110
1092
result_ptr->response_info ().mediation_adapter_class_name ().empty ());
@@ -1133,14 +1115,8 @@ TEST_F(FirebaseGmaTest, TestAdViewLoadAdAnchorAdaptiveAd) {
1133
1115
kBannerAdUnit , banner_ad_size),
1134
1116
" Initialize" );
1135
1117
1136
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1137
- // return NoFill for valid ad requests if there aren't any ads to serve.
1138
- FLAKY_TEST_SECTION_BEGIN ();
1139
-
1140
1118
WaitForCompletion (ad_view->LoadAd (GetAdRequest ()), " LoadAd" );
1141
1119
1142
- FLAKY_TEST_SECTION_END ();
1143
-
1144
1120
const AdSize ad_size = ad_view->ad_size ();
1145
1121
EXPECT_EQ (ad_size.width (), kBannerWidth );
1146
1122
EXPECT_NE (ad_size.height (), 0 );
@@ -1163,14 +1139,8 @@ TEST_F(FirebaseGmaTest, TestAdViewLoadAdInlineAdaptiveAd) {
1163
1139
kBannerAdUnit , banner_ad_size),
1164
1140
" Initialize" );
1165
1141
1166
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1167
- // return NoFill for valid ad requests if there aren't any ads to serve.
1168
- FLAKY_TEST_SECTION_BEGIN ();
1169
-
1170
1142
WaitForCompletion (ad_view->LoadAd (GetAdRequest ()), " LoadAd" );
1171
1143
1172
- FLAKY_TEST_SECTION_END ();
1173
-
1174
1144
const AdSize ad_size = ad_view->ad_size ();
1175
1145
EXPECT_EQ (ad_size.width (), kBannerWidth );
1176
1146
EXPECT_NE (ad_size.height (), 0 );
@@ -1192,14 +1162,8 @@ TEST_F(FirebaseGmaTest, TestAdViewLoadAdGetInlineAdaptiveBannerMaxHeight) {
1192
1162
kBannerAdUnit , banner_ad_size),
1193
1163
" Initialize" );
1194
1164
1195
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1196
- // return NoFill for valid ad requests if there aren't any ads to serve.
1197
- FLAKY_TEST_SECTION_BEGIN ();
1198
-
1199
1165
WaitForCompletion (ad_view->LoadAd (GetAdRequest ()), " LoadAd" );
1200
1166
1201
- FLAKY_TEST_SECTION_END ();
1202
-
1203
1167
const AdSize ad_size = ad_view->ad_size ();
1204
1168
EXPECT_EQ (ad_size.width (), kBannerWidth );
1205
1169
EXPECT_NE (ad_size.height (), 0 );
@@ -1219,15 +1183,7 @@ TEST_F(FirebaseGmaTest, TestAdViewLoadAdDestroyNotCalled) {
1219
1183
WaitForCompletion (ad_view->Initialize (app_framework::GetWindowContext (),
1220
1184
kBannerAdUnit , banner_ad_size),
1221
1185
" Initialize" );
1222
-
1223
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1224
- // return NoFill for valid ad requests if there aren't any ads to serve.
1225
- FLAKY_TEST_SECTION_BEGIN ();
1226
-
1227
1186
WaitForCompletion (ad_view->LoadAd (GetAdRequest ()), " LoadAd" );
1228
-
1229
- FLAKY_TEST_SECTION_END ();
1230
-
1231
1187
delete ad_view;
1232
1188
}
1233
1189
@@ -1305,10 +1261,6 @@ TEST_F(FirebaseGmaTest, TestAdView) {
1305
1261
SKIP_TEST_ON_DESKTOP;
1306
1262
SKIP_TEST_ON_SIMULATOR;
1307
1263
1308
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1309
- // return NoFill for valid ad requests if there aren't any ads to serve.
1310
- FLAKY_TEST_SECTION_BEGIN ();
1311
-
1312
1264
const firebase::gma::AdSize banner_ad_size (kBannerWidth , kBannerHeight );
1313
1265
firebase::gma::AdView* ad_view = new firebase::gma::AdView ();
1314
1266
WaitForCompletion (ad_view->Initialize (app_framework::GetWindowContext (),
@@ -1504,8 +1456,6 @@ TEST_F(FirebaseGmaTest, TestAdView) {
1504
1456
bounding_box_listener.bounding_box_changes_ .back ().height == -1 );
1505
1457
#endif // defined(ANDROID) || TARGET_OS_IPHONE
1506
1458
}
1507
-
1508
- FLAKY_TEST_SECTION_END ();
1509
1459
}
1510
1460
1511
1461
TEST_F (FirebaseGmaTest, TestAdViewErrorNotInitialized) {
@@ -1674,10 +1624,6 @@ TEST_F(FirebaseGmaTest, TestInterstitialAdLoadEmptyRequest) {
1674
1624
SKIP_TEST_ON_DESKTOP;
1675
1625
SKIP_TEST_ON_SIMULATOR;
1676
1626
1677
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1678
- // return NoFill for valid ad requests if there aren't any ads to serve.
1679
- FLAKY_TEST_SECTION_BEGIN ();
1680
-
1681
1627
firebase::gma::InterstitialAd* interstitial =
1682
1628
new firebase::gma::InterstitialAd ();
1683
1629
@@ -1701,8 +1647,6 @@ TEST_F(FirebaseGmaTest, TestInterstitialAdLoadEmptyRequest) {
1701
1647
EXPECT_FALSE (result_ptr->response_info ().ToString ().empty ());
1702
1648
1703
1649
delete interstitial;
1704
-
1705
- FLAKY_TEST_SECTION_END ();
1706
1650
}
1707
1651
1708
1652
TEST_F (FirebaseGmaTest, TestInterstitialAdErrorNotInitialized) {
@@ -1851,9 +1795,8 @@ TEST_F(FirebaseGmaTest, TestRewardedAdLoadEmptyRequest) {
1851
1795
SKIP_TEST_ON_DESKTOP;
1852
1796
SKIP_TEST_ON_SIMULATOR;
1853
1797
1854
- // Loading Ads has been deemed flaky as the AdMob Service has a chance to
1855
- // return NoFill for valid ad requests if there aren't any ads to serve.
1856
- FLAKY_TEST_SECTION_BEGIN ();
1798
+ // TODO(@drsanta): remove when GMA whitelists CI devices.
1799
+ TEST_REQUIRES_USER_INTERACTION_ON_IOS;
1857
1800
1858
1801
// Note: while showing an ad requires user interaction in another test,
1859
1802
// this test is mean as a baseline loadAd functionality test.
@@ -1878,8 +1821,6 @@ TEST_F(FirebaseGmaTest, TestRewardedAdLoadEmptyRequest) {
1878
1821
EXPECT_FALSE (result_ptr->response_info ().ToString ().empty ());
1879
1822
1880
1823
delete rewarded;
1881
-
1882
- FLAKY_TEST_SECTION_END ();
1883
1824
}
1884
1825
1885
1826
TEST_F (FirebaseGmaTest, TestRewardedAdErrorNotInitialized) {
@@ -1938,6 +1879,9 @@ TEST_F(FirebaseGmaTest, TesRewardedAdErrorAlreadyInitialized) {
1938
1879
TEST_F (FirebaseGmaTest, TestRewardedAdErrorLoadInProgress) {
1939
1880
SKIP_TEST_ON_DESKTOP;
1940
1881
1882
+ // TODO(@drsanta): remove when GMA whitelists CI devices.
1883
+ TEST_REQUIRES_USER_INTERACTION_ON_IOS;
1884
+
1941
1885
firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd ();
1942
1886
WaitForCompletion (rewarded->Initialize (app_framework::GetWindowContext ()),
1943
1887
" Initialize" );
@@ -2029,10 +1973,16 @@ TEST_F(FirebaseGmaTest, TestAdViewStress) {
2029
1973
2030
1974
// Load the AdView ad.
2031
1975
firebase::gma::AdRequest request = GetAdRequest ();
2032
- WaitForCompletion (ad_view->LoadAd (request), " TestAdViewStress LoadAd" );
2033
- EXPECT_EQ (ad_view->ad_size ().width (), kBannerWidth );
2034
- EXPECT_EQ (ad_view->ad_size ().height (), kBannerHeight );
2035
-
1976
+ firebase::Future<firebase::gma::AdResult> future = ad_view->LoadAd (request);
1977
+ WaitForCompletionAnyResult (future, " TestAdViewStress LoadAd" );
1978
+ // Stress tests may exhaust the ad pool. If so, loadAd will return
1979
+ // kAdErrorCodeNoFill.
1980
+ EXPECT_TRUE (future.error () == firebase::gma::kAdErrorCodeNone ||
1981
+ future.error () == firebase::gma::kAdErrorCodeNoFill );
1982
+ if (future.error () == firebase::gma::kAdErrorCodeNone ) {
1983
+ EXPECT_EQ (ad_view->ad_size ().width (), kBannerWidth );
1984
+ EXPECT_EQ (ad_view->ad_size ().height (), kBannerHeight );
1985
+ }
2036
1986
WaitForCompletion (ad_view->Destroy (), " Destroy the AdView" );
2037
1987
delete ad_view;
2038
1988
}
@@ -2055,8 +2005,13 @@ TEST_F(FirebaseGmaTest, TestInterstitialAdStress) {
2055
2005
2056
2006
// When the InterstitialAd is initialized, load an ad.
2057
2007
firebase::gma::AdRequest request = GetAdRequest ();
2058
- WaitForCompletion (interstitial->LoadAd (kInterstitialAdUnit , request),
2059
- " TestInterstitialAdStress LoadAd" );
2008
+ firebase::Future<firebase::gma::AdResult> future =
2009
+ interstitial->LoadAd (kInterstitialAdUnit , request);
2010
+ WaitForCompletionAnyResult (future, " TestInterstitialAdStress LoadAd" );
2011
+ // Stress tests may exhaust the ad pool. If so, loadAd will return
2012
+ // kAdErrorCodeNoFill.
2013
+ EXPECT_TRUE (future.error () == firebase::gma::kAdErrorCodeNone ||
2014
+ future.error () == firebase::gma::kAdErrorCodeNoFill );
2060
2015
delete interstitial;
2061
2016
}
2062
2017
}
@@ -2065,7 +2020,7 @@ TEST_F(FirebaseGmaTest, TestRewardedAdStress) {
2065
2020
SKIP_TEST_ON_DESKTOP;
2066
2021
SKIP_TEST_ON_EMULATOR;
2067
2022
2068
- // TODO(@drsanta): remove when GMA whitelists CI devices
2023
+ // TODO(@drsanta): remove when GMA whitelists CI devices.
2069
2024
TEST_REQUIRES_USER_INTERACTION_ON_IOS;
2070
2025
2071
2026
for (int i = 0 ; i < 10 ; ++i) {
@@ -2076,8 +2031,13 @@ TEST_F(FirebaseGmaTest, TestRewardedAdStress) {
2076
2031
2077
2032
// When the RewardedAd is initialized, load an ad.
2078
2033
firebase::gma::AdRequest request = GetAdRequest ();
2079
- WaitForCompletion (rewarded->LoadAd (kRewardedAdUnit , request),
2080
- " TestRewardedAdStress LoadAd" );
2034
+ firebase::Future<firebase::gma::AdResult> future =
2035
+ rewarded->LoadAd (kRewardedAdUnit , request);
2036
+ WaitForCompletionAnyResult (future, " TestRewardedAdStress LoadAd" );
2037
+ // Stress tests may exhaust the ad pool. If so, loadAd will return
2038
+ // kAdErrorCodeNoFill.
2039
+ EXPECT_TRUE (future.error () == firebase::gma::kAdErrorCodeNone ||
2040
+ future.error () == firebase::gma::kAdErrorCodeNoFill );
2081
2041
delete rewarded;
2082
2042
}
2083
2043
}
0 commit comments