Skip to content

Commit fb93580

Browse files
Mobile Ads Developer Relationscopybara-github
authored andcommitted
Add unit tests for AppOpenAdPreloader.PeekAdResponseInfo.
PiperOrigin-RevId: 952974572
1 parent 1c59495 commit fb93580

26 files changed

Lines changed: 300 additions & 5 deletions

source/plugin/Assets/GoogleMobileAds/Api/AppOpenAdPreloader.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static Dictionary<string, PreloadConfiguration> GetConfigurations()
127127
/// Returns a preloaded ad and removes it from the cache.
128128
/// </summary>
129129
/// <param name="preloadId">
130-
/// The ad's preload ID.
130+
/// A string identifier used to preload the ads for that configuration.
131131
/// </param>
132132
/// <returns>
133133
/// The preloaded ad for the given preload ID, or null if no ad is available.
@@ -146,6 +146,26 @@ public static AppOpenAd DequeueAd(string preloadId)
146146
return new AppOpenAd(client);
147147
}
148148

149+
/// <summary>
150+
/// Returns the ResponseInfo of a preloaded ad for the given preload ID without
151+
/// dequeuing it, or null if no ad is available.
152+
/// </summary>
153+
/// <param name="preloadId">
154+
/// A string identifier used to preload the ads for that configuration.
155+
/// </param>
156+
/// <returns>
157+
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
158+
/// </returns>
159+
public static ResponseInfo PeekAdResponseInfo(string preloadId)
160+
{
161+
var responseInfoClient = _client.PeekAdResponseInfo(preloadId);
162+
if (responseInfoClient == null)
163+
{
164+
return null;
165+
}
166+
return new ResponseInfo(responseInfoClient);
167+
}
168+
149169
/// <summary>
150170
/// Get the number of ads available for the given preload ID.
151171
/// </summary>

source/plugin/Assets/GoogleMobileAds/Api/InterstitialAdPreloader.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static Dictionary<string, PreloadConfiguration> GetConfigurations()
127127
/// Returns a preloaded ad and removes it from the cache.
128128
/// </summary>
129129
/// <param name="preloadId">
130-
/// The ad's preload ID.
130+
/// A string identifier used to preload the ads for that configuration.
131131
/// </param>
132132
/// <returns>
133133
/// The preloaded ad for the given preload ID, or null if no ad is available.
@@ -146,6 +146,26 @@ public static InterstitialAd DequeueAd(string preloadId)
146146
return new InterstitialAd(client);
147147
}
148148

149+
/// <summary>
150+
/// Returns the ResponseInfo of a preloaded ad for the given preload ID without
151+
/// dequeuing it, or null if no ad is available.
152+
/// </summary>
153+
/// <param name="preloadId">
154+
/// A string identifier used to preload the ads for that configuration.
155+
/// </param>
156+
/// <returns>
157+
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
158+
/// </returns>
159+
public static ResponseInfo PeekAdResponseInfo(string preloadId)
160+
{
161+
var responseInfoClient = _client.PeekAdResponseInfo(preloadId);
162+
if (responseInfoClient == null)
163+
{
164+
return null;
165+
}
166+
return new ResponseInfo(responseInfoClient);
167+
}
168+
149169
/// <summary>
150170
/// Get the number of ads available for the given preload ID.
151171
/// </summary>

source/plugin/Assets/GoogleMobileAds/Api/RewardedAdPreloader.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static Dictionary<string, PreloadConfiguration> GetConfigurations()
126126
/// Returns a preloaded ad and removes it from the cache.
127127
/// </summary>
128128
/// <param name="preloadId">
129-
/// The ad's preload ID.
129+
/// A string identifier used to preload the ads for that configuration.
130130
/// </param>
131131
/// <returns>
132132
/// The preloaded ad for the given preload ID, or null if no ad is available.
@@ -145,6 +145,26 @@ public static RewardedAd DequeueAd(string preloadId)
145145
return new RewardedAd(client);
146146
}
147147

148+
/// <summary>
149+
/// Returns the ResponseInfo of a preloaded ad for the given preload ID without
150+
/// dequeuing it, or null if no ad is available.
151+
/// </summary>
152+
/// <param name="preloadId">
153+
/// A string identifier used to preload the ads for that configuration.
154+
/// </param>
155+
/// <returns>
156+
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
157+
/// </returns>
158+
public static ResponseInfo PeekAdResponseInfo(string preloadId)
159+
{
160+
var responseInfoClient = _client.PeekAdResponseInfo(preloadId);
161+
if (responseInfoClient == null)
162+
{
163+
return null;
164+
}
165+
return new ResponseInfo(responseInfoClient);
166+
}
167+
148168
/// <summary>
149169
/// Get the number of ads available for the given preload ID.
150170
/// </summary>

source/plugin/Assets/GoogleMobileAds/Common/IAppOpenAdPreloaderClient.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
7676
/// </remarks>
7777
IAppOpenAdClient DequeueAd(string preloadId);
7878

79+
/// <summary>
80+
/// Returns the ResponseInfo of an ad available for the given preload ID without
81+
/// dequeuing it, or null if no ad is available.
82+
/// </summary>
83+
/// <param name="preloadId">
84+
/// A string identifier used to preload the ads for that configuration.
85+
/// </param>
86+
/// <returns>
87+
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
88+
/// </returns>
89+
IResponseInfoClient PeekAdResponseInfo(string preloadId);
90+
7991
/// <summary>
8092
/// Get the number of ads available for the given preload ID.
8193
/// </summary>

source/plugin/Assets/GoogleMobileAds/Common/IInterstitialAdPreloaderClient.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
6565
/// Returns a preloaded ad and removes it from the cache.
6666
/// </summary>
6767
/// <param name="preloadId">
68-
/// The ad's preload ID.
68+
/// A string identifier used to preload the ads for that configuration.
6969
/// </param>
7070
/// <returns>
7171
/// The preloaded ad for the given preload ID, or null if no ad is available.
@@ -76,6 +76,18 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
7676
/// </remarks>
7777
IInterstitialClient DequeueAd(string preloadId);
7878

79+
/// <summary>
80+
/// Returns the ResponseInfo of an ad available for the given preload ID without
81+
/// dequeuing it, or null if no ad is available.
82+
/// </summary>
83+
/// <param name="preloadId">
84+
/// A string identifier used to preload the ads for that configuration.
85+
/// </param>
86+
/// <returns>
87+
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
88+
/// </returns>
89+
IResponseInfoClient PeekAdResponseInfo(string preloadId);
90+
7991
/// <summary>
8092
/// Get the number of ads available for the given preload ID.
8193
/// </summary>

source/plugin/Assets/GoogleMobileAds/Common/IRewardedAdPreloaderClient.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
6565
/// Returns a preloaded ad and removes it from the cache.
6666
/// </summary>
6767
/// <param name="preloadId">
68-
/// The ad's preload ID.
68+
/// A string identifier used to preload the ads for that configuration.
6969
/// </param>
7070
/// <returns>
7171
/// The preloaded ad for the given preload ID, or null if no ad is available.
@@ -76,6 +76,18 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
7676
/// </remarks>
7777
IRewardedAdClient DequeueAd(string preloadId);
7878

79+
/// <summary>
80+
/// Returns the ResponseInfo of an ad available for the given preload ID without
81+
/// dequeuing it, or null if no ad is available.
82+
/// </summary>
83+
/// <param name="preloadId">
84+
/// A string identifier used to preload the ads for that configuration.
85+
/// </param>
86+
/// <returns>
87+
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
88+
/// </returns>
89+
IResponseInfoClient PeekAdResponseInfo(string preloadId);
90+
7991
/// <summary>
8092
/// Get the number of ads available for the given preload ID.
8193
/// </summary>

source/plugin/Assets/GoogleMobileAds/Platforms/Android/AppOpenAdPreloaderClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ public IAppOpenAdClient DequeueAd(string preloadId)
7070
return appOpenAdClient;
7171
}
7272

73+
public IResponseInfoClient PeekAdResponseInfo(string preloadId)
74+
{
75+
UnityEngine.Debug.LogError(
76+
"PeekAdResponseInfo API is not available on the Legacy version of Google Mobile Ads Android SDK.");
77+
return null;
78+
}
79+
7380
public int GetNumAdsAvailable(string preloadId)
7481
{
7582
return _unityAppOpenAdPreloader.Call<int>("getNumAdsAvailable", preloadId);

source/plugin/Assets/GoogleMobileAds/Platforms/Android/InterstitialAdPreloaderClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ public IInterstitialClient DequeueAd(string preloadId)
7070
return interstitialClient;
7171
}
7272

73+
public IResponseInfoClient PeekAdResponseInfo(string preloadId)
74+
{
75+
UnityEngine.Debug.LogError(
76+
"PeekAdResponseInfo API is not available on the Legacy version of Google Mobile Ads Android SDK.");
77+
return null;
78+
}
79+
7380
public int GetNumAdsAvailable(string preloadId)
7481
{
7582
return _unityInterstitialPreloader.Call<int>("getNumAdsAvailable", preloadId);

source/plugin/Assets/GoogleMobileAds/Platforms/Android/NextGenAppOpenAdPreloaderClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public IAppOpenAdClient DequeueAd(string preloadId) {
6262
return appOpenAdClient;
6363
}
6464

65+
public IResponseInfoClient PeekAdResponseInfo(string preloadId) {
66+
// TODO: Implement Android Peek API
67+
return null;
68+
}
69+
6570
public int GetNumAdsAvailable(string preloadId) {
6671
return _unityAppOpenAdPreloader.Call<int>("getNumAdsAvailable", preloadId);
6772
}

source/plugin/Assets/GoogleMobileAds/Platforms/Android/NextGenInterstitialAdPreloaderClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public IInterstitialClient DequeueAd(string preloadId) {
6363
return interstitialAdClient;
6464
}
6565

66+
public IResponseInfoClient PeekAdResponseInfo(string preloadId) {
67+
// TODO: Implement Android Peek API
68+
return null;
69+
}
70+
6671
public int GetNumAdsAvailable(string preloadId) {
6772
return _unityInterstitialAdPreloader.Call<int>("getNumAdsAvailable", preloadId);
6873
}

0 commit comments

Comments
 (0)