From d81b0ebf1acefb3d2c1d82f6bb7b9aecf19e146a Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:00:05 -0400 Subject: [PATCH 1/2] impl --- packages/interactive_media_ads/CHANGELOG.md | 4 + .../AdsRequestProxyApi.kt | 2 +- .../BaseManagerProxyApi.kt | 37 ++++- .../InteractiveMediaAdsLibrary.g.kt | 153 +++++++++++++++++- .../BaseManagerProxyApiTest.kt | 64 +++++++- .../AdsRequestProxyAPIDelegate.swift | 2 +- .../lib/src/android/android_ads_manager.dart | 2 +- .../src/android/interactive_media_ads.g.dart | 144 ++++++++++++++++- .../interactive_media_ads_android.dart | 19 ++- packages/interactive_media_ads/pubspec.yaml | 2 +- 10 files changed, 414 insertions(+), 15 deletions(-) diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md index 7bfcc2e6e164..a28196a4f2df 100644 --- a/packages/interactive_media_ads/CHANGELOG.md +++ b/packages/interactive_media_ads/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.2+15 + +* Adds remaining methods for internal wrapper of the Android native `BaseManager`. + ## 0.2.2+13 * Adds internal wrapper for Android native `Ad`. diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index 469848956ca2..5d14b8a72db3 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : * * This must match the version in pubspec.yaml. */ - const val pluginVersion = "0.2.2+13" + const val pluginVersion = "0.2.2+15" } override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) { diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt index 92d7558fa7cc..a227cf916c02 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApi.kt @@ -4,8 +4,11 @@ package dev.flutter.packages.interactive_media_ads +import com.google.ads.interactivemedia.v3.api.Ad import com.google.ads.interactivemedia.v3.api.AdErrorEvent import com.google.ads.interactivemedia.v3.api.AdEvent +import com.google.ads.interactivemedia.v3.api.AdProgressInfo +import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings import com.google.ads.interactivemedia.v3.api.BaseManager /** @@ -34,7 +37,37 @@ class BaseManagerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : pigeon_instance.destroy() } - override fun init(pigeon_instance: BaseManager) { - pigeon_instance.init() + override fun init(pigeon_instance: BaseManager, settings: AdsRenderingSettings?) { + if (settings == null) { + pigeon_instance.init() + } else { + pigeon_instance.init(settings) + } + } + + override fun focus(pigeon_instance: BaseManager) { + pigeon_instance.focus() + } + + override fun getAdProgressInfo(pigeon_instance: BaseManager): AdProgressInfo? { + return pigeon_instance.adProgressInfo + } + + override fun getCurrentAd(pigeon_instance: BaseManager): Ad? { + return pigeon_instance.currentAd + } + + override fun removeAdErrorListener( + pigeon_instance: BaseManager, + errorListener: AdErrorEvent.AdErrorListener + ) { + pigeon_instance.removeAdErrorListener(errorListener) + } + + override fun removeAdEventListener( + pigeon_instance: BaseManager, + adEventListener: AdEvent.AdEventListener + ) { + pigeon_instance.removeAdEventListener(adEventListener) } } diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 5547ada0db20..b42ee9d2fd5b 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -1861,8 +1861,36 @@ abstract class PigeonApiBaseManager( /** Stops the ad and all tracking, then releases all assets that were loaded to play the ad. */ abstract fun destroy(pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager) - /** Initializes the ad experience using default rendering settings */ - abstract fun init(pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager) + /** Initializes the ad experience on the manager. */ + abstract fun init( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager, + settings: com.google.ads.interactivemedia.v3.api.AdsRenderingSettings? + ) + + /** Generic focus endpoint that puts focus on the skip button if present. */ + abstract fun focus(pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager) + + /** Returns the latest AdProgressInfo for the current playing ad. */ + abstract fun getAdProgressInfo( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager + ): com.google.ads.interactivemedia.v3.api.AdProgressInfo? + + /** Get currently playing ad. */ + abstract fun getCurrentAd( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager + ): com.google.ads.interactivemedia.v3.api.Ad? + + /** Removes a listener for error events. */ + abstract fun removeAdErrorListener( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager, + errorListener: com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + ) + + /** Removes a listener for ad events. */ + abstract fun removeAdEventListener( + pigeon_instance: com.google.ads.interactivemedia.v3.api.BaseManager, + adEventListener: com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener + ) companion object { @Suppress("LocalVariableName") @@ -1949,9 +1977,128 @@ abstract class PigeonApiBaseManager( channel.setMessageHandler { message, reply -> val args = message as List val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val settingsArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdsRenderingSettings? + val wrapped: List = + try { + api.init(pigeon_instanceArg, settingsArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.focus", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val wrapped: List = + try { + api.focus(pigeon_instanceArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.getAdProgressInfo", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val wrapped: List = + try { + listOf(api.getAdProgressInfo(pigeon_instanceArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.getCurrentAd", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val wrapped: List = + try { + listOf(api.getCurrentAd(pigeon_instanceArg)) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.removeAdErrorListener", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val errorListenerArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener + val wrapped: List = + try { + api.removeAdErrorListener(pigeon_instanceArg, errorListenerArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.BaseManager.removeAdEventListener", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.BaseManager + val adEventListenerArg = + args[1] as com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener val wrapped: List = try { - api.init(pigeon_instanceArg) + api.removeAdEventListener(pigeon_instanceArg, adEventListenerArg) listOf(null) } catch (exception: Throwable) { wrapError(exception) diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt index 0c9293d8d712..728bc38ba05e 100644 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/BaseManagerProxyApiTest.kt @@ -4,12 +4,17 @@ package dev.flutter.packages.interactive_media_ads +import com.google.ads.interactivemedia.v3.api.Ad import com.google.ads.interactivemedia.v3.api.AdErrorEvent import com.google.ads.interactivemedia.v3.api.AdEvent +import com.google.ads.interactivemedia.v3.api.AdProgressInfo +import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings import com.google.ads.interactivemedia.v3.api.BaseManager +import junit.framework.TestCase.assertEquals import kotlin.test.Test import org.mockito.kotlin.mock import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever class BaseManagerProxyApiTest { @Test @@ -49,8 +54,63 @@ class BaseManagerProxyApiTest { val api = TestProxyApiRegistrar().getPigeonApiBaseManager() val instance = mock() - api.init(instance) + val settings = mock() + api.init(instance, settings) - verify(instance).init() + verify(instance).init(settings) + } + + @Test + fun focus() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + api.focus(instance) + + verify(instance).focus() + } + + @Test + fun getAdProgressInfo() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + val value = mock() + whenever(instance.adProgressInfo).thenReturn(value) + + assertEquals(value, api.getAdProgressInfo(instance)) + } + + @Test + fun getCurrentAd() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + val value = mock() + whenever(instance.currentAd).thenReturn(value) + + assertEquals(value, api.getCurrentAd(instance)) + } + + @Test + fun removeAdErrorListener() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + val errorListener = mock() + api.removeAdErrorListener(instance, errorListener) + + verify(instance).removeAdErrorListener(errorListener) + } + + @Test + fun removeAdEventListener() { + val api = TestProxyApiRegistrar().getPigeonApiBaseManager() + + val instance = mock() + val adEventListener = mock() + api.removeAdEventListener(instance, adEventListener) + + verify(instance).removeAdEventListener(adEventListener) } } diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift index c451d574ab23..de4a711123da 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift @@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest { /// The current version of the `interactive_media_ads` plugin. /// /// This must match the version in pubspec.yaml. - static let pluginVersion = "0.2.2+13" + static let pluginVersion = "0.2.2+15" func pigeonDefaultConstructor( pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer, diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart b/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart index 4ec075838b97..fbba105e4e27 100644 --- a/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart +++ b/packages/interactive_media_ads/lib/src/android/android_ads_manager.dart @@ -33,7 +33,7 @@ class AndroidAdsManager extends PlatformAdsManager { @override Future init(AdsManagerInitParams params) { - return _manager.init(); + return _manager.init(null); } @override diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart index be8cd0fadb28..330cf444e2f6 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -1970,8 +1970,8 @@ class BaseManager extends PigeonInternalProxyApiBaseClass { } } - /// Initializes the ad experience using default rendering settings - Future init() async { + /// Initializes the ad experience on the manager. + Future init(AdsRenderingSettings? settings) async { final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecBaseManager; final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; @@ -1983,6 +1983,90 @@ class BaseManager extends PigeonInternalProxyApiBaseClass { pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([this, settings]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + /// Generic focus endpoint that puts focus on the skip button if present. + Future focus() async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.focus'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + /// Returns the latest AdProgressInfo for the current playing ad. + Future getAdProgressInfo() async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.getAdProgressInfo'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return (pigeonVar_replyList[0] as AdProgressInfo?); + } + } + + /// Get currently playing ad. + Future getCurrentAd() async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.getCurrentAd'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([this]) as List?; if (pigeonVar_replyList == null) { @@ -1993,6 +2077,62 @@ class BaseManager extends PigeonInternalProxyApiBaseClass { message: pigeonVar_replyList[1] as String?, details: pigeonVar_replyList[2], ); + } else { + return (pigeonVar_replyList[0] as Ad?); + } + } + + /// Removes a listener for error events. + Future removeAdErrorListener(AdErrorListener errorListener) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.removeAdErrorListener'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([this, errorListener]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + /// Removes a listener for ad events. + Future removeAdEventListener(AdEventListener adEventListener) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.BaseManager.removeAdEventListener'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([this, adEventListener]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); } else { return; } diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 0d3aa77b5342..24318a2c6fc1 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -403,8 +403,23 @@ abstract class BaseManager { /// to play the ad. void destroy(); - /// Initializes the ad experience using default rendering settings - void init(); + /// Initializes the ad experience on the manager. + void init(AdsRenderingSettings? settings); + + /// Generic focus endpoint that puts focus on the skip button if present. + void focus(); + + /// Returns the latest AdProgressInfo for the current playing ad. + AdProgressInfo? getAdProgressInfo(); + + /// Get currently playing ad. + Ad? getCurrentAd(); + + /// Removes a listener for error events. + void removeAdErrorListener(AdErrorListener errorListener); + + /// Removes a listener for ad events. + void removeAdEventListener(AdEventListener adEventListener); } /// Event to notify publisher that an event occurred with an Ad. diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index d3101f0322d7..88e8c6fc8489 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -2,7 +2,7 @@ name: interactive_media_ads description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS. repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22 -version: 0.2.2+13 # This must match the version in +version: 0.2.2+15 # This must match the version in # `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and # `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift` From 685246c1441c5cc31ebbf3fa958699a91fe2c8fe Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:03:40 -0400 Subject: [PATCH 2/2] fix tests --- .../test/android/ads_loader_test.mocks.dart | 56 ++++++++++++++++++- .../test/android/ads_manager_test.dart | 2 +- .../test/android/ads_manager_test.mocks.dart | 56 ++++++++++++++++++- 3 files changed, 111 insertions(+), 3 deletions(-) diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart index 9956d7eabf50..fc6fe08a4000 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart @@ -654,11 +654,65 @@ class MockAdsManager extends _i1.Mock implements _i2.AdsManager { ) as _i6.Future); @override - _i6.Future init() => (super.noSuchMethod( + _i6.Future init(_i2.AdsRenderingSettings? settings) => + (super.noSuchMethod( Invocation.method( #init, + [settings], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future focus() => (super.noSuchMethod( + Invocation.method( + #focus, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future<_i2.AdProgressInfo?> getAdProgressInfo() => (super.noSuchMethod( + Invocation.method( + #getAdProgressInfo, + [], + ), + returnValue: _i6.Future<_i2.AdProgressInfo?>.value(), + returnValueForMissingStub: _i6.Future<_i2.AdProgressInfo?>.value(), + ) as _i6.Future<_i2.AdProgressInfo?>); + + @override + _i6.Future<_i2.Ad?> getCurrentAd() => (super.noSuchMethod( + Invocation.method( + #getCurrentAd, [], ), + returnValue: _i6.Future<_i2.Ad?>.value(), + returnValueForMissingStub: _i6.Future<_i2.Ad?>.value(), + ) as _i6.Future<_i2.Ad?>); + + @override + _i6.Future removeAdErrorListener(_i2.AdErrorListener? errorListener) => + (super.noSuchMethod( + Invocation.method( + #removeAdErrorListener, + [errorListener], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + + @override + _i6.Future removeAdEventListener( + _i2.AdEventListener? adEventListener) => + (super.noSuchMethod( + Invocation.method( + #removeAdEventListener, + [adEventListener], + ), returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); diff --git a/packages/interactive_media_ads/test/android/ads_manager_test.dart b/packages/interactive_media_ads/test/android/ads_manager_test.dart index bfcbaeec676c..0b94d6a7d753 100644 --- a/packages/interactive_media_ads/test/android/ads_manager_test.dart +++ b/packages/interactive_media_ads/test/android/ads_manager_test.dart @@ -37,7 +37,7 @@ void main() { final AndroidAdsManager adsManager = AndroidAdsManager(mockAdsManager); adsManager.init(AdsManagerInitParams()); - verify(mockAdsManager.init()); + verify(mockAdsManager.init(null)); }); test('start', () { diff --git a/packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart b/packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart index bb4dc3235f0e..6006ba48f18a 100644 --- a/packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart +++ b/packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart @@ -520,11 +520,65 @@ class MockAdsManager extends _i1.Mock implements _i2.AdsManager { ) as _i4.Future); @override - _i4.Future init() => (super.noSuchMethod( + _i4.Future init(_i2.AdsRenderingSettings? settings) => + (super.noSuchMethod( Invocation.method( #init, + [settings], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future focus() => (super.noSuchMethod( + Invocation.method( + #focus, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future<_i2.AdProgressInfo?> getAdProgressInfo() => (super.noSuchMethod( + Invocation.method( + #getAdProgressInfo, + [], + ), + returnValue: _i4.Future<_i2.AdProgressInfo?>.value(), + returnValueForMissingStub: _i4.Future<_i2.AdProgressInfo?>.value(), + ) as _i4.Future<_i2.AdProgressInfo?>); + + @override + _i4.Future<_i2.Ad?> getCurrentAd() => (super.noSuchMethod( + Invocation.method( + #getCurrentAd, [], ), + returnValue: _i4.Future<_i2.Ad?>.value(), + returnValueForMissingStub: _i4.Future<_i2.Ad?>.value(), + ) as _i4.Future<_i2.Ad?>); + + @override + _i4.Future removeAdErrorListener(_i2.AdErrorListener? errorListener) => + (super.noSuchMethod( + Invocation.method( + #removeAdErrorListener, + [errorListener], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future removeAdEventListener( + _i2.AdEventListener? adEventListener) => + (super.noSuchMethod( + Invocation.method( + #removeAdEventListener, + [adEventListener], + ), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future);