Mztj67_#M}W?l>kYSliK<%xAp;0j{!}J0!o7b
zE>q9${Lb$D&h7k=+4=!ek^n+`0zq>LL1O?lVyea53S5x`Nqqo2YyeuIrQrJj9XjOp
z{;T5qbj3}&1vg1VK~#9!?b~^C5-}JC@Pyrv-6dSEqJqT}#j9#dJ@GzT@B8}x
zU&J@bBI>f6w6en+CeI)3^kC*U?}X%OD8$Fd$H&LV$H&LV$H&LV#|K5~mLYf|VqzOc
zkc7qL~0sOYuM{tG`rYEDV{DWY`Z8&)kW*hc2VkBuY+^Yx&92j&StN}Wp=LD
zxoGxXw6f&8sB^u})h@b@z0RBeD`K7RMR9deyL(ZJu#39Z>rT)^>v}Khq8U-IbIvT>
z?4pV9qGj=2)TNH3d)=De<+^w;>S7m_eFKTvzeaBeir45xY!^m!FmxnljbSS_3o=g(
z->^wC9%qkR{kbGnW8MfFew_o9h3(r55Is`L$8KI@d+*%{=Nx+FXJ98L0PjFIu;rGnnfY
zn1R5Qnp<{Jq0M1vX=X&F8gtLmcWv$1*M@4ZfF^9``()#hGTeKeP`1!iED
ztNE(TN}M5}3Bbc*d=FIv`DNv&@|C6yYj{sSqUj5oo$#*0$7pu|Dd2TLI>t5%I
zIa4Dvr(iayb+5x=j*Vum9&irk)xV1`t509lnPO0%skL8_1c#Xbamh(2@f?4yUI
zhhuT5<#8RJhGz4%b$`PJwKPAudsm|at?u;*hGgnA
zU1;9gnxVBC)wA(BsB`AW54N{|qmikJR*%x0c`{LGsSfa|NK61pYH(r-UQ4_JXd!Rsz)=k
zL{GMc5{h138)fF5CzHEDM>+FqY)$pdN3}Ml+riTgJOLN0F*Vh?{9ESR{SVVg>*>=#
zix;VJHPtvFFCRY$Ks*F;VX~%*r9F)W`PmPE9F!(&s#x07n2<}?S{(ygpXgX-&B&OM
zONY&BRQ(#%0%jeQs?oJ4P!p*R98>qCy5p8w>_gpuh39NcOlp)(wOoz0sY-Qz55eB~
z7OC-fKBaD1sE3$l-6QgBJO!n?QOTza`!S_YK
z_v-lm^7{VO^8Q@M_^8F)09Ki6%=s?2_5eupee(w1FB%aqSweusQ-T+CH0Xt{`
zFjMvW{@C&TB)k25()nh~_yJ9coBRL(0oO@HK~z}7?bm5j;y@69;bvlHb2tf!$ReA~x{22wTq550
z?f?Hnw(;m3ip30;QzdV~7pi!wyMYhDtXW#cO7T>|f=bdFhu+F!zMZ2UFj;GUKX7tI
z;hv3{q~!*pMj75WP_c}>6)IWvg5_yyg<9Op()eD1hWC19M@?_9_MHec{Z8n3FaF{8
z;u`Mw0ly(uE>*CgQYv{be6ab2LWhlaH1^iLIM{olnag$78^Fd}%dR7;JECQ+hmk|o
z!u2&!3MqPfP5ChDSkFSH8F2WVOEf0(E_M(JL17G}Y+fg0_IuW%WQ
zG(mG&u?|->YSdk0;8rc{yw2@2Z&GA}z{Wb91Ooz9VhA{b2DYE7RmG
zjL}?eq#iX%3#k;JWMx_{^2nNax`xPhByFiDX+a7uTGU|otOvIAUy|dEKkXOm-`aWS
z27pUzD{a)Ct<6p{{3)+lq@i`t@%>-wT4r?*S}k)58e09WZYP0{{R3FC5Sl00039P)t-s|Ns9~
z#rP?<_5oL$Q^olD{r_0T`27C={r>*`|Nj71npVa5OTzc(_WfbW_({R{p56NV{r*M2
z_xt?)2V0#0NsfV0u>{42ctGP(8vQj-Btk1n|O0ZD=YLwd&R{Ko41Gr9H=
zY@z@@bOAMB5Ltl$E>bJJ{>JP30ZxkmI%?eW{k`b?Wy<&gOo;dS`~CR$Vwb@XWtR|N
zi~t=w02?-0&j0TD{>bb6sNwsK*!p?V`RMQUl(*DVjk-9Cx+-z1KXab|Ka2oXhX5f%
z`$|e!000AhNklrxs)5QTeTVRiEmz~MKK1WAjCw(c-JK6eox;2O)?`?
zTG`AHia671e^vgmp!llKp|=5sVHk#C7=~epA~VAf-~%aPC=%Qw01h8mnSZ|p?hz91
z7p83F3%LVu9;S$tSI$C^%^yud1dfTM_6p2|+5Ejp$bd`GDvbR|xit>i!ZD&F>@CJrPmu*UjD&?DfZs=$@e3FQA(vNiU+$A*%a}
z?`XcG2jDxJ_ZQ#Md`H{4Lpf6QBDp81_KWZ6Tk#yCy1)32zO#3<7>b`eT7UyYH1eGz
z;O(rH$=QR*L%%ZcBpc=eGua?N55nD^K(8<#gl2+pN_j~b2MHs4#mcLmv%DkspS-3<
zpI1F=^9siI0s-;IN_IrA;5xm~3?3!StX}pUv0vkxMaqm+zxrg7X7(I&*N~&dEd0kD
z-FRV|g=|QuUsuh>-xCI}vD2imzYIOIdcCVV=$Bz@*u0+Bs<|L^)32nN*=wu3n%Ynw
z@1|eLG>!8ruU1pFXUfb`j>(=Gy~?Rn4QJ-c3%3T|(Frd!bI`9u&zAnyFYTqlG#&J7
zAkD(jpw|oZLNiA>;>hgp1KX7-wxC~31II47gc
zHcehD6Uxlf%+M^^uN5Wc*G%^;>D5qT{>=uxUhX%WJu^Z*(_Wq9y}npFO{Hhb>s6<9
zNi0pHXWFaVZnb)1+RS&F)xOv6&aeILcI)`k#0YE+?e)5r7J#c`3Z7x!LpTc01dx
zrdC3{Z;joZ^KN&))zB_i)I9fWedoN>Zl-6_Iz+^G&*ak2jpF07*qoM6N<$f;w%0(f|Me
literal 0
HcmV?d00001
diff --git a/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
new file mode 100644
index 0000000000000000000000000000000000000000..0467bf12aa4d28f374bb26596605a46dcbb3e7c8
GIT binary patch
literal 1418
zcmV;51$Fv~P)q
zKfU)WzW*n(@|xWGCA9ScMt*e9`2kdxPQ&&>|-UCa7_51w+
zLUsW@ZzZSW0y$)Hp~e9%PvP|a03ks1`~K?q{u;6NC8*{AOqIUq{CL&;p56Lf$oQGq
z^={4hPQv)y=I|4n+?>7Fim=dxt1
z2H+Dm+1+fh+IF>G0SjJMkQQre1x4|G*Z==(Ot&kCnUrL4I(rf(ucITwmuHf^hXiJT
zkdTm&kdTm&kdTm&kdP`esgWG0BcWCVkVZ&2dUwN`cgM8QJb`Z7Z~e<&Yj2(}>Tmf`
zm1{eLgw!b{bXkjWbF%dTkTZEJWyWOb##Lfw4EK2}<0d6%>AGS{po>WCOy&f$Tay_>
z?NBlkpo@s-O;0V%Y_Xa-G#_O08q5LR*~F%&)}{}r&L%Sbs8AS4t7Y0NEx*{soY=0MZExqA5XHQkqi#4gW3
zqODM^iyZl;dvf)-bOXtOru(s)Uc7~BFx{w-FK;2{`VA?(g&@3z&bfLFyctOH!cVsF
z7IL=fo-qBndRUm;kAdXR4e6>k-z|21AaN%ubeVrHl*<|s&Ax@W-t?LR(P-24A5=>a
z*R9#QvjzF8n%@1Nw@?CG@6(%>+-0ASK~jEmCV|&a*7-GKT72W<(TbSjf)&Eme6nGE
z>Gkj4Sq&2e+-G%|+NM8OOm5zVl9{Z8Dd8A5z3y8mZ=4Bv4%>as_{9cN#bm~;h>62(
zdqY93Zy}v&c4n($Vv!UybR8ocs7#zbfX1IY-*w~)p}XyZ-SFC~4w>BvMVr`dFbelV{lLL0bx7@*ZZdebr3`sP;?
zVImji)kG)(6Juv0lz@q`F!k1FE;CQ(D0iG$wchPbKZQELlsZ#~rt8#90Y_Xh&3U-<
z{s<&cCV_1`^TD^ia9!*mQDq&
zn2{r`j};V|uV%_wsP!zB?m%;FeaRe+X47K0e+KE!8C{gAWF8)lCd1u1%~|M!XNRvw
zvtqy3iz0WSpWdhn6$hP8PaRBmp)q`#PCA`Vd#Tc$@f1tAcM>f_I@bC)hkI9|o(Iqv
zo}Piadq!j76}004RBio<`)70k^`K1NK)q>w?p^C6J2ZC!+UppiK6&y3Kmbv&O!oYF
z34$0Z;QO!JOY#!`qyGH<3Pd}Pt@q*A0V=3SVtWKRR8d8Z&@)3qLPA19LPA19LPEUC
YUoZo%k(ykuW&i*H07*qoM6N<$f+CH{y8r+H
literal 0
HcmV?d00001
diff --git a/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
new file mode 100644
index 000000000000..0bedcf2fd467
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
@@ -0,0 +1,23 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchImage.png",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchImage@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "filename" : "LaunchImage@3x.png",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
diff --git a/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
new file mode 100644
index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838
GIT binary patch
literal 68
zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J
Q1PU{Fy85}Sb4q9e0B4a5jsO4v
literal 0
HcmV?d00001
diff --git a/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
new file mode 100644
index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838
GIT binary patch
literal 68
zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J
Q1PU{Fy85}Sb4q9e0B4a5jsO4v
literal 0
HcmV?d00001
diff --git a/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
new file mode 100644
index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838
GIT binary patch
literal 68
zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J
Q1PU{Fy85}Sb4q9e0B4a5jsO4v
literal 0
HcmV?d00001
diff --git a/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
new file mode 100644
index 000000000000..89c2725b70f1
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
@@ -0,0 +1,5 @@
+# Launch Screen Assets
+
+You can customize the launch screen with your own desired assets by replacing the image files in this directory.
+
+You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
\ No newline at end of file
diff --git a/packages/interactive_media_ads/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/interactive_media_ads/example/ios/Runner/Base.lproj/LaunchScreen.storyboard
new file mode 100644
index 000000000000..f2e259c7c939
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Runner/Base.lproj/LaunchScreen.storyboard
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/interactive_media_ads/example/ios/Runner/Base.lproj/Main.storyboard b/packages/interactive_media_ads/example/ios/Runner/Base.lproj/Main.storyboard
new file mode 100644
index 000000000000..f3c28516fb38
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Runner/Base.lproj/Main.storyboard
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/interactive_media_ads/example/ios/Runner/Info.plist b/packages/interactive_media_ads/example/ios/Runner/Info.plist
new file mode 100644
index 000000000000..5394f403367c
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Runner/Info.plist
@@ -0,0 +1,49 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleDisplayName
+ Interactive Media Ads
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ interactive_media_ads_example
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ $(FLUTTER_BUILD_NAME)
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ $(FLUTTER_BUILD_NUMBER)
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIMainStoryboardFile
+ Main
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ CADisableMinimumFrameDurationOnPhone
+
+ UIApplicationSupportsIndirectInputEvents
+
+
+
diff --git a/packages/interactive_media_ads/example/ios/Runner/Runner-Bridging-Header.h b/packages/interactive_media_ads/example/ios/Runner/Runner-Bridging-Header.h
new file mode 100644
index 000000000000..308a2a560b42
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Runner/Runner-Bridging-Header.h
@@ -0,0 +1 @@
+#import "GeneratedPluginRegistrant.h"
diff --git a/packages/interactive_media_ads/example/ios/RunnerTests/RunnerTests.swift b/packages/interactive_media_ads/example/ios/RunnerTests/RunnerTests.swift
new file mode 100644
index 000000000000..93e9c95da0fb
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/RunnerTests/RunnerTests.swift
@@ -0,0 +1,26 @@
+import Flutter
+import UIKit
+import XCTest
+
+@testable import interactive_media_ads
+
+// This demonstrates a simple unit test of the Swift portion of this plugin's implementation.
+//
+// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
+
+class RunnerTests: XCTestCase {
+
+ func testGetPlatformVersion() {
+ let plugin = InteractiveMediaAdsPlugin()
+
+ let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: [])
+
+ let resultExpectation = expectation(description: "result block must be called.")
+ plugin.handle(call) { result in
+ XCTAssertEqual(result as! String, "iOS " + UIDevice.current.systemVersion)
+ resultExpectation.fulfill()
+ }
+ waitForExpectations(timeout: 1)
+ }
+
+}
diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart
new file mode 100644
index 000000000000..4fe2dc921df5
--- /dev/null
+++ b/packages/interactive_media_ads/example/lib/main.dart
@@ -0,0 +1,63 @@
+import 'package:flutter/material.dart';
+import 'dart:async';
+
+import 'package:flutter/services.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+
+void main() {
+ runApp(const MyApp());
+}
+
+class MyApp extends StatefulWidget {
+ const MyApp({super.key});
+
+ @override
+ State createState() => _MyAppState();
+}
+
+class _MyAppState extends State {
+ String _platformVersion = 'Unknown';
+ final _interactiveMediaAdsPlugin = InteractiveMediaAds();
+
+ @override
+ void initState() {
+ super.initState();
+ initPlatformState();
+ }
+
+ // Platform messages are asynchronous, so we initialize in an async method.
+ Future initPlatformState() async {
+ String platformVersion;
+ // Platform messages may fail, so we use a try/catch PlatformException.
+ // We also handle the message potentially returning null.
+ try {
+ platformVersion =
+ await _interactiveMediaAdsPlugin.getPlatformVersion() ?? 'Unknown platform version';
+ } on PlatformException {
+ platformVersion = 'Failed to get platform version.';
+ }
+
+ // If the widget was removed from the tree while the asynchronous platform
+ // message was in flight, we want to discard the reply rather than calling
+ // setState to update our non-existent appearance.
+ if (!mounted) return;
+
+ setState(() {
+ _platformVersion = platformVersion;
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return MaterialApp(
+ home: Scaffold(
+ appBar: AppBar(
+ title: const Text('Plugin example app'),
+ ),
+ body: Center(
+ child: Text('Running on: $_platformVersion\n'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/packages/interactive_media_ads/example/pubspec.yaml b/packages/interactive_media_ads/example/pubspec.yaml
new file mode 100644
index 000000000000..d67bf3d19c60
--- /dev/null
+++ b/packages/interactive_media_ads/example/pubspec.yaml
@@ -0,0 +1,85 @@
+name: interactive_media_ads_example
+description: "Demonstrates how to use the interactive_media_ads plugin."
+# The following line prevents the package from being accidentally published to
+# pub.dev using `flutter pub publish`. This is preferred for private packages.
+publish_to: 'none' # Remove this line if you wish to publish to pub.dev
+
+environment:
+ sdk: '>=3.4.0-82.0.dev <4.0.0'
+
+# Dependencies specify other packages that your package needs in order to work.
+# To automatically upgrade your package dependencies to the latest versions
+# consider running `flutter pub upgrade --major-versions`. Alternatively,
+# dependencies can be manually updated by changing the version numbers below to
+# the latest version available on pub.dev. To see which dependencies have newer
+# versions available, run `flutter pub outdated`.
+dependencies:
+ flutter:
+ sdk: flutter
+
+ interactive_media_ads:
+ # When depending on this package from a real application you should use:
+ # interactive_media_ads: ^x.y.z
+ # See https://dart.dev/tools/pub/dependencies#version-constraints
+ # The example app is bundled with the plugin so we use a path dependency on
+ # the parent directory to use the current plugin's version.
+ path: ../
+
+ # The following adds the Cupertino Icons font to your application.
+ # Use with the CupertinoIcons class for iOS style icons.
+ cupertino_icons: ^1.0.6
+
+dev_dependencies:
+ integration_test:
+ sdk: flutter
+ flutter_test:
+ sdk: flutter
+
+ # The "flutter_lints" package below contains a set of recommended lints to
+ # encourage good coding practices. The lint set provided by the package is
+ # activated in the `analysis_options.yaml` file located at the root of your
+ # package. See that file for information about deactivating specific lint
+ # rules and activating additional ones.
+ flutter_lints: ^3.0.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter packages.
+flutter:
+
+ # The following line ensures that the Material Icons font is
+ # included with your application, so that you can use the icons in
+ # the material Icons class.
+ uses-material-design: true
+
+ # To add assets to your application, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.dev/assets-and-images/#resolution-aware
+
+ # For details regarding adding assets from package dependencies, see
+ # https://flutter.dev/assets-and-images/#from-packages
+
+ # To add custom fonts to your application, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts from package dependencies,
+ # see https://flutter.dev/custom-fonts/#from-packages
diff --git a/packages/interactive_media_ads/example/test/widget_test.dart b/packages/interactive_media_ads/example/test/widget_test.dart
new file mode 100644
index 000000000000..bc01bb34eef3
--- /dev/null
+++ b/packages/interactive_media_ads/example/test/widget_test.dart
@@ -0,0 +1,27 @@
+// This is a basic Flutter widget test.
+//
+// To perform an interaction with a widget in your test, use the WidgetTester
+// utility in the flutter_test package. For example, you can send tap and scroll
+// gestures. You can also use WidgetTester to find child widgets in the widget
+// tree, read text, and verify that the values of widget properties are correct.
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:interactive_media_ads_example/main.dart';
+
+void main() {
+ testWidgets('Verify Platform version', (WidgetTester tester) async {
+ // Build our app and trigger a frame.
+ await tester.pumpWidget(const MyApp());
+
+ // Verify that platform version is retrieved.
+ expect(
+ find.byWidgetPredicate(
+ (Widget widget) => widget is Text &&
+ widget.data!.startsWith('Running on:'),
+ ),
+ findsOneWidget,
+ );
+ });
+}
diff --git a/packages/interactive_media_ads/ios/.gitignore b/packages/interactive_media_ads/ios/.gitignore
new file mode 100644
index 000000000000..034771fc9c9b
--- /dev/null
+++ b/packages/interactive_media_ads/ios/.gitignore
@@ -0,0 +1,38 @@
+.idea/
+.vagrant/
+.sconsign.dblite
+.svn/
+
+.DS_Store
+*.swp
+profile
+
+DerivedData/
+build/
+GeneratedPluginRegistrant.h
+GeneratedPluginRegistrant.m
+
+.generated/
+
+*.pbxuser
+*.mode1v3
+*.mode2v3
+*.perspectivev3
+
+!default.pbxuser
+!default.mode1v3
+!default.mode2v3
+!default.perspectivev3
+
+xcuserdata
+
+*.moved-aside
+
+*.pyc
+*sync/
+Icon?
+.tags*
+
+/Flutter/Generated.xcconfig
+/Flutter/ephemeral/
+/Flutter/flutter_export_environment.sh
diff --git a/packages/interactive_media_ads/ios/Assets/.gitkeep b/packages/interactive_media_ads/ios/Assets/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift b/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift
new file mode 100644
index 000000000000..d5483676b55e
--- /dev/null
+++ b/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift
@@ -0,0 +1,19 @@
+import Flutter
+import UIKit
+
+public class InteractiveMediaAdsPlugin: NSObject, FlutterPlugin {
+ public static func register(with registrar: FlutterPluginRegistrar) {
+ let channel = FlutterMethodChannel(name: "interactive_media_ads", binaryMessenger: registrar.messenger())
+ let instance = InteractiveMediaAdsPlugin()
+ registrar.addMethodCallDelegate(instance, channel: channel)
+ }
+
+ public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
+ switch call.method {
+ case "getPlatformVersion":
+ result("iOS " + UIDevice.current.systemVersion)
+ default:
+ result(FlutterMethodNotImplemented)
+ }
+ }
+}
diff --git a/packages/interactive_media_ads/ios/interactive_media_ads.podspec b/packages/interactive_media_ads/ios/interactive_media_ads.podspec
new file mode 100644
index 000000000000..d26fb346fa7f
--- /dev/null
+++ b/packages/interactive_media_ads/ios/interactive_media_ads.podspec
@@ -0,0 +1,23 @@
+#
+# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
+# Run `pod lib lint interactive_media_ads.podspec` to validate before publishing.
+#
+Pod::Spec.new do |s|
+ s.name = 'interactive_media_ads'
+ s.version = '0.0.1'
+ s.summary = 'A new Flutter plugin project.'
+ s.description = <<-DESC
+A new Flutter plugin project.
+ DESC
+ s.homepage = 'http://example.com'
+ s.license = { :file => '../LICENSE' }
+ s.author = { 'Your Company' => 'email@example.com' }
+ s.source = { :path => '.' }
+ s.source_files = 'Classes/**/*'
+ s.dependency 'Flutter'
+ s.platform = :ios, '11.0'
+
+ # Flutter.framework does not contain a i386 slice.
+ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
+ s.swift_version = '5.0'
+end
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart
new file mode 100644
index 000000000000..11b021f90d1f
--- /dev/null
+++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart
@@ -0,0 +1,8 @@
+
+import 'interactive_media_ads_platform_interface.dart';
+
+class InteractiveMediaAds {
+ Future getPlatformVersion() {
+ return InteractiveMediaAdsPlatform.instance.getPlatformVersion();
+ }
+}
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
new file mode 100644
index 000000000000..f7c2e245020e
--- /dev/null
+++ b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
@@ -0,0 +1,17 @@
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
+
+import 'interactive_media_ads_platform_interface.dart';
+
+/// An implementation of [InteractiveMediaAdsPlatform] that uses method channels.
+class MethodChannelInteractiveMediaAds extends InteractiveMediaAdsPlatform {
+ /// The method channel used to interact with the native platform.
+ @visibleForTesting
+ final methodChannel = const MethodChannel('interactive_media_ads');
+
+ @override
+ Future getPlatformVersion() async {
+ final version = await methodChannel.invokeMethod('getPlatformVersion');
+ return version;
+ }
+}
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
new file mode 100644
index 000000000000..862962d72750
--- /dev/null
+++ b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
@@ -0,0 +1,29 @@
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'interactive_media_ads_method_channel.dart';
+
+abstract class InteractiveMediaAdsPlatform extends PlatformInterface {
+ /// Constructs a InteractiveMediaAdsPlatform.
+ InteractiveMediaAdsPlatform() : super(token: _token);
+
+ static final Object _token = Object();
+
+ static InteractiveMediaAdsPlatform _instance = MethodChannelInteractiveMediaAds();
+
+ /// The default instance of [InteractiveMediaAdsPlatform] to use.
+ ///
+ /// Defaults to [MethodChannelInteractiveMediaAds].
+ static InteractiveMediaAdsPlatform get instance => _instance;
+
+ /// Platform-specific implementations should set this with their own
+ /// platform-specific class that extends [InteractiveMediaAdsPlatform] when
+ /// they register themselves.
+ static set instance(InteractiveMediaAdsPlatform instance) {
+ PlatformInterface.verifyToken(instance, _token);
+ _instance = instance;
+ }
+
+ Future getPlatformVersion() {
+ throw UnimplementedError('platformVersion() has not been implemented.');
+ }
+}
diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml
new file mode 100644
index 000000000000..4c0a81bc4d22
--- /dev/null
+++ b/packages/interactive_media_ads/pubspec.yaml
@@ -0,0 +1,72 @@
+name: interactive_media_ads
+description: "A new Flutter plugin project."
+version: 0.0.1
+homepage:
+
+environment:
+ sdk: '>=3.4.0-82.0.dev <4.0.0'
+ flutter: '>=3.3.0'
+
+dependencies:
+ flutter:
+ sdk: flutter
+ plugin_platform_interface: ^2.0.2
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
+ flutter_lints: ^3.0.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter packages.
+flutter:
+ # This section identifies this Flutter project as a plugin project.
+ # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
+ # which should be registered in the plugin registry. This is required for
+ # using method channels.
+ # The Android 'package' specifies package in which the registered class is.
+ # This is required for using method channels on Android.
+ # The 'ffiPlugin' specifies that native code should be built and bundled.
+ # This is required for using `dart:ffi`.
+ # All these are used by the tooling to maintain consistency when
+ # adding or updating assets for this project.
+ plugin:
+ platforms:
+ android:
+ package: dev.flutter.plugins.interactive_media_ads
+ pluginClass: InteractiveMediaAdsPlugin
+ ios:
+ pluginClass: InteractiveMediaAdsPlugin
+
+ # To add assets to your plugin package, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+ #
+ # For details regarding assets in packages, see
+ # https://flutter.dev/assets-and-images/#from-packages
+ #
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.dev/assets-and-images/#resolution-aware
+
+ # To add custom fonts to your plugin package, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts in packages, see
+ # https://flutter.dev/custom-fonts/#from-packages
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
new file mode 100644
index 000000000000..08eb507a037f
--- /dev/null
+++ b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
@@ -0,0 +1,27 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ MethodChannelInteractiveMediaAds platform = MethodChannelInteractiveMediaAds();
+ const MethodChannel channel = MethodChannel('interactive_media_ads');
+
+ setUp(() {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ (MethodCall methodCall) async {
+ return '42';
+ },
+ );
+ });
+
+ tearDown(() {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null);
+ });
+
+ test('getPlatformVersion', () async {
+ expect(await platform.getPlatformVersion(), '42');
+ });
+}
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
new file mode 100644
index 000000000000..03edb259a2fa
--- /dev/null
+++ b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
@@ -0,0 +1,29 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+import 'package:interactive_media_ads/interactive_media_ads_platform_interface.dart';
+import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+class MockInteractiveMediaAdsPlatform
+ with MockPlatformInterfaceMixin
+ implements InteractiveMediaAdsPlatform {
+
+ @override
+ Future getPlatformVersion() => Future.value('42');
+}
+
+void main() {
+ final InteractiveMediaAdsPlatform initialPlatform = InteractiveMediaAdsPlatform.instance;
+
+ test('$MethodChannelInteractiveMediaAds is the default instance', () {
+ expect(initialPlatform, isInstanceOf());
+ });
+
+ test('getPlatformVersion', () async {
+ InteractiveMediaAds interactiveMediaAdsPlugin = InteractiveMediaAds();
+ MockInteractiveMediaAdsPlatform fakePlatform = MockInteractiveMediaAdsPlatform();
+ InteractiveMediaAdsPlatform.instance = fakePlatform;
+
+ expect(await interactiveMediaAdsPlugin.getPlatformVersion(), '42');
+ });
+}
From 6847016e62dabc6fb8ad409eac28ee88a2b3ac7c Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 15:11:53 -0500
Subject: [PATCH 02/76] add repo required stuff
---
.github/dependabot.yml | 28 ++++++++++++++++++
packages/interactive_media_ads/.gitignore | 29 -------------------
packages/interactive_media_ads/AUTHORS | 6 ++++
packages/interactive_media_ads/CHANGELOG.md | 2 +-
packages/interactive_media_ads/LICENSE | 26 ++++++++++++++++-
packages/interactive_media_ads/README.md | 15 ++--------
.../android/build.gradle | 14 +++++++--
.../interactive_media_ads/example/README.md | 21 +++++---------
8 files changed, 82 insertions(+), 59 deletions(-)
delete mode 100644 packages/interactive_media_ads/.gitignore
create mode 100644 packages/interactive_media_ads/AUTHORS
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index d9157022847f..d1f55572e699 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -395,6 +395,34 @@ updates:
- dependency-name: "*"
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
+ - package-ecosystem: "gradle"
+ directory: "/packages/interactive_media_ads/android"
+ commit-message:
+ prefix: "[interactive_media_ads]"
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 10
+ ignore:
+ - dependency-name: "com.android.tools.build:gradle"
+ update-types: ["version-update:semver-minor", "version-update:semver-patch"]
+ - dependency-name: "junit:junit"
+ update-types: ["version-update:semver-minor", "version-update:semver-patch"]
+ - dependency-name: "org.mockito:*"
+ update-types: ["version-update:semver-minor", "version-update:semver-patch"]
+ - dependency-name: "androidx.test:*"
+ update-types: ["version-update:semver-minor", "version-update:semver-patch"]
+
+ - package-ecosystem: "gradle"
+ directory: "/packages/interactive_media_ads/example/android/app"
+ commit-message:
+ prefix: "[interactive_media_ads]"
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 10
+ ignore:
+ - dependency-name: "*"
+ update-types: ["version-update:semver-minor", "version-update:semver-patch"]
+
- package-ecosystem: "gradle"
directory: "/packages/image_picker/image_picker/example/android/app"
commit-message:
diff --git a/packages/interactive_media_ads/.gitignore b/packages/interactive_media_ads/.gitignore
deleted file mode 100644
index ac5aa9893e48..000000000000
--- a/packages/interactive_media_ads/.gitignore
+++ /dev/null
@@ -1,29 +0,0 @@
-# Miscellaneous
-*.class
-*.log
-*.pyc
-*.swp
-.DS_Store
-.atom/
-.buildlog/
-.history
-.svn/
-migrate_working_dir/
-
-# IntelliJ related
-*.iml
-*.ipr
-*.iws
-.idea/
-
-# The .vscode folder contains launch configuration and tasks you configure in
-# VS Code which you may wish to be included in version control, so this line
-# is commented out by default.
-#.vscode/
-
-# Flutter/Dart/Pub related
-# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
-/pubspec.lock
-**/doc/api/
-.dart_tool/
-build/
diff --git a/packages/interactive_media_ads/AUTHORS b/packages/interactive_media_ads/AUTHORS
new file mode 100644
index 000000000000..8c0344813dc1
--- /dev/null
+++ b/packages/interactive_media_ads/AUTHORS
@@ -0,0 +1,6 @@
+# Below is a list of people and organizations that have contributed
+# to the Flutter project. Names should be added to the list like so:
+#
+# Name/Organization
+
+Google Inc.
\ No newline at end of file
diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md
index 41cc7d8192ec..e9d7ac42c73d 100644
--- a/packages/interactive_media_ads/CHANGELOG.md
+++ b/packages/interactive_media_ads/CHANGELOG.md
@@ -1,3 +1,3 @@
## 0.0.1
-* TODO: Describe initial release.
+* Adds platform interface.
diff --git a/packages/interactive_media_ads/LICENSE b/packages/interactive_media_ads/LICENSE
index ba75c69f7f21..c6823b81eb84 100644
--- a/packages/interactive_media_ads/LICENSE
+++ b/packages/interactive_media_ads/LICENSE
@@ -1 +1,25 @@
-TODO: Add your license here.
+Copyright 2013 The Flutter Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/packages/interactive_media_ads/README.md b/packages/interactive_media_ads/README.md
index ee4f909824fd..c7627473e0eb 100644
--- a/packages/interactive_media_ads/README.md
+++ b/packages/interactive_media_ads/README.md
@@ -1,15 +1,6 @@
-# interactive_media_ads
+# interactive\_media\_ads
-A new Flutter plugin project.
+Flutter plugin for the [Interactive Media Ads SDKs][1].
-## Getting Started
-
-This project is a starting point for a Flutter
-[plug-in package](https://flutter.dev/developing-packages/),
-a specialized package that includes platform-specific implementation code for
-Android and/or iOS.
-
-For help getting started with Flutter development, view the
-[online documentation](https://flutter.dev/docs), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
+[1]: https://developers.google.com/interactive-media-ads
diff --git a/packages/interactive_media_ads/android/build.gradle b/packages/interactive_media_ads/android/build.gradle
index 5f150cda9a5e..8e51ccbd37d3 100644
--- a/packages/interactive_media_ads/android/build.gradle
+++ b/packages/interactive_media_ads/android/build.gradle
@@ -50,14 +50,24 @@ android {
}
dependencies {
+ implementation 'androidx.annotation:annotation:1.5.0'
+ testImplementation 'junit:junit:4.13.2'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
- testImplementation 'org.mockito:mockito-core:5.0.0'
+ testImplementation 'org.mockito:mockito-inline:5.1.0'
+ testImplementation 'androidx.test:core:1.3.0'
+ }
+
+ lintOptions {
+ checkAllWarnings true
+ warningsAsErrors true
+ disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
}
testOptions {
+ unitTests.includeAndroidResources = true
+ unitTests.returnDefaultValues = true
unitTests.all {
useJUnitPlatform()
-
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
diff --git a/packages/interactive_media_ads/example/README.md b/packages/interactive_media_ads/example/README.md
index f618120191f4..b62c363535b6 100644
--- a/packages/interactive_media_ads/example/README.md
+++ b/packages/interactive_media_ads/example/README.md
@@ -1,16 +1,9 @@
-# interactive_media_ads_example
+# Platform Implementation Test App
-Demonstrates how to use the interactive_media_ads plugin.
+This is a test app for manual testing and automated integration testing
+of this platform implementation. It is not intended to demonstrate actual use of
+this package, since the intent is that plugin clients use the app-facing
+package.
-## Getting Started
-
-This project is a starting point for a Flutter application.
-
-A few resources to get you started if this is your first Flutter project:
-
-- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
-
-For help getting started with Flutter development, view the
-[online documentation](https://docs.flutter.dev/), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
+Unless you are making changes to this implementation package, this example is
+very unlikely to be relevant.
\ No newline at end of file
From b49ae749ffe83433ece5e79cd4d79d60200a2270 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 15:20:55 -0500
Subject: [PATCH 03/76] fix pubspecs and add licenses
---
packages/interactive_media_ads/.metadata | 33 ---------
.../interactive_media_ads/android/.gitignore | 9 ---
.../InteractiveMediaAdsPlugin.kt | 4 ++
.../InteractiveMediaAdsPluginTest.kt | 4 ++
.../interactive_media_ads/example/.gitignore | 43 -----------
.../example/analysis_options.yaml | 28 --------
.../plugin_integration_test.dart | 11 +--
.../example/ios/Flutter/Debug.xcconfig | 1 +
.../example/ios/Flutter/Release.xcconfig | 1 +
.../example/lib/main.dart | 4 ++
.../example/pubspec.yaml | 65 +----------------
packages/interactive_media_ads/ios/.gitignore | 38 ----------
.../Classes/InteractiveMediaAdsPlugin.swift | 4 ++
.../lib/interactive_media_ads.dart | 3 +
.../interactive_media_ads_method_channel.dart | 4 ++
...eractive_media_ads_platform_interface.dart | 4 ++
packages/interactive_media_ads/pubspec.yaml | 72 ++++---------------
...ractive_media_ads_method_channel_test.dart | 4 ++
.../test/interactive_media_ads_test.dart | 4 ++
19 files changed, 57 insertions(+), 279 deletions(-)
delete mode 100644 packages/interactive_media_ads/.metadata
delete mode 100644 packages/interactive_media_ads/android/.gitignore
delete mode 100644 packages/interactive_media_ads/example/.gitignore
delete mode 100644 packages/interactive_media_ads/example/analysis_options.yaml
delete mode 100644 packages/interactive_media_ads/ios/.gitignore
diff --git a/packages/interactive_media_ads/.metadata b/packages/interactive_media_ads/.metadata
deleted file mode 100644
index 0a849e2c5274..000000000000
--- a/packages/interactive_media_ads/.metadata
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file tracks properties of this Flutter project.
-# Used by Flutter tool to assess capabilities and perform upgrades etc.
-#
-# This file should be version controlled and should not be manually edited.
-
-version:
- revision: "bdb71b8f5a765332345650e390ca39a7623baf21"
- channel: "main"
-
-project_type: plugin
-
-# Tracks metadata for the flutter migrate command
-migration:
- platforms:
- - platform: root
- create_revision: bdb71b8f5a765332345650e390ca39a7623baf21
- base_revision: bdb71b8f5a765332345650e390ca39a7623baf21
- - platform: android
- create_revision: bdb71b8f5a765332345650e390ca39a7623baf21
- base_revision: bdb71b8f5a765332345650e390ca39a7623baf21
- - platform: ios
- create_revision: bdb71b8f5a765332345650e390ca39a7623baf21
- base_revision: bdb71b8f5a765332345650e390ca39a7623baf21
-
- # User provided section
-
- # List of Local paths (relative to this file) that should be
- # ignored by the migrate tool.
- #
- # Files that are not part of the templates will be ignored by default.
- unmanaged_files:
- - 'lib/main.dart'
- - 'ios/Runner.xcodeproj/project.pbxproj'
diff --git a/packages/interactive_media_ads/android/.gitignore b/packages/interactive_media_ads/android/.gitignore
deleted file mode 100644
index 161bdcdaf88c..000000000000
--- a/packages/interactive_media_ads/android/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-*.iml
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
-/captures
-.cxx
diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPlugin.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPlugin.kt
index 8e79952dd64f..648ee6b46139 100644
--- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPlugin.kt
+++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPlugin.kt
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
package dev.flutter.plugins.interactive_media_ads
import androidx.annotation.NonNull
diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPluginTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPluginTest.kt
index 4c264a65f846..2bfc49d5eeae 100644
--- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPluginTest.kt
+++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/plugins/interactive_media_ads/InteractiveMediaAdsPluginTest.kt
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
package dev.flutter.plugins.interactive_media_ads
import io.flutter.plugin.common.MethodCall
diff --git a/packages/interactive_media_ads/example/.gitignore b/packages/interactive_media_ads/example/.gitignore
deleted file mode 100644
index 29a3a5017f04..000000000000
--- a/packages/interactive_media_ads/example/.gitignore
+++ /dev/null
@@ -1,43 +0,0 @@
-# Miscellaneous
-*.class
-*.log
-*.pyc
-*.swp
-.DS_Store
-.atom/
-.buildlog/
-.history
-.svn/
-migrate_working_dir/
-
-# IntelliJ related
-*.iml
-*.ipr
-*.iws
-.idea/
-
-# The .vscode folder contains launch configuration and tasks you configure in
-# VS Code which you may wish to be included in version control, so this line
-# is commented out by default.
-#.vscode/
-
-# Flutter/Dart/Pub related
-**/doc/api/
-**/ios/Flutter/.last_build_id
-.dart_tool/
-.flutter-plugins
-.flutter-plugins-dependencies
-.pub-cache/
-.pub/
-/build/
-
-# Symbolication related
-app.*.symbols
-
-# Obfuscation related
-app.*.map.json
-
-# Android Studio will place build artifacts here
-/android/app/debug
-/android/app/profile
-/android/app/release
diff --git a/packages/interactive_media_ads/example/analysis_options.yaml b/packages/interactive_media_ads/example/analysis_options.yaml
deleted file mode 100644
index 0d2902135cae..000000000000
--- a/packages/interactive_media_ads/example/analysis_options.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-# This file configures the analyzer, which statically analyzes Dart code to
-# check for errors, warnings, and lints.
-#
-# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
-# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
-# invoked from the command line by running `flutter analyze`.
-
-# The following line activates a set of recommended lints for Flutter apps,
-# packages, and plugins designed to encourage good coding practices.
-include: package:flutter_lints/flutter.yaml
-
-linter:
- # The lint rules applied to this project can be customized in the
- # section below to disable rules from the `package:flutter_lints/flutter.yaml`
- # included above or to enable additional rules. A list of all available lints
- # and their documentation is published at https://dart.dev/lints.
- #
- # Instead of disabling a lint rule for the entire project in the
- # section below, it can also be suppressed for a single line of code
- # or a specific dart file by using the `// ignore: name_of_lint` and
- # `// ignore_for_file: name_of_lint` syntax on the line or in the file
- # producing the lint.
- rules:
- # avoid_print: false # Uncomment to disable the `avoid_print` rule
- # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
-
-# Additional information about this file can be found at
-# https://dart.dev/guides/language/analysis-options
diff --git a/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart b/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart
index 4e71b6d604d7..236a6cc53a66 100644
--- a/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart
+++ b/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart
@@ -1,11 +1,6 @@
-// This is a basic Flutter integration test.
-//
-// Since integration tests run in a full Flutter application, they can interact
-// with the host side of a plugin implementation, unlike Dart unit tests.
-//
-// For more information about Flutter integration tests, please see
-// https://docs.flutter.dev/cookbook/testing/integration/introduction
-
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
diff --git a/packages/interactive_media_ads/example/ios/Flutter/Debug.xcconfig b/packages/interactive_media_ads/example/ios/Flutter/Debug.xcconfig
index 592ceee85b89..ec97fc6f3021 100644
--- a/packages/interactive_media_ads/example/ios/Flutter/Debug.xcconfig
+++ b/packages/interactive_media_ads/example/ios/Flutter/Debug.xcconfig
@@ -1 +1,2 @@
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
diff --git a/packages/interactive_media_ads/example/ios/Flutter/Release.xcconfig b/packages/interactive_media_ads/example/ios/Flutter/Release.xcconfig
index 592ceee85b89..c4855bfe2000 100644
--- a/packages/interactive_media_ads/example/ios/Flutter/Release.xcconfig
+++ b/packages/interactive_media_ads/example/ios/Flutter/Release.xcconfig
@@ -1 +1,2 @@
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart
index 4fe2dc921df5..ed040b154d8a 100644
--- a/packages/interactive_media_ads/example/lib/main.dart
+++ b/packages/interactive_media_ads/example/lib/main.dart
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
import 'package:flutter/material.dart';
import 'dart:async';
diff --git a/packages/interactive_media_ads/example/pubspec.yaml b/packages/interactive_media_ads/example/pubspec.yaml
index d67bf3d19c60..f067af2a17e6 100644
--- a/packages/interactive_media_ads/example/pubspec.yaml
+++ b/packages/interactive_media_ads/example/pubspec.yaml
@@ -1,32 +1,17 @@
name: interactive_media_ads_example
description: "Demonstrates how to use the interactive_media_ads plugin."
-# The following line prevents the package from being accidentally published to
-# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
- sdk: '>=3.4.0-82.0.dev <4.0.0'
+ sdk: ">=3.0.0 <4.0.0"
+ flutter: ">=3.10.0"
-# Dependencies specify other packages that your package needs in order to work.
-# To automatically upgrade your package dependencies to the latest versions
-# consider running `flutter pub upgrade --major-versions`. Alternatively,
-# dependencies can be manually updated by changing the version numbers below to
-# the latest version available on pub.dev. To see which dependencies have newer
-# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
interactive_media_ads:
- # When depending on this package from a real application you should use:
- # interactive_media_ads: ^x.y.z
- # See https://dart.dev/tools/pub/dependencies#version-constraints
- # The example app is bundled with the plugin so we use a path dependency on
- # the parent directory to use the current plugin's version.
path: ../
-
- # The following adds the Cupertino Icons font to your application.
- # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.6
dev_dependencies:
@@ -35,51 +20,5 @@ dev_dependencies:
flutter_test:
sdk: flutter
- # The "flutter_lints" package below contains a set of recommended lints to
- # encourage good coding practices. The lint set provided by the package is
- # activated in the `analysis_options.yaml` file located at the root of your
- # package. See that file for information about deactivating specific lint
- # rules and activating additional ones.
- flutter_lints: ^3.0.0
-
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter packages.
flutter:
-
- # The following line ensures that the Material Icons font is
- # included with your application, so that you can use the icons in
- # the material Icons class.
uses-material-design: true
-
- # To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
-
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware
-
- # For details regarding adding assets from package dependencies, see
- # https://flutter.dev/assets-and-images/#from-packages
-
- # To add custom fonts to your application, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts from package dependencies,
- # see https://flutter.dev/custom-fonts/#from-packages
diff --git a/packages/interactive_media_ads/ios/.gitignore b/packages/interactive_media_ads/ios/.gitignore
deleted file mode 100644
index 034771fc9c9b..000000000000
--- a/packages/interactive_media_ads/ios/.gitignore
+++ /dev/null
@@ -1,38 +0,0 @@
-.idea/
-.vagrant/
-.sconsign.dblite
-.svn/
-
-.DS_Store
-*.swp
-profile
-
-DerivedData/
-build/
-GeneratedPluginRegistrant.h
-GeneratedPluginRegistrant.m
-
-.generated/
-
-*.pbxuser
-*.mode1v3
-*.mode2v3
-*.perspectivev3
-
-!default.pbxuser
-!default.mode1v3
-!default.mode2v3
-!default.perspectivev3
-
-xcuserdata
-
-*.moved-aside
-
-*.pyc
-*sync/
-Icon?
-.tags*
-
-/Flutter/Generated.xcconfig
-/Flutter/ephemeral/
-/Flutter/flutter_export_environment.sh
diff --git a/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift b/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift
index d5483676b55e..78fc747514b1 100644
--- a/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift
+++ b/packages/interactive_media_ads/ios/Classes/InteractiveMediaAdsPlugin.swift
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
import Flutter
import UIKit
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart
index 11b021f90d1f..740cd7ec7918 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart
@@ -1,3 +1,6 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
import 'interactive_media_ads_platform_interface.dart';
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
index f7c2e245020e..46d3d0d800ee 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
index 862962d72750..9627e55f2ce0 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'interactive_media_ads_method_channel.dart';
diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml
index 4c0a81bc4d22..fe8146275640 100644
--- a/packages/interactive_media_ads/pubspec.yaml
+++ b/packages/interactive_media_ads/pubspec.yaml
@@ -1,37 +1,14 @@
name: interactive_media_ads
-description: "A new Flutter plugin project."
+description: "Flutter plugin for the Interactive Media Ads SDKs."
+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.0.1
-homepage:
environment:
- sdk: '>=3.4.0-82.0.dev <4.0.0'
- flutter: '>=3.3.0'
+ sdk: ">=3.0.0 <4.0.0"
+ flutter: ">=3.10.0"
-dependencies:
- flutter:
- sdk: flutter
- plugin_platform_interface: ^2.0.2
-
-dev_dependencies:
- flutter_test:
- sdk: flutter
- flutter_lints: ^3.0.0
-
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter packages.
flutter:
- # This section identifies this Flutter project as a plugin project.
- # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
- # which should be registered in the plugin registry. This is required for
- # using method channels.
- # The Android 'package' specifies package in which the registered class is.
- # This is required for using method channels on Android.
- # The 'ffiPlugin' specifies that native code should be built and bundled.
- # This is required for using `dart:ffi`.
- # All these are used by the tooling to maintain consistency when
- # adding or updating assets for this project.
plugin:
platforms:
android:
@@ -40,33 +17,14 @@ flutter:
ios:
pluginClass: InteractiveMediaAdsPlugin
- # To add assets to your plugin package, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
- #
- # For details regarding assets in packages, see
- # https://flutter.dev/assets-and-images/#from-packages
- #
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware
+dependencies:
+ flutter:
+ sdk: flutter
+ plugin_platform_interface: ^2.0.2
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
- # To add custom fonts to your plugin package, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts in packages, see
- # https://flutter.dev/custom-fonts/#from-packages
+topics:
+ - ads
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
index 08eb507a037f..0fd46d9a54c7 100644
--- a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
+++ b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart';
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
index 03edb259a2fa..b50dce0db3b9 100644
--- a/packages/interactive_media_ads/test/interactive_media_ads_test.dart
+++ b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
@@ -1,3 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
import 'package:flutter_test/flutter_test.dart';
import 'package:interactive_media_ads/interactive_media_ads.dart';
import 'package:interactive_media_ads/interactive_media_ads_platform_interface.dart';
From c1067a61c630e4db41f6d0e6bc4f5a29d0271044 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 15:32:32 -0500
Subject: [PATCH 04/76] remove analysis options
---
packages/interactive_media_ads/analysis_options.yaml | 4 ----
1 file changed, 4 deletions(-)
delete mode 100644 packages/interactive_media_ads/analysis_options.yaml
diff --git a/packages/interactive_media_ads/analysis_options.yaml b/packages/interactive_media_ads/analysis_options.yaml
deleted file mode 100644
index a5744c1cfbe7..000000000000
--- a/packages/interactive_media_ads/analysis_options.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-include: package:flutter_lints/flutter.yaml
-
-# Additional information about this file can be found at
-# https://dart.dev/guides/language/analysis-options
From 3f7f6bb8ed61bbacf218eed2faeeffd84a9b709b Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 16:15:45 -0500
Subject: [PATCH 05/76] fix analyze warnings
---
.../interactive_media_ads/example/lib/main.dart | 14 +++++++++-----
.../interactive_media_ads/example/pubspec.yaml | 7 +++----
.../lib/interactive_media_ads.dart | 2 ++
.../lib/interactive_media_ads_method_channel.dart | 8 ++++++--
.../interactive_media_ads_platform_interface.dart | 5 ++++-
.../interactive_media_ads_method_channel_test.dart | 9 ++++++---
.../test/interactive_media_ads_test.dart | 11 ++++++-----
7 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart
index ed040b154d8a..50d59ac44a63 100644
--- a/packages/interactive_media_ads/example/lib/main.dart
+++ b/packages/interactive_media_ads/example/lib/main.dart
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter/material.dart';
+// ignore_for_file: public_member_api_docs
+
import 'dart:async';
+import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:interactive_media_ads/interactive_media_ads.dart';
@@ -21,7 +23,7 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State {
String _platformVersion = 'Unknown';
- final _interactiveMediaAdsPlugin = InteractiveMediaAds();
+ final InteractiveMediaAds _interactiveMediaAdsPlugin = InteractiveMediaAds();
@override
void initState() {
@@ -35,8 +37,8 @@ class _MyAppState extends State {
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
- platformVersion =
- await _interactiveMediaAdsPlugin.getPlatformVersion() ?? 'Unknown platform version';
+ platformVersion = await _interactiveMediaAdsPlugin.getPlatformVersion() ??
+ 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
@@ -44,7 +46,9 @@ class _MyAppState extends State {
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
- if (!mounted) return;
+ if (!mounted) {
+ return;
+ }
setState(() {
_platformVersion = platformVersion;
diff --git a/packages/interactive_media_ads/example/pubspec.yaml b/packages/interactive_media_ads/example/pubspec.yaml
index f067af2a17e6..ccec925847fe 100644
--- a/packages/interactive_media_ads/example/pubspec.yaml
+++ b/packages/interactive_media_ads/example/pubspec.yaml
@@ -7,18 +7,17 @@ environment:
flutter: ">=3.10.0"
dependencies:
+ cupertino_icons: ^1.0.6
flutter:
sdk: flutter
-
interactive_media_ads:
path: ../
- cupertino_icons: ^1.0.6
dev_dependencies:
- integration_test:
- sdk: flutter
flutter_test:
sdk: flutter
+ integration_test:
+ sdk: flutter
flutter:
uses-material-design: true
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart
index 740cd7ec7918..c803464a245a 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: public_member_api_docs
+
import 'interactive_media_ads_platform_interface.dart';
class InteractiveMediaAds {
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
index 46d3d0d800ee..af55cdb1431d 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: public_member_api_docs
+
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
@@ -11,11 +13,13 @@ import 'interactive_media_ads_platform_interface.dart';
class MethodChannelInteractiveMediaAds extends InteractiveMediaAdsPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
- final methodChannel = const MethodChannel('interactive_media_ads');
+ final MethodChannel methodChannel =
+ const MethodChannel('interactive_media_ads');
@override
Future getPlatformVersion() async {
- final version = await methodChannel.invokeMethod('getPlatformVersion');
+ final String? version =
+ await methodChannel.invokeMethod('getPlatformVersion');
return version;
}
}
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
index 9627e55f2ce0..34fb9577f811 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: public_member_api_docs
+
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'interactive_media_ads_method_channel.dart';
@@ -12,7 +14,8 @@ abstract class InteractiveMediaAdsPlatform extends PlatformInterface {
static final Object _token = Object();
- static InteractiveMediaAdsPlatform _instance = MethodChannelInteractiveMediaAds();
+ static InteractiveMediaAdsPlatform _instance =
+ MethodChannelInteractiveMediaAds();
/// The default instance of [InteractiveMediaAdsPlatform] to use.
///
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
index 0fd46d9a54c7..147cb09b13ce 100644
--- a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
+++ b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
@@ -9,11 +9,13 @@ import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart'
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
- MethodChannelInteractiveMediaAds platform = MethodChannelInteractiveMediaAds();
+ final MethodChannelInteractiveMediaAds platform =
+ MethodChannelInteractiveMediaAds();
const MethodChannel channel = MethodChannel('interactive_media_ads');
setUp(() {
- TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(
channel,
(MethodCall methodCall) async {
return '42';
@@ -22,7 +24,8 @@ void main() {
});
tearDown(() {
- TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null);
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(channel, null);
});
test('getPlatformVersion', () async {
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
index b50dce0db3b9..0c2468db9996 100644
--- a/packages/interactive_media_ads/test/interactive_media_ads_test.dart
+++ b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
@@ -11,21 +11,22 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class MockInteractiveMediaAdsPlatform
with MockPlatformInterfaceMixin
implements InteractiveMediaAdsPlatform {
-
@override
- Future getPlatformVersion() => Future.value('42');
+ Future getPlatformVersion() => Future.value('42');
}
void main() {
- final InteractiveMediaAdsPlatform initialPlatform = InteractiveMediaAdsPlatform.instance;
+ final InteractiveMediaAdsPlatform initialPlatform =
+ InteractiveMediaAdsPlatform.instance;
test('$MethodChannelInteractiveMediaAds is the default instance', () {
expect(initialPlatform, isInstanceOf());
});
test('getPlatformVersion', () async {
- InteractiveMediaAds interactiveMediaAdsPlugin = InteractiveMediaAds();
- MockInteractiveMediaAdsPlatform fakePlatform = MockInteractiveMediaAdsPlatform();
+ final InteractiveMediaAds interactiveMediaAdsPlugin = InteractiveMediaAds();
+ final MockInteractiveMediaAdsPlatform fakePlatform =
+ MockInteractiveMediaAdsPlatform();
InteractiveMediaAdsPlatform.instance = fakePlatform;
expect(await interactiveMediaAdsPlugin.getPlatformVersion(), '42');
From b29653d011789f5639d7e2fb2ffcfcd96aa7e519 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 16:16:10 -0500
Subject: [PATCH 06/76] add podfile for example
---
.../interactive_media_ads/example/ios/Podfile | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 packages/interactive_media_ads/example/ios/Podfile
diff --git a/packages/interactive_media_ads/example/ios/Podfile b/packages/interactive_media_ads/example/ios/Podfile
new file mode 100644
index 000000000000..d97f17e223fb
--- /dev/null
+++ b/packages/interactive_media_ads/example/ios/Podfile
@@ -0,0 +1,44 @@
+# Uncomment this line to define a global platform for your project
+# platform :ios, '12.0'
+
+# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
+ENV['COCOAPODS_DISABLE_STATS'] = 'true'
+
+project 'Runner', {
+ 'Debug' => :debug,
+ 'Profile' => :release,
+ 'Release' => :release,
+}
+
+def flutter_root
+ generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
+ unless File.exist?(generated_xcode_build_settings_path)
+ raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
+ end
+
+ File.foreach(generated_xcode_build_settings_path) do |line|
+ matches = line.match(/FLUTTER_ROOT\=(.*)/)
+ return matches[1].strip if matches
+ end
+ raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
+end
+
+require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
+
+flutter_ios_podfile_setup
+
+target 'Runner' do
+ use_frameworks!
+ use_modular_headers!
+
+ flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
+ target 'RunnerTests' do
+ inherit! :search_paths
+ end
+end
+
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ flutter_additional_ios_build_settings(target)
+ end
+end
From c0cff54c467a2f43f142ea2926a37896b5c35744 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 16:22:57 -0500
Subject: [PATCH 07/76] add base platform interface classes
---
.../lib/src/ads_manager.dart | 0
.../interactive_media_ads_platform.dart | 73 +++++++++++++++++
.../platform_ad_display_container.dart | 80 ++++++++++++++++++
.../platform_ads_loader.dart | 78 ++++++++++++++++++
.../platform_ads_manager.dart | 79 ++++++++++++++++++
.../platform_ads_manager_delegate.dart | 81 +++++++++++++++++++
6 files changed, 391 insertions(+)
create mode 100644 packages/interactive_media_ads/lib/src/ads_manager.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
diff --git a/packages/interactive_media_ads/lib/src/ads_manager.dart b/packages/interactive_media_ads/lib/src/ads_manager.dart
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
new file mode 100644
index 000000000000..e358a580de13
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
@@ -0,0 +1,73 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'platform_ad_display_container.dart';
+import 'platform_ads_loader.dart';
+import 'platform_ads_manager.dart';
+import 'platform_ads_manager_delegate.dart';
+
+/// Interface for a platform implementation of the Interactive Media Ads SDKs.
+abstract class InteractiveMediaAdsPlatform extends PlatformInterface {
+ /// Creates a new [InteractiveMediaAdsPlatform].
+ InteractiveMediaAdsPlatform() : super(token: _token);
+
+ static final Object _token = Object();
+
+ static InteractiveMediaAdsPlatform? _instance;
+
+ /// The instance of [InteractiveMediaAdsPlatform] to use.
+ static InteractiveMediaAdsPlatform? get instance => _instance;
+
+ /// Platform-specific plugins should set this with their own platform-specific
+ /// class that extends [InteractiveMediaAdsPlatform] when they register
+ /// themselves.
+ static set instance(InteractiveMediaAdsPlatform? instance) {
+ if (instance == null) {
+ throw AssertionError(
+ 'Platform interfaces can only be set to a non-null instance',
+ );
+ }
+
+ PlatformInterface.verify(instance, _token);
+ _instance = instance;
+ }
+
+ /// Creates a new [PlatformAdsManager].
+ PlatformAdsManager createPlatformAdsManager(
+ PlatformAdsManagerCreationParams params,
+ ) {
+ throw UnimplementedError(
+ 'createPlatformAdsManager is not implemented on the current platform.',
+ );
+ }
+
+ /// Creates a new [PlatformAdsLoader].
+ PlatformAdsLoader createPlatformAdsLoader(
+ PlatformAdsLoaderCreationParams params,
+ ) {
+ throw UnimplementedError(
+ 'createPlatformAdsLoader is not implemented on the current platform.',
+ );
+ }
+
+ /// Creates a new [PlatformAdsManagerDelegate].
+ PlatformAdsManagerDelegate createPlatformAdsManagerDelegate(
+ PlatformAdsManagerDelegateCreationParams params,
+ ) {
+ throw UnimplementedError(
+ 'createPlatformAdsManagerDelegate is not implemented on the current platform.',
+ );
+ }
+
+ /// Creates a new [PlatformAdDisplayContainer].
+ PlatformAdDisplayContainer createPlatformAdDisplayContainer(
+ PlatformAdDisplayContainerCreationParams params,
+ ) {
+ throw UnimplementedError(
+ 'createPlatformAdDisplayContainer is not implemented on the current platform.',
+ );
+ }
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
new file mode 100644
index 000000000000..95d1b3bad9f8
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
@@ -0,0 +1,80 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/foundation.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'interactive_media_ads_platform.dart';
+
+/// Object specifying creation parameters for creating a
+/// [PlatformAdDisplayContainer].
+///
+/// Platform specific implementations can add additional fields by extending
+/// this class.
+///
+/// This example demonstrates how to extend the
+/// [PlatformAdDisplayContainerCreationParams] to provide additional platform
+/// specific parameters.
+///
+/// When extending [PlatformAdDisplayContainerCreationParams] additional
+/// parameters should always accept `null` or have a default value to prevent
+/// breaking changes.
+///
+/// ```dart
+/// class AndroidPlatformAdDisplayContainerCreationParams
+/// extends PlatformAdDisplayContainerCreationParams {
+/// AndroidPlatformAdDisplayContainerCreationParams._(
+/// PlatformAdDisplayContainerCreationParams params, {
+/// this.uri,
+/// }) : super();
+///
+/// factory AndroidAdDisplayContainerCreationParams.fromPlatformAdDisplayContainerCreationParams(
+/// PlatformAdDisplayContainerCreationParams params, {
+/// Uri? uri,
+/// }) {
+/// return AndroidAdDisplayContainerCreationParams._(params, uri: uri);
+/// }
+///
+/// final Uri? uri;
+/// }
+/// ```
+@immutable
+class PlatformAdDisplayContainerCreationParams {
+ /// Used by the platform implementation to create a new [PlatformAdDisplayContainer].
+ const PlatformAdDisplayContainerCreationParams();
+}
+
+/// Interface for a platform implementation of a `AdDisplayContainer`.
+abstract class PlatformAdDisplayContainer extends PlatformInterface {
+ /// Creates a new [PlatformAdDisplayContainer]
+ factory PlatformAdDisplayContainer(
+ PlatformAdDisplayContainerCreationParams params,
+ ) {
+ assert(
+ InteractiveMediaAdsPlatform.instance != null,
+ 'A platform implementation for `interactive_media_ads` has not been set. '
+ 'Please ensure that an implementation of `InteractiveMediaAdsPlatform` '
+ 'has been set to `InteractiveMediaAdsPlatform.instance` before use. For '
+ 'unit testing, `InteractiveMediaAdsPlatform.instance` can be set with '
+ 'your own test implementation.',
+ );
+ final PlatformAdDisplayContainer implementation =
+ InteractiveMediaAdsPlatform.instance!
+ .createPlatformAdDisplayContainer(params);
+ PlatformInterface.verify(implementation, _token);
+ return implementation;
+ }
+
+ /// Used by the platform implementation to create a new [PlatformAdDisplayContainer].
+ ///
+ /// Should only be used by platform implementations because they can't extend
+ /// a class that only contains a factory constructor.
+ @protected
+ PlatformAdDisplayContainer.implementation(this.params) : super(token: _token);
+
+ static final Object _token = Object();
+
+ /// The parameters used to initialize the [PlatformAdDisplayContainer].
+ final PlatformAdDisplayContainerCreationParams params;
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
new file mode 100644
index 000000000000..0e13ae29ffdc
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -0,0 +1,78 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/foundation.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'interactive_media_ads_platform.dart';
+
+/// Object specifying creation parameters for creating a [PlatformAdsLoader].
+///
+/// Platform specific implementations can add additional fields by extending
+/// this class.
+///
+/// This example demonstrates how to extend the
+/// [PlatformAdsLoaderCreationParams] to provide additional platform specific
+/// parameters.
+///
+/// When extending [PlatformAdsLoaderCreationParams] additional parameters
+/// should always accept `null` or have a default value to prevent breaking
+/// changes.
+///
+/// ```dart
+/// class AndroidPlatformAdsLoaderCreationParams
+/// extends PlatformAdsLoaderCreationParams {
+/// AndroidPlatformAdsLoaderCreationParams._(
+/// PlatformAdsLoaderCreationParams params, {
+/// this.uri,
+/// }) : super();
+///
+/// factory AndroidAdsLoaderCreationParams.fromPlatformAdsLoaderCreationParams(
+/// PlatformAdsLoaderCreationParams params, {
+/// Uri? uri,
+/// }) {
+/// return AndroidAdsLoaderCreationParams._(params, uri: uri);
+/// }
+///
+/// final Uri? uri;
+/// }
+/// ```
+@immutable
+class PlatformAdsLoaderCreationParams {
+ /// Used by the platform implementation to create a new [PlatformAdsLoader].
+ const PlatformAdsLoaderCreationParams();
+}
+
+/// Interface for a platform implementation of a `AdsLoader`.
+abstract class PlatformAdsLoader extends PlatformInterface {
+ /// Creates a new [PlatformAdsLoader]
+ factory PlatformAdsLoader(
+ PlatformAdsLoaderCreationParams params,
+ ) {
+ assert(
+ InteractiveMediaAdsPlatform.instance != null,
+ 'A platform implementation for `interactive_media_ads` has not been set. '
+ 'Please ensure that an implementation of `InteractiveMediaAdsPlatform` '
+ 'has been set to `InteractiveMediaAdsPlatform.instance` before use. For '
+ 'unit testing, `InteractiveMediaAdsPlatform.instance` can be set with '
+ 'your own test implementation.',
+ );
+ final PlatformAdsLoader implementation =
+ InteractiveMediaAdsPlatform.instance!.createPlatformAdsLoader(params);
+ PlatformInterface.verify(implementation, _token);
+ return implementation;
+ }
+
+ /// Used by the platform implementation to create a new [PlatformAdsLoader].
+ ///
+ /// Should only be used by platform implementations because they can't extend
+ /// a class that only contains a factory constructor.
+ @protected
+ PlatformAdsLoader.implementation(this.params) : super(token: _token);
+
+ static final Object _token = Object();
+
+ /// The parameters used to initialize the [PlatformAdsLoader].
+ final PlatformAdsLoaderCreationParams params;
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
new file mode 100644
index 000000000000..71b294724598
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -0,0 +1,79 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/foundation.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'interactive_media_ads_platform.dart';
+
+/// Object specifying creation parameters for creating a [PlatformAdsManager].
+///
+/// Platform specific implementations can add additional fields by extending
+/// this class.
+///
+/// This example demonstrates how to extend the
+/// [PlatformAdsManagerCreationParams] to provide additional platform specific
+/// parameters.
+///
+/// When extending [PlatformAdsManagerCreationParams] additional parameters
+/// should always accept `null` or have a default value to prevent breaking
+/// changes.
+///
+/// ```dart
+/// class AndroidPlatformAdsManagerCreationParams
+/// extends PlatformAdsManagerCreationParams {
+/// AndroidPlatformAdsManagerCreationParams._(
+/// PlatformAdsManagerCreationParams params, {
+/// this.uri,
+/// }) : super();
+///
+/// factory AndroidAdsManagerCreationParams.fromPlatformAdsManagerCreationParams(
+/// PlatformAdsManagerCreationParams params, {
+/// Uri? uri,
+/// }) {
+/// return AndroidAdsManagerCreationParams._(params, uri: uri);
+/// }
+///
+/// final Uri? uri;
+/// }
+/// ```
+@immutable
+class PlatformAdsManagerCreationParams {
+ /// Used by the platform implementation to create a new [PlatformAdsManager].
+ const PlatformAdsManagerCreationParams();
+}
+
+/// Interface for a platform implementation of a `AdsManager`.
+abstract class PlatformAdsManager extends PlatformInterface {
+ /// Creates a new [PlatformAdsManager]
+ factory PlatformAdsManager(
+ PlatformAdsManagerCreationParams params,
+ ) {
+ assert(
+ InteractiveMediaAdsPlatform.instance != null,
+ 'A platform implementation for `interactive_media_ads` has not been set. '
+ 'Please ensure that an implementation of `InteractiveMediaAdsPlatform` '
+ 'has been set to `InteractiveMediaAdsPlatform.instance` before use. For '
+ 'unit testing, `InteractiveMediaAdsPlatform.instance` can be set with '
+ 'your own test implementation.',
+ );
+ final PlatformAdsManager implementation = InteractiveMediaAdsPlatform
+ .instance!
+ .createPlatformAdsManager(params);
+ PlatformInterface.verify(implementation, _token);
+ return implementation;
+ }
+
+ /// Used by the platform implementation to create a new [PlatformAdsManager].
+ ///
+ /// Should only be used by platform implementations because they can't extend
+ /// a class that only contains a factory constructor.
+ @protected
+ PlatformAdsManager.implementation(this.params) : super(token: _token);
+
+ static final Object _token = Object();
+
+ /// The parameters used to initialize the [PlatformAdsManager].
+ final PlatformAdsManagerCreationParams params;
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
new file mode 100644
index 000000000000..6596f0daa314
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
@@ -0,0 +1,81 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/foundation.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'interactive_media_ads_platform.dart';
+
+/// Object specifying creation parameters for creating a
+/// [PlatformAdsManagerDelegate].
+///
+/// Platform specific implementations can add additional fields by extending
+/// this class.
+///
+/// This example demonstrates how to extend the
+/// [PlatformAdsManagerDelegateCreationParams] to provide additional platform
+/// specific parameters.
+///
+/// When extending [PlatformAdsManagerDelegateCreationParams] additional
+/// parameters should always accept `null` or have a default value to prevent
+/// breaking changes.
+///
+/// ```dart
+/// class AndroidPlatformAdsManagerDelegateCreationParams
+/// extends PlatformAdsManagerDelegateCreationParams {
+/// AndroidPlatformAdsManagerDelegateCreationParams._(
+/// PlatformAdsManagerDelegateCreationParams params, {
+/// this.uri,
+/// }) : super();
+///
+/// factory AndroidAdsManagerDelegateCreationParams.fromPlatformAdsManagerDelegateCreationParams(
+/// PlatformAdsManagerDelegateCreationParams params, {
+/// Uri? uri,
+/// }) {
+/// return AndroidAdsManagerDelegateCreationParams._(params, uri: uri);
+/// }
+///
+/// final Uri? uri;
+/// }
+/// ```
+@immutable
+class PlatformAdsManagerDelegateCreationParams {
+ /// Used by the platform implementation to create a new [PlatformAdsManagerDelegate].
+ const PlatformAdsManagerDelegateCreationParams();
+}
+
+/// Interface for a platform implementation of a `AdsManagerDelegate`.
+abstract class PlatformAdsManagerDelegate extends PlatformInterface {
+ /// Creates a new [PlatformAdsManagerDelegate]
+ factory PlatformAdsManagerDelegate(
+ PlatformAdsManagerDelegateCreationParams params,
+ ) {
+ assert(
+ InteractiveMediaAdsPlatform.instance != null,
+ 'A platform implementation for `interactive_media_ads` has not been set. '
+ 'Please ensure that an implementation of `InteractiveMediaAdsPlatform` '
+ 'has been set to `InteractiveMediaAdsPlatform.instance` before use. For '
+ 'unit testing, `InteractiveMediaAdsPlatform.instance` can be set with '
+ 'your own test implementation.',
+ );
+ final PlatformAdsManagerDelegate implementation =
+ InteractiveMediaAdsPlatform.instance!
+ .createPlatformAdsManagerDelegate(params);
+ PlatformInterface.verify(implementation, _token);
+ return implementation;
+ }
+
+ /// Used by the platform implementation to create a new
+ /// [PlatformAdsManagerDelegate].
+ ///
+ /// Should only be used by platform implementations because they can't extend
+ /// a class that only contains a factory constructor.
+ @protected
+ PlatformAdsManagerDelegate.implementation(this.params) : super(token: _token);
+
+ static final Object _token = Object();
+
+ /// The parameters used to initialize the [PlatformAdsManagerDelegate].
+ final PlatformAdsManagerDelegateCreationParams params;
+}
From 0801f4c6439ae7de7066c52a541a21940e269087 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 16:24:05 -0500
Subject: [PATCH 08/76] fix analyze warning
---
.../interactive_media_ads/test/interactive_media_ads_test.dart | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
index 0c2468db9996..88f4b8bfae0a 100644
--- a/packages/interactive_media_ads/test/interactive_media_ads_test.dart
+++ b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
@@ -4,8 +4,8 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:interactive_media_ads/interactive_media_ads.dart';
-import 'package:interactive_media_ads/interactive_media_ads_platform_interface.dart';
import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart';
+import 'package:interactive_media_ads/interactive_media_ads_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class MockInteractiveMediaAdsPlatform
From c980a804fbb00c5aa9f816f8e6c949355fe8b404 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 17:54:37 -0500
Subject: [PATCH 09/76] more impls
---
.../lib/src/ads_loader.dart | 75 +++++++++++++++++++
.../lib/src/ads_manager.dart | 75 +++++++++++++++++++
.../platform_ad_display_container.dart | 2 +-
.../platform_ads_loader.dart | 2 +-
.../platform_ads_manager.dart | 2 +-
.../platform_ads_manager_delegate.dart | 2 +-
.../platform_interface.dart | 9 +++
packages/interactive_media_ads/pubspec.yaml | 2 +-
8 files changed, 164 insertions(+), 5 deletions(-)
create mode 100644 packages/interactive_media_ads/lib/src/ads_loader.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
diff --git a/packages/interactive_media_ads/lib/src/ads_loader.dart b/packages/interactive_media_ads/lib/src/ads_loader.dart
new file mode 100644
index 000000000000..1840768b4f8e
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/ads_loader.dart
@@ -0,0 +1,75 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'platform_interface/platform_interface.dart';
+
+/// Handles playing ads after they've been received from the server.
+///
+/// ## Platform-Specific Features
+/// This class contains an underlying implementation provided by the current
+/// platform. Once a platform implementation is imported, the examples below
+/// can be followed to use features provided by a platform's implementation.
+///
+/// {@macro interactive_media_ads.AdsLoader.fromPlatformCreationParams}
+///
+/// Below is an example of accessing the platform-specific implementation for
+/// iOS and Android:
+///
+/// ```dart
+/// final AdsLoader loader = AdsLoader();
+///
+/// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+/// final IosAdsLoader iosLoader = loader.platform as IosAdsLoader;
+/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+/// final AndroidAdsLoader androidLoader =
+/// loader.platform as AndroidAdsLoader;
+/// }
+/// ```
+class AdsLoader {
+ /// Constructs an [AdsLoader].
+ ///
+ /// See [AdsLoader.fromPlatformCreationParams] for setting parameters for a
+ /// specific platform.
+ AdsLoader()
+ : this.fromPlatformCreationParams(
+ const PlatformAdsLoaderCreationParams(),
+ );
+
+ /// Constructs an [AdsLoader] from creation params for a specific platform.
+ ///
+ /// {@template interactive_media_ads.AdsLoader.fromPlatformCreationParams}
+ /// Below is an example of setting platform-specific creation parameters for
+ /// iOS and Android:
+ ///
+ /// ```dart
+ /// PlatformAdsLoaderCreationParams params =
+ /// const PlatformAdsLoaderCreationParams();
+ ///
+ /// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+ /// params = IosAdsLoaderCreationParams
+ /// .fromPlatformAdsLoaderCreationParams(
+ /// params,
+ /// );
+ /// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+ /// params = AndroidAdsLoaderCreationParams
+ /// .fromPlatformAdsLoaderCreationParams(
+ /// params,
+ /// );
+ /// }
+ ///
+ /// final AdsLoader loader = AdsLoader.fromPlatformCreationParams(
+ /// params,
+ /// );
+ /// ```
+ /// {@endtemplate}
+ AdsLoader.fromPlatformCreationParams(
+ PlatformAdsLoaderCreationParams params,
+ ) : this.fromPlatform(PlatformAdsLoader(params));
+
+ /// Constructs a [AdsLoader] from a specific platform implementation.
+ AdsLoader.fromPlatform(this.platform);
+
+ /// Implementation of [PlatformAdsLoader] for the current platform.
+ final PlatformAdsLoader platform;
+}
diff --git a/packages/interactive_media_ads/lib/src/ads_manager.dart b/packages/interactive_media_ads/lib/src/ads_manager.dart
index e69de29bb2d1..d23efdca65c0 100644
--- a/packages/interactive_media_ads/lib/src/ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/ads_manager.dart
@@ -0,0 +1,75 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'platform_interface/platform_interface.dart';
+
+/// Handles playing ads after they've been received from the server.
+///
+/// ## Platform-Specific Features
+/// This class contains an underlying implementation provided by the current
+/// platform. Once a platform implementation is imported, the examples below
+/// can be followed to use features provided by a platform's implementation.
+///
+/// {@macro interactive_media_ads.AdsManager.fromPlatformCreationParams}
+///
+/// Below is an example of accessing the platform-specific implementation for
+/// iOS and Android:
+///
+/// ```dart
+/// final AdsManager manager = AdsManager();
+///
+/// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+/// final IosAdsManager iosManager = manager.platform as WebKitAdsManager;
+/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+/// final AndroidAdsManager androidManager =
+/// manager.platform as AndroidAdsManager;
+/// }
+/// ```
+class AdsManager {
+ /// Constructs an [AdsManager].
+ ///
+ /// See [AdsManager.fromPlatformCreationParams] for setting parameters for a
+ /// specific platform.
+ AdsManager()
+ : this.fromPlatformCreationParams(
+ const PlatformAdsManagerCreationParams(),
+ );
+
+ /// Constructs an [AdsManager] from creation params for a specific platform.
+ ///
+ /// {@template interactive_media_ads.AdsManager.fromPlatformCreationParams}
+ /// Below is an example of setting platform-specific creation parameters for
+ /// iOS and Android:
+ ///
+ /// ```dart
+ /// PlatformAdsManagerCreationParams params =
+ /// const PlatformAdsManagerCreationParams();
+ ///
+ /// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+ /// params = IosAdsManagerCreationParams
+ /// .fromPlatformAdsManagerCreationParams(
+ /// params,
+ /// );
+ /// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+ /// params = AndroidAdsManagerCreationParams
+ /// .fromPlatformAdsManagerCreationParams(
+ /// params,
+ /// );
+ /// }
+ ///
+ /// final AdsManager manager = AdsManager.fromPlatformCreationParams(
+ /// params,
+ /// );
+ /// ```
+ /// {@endtemplate}
+ AdsManager.fromPlatformCreationParams(
+ PlatformAdsManagerCreationParams params,
+ ) : this.fromPlatform(PlatformAdsManager(params));
+
+ /// Constructs a [AdsManager] from a specific platform implementation.
+ AdsManager.fromPlatform(this.platform);
+
+ /// Implementation of [PlatformAdsManager] for the current platform.
+ final PlatformAdsManager platform;
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
index 95d1b3bad9f8..c2279b038710 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
@@ -40,7 +40,7 @@ import 'interactive_media_ads_platform.dart';
/// }
/// ```
@immutable
-class PlatformAdDisplayContainerCreationParams {
+base class PlatformAdDisplayContainerCreationParams {
/// Used by the platform implementation to create a new [PlatformAdDisplayContainer].
const PlatformAdDisplayContainerCreationParams();
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
index 0e13ae29ffdc..103ca52d71b3 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -39,7 +39,7 @@ import 'interactive_media_ads_platform.dart';
/// }
/// ```
@immutable
-class PlatformAdsLoaderCreationParams {
+base class PlatformAdsLoaderCreationParams {
/// Used by the platform implementation to create a new [PlatformAdsLoader].
const PlatformAdsLoaderCreationParams();
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
index 71b294724598..6bc9b602b4ea 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -39,7 +39,7 @@ import 'interactive_media_ads_platform.dart';
/// }
/// ```
@immutable
-class PlatformAdsManagerCreationParams {
+base class PlatformAdsManagerCreationParams {
/// Used by the platform implementation to create a new [PlatformAdsManager].
const PlatformAdsManagerCreationParams();
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
index 6596f0daa314..63bd8d092764 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
@@ -40,7 +40,7 @@ import 'interactive_media_ads_platform.dart';
/// }
/// ```
@immutable
-class PlatformAdsManagerDelegateCreationParams {
+base class PlatformAdsManagerDelegateCreationParams {
/// Used by the platform implementation to create a new [PlatformAdsManagerDelegate].
const PlatformAdsManagerDelegateCreationParams();
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
new file mode 100644
index 000000000000..38e035770f25
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
@@ -0,0 +1,9 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+export 'interactive_media_ads_platform.dart';
+export 'platform_ad_display_container.dart';
+export 'platform_ads_loader.dart';
+export 'platform_ads_manager.dart';
+export 'platform_ads_manager_delegate.dart';
diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml
index fe8146275640..90fc79b91b09 100644
--- a/packages/interactive_media_ads/pubspec.yaml
+++ b/packages/interactive_media_ads/pubspec.yaml
@@ -20,7 +20,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
- plugin_platform_interface: ^2.0.2
+ plugin_platform_interface: ^2.1.3
dev_dependencies:
flutter_test:
From d2bde7045b2fe5fc0cc182cedd31caff6f626456 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 17:55:40 -0500
Subject: [PATCH 10/76] use verify token
---
.../src/platform_interface/interactive_media_ads_platform.dart | 2 +-
.../src/platform_interface/platform_ad_display_container.dart | 2 +-
.../lib/src/platform_interface/platform_ads_loader.dart | 2 +-
.../lib/src/platform_interface/platform_ads_manager.dart | 2 +-
.../src/platform_interface/platform_ads_manager_delegate.dart | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
index e358a580de13..72ad4971d1ae 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
@@ -31,7 +31,7 @@ abstract class InteractiveMediaAdsPlatform extends PlatformInterface {
);
}
- PlatformInterface.verify(instance, _token);
+ PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
index c2279b038710..09c2546f9844 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
@@ -62,7 +62,7 @@ abstract class PlatformAdDisplayContainer extends PlatformInterface {
final PlatformAdDisplayContainer implementation =
InteractiveMediaAdsPlatform.instance!
.createPlatformAdDisplayContainer(params);
- PlatformInterface.verify(implementation, _token);
+ PlatformInterface.verifyToken(implementation, _token);
return implementation;
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
index 103ca52d71b3..cfdb1b6c9524 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -60,7 +60,7 @@ abstract class PlatformAdsLoader extends PlatformInterface {
);
final PlatformAdsLoader implementation =
InteractiveMediaAdsPlatform.instance!.createPlatformAdsLoader(params);
- PlatformInterface.verify(implementation, _token);
+ PlatformInterface.verifyToken(implementation, _token);
return implementation;
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
index 6bc9b602b4ea..fe78e8d9b4b2 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -61,7 +61,7 @@ abstract class PlatformAdsManager extends PlatformInterface {
final PlatformAdsManager implementation = InteractiveMediaAdsPlatform
.instance!
.createPlatformAdsManager(params);
- PlatformInterface.verify(implementation, _token);
+ PlatformInterface.verifyToken(implementation, _token);
return implementation;
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
index 63bd8d092764..821363324236 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
@@ -62,7 +62,7 @@ abstract class PlatformAdsManagerDelegate extends PlatformInterface {
final PlatformAdsManagerDelegate implementation =
InteractiveMediaAdsPlatform.instance!
.createPlatformAdsManagerDelegate(params);
- PlatformInterface.verify(implementation, _token);
+ PlatformInterface.verifyToken(implementation, _token);
return implementation;
}
From e54e56a6e70760a10611cb928b053c52ac660157 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Mon, 5 Feb 2024 18:04:46 -0500
Subject: [PATCH 11/76] add app facing interface
---
.../lib/src/ad_display_container.dart | 75 +++++++++++++++++++
.../lib/src/ads_manager_delegate.dart | 75 +++++++++++++++++++
2 files changed, 150 insertions(+)
create mode 100644 packages/interactive_media_ads/lib/src/ad_display_container.dart
create mode 100644 packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
diff --git a/packages/interactive_media_ads/lib/src/ad_display_container.dart b/packages/interactive_media_ads/lib/src/ad_display_container.dart
new file mode 100644
index 000000000000..3c86b1155e3f
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/ad_display_container.dart
@@ -0,0 +1,75 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'platform_interface/platform_interface.dart';
+
+/// Handles playing ads after they've been received from the server.
+///
+/// ## Platform-Specific Features
+/// This class contains an underlying implementation provided by the current
+/// platform. Once a platform implementation is imported, the examples below
+/// can be followed to use features provided by a platform's implementation.
+///
+/// {@macro interactive_media_ads.AdDisplayContainer.fromPlatformCreationParams}
+///
+/// Below is an example of accessing the platform-specific implementation for
+/// iOS and Android:
+///
+/// ```dart
+/// final AdDisplayContainer container = AdDisplayContainer();
+///
+/// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+/// final IosAdDisplayContainer iosContainer = container.platform as IosAdDisplayContainer;
+/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+/// final AndroidAdDisplayContainer androidContainer =
+/// container.platform as AndroidAdDisplayContainer;
+/// }
+/// ```
+class AdDisplayContainer {
+ /// Constructs an [AdDisplayContainer].
+ ///
+ /// See [AdDisplayContainer.fromPlatformCreationParams] for setting parameters for a
+ /// specific platform.
+ AdDisplayContainer()
+ : this.fromPlatformCreationParams(
+ const PlatformAdDisplayContainerCreationParams(),
+ );
+
+ /// Constructs an [AdDisplayContainer] from creation params for a specific platform.
+ ///
+ /// {@template interactive_media_ads.AdDisplayContainer.fromPlatformCreationParams}
+ /// Below is an example of setting platform-specific creation parameters for
+ /// iOS and Android:
+ ///
+ /// ```dart
+ /// PlatformAdDisplayContainerCreationParams params =
+ /// const PlatformAdDisplayContainerCreationParams();
+ ///
+ /// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+ /// params = IosAdDisplayContainerCreationParams
+ /// .fromPlatformAdDisplayContainerCreationParams(
+ /// params,
+ /// );
+ /// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+ /// params = AndroidAdDisplayContainerCreationParams
+ /// .fromPlatformAdDisplayContainerCreationParams(
+ /// params,
+ /// );
+ /// }
+ ///
+ /// final AdDisplayContainer container = AdDisplayContainer.fromPlatformCreationParams(
+ /// params,
+ /// );
+ /// ```
+ /// {@endtemplate}
+ AdDisplayContainer.fromPlatformCreationParams(
+ PlatformAdDisplayContainerCreationParams params,
+ ) : this.fromPlatform(PlatformAdDisplayContainer(params));
+
+ /// Constructs a [AdDisplayContainer] from a specific platform implementation.
+ AdDisplayContainer.fromPlatform(this.platform);
+
+ /// Implementation of [PlatformAdDisplayContainer] for the current platform.
+ final PlatformAdDisplayContainer platform;
+}
diff --git a/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
new file mode 100644
index 000000000000..ca2ef714d1b6
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
@@ -0,0 +1,75 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'platform_interface/platform_interface.dart';
+
+/// Handles playing ads after they've been received from the server.
+///
+/// ## Platform-Specific Features
+/// This class contains an underlying implementation provided by the current
+/// platform. Once a platform implementation is imported, the examples below
+/// can be followed to use features provided by a platform's implementation.
+///
+/// {@macro interactive_media_ads.AdsManagerDelegate.fromPlatformCreationParams}
+///
+/// Below is an example of accessing the platform-specific implementation for
+/// iOS and Android:
+///
+/// ```dart
+/// final AdsManagerDelegate delegate = AdsManagerDelegate();
+///
+/// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+/// final IosAdsManagerDelegate iosDelegate = delegate.platform as IosAdsManagerDelegate;
+/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+/// final AndroidAdsManagerDelegate androidDelegate =
+/// delegate.platform as AndroidAdsManagerDelegate;
+/// }
+/// ```
+class AdsManagerDelegate {
+ /// Constructs an [AdsManagerDelegate].
+ ///
+ /// See [AdsManagerDelegate.fromPlatformCreationParams] for setting parameters for a
+ /// specific platform.
+ AdsManagerDelegate()
+ : this.fromPlatformCreationParams(
+ const PlatformAdsManagerDelegateCreationParams(),
+ );
+
+ /// Constructs an [AdsManagerDelegate] from creation params for a specific platform.
+ ///
+ /// {@template interactive_media_ads.AdsManagerDelegate.fromPlatformCreationParams}
+ /// Below is an example of setting platform-specific creation parameters for
+ /// iOS and Android:
+ ///
+ /// ```dart
+ /// PlatformAdsManagerDelegateCreationParams params =
+ /// const PlatformAdsManagerDelegateCreationParams();
+ ///
+ /// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+ /// params = IosAdsManagerDelegateCreationParams
+ /// .fromPlatformAdsManagerDelegateCreationParams(
+ /// params,
+ /// );
+ /// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+ /// params = AndroidAdsManagerDelegateCreationParams
+ /// .fromPlatformAdsManagerDelegateCreationParams(
+ /// params,
+ /// );
+ /// }
+ ///
+ /// final AdsManagerDelegate delegate = AdsManagerDelegate.fromPlatformCreationParams(
+ /// params,
+ /// );
+ /// ```
+ /// {@endtemplate}
+ AdsManagerDelegate.fromPlatformCreationParams(
+ PlatformAdsManagerDelegateCreationParams params,
+ ) : this.fromPlatform(PlatformAdsManagerDelegate(params));
+
+ /// Constructs a [AdsManagerDelegate] from a specific platform implementation.
+ AdsManagerDelegate.fromPlatform(this.platform);
+
+ /// Implementation of [PlatformAdsManagerDelegate] for the current platform.
+ final PlatformAdsManagerDelegate platform;
+}
From e4bdf4515c259b7fa378359ff29da865ac1ce562 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 6 Feb 2024 14:29:15 -0500
Subject: [PATCH 12/76] implementation of addisplaycontainer
---
.../lib/src/ad_display_container.dart | 43 +++++++---
.../platform_ad_display_container.dart | 20 ++++-
.../platform_ads_loader.dart | 2 +-
.../platform_ads_manager.dart | 80 ++++---------------
.../test/interactive_media_ads_test.dart | 13 ---
5 files changed, 67 insertions(+), 91 deletions(-)
diff --git a/packages/interactive_media_ads/lib/src/ad_display_container.dart b/packages/interactive_media_ads/lib/src/ad_display_container.dart
index 3c86b1155e3f..5d924019635e 100644
--- a/packages/interactive_media_ads/lib/src/ad_display_container.dart
+++ b/packages/interactive_media_ads/lib/src/ad_display_container.dart
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:flutter/cupertino.dart';
+
+import 'platform_interface/platform_ad_display_container.dart';
import 'platform_interface/platform_interface.dart';
/// Handles playing ads after they've been received from the server.
@@ -26,14 +29,23 @@ import 'platform_interface/platform_interface.dart';
/// container.platform as AndroidAdDisplayContainer;
/// }
/// ```
-class AdDisplayContainer {
+class AdDisplayContainer extends StatelessWidget {
/// Constructs an [AdDisplayContainer].
///
/// See [AdDisplayContainer.fromPlatformCreationParams] for setting parameters for a
/// specific platform.
- AdDisplayContainer()
- : this.fromPlatformCreationParams(
- const PlatformAdDisplayContainerCreationParams(),
+ AdDisplayContainer({
+ Key? key,
+ required void Function(AdDisplayContainer container) onContainerAdded,
+ }) : this.fromPlatformCreationParams(
+ key: key,
+ params: PlatformAdDisplayContainerCreationParams(
+ onContainerAdded: (PlatformAdDisplayContainer container) {
+ onContainerAdded(AdDisplayContainer.fromPlatform(
+ platform: container,
+ ));
+ },
+ ),
);
/// Constructs an [AdDisplayContainer] from creation params for a specific platform.
@@ -63,13 +75,26 @@ class AdDisplayContainer {
/// );
/// ```
/// {@endtemplate}
- AdDisplayContainer.fromPlatformCreationParams(
- PlatformAdDisplayContainerCreationParams params,
- ) : this.fromPlatform(PlatformAdDisplayContainer(params));
+ AdDisplayContainer.fromPlatformCreationParams({
+ Key? key,
+ required PlatformAdDisplayContainerCreationParams params,
+ }) : this.fromPlatform(
+ key: key,
+ platform: PlatformAdDisplayContainer(params),
+ );
- /// Constructs a [AdDisplayContainer] from a specific platform implementation.
- AdDisplayContainer.fromPlatform(this.platform);
+ /// Constructs an [AdDisplayContainer] from a specific platform
+ /// implementation.
+ const AdDisplayContainer.fromPlatform({super.key, required this.platform});
/// Implementation of [PlatformAdDisplayContainer] for the current platform.
final PlatformAdDisplayContainer platform;
+
+ void Function(PlatformAdDisplayContainer container) get onContainerAdded =>
+ platform.params.onContainerAdded;
+
+ @override
+ Widget build(BuildContext context) {
+ return platform.build(context);
+ }
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
index 09c2546f9844..c39984b9e702 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter/foundation.dart';
+import 'package:flutter/cupertino.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'interactive_media_ads_platform.dart';
@@ -41,8 +41,20 @@ import 'interactive_media_ads_platform.dart';
/// ```
@immutable
base class PlatformAdDisplayContainerCreationParams {
- /// Used by the platform implementation to create a new [PlatformAdDisplayContainer].
- const PlatformAdDisplayContainerCreationParams();
+ /// Used by the platform implementation to create a new
+ /// [PlatformAdDisplayContainer].
+ const PlatformAdDisplayContainerCreationParams({
+ this.key,
+ required this.onContainerAdded,
+ });
+
+ /// Controls how one widget replaces another widget in the tree.
+ ///
+ /// See also:
+ /// * The discussions at [Key] and [GlobalKey].
+ final Key? key;
+
+ final void Function(PlatformAdDisplayContainer container) onContainerAdded;
}
/// Interface for a platform implementation of a `AdDisplayContainer`.
@@ -77,4 +89,6 @@ abstract class PlatformAdDisplayContainer extends PlatformInterface {
/// The parameters used to initialize the [PlatformAdDisplayContainer].
final PlatformAdDisplayContainerCreationParams params;
+
+ Widget build(BuildContext context);
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
index cfdb1b6c9524..20a912c3ad4a 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -44,7 +44,7 @@ base class PlatformAdsLoaderCreationParams {
const PlatformAdsLoaderCreationParams();
}
-/// Interface for a platform implementation of a `AdsLoader`.
+/// Interface for a platform implementation of an `AdsLoader`.
abstract class PlatformAdsLoader extends PlatformInterface {
/// Creates a new [PlatformAdsLoader]
factory PlatformAdsLoader(
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
index fe78e8d9b4b2..ebf52a32ef21 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -3,77 +3,27 @@
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
-import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-import 'interactive_media_ads_platform.dart';
+import 'platform_ads_manager_delegate.dart';
+
+base class AdsManagerInitParams {
-/// Object specifying creation parameters for creating a [PlatformAdsManager].
-///
-/// Platform specific implementations can add additional fields by extending
-/// this class.
-///
-/// This example demonstrates how to extend the
-/// [PlatformAdsManagerCreationParams] to provide additional platform specific
-/// parameters.
-///
-/// When extending [PlatformAdsManagerCreationParams] additional parameters
-/// should always accept `null` or have a default value to prevent breaking
-/// changes.
-///
-/// ```dart
-/// class AndroidPlatformAdsManagerCreationParams
-/// extends PlatformAdsManagerCreationParams {
-/// AndroidPlatformAdsManagerCreationParams._(
-/// PlatformAdsManagerCreationParams params, {
-/// this.uri,
-/// }) : super();
-///
-/// factory AndroidAdsManagerCreationParams.fromPlatformAdsManagerCreationParams(
-/// PlatformAdsManagerCreationParams params, {
-/// Uri? uri,
-/// }) {
-/// return AndroidAdsManagerCreationParams._(params, uri: uri);
-/// }
-///
-/// final Uri? uri;
-/// }
-/// ```
-@immutable
-base class PlatformAdsManagerCreationParams {
- /// Used by the platform implementation to create a new [PlatformAdsManager].
- const PlatformAdsManagerCreationParams();
}
-/// Interface for a platform implementation of a `AdsManager`.
-abstract class PlatformAdsManager extends PlatformInterface {
- /// Creates a new [PlatformAdsManager]
- factory PlatformAdsManager(
- PlatformAdsManagerCreationParams params,
- ) {
- assert(
- InteractiveMediaAdsPlatform.instance != null,
- 'A platform implementation for `interactive_media_ads` has not been set. '
- 'Please ensure that an implementation of `InteractiveMediaAdsPlatform` '
- 'has been set to `InteractiveMediaAdsPlatform.instance` before use. For '
- 'unit testing, `InteractiveMediaAdsPlatform.instance` can be set with '
- 'your own test implementation.',
- );
- final PlatformAdsManager implementation = InteractiveMediaAdsPlatform
- .instance!
- .createPlatformAdsManager(params);
- PlatformInterface.verifyToken(implementation, _token);
- return implementation;
- }
+base class AdsManagerStartParams {
+
+}
- /// Used by the platform implementation to create a new [PlatformAdsManager].
- ///
- /// Should only be used by platform implementations because they can't extend
- /// a class that only contains a factory constructor.
+/// Interface for a platform implementation of a `AdsManager`.
+abstract base class PlatformAdsManager {
@protected
- PlatformAdsManager.implementation(this.params) : super(token: _token);
+ PlatformAdsManager();
+
+ void init(AdsManagerInitParams params);
+
+ void start(AdsManagerStartParams params);
- static final Object _token = Object();
+ void setAdsManagerDelegate(PlatformAdsManagerDelegate delegate);
- /// The parameters used to initialize the [PlatformAdsManager].
- final PlatformAdsManagerCreationParams params;
+ void destroy();
}
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
index 88f4b8bfae0a..2c0dc349879a 100644
--- a/packages/interactive_media_ads/test/interactive_media_ads_test.dart
+++ b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
@@ -8,13 +8,6 @@ import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart'
import 'package:interactive_media_ads/interactive_media_ads_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-class MockInteractiveMediaAdsPlatform
- with MockPlatformInterfaceMixin
- implements InteractiveMediaAdsPlatform {
- @override
- Future getPlatformVersion() => Future.value('42');
-}
-
void main() {
final InteractiveMediaAdsPlatform initialPlatform =
InteractiveMediaAdsPlatform.instance;
@@ -24,11 +17,5 @@ void main() {
});
test('getPlatformVersion', () async {
- final InteractiveMediaAds interactiveMediaAdsPlugin = InteractiveMediaAds();
- final MockInteractiveMediaAdsPlatform fakePlatform =
- MockInteractiveMediaAdsPlatform();
- InteractiveMediaAdsPlatform.instance = fakePlatform;
-
- expect(await interactiveMediaAdsPlugin.getPlatformVersion(), '42');
});
}
From bab7c98e567f69e2c9267a3303cac8fbd888ece0 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 6 Feb 2024 15:28:09 -0500
Subject: [PATCH 13/76] connect app facing to platform interface
---
.../lib/src/ads_loader.dart | 76 ++++++++++++++++++-
.../lib/src/ads_manager.dart | 75 ------------------
.../lib/src/ads_manager_delegate.dart | 16 +++-
.../interactive_media_ads_platform.dart | 10 ---
.../platform_ads_loader.dart | 34 ++++++++-
.../platform_ads_manager.dart | 8 +-
.../platform_ads_manager_delegate.dart | 15 +++-
.../lib/src/types/ads_request.dart | 3 +
8 files changed, 140 insertions(+), 97 deletions(-)
delete mode 100644 packages/interactive_media_ads/lib/src/ads_manager.dart
create mode 100644 packages/interactive_media_ads/lib/src/types/ads_request.dart
diff --git a/packages/interactive_media_ads/lib/src/ads_loader.dart b/packages/interactive_media_ads/lib/src/ads_loader.dart
index 1840768b4f8e..14b3dc44d462 100644
--- a/packages/interactive_media_ads/lib/src/ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/ads_loader.dart
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:flutter/foundation.dart';
+
+import 'ad_display_container.dart';
+import 'ads_manager_delegate.dart';
import 'platform_interface/platform_interface.dart';
/// Handles playing ads after they've been received from the server.
@@ -31,9 +35,22 @@ class AdsLoader {
///
/// See [AdsLoader.fromPlatformCreationParams] for setting parameters for a
/// specific platform.
- AdsLoader()
- : this.fromPlatformCreationParams(
- const PlatformAdsLoaderCreationParams(),
+ AdsLoader({
+ required AdDisplayContainer container,
+ required void Function(OnAdsLoadedData data) onAdsLoaded,
+ required void Function(AdsLoadErrorData data) onAdsLoadError,
+ }) : this.fromPlatformCreationParams(
+ PlatformAdsLoaderCreationParams(
+ container: container.platform,
+ onAdsLoaded: (PlatformOnAdsLoadedData data) {
+ onAdsLoaded(
+ OnAdsLoadedData._(
+ manager: AdsManager._fromPlatform(data.manager),
+ ),
+ );
+ },
+ onAdsLoadError: onAdsLoadError,
+ ),
);
/// Constructs an [AdsLoader] from creation params for a specific platform.
@@ -73,3 +90,56 @@ class AdsLoader {
/// Implementation of [PlatformAdsLoader] for the current platform.
final PlatformAdsLoader platform;
}
+
+@immutable
+class OnAdsLoadedData {
+ const OnAdsLoadedData._({required this.manager});
+
+ final AdsManager manager;
+}
+
+/// Handles playing ads after they've been received from the server.
+///
+/// ## Platform-Specific Features
+/// This class contains an underlying implementation provided by the current
+/// platform. Once a platform implementation is imported, the examples below
+/// can be followed to use features provided by a platform's implementation.
+///
+/// {@macro interactive_media_ads.AdsManager.fromPlatformCreationParams}
+///
+/// Below is an example of accessing the platform-specific implementation for
+/// iOS and Android:
+///
+/// ```dart
+/// final AdsManager manager = AdsManager();
+///
+/// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
+/// final IosAdsManager iosManager = manager.platform as IosAdsManager;
+/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
+/// final AndroidAdsManager androidManager =
+/// manager.platform as AndroidAdsManager;
+/// }
+/// ```
+class AdsManager {
+ /// Constructs a [AdsManager] from a specific platform implementation.
+ AdsManager._fromPlatform(this.platform);
+
+ /// Implementation of [PlatformAdsManager] for the current platform.
+ final PlatformAdsManager platform;
+
+ Future init() {
+ return platform.init(AdsManagerInitParams());
+ }
+
+ Future start() {
+ return platform.start(AdsManagerStartParams());
+ }
+
+ Future setAdsManagerDelegate(AdsManagerDelegate delegate) {
+ return platform.setAdsManagerDelegate(delegate.platform);
+ }
+
+ Future destroy() {
+ return platform.destroy();
+ }
+}
diff --git a/packages/interactive_media_ads/lib/src/ads_manager.dart b/packages/interactive_media_ads/lib/src/ads_manager.dart
deleted file mode 100644
index d23efdca65c0..000000000000
--- a/packages/interactive_media_ads/lib/src/ads_manager.dart
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'platform_interface/platform_interface.dart';
-
-/// Handles playing ads after they've been received from the server.
-///
-/// ## Platform-Specific Features
-/// This class contains an underlying implementation provided by the current
-/// platform. Once a platform implementation is imported, the examples below
-/// can be followed to use features provided by a platform's implementation.
-///
-/// {@macro interactive_media_ads.AdsManager.fromPlatformCreationParams}
-///
-/// Below is an example of accessing the platform-specific implementation for
-/// iOS and Android:
-///
-/// ```dart
-/// final AdsManager manager = AdsManager();
-///
-/// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
-/// final IosAdsManager iosManager = manager.platform as WebKitAdsManager;
-/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
-/// final AndroidAdsManager androidManager =
-/// manager.platform as AndroidAdsManager;
-/// }
-/// ```
-class AdsManager {
- /// Constructs an [AdsManager].
- ///
- /// See [AdsManager.fromPlatformCreationParams] for setting parameters for a
- /// specific platform.
- AdsManager()
- : this.fromPlatformCreationParams(
- const PlatformAdsManagerCreationParams(),
- );
-
- /// Constructs an [AdsManager] from creation params for a specific platform.
- ///
- /// {@template interactive_media_ads.AdsManager.fromPlatformCreationParams}
- /// Below is an example of setting platform-specific creation parameters for
- /// iOS and Android:
- ///
- /// ```dart
- /// PlatformAdsManagerCreationParams params =
- /// const PlatformAdsManagerCreationParams();
- ///
- /// if (InteractiveMediaAdsPlatform.instance is IosInteractiveMediaAdsPlatform) {
- /// params = IosAdsManagerCreationParams
- /// .fromPlatformAdsManagerCreationParams(
- /// params,
- /// );
- /// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
- /// params = AndroidAdsManagerCreationParams
- /// .fromPlatformAdsManagerCreationParams(
- /// params,
- /// );
- /// }
- ///
- /// final AdsManager manager = AdsManager.fromPlatformCreationParams(
- /// params,
- /// );
- /// ```
- /// {@endtemplate}
- AdsManager.fromPlatformCreationParams(
- PlatformAdsManagerCreationParams params,
- ) : this.fromPlatform(PlatformAdsManager(params));
-
- /// Constructs a [AdsManager] from a specific platform implementation.
- AdsManager.fromPlatform(this.platform);
-
- /// Implementation of [PlatformAdsManager] for the current platform.
- final PlatformAdsManager platform;
-}
diff --git a/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
index ca2ef714d1b6..9d88eefcd5a7 100644
--- a/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
+++ b/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
@@ -31,9 +31,14 @@ class AdsManagerDelegate {
///
/// See [AdsManagerDelegate.fromPlatformCreationParams] for setting parameters for a
/// specific platform.
- AdsManagerDelegate()
- : this.fromPlatformCreationParams(
- const PlatformAdsManagerDelegateCreationParams(),
+ AdsManagerDelegate({
+ void Function(AdEvent event)? onAdEvent,
+ void Function(AdErrorEvent event)? onAdErrorEvent,
+ }) : this.fromPlatformCreationParams(
+ PlatformAdsManagerDelegateCreationParams(
+ onAdEvent: onAdEvent,
+ onAdErrorEvent: onAdErrorEvent,
+ ),
);
/// Constructs an [AdsManagerDelegate] from creation params for a specific platform.
@@ -72,4 +77,9 @@ class AdsManagerDelegate {
/// Implementation of [PlatformAdsManagerDelegate] for the current platform.
final PlatformAdsManagerDelegate platform;
+
+ void Function(AdEvent event)? get onAdEvent => platform.params.onAdEvent;
+
+ void Function(AdErrorEvent event)? get onAdErrorEvent =>
+ platform.params.onAdErrorEvent;
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
index 72ad4971d1ae..c0e4e60de32b 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart
@@ -6,7 +6,6 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'platform_ad_display_container.dart';
import 'platform_ads_loader.dart';
-import 'platform_ads_manager.dart';
import 'platform_ads_manager_delegate.dart';
/// Interface for a platform implementation of the Interactive Media Ads SDKs.
@@ -35,15 +34,6 @@ abstract class InteractiveMediaAdsPlatform extends PlatformInterface {
_instance = instance;
}
- /// Creates a new [PlatformAdsManager].
- PlatformAdsManager createPlatformAdsManager(
- PlatformAdsManagerCreationParams params,
- ) {
- throw UnimplementedError(
- 'createPlatformAdsManager is not implemented on the current platform.',
- );
- }
-
/// Creates a new [PlatformAdsLoader].
PlatformAdsLoader createPlatformAdsLoader(
PlatformAdsLoaderCreationParams params,
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
index 20a912c3ad4a..b3048bb55491 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'interactive_media_ads_platform.dart';
+import 'platform_ad_display_container.dart';
+import 'platform_ads_manager.dart';
/// Object specifying creation parameters for creating a [PlatformAdsLoader].
///
@@ -41,7 +43,15 @@ import 'interactive_media_ads_platform.dart';
@immutable
base class PlatformAdsLoaderCreationParams {
/// Used by the platform implementation to create a new [PlatformAdsLoader].
- const PlatformAdsLoaderCreationParams();
+ const PlatformAdsLoaderCreationParams({
+ required this.container,
+ required this.onAdsLoaded,
+ required this.onAdsLoadError,
+ });
+
+ final PlatformAdDisplayContainer container;
+ final void Function(PlatformOnAdsLoadedData data) onAdsLoaded;
+ final void Function(AdsLoadErrorData data) onAdsLoadError;
}
/// Interface for a platform implementation of an `AdsLoader`.
@@ -75,4 +85,26 @@ abstract class PlatformAdsLoader extends PlatformInterface {
/// The parameters used to initialize the [PlatformAdsLoader].
final PlatformAdsLoaderCreationParams params;
+
+ Future contentComplete() {
+ throw UnimplementedError(
+ 'contentComplete is not implemented on the current platform',
+ );
+ }
+
+ Future request() {
+ throw UnimplementedError(
+ 'request is not implemented on the current platform',
+ );
+ }
}
+
+@immutable
+class PlatformOnAdsLoadedData {
+ PlatformOnAdsLoadedData({required this.manager});
+
+ final PlatformAdsManager manager;
+}
+
+@immutable
+class AdsLoadErrorData {}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
index ebf52a32ef21..7b0c0a065661 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -19,11 +19,11 @@ abstract base class PlatformAdsManager {
@protected
PlatformAdsManager();
- void init(AdsManagerInitParams params);
+ Future init(AdsManagerInitParams params);
- void start(AdsManagerStartParams params);
+ Future start(AdsManagerStartParams params);
- void setAdsManagerDelegate(PlatformAdsManagerDelegate delegate);
+ Future setAdsManagerDelegate(PlatformAdsManagerDelegate delegate);
- void destroy();
+ Future destroy();
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
index 821363324236..a50def96fdae 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
@@ -42,7 +42,14 @@ import 'interactive_media_ads_platform.dart';
@immutable
base class PlatformAdsManagerDelegateCreationParams {
/// Used by the platform implementation to create a new [PlatformAdsManagerDelegate].
- const PlatformAdsManagerDelegateCreationParams();
+ PlatformAdsManagerDelegateCreationParams({
+ this.onAdEvent,
+ this.onAdErrorEvent,
+ });
+
+ void Function(AdEvent event)? onAdEvent;
+
+ void Function(AdErrorEvent event)? onAdErrorEvent;
}
/// Interface for a platform implementation of a `AdsManagerDelegate`.
@@ -79,3 +86,9 @@ abstract class PlatformAdsManagerDelegate extends PlatformInterface {
/// The parameters used to initialize the [PlatformAdsManagerDelegate].
final PlatformAdsManagerDelegateCreationParams params;
}
+
+@immutable
+class AdEvent {}
+
+@immutable
+class AdErrorEvent {}
diff --git a/packages/interactive_media_ads/lib/src/types/ads_request.dart b/packages/interactive_media_ads/lib/src/types/ads_request.dart
new file mode 100644
index 000000000000..967430696e69
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/types/ads_request.dart
@@ -0,0 +1,3 @@
+class AdsRequest {
+
+}
\ No newline at end of file
From 645753ade11e64e31db5ecbda98aba909f713ffb Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 6 Feb 2024 16:06:28 -0500
Subject: [PATCH 14/76] stuff
---
packages/interactive_media_ads/AUTHORS | 2 +-
.../platform_ad_display_container.dart | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/packages/interactive_media_ads/AUTHORS b/packages/interactive_media_ads/AUTHORS
index 8c0344813dc1..557dff97933b 100644
--- a/packages/interactive_media_ads/AUTHORS
+++ b/packages/interactive_media_ads/AUTHORS
@@ -3,4 +3,4 @@
#
# Name/Organization
-Google Inc.
\ No newline at end of file
+Google Inc.
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
index c39984b9e702..763ec24b7084 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ad_display_container.dart
@@ -54,10 +54,13 @@ base class PlatformAdDisplayContainerCreationParams {
/// * The discussions at [Key] and [GlobalKey].
final Key? key;
+ /// Invoked when the View that contains the ad has been added to the platform
+ /// view hierarchy.
final void Function(PlatformAdDisplayContainer container) onContainerAdded;
}
-/// Interface for a platform implementation of a `AdDisplayContainer`.
+/// The interface for a platform implementation for a container in which to
+/// display ads.
abstract class PlatformAdDisplayContainer extends PlatformInterface {
/// Creates a new [PlatformAdDisplayContainer]
factory PlatformAdDisplayContainer(
@@ -78,7 +81,8 @@ abstract class PlatformAdDisplayContainer extends PlatformInterface {
return implementation;
}
- /// Used by the platform implementation to create a new [PlatformAdDisplayContainer].
+ /// Used by the platform implementation to create a new
+ /// [PlatformAdDisplayContainer].
///
/// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor.
@@ -90,5 +94,6 @@ abstract class PlatformAdDisplayContainer extends PlatformInterface {
/// The parameters used to initialize the [PlatformAdDisplayContainer].
final PlatformAdDisplayContainerCreationParams params;
+ /// Builds the Widget that contains the native View.
Widget build(BuildContext context);
}
From 3c600122c879ceab9efcf84e6deff1d43e025f15 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 14:11:01 -0500
Subject: [PATCH 15/76] add documentation
---
.../lib/interactive_media_ads.dart | 15 +-
.../interactive_media_ads_method_channel.dart | 25 ---
...eractive_media_ads_platform_interface.dart | 36 ----
.../lib/src/ad_display_container.dart | 1 +
.../lib/src/ads_loader.dart | 8 +
.../lib/src/ads_manager_delegate.dart | 3 +
.../lib/src/platform_interface/ad_error.dart | 156 ++++++++++++++++++
.../lib/src/platform_interface/ad_event.dart | 53 ++++++
.../ads_request.dart | 0
.../platform_ads_loader.dart | 33 +++-
.../platform_ads_manager.dart | 19 ++-
.../platform_ads_manager_delegate.dart | 16 +-
.../platform_interface.dart | 2 +
13 files changed, 275 insertions(+), 92 deletions(-)
delete mode 100644 packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
delete mode 100644 packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/ad_error.dart
create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/ad_event.dart
rename packages/interactive_media_ads/lib/src/{types => platform_interface}/ads_request.dart (100%)
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart
index c803464a245a..185d304cf5bc 100644
--- a/packages/interactive_media_ads/lib/interactive_media_ads.dart
+++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart
@@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// ignore_for_file: public_member_api_docs
-
-import 'interactive_media_ads_platform_interface.dart';
-
-class InteractiveMediaAds {
- Future getPlatformVersion() {
- return InteractiveMediaAdsPlatform.instance.getPlatformVersion();
- }
-}
+export 'src/ad_display_container.dart';
+export 'src/ads_loader.dart';
+export 'src/ads_manager_delegate.dart';
+export 'src/platform_interface/ad_error.dart';
+export 'src/platform_interface/ad_event.dart';
+export 'src/platform_interface/ads_request.dart';
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart b/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
deleted file mode 100644
index af55cdb1431d..000000000000
--- a/packages/interactive_media_ads/lib/interactive_media_ads_method_channel.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// ignore_for_file: public_member_api_docs
-
-import 'package:flutter/foundation.dart';
-import 'package:flutter/services.dart';
-
-import 'interactive_media_ads_platform_interface.dart';
-
-/// An implementation of [InteractiveMediaAdsPlatform] that uses method channels.
-class MethodChannelInteractiveMediaAds extends InteractiveMediaAdsPlatform {
- /// The method channel used to interact with the native platform.
- @visibleForTesting
- final MethodChannel methodChannel =
- const MethodChannel('interactive_media_ads');
-
- @override
- Future getPlatformVersion() async {
- final String? version =
- await methodChannel.invokeMethod('getPlatformVersion');
- return version;
- }
-}
diff --git a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart b/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
deleted file mode 100644
index 34fb9577f811..000000000000
--- a/packages/interactive_media_ads/lib/interactive_media_ads_platform_interface.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// ignore_for_file: public_member_api_docs
-
-import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-
-import 'interactive_media_ads_method_channel.dart';
-
-abstract class InteractiveMediaAdsPlatform extends PlatformInterface {
- /// Constructs a InteractiveMediaAdsPlatform.
- InteractiveMediaAdsPlatform() : super(token: _token);
-
- static final Object _token = Object();
-
- static InteractiveMediaAdsPlatform _instance =
- MethodChannelInteractiveMediaAds();
-
- /// The default instance of [InteractiveMediaAdsPlatform] to use.
- ///
- /// Defaults to [MethodChannelInteractiveMediaAds].
- static InteractiveMediaAdsPlatform get instance => _instance;
-
- /// Platform-specific implementations should set this with their own
- /// platform-specific class that extends [InteractiveMediaAdsPlatform] when
- /// they register themselves.
- static set instance(InteractiveMediaAdsPlatform instance) {
- PlatformInterface.verifyToken(instance, _token);
- _instance = instance;
- }
-
- Future getPlatformVersion() {
- throw UnimplementedError('platformVersion() has not been implemented.');
- }
-}
diff --git a/packages/interactive_media_ads/lib/src/ad_display_container.dart b/packages/interactive_media_ads/lib/src/ad_display_container.dart
index 5d924019635e..7b8e8e125270 100644
--- a/packages/interactive_media_ads/lib/src/ad_display_container.dart
+++ b/packages/interactive_media_ads/lib/src/ad_display_container.dart
@@ -90,6 +90,7 @@ class AdDisplayContainer extends StatelessWidget {
/// Implementation of [PlatformAdDisplayContainer] for the current platform.
final PlatformAdDisplayContainer platform;
+ /// When
void Function(PlatformAdDisplayContainer container) get onContainerAdded =>
platform.params.onContainerAdded;
diff --git a/packages/interactive_media_ads/lib/src/ads_loader.dart b/packages/interactive_media_ads/lib/src/ads_loader.dart
index 14b3dc44d462..be3c1d8ea71b 100644
--- a/packages/interactive_media_ads/lib/src/ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/ads_loader.dart
@@ -91,10 +91,13 @@ class AdsLoader {
final PlatformAdsLoader platform;
}
+/// Data when ads are successfully loaded from the ad server through an
+/// [AdsLoader].
@immutable
class OnAdsLoadedData {
const OnAdsLoadedData._({required this.manager});
+ /// The ads manager instance created by the ads loader.
final AdsManager manager;
}
@@ -127,18 +130,23 @@ class AdsManager {
/// Implementation of [PlatformAdsManager] for the current platform.
final PlatformAdsManager platform;
+ /// Initializes the ad experience using default rendering settings.
Future init() {
return platform.init(AdsManagerInitParams());
}
+ /// Starts playing the ads.
Future start() {
return platform.start(AdsManagerStartParams());
}
+ /// The [AdsManagerDelegate] to notify with events during ad playback.
Future setAdsManagerDelegate(AdsManagerDelegate delegate) {
return platform.setAdsManagerDelegate(delegate.platform);
}
+ /// Stops the ad and all tracking, then releases all assets that were loaded
+ /// to play the ad.
Future destroy() {
return platform.destroy();
}
diff --git a/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
index 9d88eefcd5a7..bbf032326291 100644
--- a/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
+++ b/packages/interactive_media_ads/lib/src/ads_manager_delegate.dart
@@ -78,8 +78,11 @@ class AdsManagerDelegate {
/// Implementation of [PlatformAdsManagerDelegate] for the current platform.
final PlatformAdsManagerDelegate platform;
+ /// Invoked when there is an [AdEvent].
void Function(AdEvent event)? get onAdEvent => platform.params.onAdEvent;
+ /// Invoked when there was an error playing the ad. Log the error and resume
+ /// playing content.
void Function(AdErrorEvent event)? get onAdErrorEvent =>
platform.params.onAdErrorEvent;
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/ad_error.dart b/packages/interactive_media_ads/lib/src/platform_interface/ad_error.dart
new file mode 100644
index 000000000000..ca89e967307b
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/ad_error.dart
@@ -0,0 +1,156 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/foundation.dart';
+
+/// The types of errors that can be encountered when loading an ad.
+enum AdErrorCode {
+ /// Generic invalid usage of the API.
+ apiError,
+
+ /// Ads player was not provided.
+ adsPlayerNotProvided,
+
+ /// There was a problem requesting ads from the server.
+ adsRequestNetworkError,
+
+ /// The ad slot is not visible on the page.
+ adslotNotVisible,
+
+ /// There was a problem requesting ads from the server.
+ companionAdLoadingFailed,
+
+ /// Content playhead was not passed in, but list of ads has been returned from
+ /// the server.
+ contentPlayheadMissing,
+
+ /// There was a problem requesting ads from the server.
+ failedToRequestAds,
+
+ /// There was an error loading the ad.
+ failedLoadingAd,
+
+ /// An error internal to the SDK occurred.
+ ///
+ /// More information may be available in the details.
+ internalError,
+
+ /// Invalid arguments were provided to SDK methods.
+ invalidArguments,
+
+ /// The version of the runtime is too old.
+ osRuntimeTooOld,
+
+ /// An overlay ad failed to load.
+ overlayAdLoadingFailed,
+
+ /// An overlay ad failed to render.
+ overlayAdPlayingFailed,
+
+ /// Ads list was returned but ContentProgressProvider was not configured.
+ playlistNoContentTracking,
+
+ /// Ads list response was malformed.
+ playlistMalformedResponse,
+
+ /// Listener for at least one of the required vast events was not added.
+ requiredListenersNotAdded,
+
+ /// There was an error initializing the stream.
+ streamInitializationFailed,
+
+ /// Ads loader sent ads loaded event when it was not expected.
+ unexpectedAdsLoadedEvent,
+
+ /// The ad response was not understood and cannot be parsed.
+ unknownAdResponse,
+
+ /// An unexpected error occurred and the cause is not known.
+ ///
+ /// Refer to the inner error for more information.
+ unknownError,
+
+ /// No assets were found in the VAST ad response.
+ vastAssetNotFound,
+
+ /// A VAST response containing a single tag with no child tags.
+ vastEmptyResponse,
+
+ /// Assets were found in the VAST ad response for a linear ad, but none of
+ /// them matched the video player's capabilities.
+ vastLinearAssetMismatch,
+
+ /// At least one VAST wrapper ad loaded successfully and a subsequent wrapper
+ /// or inline ad load has timed out.
+ vastLoadTimeout,
+
+ /// The ad response was not recognized as a valid VAST ad.
+ vastMalformedResponse,
+
+ /// Failed to load media assets from a VAST response.
+ ///
+ /// The default timeout for media loading is 8 seconds.
+ vastMediaLoadTimeout,
+
+ /// Assets were found in the VAST ad response for a nonlinear ad, but none of
+ /// them matched the video player's capabilities.
+ vastNonlinearAssetMismatch,
+
+ /// No Ads VAST response after one or more wrappers.
+ vastNoAdsAfterWrapper,
+
+ /// The maximum number of VAST wrapper redirects has been reached.
+ vastTooManyRedirects,
+
+ /// Trafficking error.
+ ///
+ /// Video player received an ad type that it was not expecting and/or cannot
+ /// display.
+ vastTraffickingError,
+
+ /// At least one VAST wrapper loaded and a subsequent wrapper or inline ad
+ /// load has resulted in a 404 response code.
+ vastInvalidUrl,
+
+ /// There was an error playing the video ad.
+ videoPlayError,
+
+ /// Another VideoAdsManager is still using the video.
+ ///
+ /// It must be unloaded before another ad can play on the same element.
+ videoElementUsed,
+
+ /// A video element was not specified where it was required.
+ videoElementRequired,
+}
+
+/// Possible error types while loading or playing ads.
+enum AdErrorType {
+ /// Indicates an error occurred while loading the ads.
+ loading,
+
+ /// Indicates an error occurred while playing the ads.
+ playing,
+
+ /// An unexpected error occurred while loading or playing the ads.
+ ///
+ /// This may mean that the SDK wasn’t loaded properly.
+ unknown,
+}
+
+/// Surfaces an error that occurred during ad loading or playing.
+@immutable
+class AdError {
+ /// Creates a [AdError].
+ const AdError({required this.type, required this.code, this.message});
+
+ /// Specifies the source of the error.
+ final AdErrorType type;
+
+ /// The error code for obtaining more specific information about the error.
+ final AdErrorCode code;
+
+ /// A brief description about the error.
+ final String? message;
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/ad_event.dart b/packages/interactive_media_ads/lib/src/platform_interface/ad_event.dart
new file mode 100644
index 000000000000..9824d9915fb3
--- /dev/null
+++ b/packages/interactive_media_ads/lib/src/platform_interface/ad_event.dart
@@ -0,0 +1,53 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/foundation.dart';
+
+import 'ad_error.dart';
+
+/// Types of events that can occur during ad playback.
+enum AdEventType {
+ /// Fired when the ads manager is done playing all the valid ads in the ads
+ /// response, or when the response doesn't return any valid ads.
+ allAdsCompleted,
+
+ /// Fired when an ad is clicked.
+ clicked,
+
+ /// Fired when an ad completes playing.
+ complete,
+
+ /// Fired when content should be paused.
+ ///
+ /// This usually happens right before an ad is about to hide the content.
+ contentPauseRequested,
+
+ /// Fired when content should be resumed.
+ ///
+ /// This usually happens when an ad finishes or collapses.
+ contentResumeRequested,
+
+ /// Fired when the VAST response has been received.
+ loaded,
+}
+
+/// Simple data class used to transport ad playback information.
+@immutable
+class AdEvent {
+ /// Creates an [AdEvent].
+ const AdEvent({required this.type});
+
+ /// The type of event that occurred.
+ final AdEventType type;
+}
+
+/// An event raised when there is an error loading or playing ads.
+@immutable
+class AdErrorEvent {
+ /// Creates an [AdErrorEvent].
+ const AdErrorEvent({required this.error});
+
+ /// The error that caused this event.
+ final AdError error;
+}
diff --git a/packages/interactive_media_ads/lib/src/types/ads_request.dart b/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart
similarity index 100%
rename from packages/interactive_media_ads/lib/src/types/ads_request.dart
rename to packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
index b3048bb55491..f55c78524865 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -5,6 +5,8 @@
import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+import 'ads_request.dart';
+import 'ad_error.dart';
import 'interactive_media_ads_platform.dart';
import 'platform_ad_display_container.dart';
import 'platform_ads_manager.dart';
@@ -49,12 +51,18 @@ base class PlatformAdsLoaderCreationParams {
required this.onAdsLoadError,
});
+ /// A container object where ads are rendered.
final PlatformAdDisplayContainer container;
+
+ /// Callback for the ads manager loaded event.
final void Function(PlatformOnAdsLoadedData data) onAdsLoaded;
+
+ /// Callback for errors that occur during the ads request.
final void Function(AdsLoadErrorData data) onAdsLoadError;
}
-/// Interface for a platform implementation of an `AdsLoader`.
+/// Interface for a platform implementation of an object that requests ads and
+/// handles events from ads request responses.
abstract class PlatformAdsLoader extends PlatformInterface {
/// Creates a new [PlatformAdsLoader]
factory PlatformAdsLoader(
@@ -86,25 +94,38 @@ abstract class PlatformAdsLoader extends PlatformInterface {
/// The parameters used to initialize the [PlatformAdsLoader].
final PlatformAdsLoaderCreationParams params;
+ /// Signal to the SDK that the content has completed.
Future contentComplete() {
throw UnimplementedError(
- 'contentComplete is not implemented on the current platform',
+ '`contentComplete` is not implemented on the current platform',
);
}
- Future request() {
+ /// Requests ads from a server.
+ Future requestAds(AdsRequest request) {
throw UnimplementedError(
- 'request is not implemented on the current platform',
+ '`requestAds` is not implemented on the current platform',
);
}
}
+/// Data when ads are successfully loaded from the ad server through an
+/// [PlatformAdsLoader].
@immutable
class PlatformOnAdsLoadedData {
- PlatformOnAdsLoadedData({required this.manager});
+ /// Creates a [PlatformOnAdsLoadedData].
+ const PlatformOnAdsLoadedData({required this.manager});
+ /// The ads manager instance created by the ads loader.
final PlatformAdsManager manager;
}
+/// Ad error data that is returned when the ads loader fails to load the ad.
@immutable
-class AdsLoadErrorData {}
+class AdsLoadErrorData {
+ /// Creates a [AdsLoadErrorData].
+ const AdsLoadErrorData({required this.error});
+
+ /// The ad error that occurred while loading the ad.
+ final AdError error;
+}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
index 7b0c0a065661..e832626c9f01 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -6,24 +6,29 @@ import 'package:flutter/foundation.dart';
import 'platform_ads_manager_delegate.dart';
-base class AdsManagerInitParams {
+/// Additional parameter passed to an [PlatformAdsManager] on initialization.
+base class AdsManagerInitParams {}
-}
-
-base class AdsManagerStartParams {
-
-}
+/// Additional parameter passed to an [PlatformAdsManager] when starting to play
+/// ads.
+base class AdsManagerStartParams {}
/// Interface for a platform implementation of a `AdsManager`.
-abstract base class PlatformAdsManager {
+abstract base class PlatformAdsManager {
+ /// Creates a [PlatformAdsManager].
@protected
PlatformAdsManager();
+ /// Initializes the ad experience using default rendering settings.
Future init(AdsManagerInitParams params);
+ /// Starts playing the ads.
Future start(AdsManagerStartParams params);
+ /// /// The [AdsManagerDelegate] to notify with events during ad playback.
Future setAdsManagerDelegate(PlatformAdsManagerDelegate delegate);
+ /// Stops the ad and all tracking, then releases all assets that were loaded
+ /// to play the ad.
Future destroy();
}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
index a50def96fdae..afa80572b7b8 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager_delegate.dart
@@ -5,6 +5,7 @@
import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+import 'ad_event.dart';
import 'interactive_media_ads_platform.dart';
/// Object specifying creation parameters for creating a
@@ -42,14 +43,17 @@ import 'interactive_media_ads_platform.dart';
@immutable
base class PlatformAdsManagerDelegateCreationParams {
/// Used by the platform implementation to create a new [PlatformAdsManagerDelegate].
- PlatformAdsManagerDelegateCreationParams({
+ const PlatformAdsManagerDelegateCreationParams({
this.onAdEvent,
this.onAdErrorEvent,
});
- void Function(AdEvent event)? onAdEvent;
+ /// Invoked when there is an [AdEvent].
+ final void Function(AdEvent event)? onAdEvent;
- void Function(AdErrorEvent event)? onAdErrorEvent;
+ /// Invoked when there was an error playing the ad. Log the error and resume
+ /// playing content.
+ final void Function(AdErrorEvent event)? onAdErrorEvent;
}
/// Interface for a platform implementation of a `AdsManagerDelegate`.
@@ -86,9 +90,3 @@ abstract class PlatformAdsManagerDelegate extends PlatformInterface {
/// The parameters used to initialize the [PlatformAdsManagerDelegate].
final PlatformAdsManagerDelegateCreationParams params;
}
-
-@immutable
-class AdEvent {}
-
-@immutable
-class AdErrorEvent {}
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
index 38e035770f25..9f551ebb50cd 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+export 'ad_error.dart';
+export 'ad_event.dart';
export 'interactive_media_ads_platform.dart';
export 'platform_ad_display_container.dart';
export 'platform_ads_loader.dart';
From 45e3fba87db647d8fd900e04a0cf1e98af2c90c4 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 14:21:52 -0500
Subject: [PATCH 16/76] cleanup some dart
---
packages/interactive_media_ads/CHANGELOG.md | 2 +-
.../plugin_integration_test.dart | 8 +---
.../example/lib/main.dart | 40 +------------------
.../src/platform_interface/ads_request.dart | 11 ++++-
4 files changed, 15 insertions(+), 46 deletions(-)
diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md
index e9d7ac42c73d..477158a8871e 100644
--- a/packages/interactive_media_ads/CHANGELOG.md
+++ b/packages/interactive_media_ads/CHANGELOG.md
@@ -1,3 +1,3 @@
## 0.0.1
-* Adds platform interface.
+* Adds platform interface for Android and iOS.
diff --git a/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart b/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart
index 236a6cc53a66..4d67e6c0ae7f 100644
--- a/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart
+++ b/packages/interactive_media_ads/example/integration_test/plugin_integration_test.dart
@@ -10,11 +10,7 @@ import 'package:interactive_media_ads/interactive_media_ads.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
- testWidgets('getPlatformVersion test', (WidgetTester tester) async {
- final InteractiveMediaAds plugin = InteractiveMediaAds();
- final String? version = await plugin.getPlatformVersion();
- // The version string depends on the host platform running the test, so
- // just assert that some non-empty string is returned.
- expect(version?.isNotEmpty, true);
+ testWidgets('placeholder test', (WidgetTester tester) async {
+
});
}
diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart
index 50d59ac44a63..68f8b2eabf4a 100644
--- a/packages/interactive_media_ads/example/lib/main.dart
+++ b/packages/interactive_media_ads/example/lib/main.dart
@@ -4,11 +4,8 @@
// ignore_for_file: public_member_api_docs
-import 'dart:async';
-
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:interactive_media_ads/interactive_media_ads.dart';
void main() {
runApp(const MyApp());
@@ -22,39 +19,6 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State {
- String _platformVersion = 'Unknown';
- final InteractiveMediaAds _interactiveMediaAdsPlugin = InteractiveMediaAds();
-
- @override
- void initState() {
- super.initState();
- initPlatformState();
- }
-
- // Platform messages are asynchronous, so we initialize in an async method.
- Future initPlatformState() async {
- String platformVersion;
- // Platform messages may fail, so we use a try/catch PlatformException.
- // We also handle the message potentially returning null.
- try {
- platformVersion = await _interactiveMediaAdsPlugin.getPlatformVersion() ??
- 'Unknown platform version';
- } on PlatformException {
- platformVersion = 'Failed to get platform version.';
- }
-
- // If the widget was removed from the tree while the asynchronous platform
- // message was in flight, we want to discard the reply rather than calling
- // setState to update our non-existent appearance.
- if (!mounted) {
- return;
- }
-
- setState(() {
- _platformVersion = platformVersion;
- });
- }
-
@override
Widget build(BuildContext context) {
return MaterialApp(
@@ -63,7 +27,7 @@ class _MyAppState extends State {
title: const Text('Plugin example app'),
),
body: Center(
- child: Text('Running on: $_platformVersion\n'),
+ child: Text('Running on: $defaultTargetPlatform'),
),
),
);
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart b/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart
index 967430696e69..72e4dfc69b63 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart
@@ -1,3 +1,12 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/// An object containing the data used to request ads from the server.
class AdsRequest {
+ /// Creates an [AdsRequest].
+ AdsRequest({required this.adTagUrl});
-}
\ No newline at end of file
+ /// The URL from which ads will be requested.
+ final String adTagUrl;
+}
From 16b0a7db66ad7fed69574d3f1ea41e2b8ba6b87a Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 21:49:09 -0500
Subject: [PATCH 17/76] add first interface test
---
packages/interactive_media_ads/pubspec.yaml | 4 +-
...ractive_media_ads_method_channel_test.dart | 34 ---
.../test/interactive_media_ads_test.dart | 21 --
.../platform_ads_manager_loader_test.dart | 101 ++++++++
...latform_ads_manager_loader_test.mocks.dart | 216 ++++++++++++++++++
5 files changed, 320 insertions(+), 56 deletions(-)
delete mode 100644 packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
delete mode 100644 packages/interactive_media_ads/test/interactive_media_ads_test.dart
create mode 100644 packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
create mode 100644 packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart
diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml
index 90fc79b91b09..7bb4b576ee28 100644
--- a/packages/interactive_media_ads/pubspec.yaml
+++ b/packages/interactive_media_ads/pubspec.yaml
@@ -20,11 +20,13 @@ flutter:
dependencies:
flutter:
sdk: flutter
- plugin_platform_interface: ^2.1.3
+ plugin_platform_interface: ^2.1.8
dev_dependencies:
+ build_runner: ^2.1.4
flutter_test:
sdk: flutter
+ mockito: 5.4.4
topics:
- ads
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
deleted file mode 100644
index 147cb09b13ce..000000000000
--- a/packages/interactive_media_ads/test/interactive_media_ads_method_channel_test.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:flutter/services.dart';
-import 'package:flutter_test/flutter_test.dart';
-import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart';
-
-void main() {
- TestWidgetsFlutterBinding.ensureInitialized();
-
- final MethodChannelInteractiveMediaAds platform =
- MethodChannelInteractiveMediaAds();
- const MethodChannel channel = MethodChannel('interactive_media_ads');
-
- setUp(() {
- TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
- .setMockMethodCallHandler(
- channel,
- (MethodCall methodCall) async {
- return '42';
- },
- );
- });
-
- tearDown(() {
- TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
- .setMockMethodCallHandler(channel, null);
- });
-
- test('getPlatformVersion', () async {
- expect(await platform.getPlatformVersion(), '42');
- });
-}
diff --git a/packages/interactive_media_ads/test/interactive_media_ads_test.dart b/packages/interactive_media_ads/test/interactive_media_ads_test.dart
deleted file mode 100644
index 2c0dc349879a..000000000000
--- a/packages/interactive_media_ads/test/interactive_media_ads_test.dart
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:flutter_test/flutter_test.dart';
-import 'package:interactive_media_ads/interactive_media_ads.dart';
-import 'package:interactive_media_ads/interactive_media_ads_method_channel.dart';
-import 'package:interactive_media_ads/interactive_media_ads_platform_interface.dart';
-import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-
-void main() {
- final InteractiveMediaAdsPlatform initialPlatform =
- InteractiveMediaAdsPlatform.instance;
-
- test('$MethodChannelInteractiveMediaAds is the default instance', () {
- expect(initialPlatform, isInstanceOf());
- });
-
- test('getPlatformVersion', () async {
- });
-}
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
new file mode 100644
index 000000000000..897c62d5096a
--- /dev/null
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
@@ -0,0 +1,101 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+import 'package:mockito/annotations.dart';
+import 'package:mockito/mockito.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'platform_ads_manager_loader_test.mocks.dart';
+
+@GenerateMocks([
+ InteractiveMediaAdsPlatform,
+ PlatformAdsLoader,
+ PlatformAdDisplayContainer,
+])
+void main() {
+ setUp(() {
+ InteractiveMediaAdsPlatform.instance =
+ MockInteractiveMediaAdsPlatformWithMixin();
+ });
+
+ PlatformAdsLoaderCreationParams createEmptyParams() {
+ return PlatformAdsLoaderCreationParams(
+ container: MockPlatformAdDisplayContainer(),
+ onAdsLoaded: (_) {},
+ onAdsLoadError: (_) {},
+ );
+ }
+
+ test('Cannot be implemented with `implements`', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdsLoader(any))
+ .thenReturn(ImplementsPlatformAdsLoader());
+
+ expect(
+ () => PlatformAdsLoader(createEmptyParams()),
+ throwsAssertionError,
+ );
+ });
+
+ test('Can be extended', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdsLoader(any))
+ .thenReturn(ExtendsPlatformAdsLoader(createEmptyParams()));
+
+ expect(PlatformAdsLoader(createEmptyParams()), isNotNull);
+ });
+
+ test('Can be mocked with `MockPlatformInterfaceMixin`', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdsLoader(any))
+ .thenReturn(MockPlatformAdsLoader());
+
+ expect(PlatformAdsLoader(createEmptyParams()), isNotNull);
+ });
+
+ test(
+ 'Default implementation of contentComplete should throw unimplemented error',
+ () {
+ final PlatformAdsLoader loader =
+ ExtendsPlatformAdsLoader(createEmptyParams());
+
+ expect(
+ () => loader.contentComplete(),
+ throwsUnimplementedError,
+ );
+ });
+
+ test('Default implementation of requestAds should throw unimplemented error',
+ () {
+ final PlatformAdsLoader loader =
+ ExtendsPlatformAdsLoader(createEmptyParams());
+
+ expect(
+ () => loader.requestAds(AdsRequest(adTagUrl: '')),
+ throwsUnimplementedError,
+ );
+ });
+}
+
+class MockInteractiveMediaAdsPlatformWithMixin
+ extends MockInteractiveMediaAdsPlatform with MockPlatformInterfaceMixin {}
+
+class ImplementsPlatformAdsLoader implements PlatformAdsLoader {
+ @override
+ dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
+
+class ExtendsPlatformAdsLoader extends PlatformAdsLoader {
+ ExtendsPlatformAdsLoader(super.params) : super.implementation();
+}
+
+class MockPlatformAdsLoader extends Mock
+ with MockPlatformInterfaceMixin
+ implements PlatformAdsLoader {}
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart
new file mode 100644
index 000000000000..44438118a126
--- /dev/null
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart
@@ -0,0 +1,216 @@
+// Mocks generated by Mockito 5.4.4 from annotations
+// in interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart.
+// Do not manually edit this file.
+
+// ignore_for_file: no_leading_underscores_for_library_prefixes
+import 'dart:async' as _i9;
+
+import 'package:flutter/cupertino.dart' as _i5;
+import 'package:flutter/foundation.dart' as _i6;
+import 'package:interactive_media_ads/src/platform_interface/ads_request.dart'
+ as _i10;
+import 'package:interactive_media_ads/src/platform_interface/interactive_media_ads_platform.dart'
+ as _i7;
+import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
+ as _i4;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_loader.dart'
+ as _i2;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_manager_delegate.dart'
+ as _i3;
+import 'package:mockito/mockito.dart' as _i1;
+import 'package:mockito/src/dummies.dart' as _i8;
+
+// ignore_for_file: type=lint
+// ignore_for_file: avoid_redundant_argument_values
+// ignore_for_file: avoid_setters_without_getters
+// ignore_for_file: comment_references
+// ignore_for_file: deprecated_member_use
+// ignore_for_file: deprecated_member_use_from_same_package
+// ignore_for_file: implementation_imports
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+// ignore_for_file: prefer_const_constructors
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: camel_case_types
+// ignore_for_file: subtype_of_sealed_class
+
+class _FakePlatformAdsLoader_0 extends _i1.SmartFake
+ implements _i2.PlatformAdsLoader {
+ _FakePlatformAdsLoader_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakePlatformAdsManagerDelegate_1 extends _i1.SmartFake
+ implements _i3.PlatformAdsManagerDelegate {
+ _FakePlatformAdsManagerDelegate_1(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakePlatformAdDisplayContainer_2 extends _i1.SmartFake
+ implements _i4.PlatformAdDisplayContainer {
+ _FakePlatformAdDisplayContainer_2(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakeWidget_3 extends _i1.SmartFake implements _i5.Widget {
+ _FakeWidget_3(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+
+ @override
+ String toString({_i6.DiagnosticLevel? minLevel = _i6.DiagnosticLevel.info}) =>
+ super.toString();
+}
+
+/// A class which mocks [InteractiveMediaAdsPlatform].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockInteractiveMediaAdsPlatform extends _i1.Mock
+ implements _i7.InteractiveMediaAdsPlatform {
+ MockInteractiveMediaAdsPlatform() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i2.PlatformAdsLoader createPlatformAdsLoader(
+ _i2.PlatformAdsLoaderCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdsLoader,
+ [params],
+ ),
+ returnValue: _FakePlatformAdsLoader_0(
+ this,
+ Invocation.method(
+ #createPlatformAdsLoader,
+ [params],
+ ),
+ ),
+ ) as _i2.PlatformAdsLoader);
+
+ @override
+ _i3.PlatformAdsManagerDelegate createPlatformAdsManagerDelegate(
+ _i3.PlatformAdsManagerDelegateCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdsManagerDelegate,
+ [params],
+ ),
+ returnValue: _FakePlatformAdsManagerDelegate_1(
+ this,
+ Invocation.method(
+ #createPlatformAdsManagerDelegate,
+ [params],
+ ),
+ ),
+ ) as _i3.PlatformAdsManagerDelegate);
+
+ @override
+ _i4.PlatformAdDisplayContainer createPlatformAdDisplayContainer(
+ _i4.PlatformAdDisplayContainerCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdDisplayContainer,
+ [params],
+ ),
+ returnValue: _FakePlatformAdDisplayContainer_2(
+ this,
+ Invocation.method(
+ #createPlatformAdDisplayContainer,
+ [params],
+ ),
+ ),
+ ) as _i4.PlatformAdDisplayContainer);
+}
+
+/// A class which mocks [PlatformAdsLoader].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdsLoader extends _i1.Mock implements _i2.PlatformAdsLoader {
+ MockPlatformAdsLoader() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i2.PlatformAdsLoaderCreationParams get params => (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue: _i8.dummyValue<_i2.PlatformAdsLoaderCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i2.PlatformAdsLoaderCreationParams);
+
+ @override
+ _i9.Future contentComplete() => (super.noSuchMethod(
+ Invocation.method(
+ #contentComplete,
+ [],
+ ),
+ returnValue: _i9.Future.value(),
+ returnValueForMissingStub: _i9.Future.value(),
+ ) as _i9.Future);
+
+ @override
+ _i9.Future requestAds(_i10.AdsRequest? request) => (super.noSuchMethod(
+ Invocation.method(
+ #requestAds,
+ [request],
+ ),
+ returnValue: _i9.Future.value(),
+ returnValueForMissingStub: _i9.Future.value(),
+ ) as _i9.Future);
+}
+
+/// A class which mocks [PlatformAdDisplayContainer].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdDisplayContainer extends _i1.Mock
+ implements _i4.PlatformAdDisplayContainer {
+ MockPlatformAdDisplayContainer() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i4.PlatformAdDisplayContainerCreationParams get params =>
+ (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue:
+ _i8.dummyValue<_i4.PlatformAdDisplayContainerCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i4.PlatformAdDisplayContainerCreationParams);
+
+ @override
+ _i5.Widget build(_i5.BuildContext? context) => (super.noSuchMethod(
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ returnValue: _FakeWidget_3(
+ this,
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ ),
+ ) as _i5.Widget);
+}
From 6c1b1ad0d506ad17e5deff0a97006dd4dbebb049 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 22:11:28 -0500
Subject: [PATCH 18/76] test platform ad display container
---
.../lib/src/ads_loader.dart | 13 +-
.../platform_ads_loader.dart | 2 +-
.../platform_ad_display_container_test.dart | 68 +++++++
...tform_ad_display_container_test.mocks.dart | 173 ++++++++++++++++++
.../platform_ads_manager_loader_test.dart | 13 --
5 files changed, 248 insertions(+), 21 deletions(-)
create mode 100644 packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.dart
create mode 100644 packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.mocks.dart
diff --git a/packages/interactive_media_ads/lib/src/ads_loader.dart b/packages/interactive_media_ads/lib/src/ads_loader.dart
index be3c1d8ea71b..01b318dff0ee 100644
--- a/packages/interactive_media_ads/lib/src/ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/ads_loader.dart
@@ -43,11 +43,7 @@ class AdsLoader {
PlatformAdsLoaderCreationParams(
container: container.platform,
onAdsLoaded: (PlatformOnAdsLoadedData data) {
- onAdsLoaded(
- OnAdsLoadedData._(
- manager: AdsManager._fromPlatform(data.manager),
- ),
- );
+ onAdsLoaded(OnAdsLoadedData._(platform: data));
},
onAdsLoadError: onAdsLoadError,
),
@@ -95,10 +91,13 @@ class AdsLoader {
/// [AdsLoader].
@immutable
class OnAdsLoadedData {
- const OnAdsLoadedData._({required this.manager});
+ OnAdsLoadedData._({required this.platform});
+
+ /// Implementation of [PlatformOnAdsLoadedData] for the current platform.
+ final PlatformOnAdsLoadedData platform;
/// The ads manager instance created by the ads loader.
- final AdsManager manager;
+ late final AdsManager manager = AdsManager._fromPlatform(platform.manager);
}
/// Handles playing ads after they've been received from the server.
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
index f55c78524865..f56fc1812638 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart
@@ -5,8 +5,8 @@
import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-import 'ads_request.dart';
import 'ad_error.dart';
+import 'ads_request.dart';
import 'interactive_media_ads_platform.dart';
import 'platform_ad_display_container.dart';
import 'platform_ads_manager.dart';
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.dart b/packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.dart
new file mode 100644
index 000000000000..cdc6792dfdb7
--- /dev/null
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.dart
@@ -0,0 +1,68 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/src/widgets/framework.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+import 'package:mockito/annotations.dart';
+import 'package:mockito/mockito.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'platform_ad_display_container_test.mocks.dart';
+
+@GenerateMocks([
+ InteractiveMediaAdsPlatform,
+ PlatformAdDisplayContainer,
+])
+void main() {
+ setUp(() {
+ InteractiveMediaAdsPlatform.instance =
+ MockInteractiveMediaAdsPlatformWithMixin();
+ });
+
+ PlatformAdDisplayContainerCreationParams createEmptyParams() {
+ return PlatformAdDisplayContainerCreationParams(
+ onContainerAdded: (_) {},
+ );
+ }
+
+ test('Cannot be implemented with `implements`', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdDisplayContainer(any))
+ .thenReturn(ImplementsPlatformAdDisplayContainer());
+
+ expect(
+ () => PlatformAdDisplayContainer(createEmptyParams()),
+ throwsAssertionError,
+ );
+ });
+
+ test('Can be extended', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdDisplayContainer(any))
+ .thenReturn(ExtendsPlatformAdDisplayContainer(createEmptyParams()));
+
+ expect(PlatformAdDisplayContainer(createEmptyParams()), isNotNull);
+ });
+}
+
+class MockInteractiveMediaAdsPlatformWithMixin
+ extends MockInteractiveMediaAdsPlatform with MockPlatformInterfaceMixin {}
+
+class ImplementsPlatformAdDisplayContainer
+ implements PlatformAdDisplayContainer {
+ @override
+ dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
+
+class ExtendsPlatformAdDisplayContainer extends PlatformAdDisplayContainer {
+ ExtendsPlatformAdDisplayContainer(super.params) : super.implementation();
+
+ @override
+ Widget build(BuildContext context) {
+ throw UnimplementedError();
+ }
+}
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.mocks.dart b/packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.mocks.dart
new file mode 100644
index 000000000000..93fa511294b0
--- /dev/null
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ad_display_container_test.mocks.dart
@@ -0,0 +1,173 @@
+// Mocks generated by Mockito 5.4.4 from annotations
+// in interactive_media_ads/test/platform_interface/platform_ad_display_container_test.dart.
+// Do not manually edit this file.
+
+// ignore_for_file: no_leading_underscores_for_library_prefixes
+import 'package:flutter/cupertino.dart' as _i5;
+import 'package:interactive_media_ads/src/platform_interface/interactive_media_ads_platform.dart'
+ as _i6;
+import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
+ as _i4;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_loader.dart'
+ as _i2;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_manager_delegate.dart'
+ as _i3;
+import 'package:mockito/mockito.dart' as _i1;
+import 'package:mockito/src/dummies.dart' as _i7;
+
+// ignore_for_file: type=lint
+// ignore_for_file: avoid_redundant_argument_values
+// ignore_for_file: avoid_setters_without_getters
+// ignore_for_file: comment_references
+// ignore_for_file: deprecated_member_use
+// ignore_for_file: deprecated_member_use_from_same_package
+// ignore_for_file: implementation_imports
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+// ignore_for_file: prefer_const_constructors
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: camel_case_types
+// ignore_for_file: subtype_of_sealed_class
+
+class _FakePlatformAdsLoader_0 extends _i1.SmartFake
+ implements _i2.PlatformAdsLoader {
+ _FakePlatformAdsLoader_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakePlatformAdsManagerDelegate_1 extends _i1.SmartFake
+ implements _i3.PlatformAdsManagerDelegate {
+ _FakePlatformAdsManagerDelegate_1(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakePlatformAdDisplayContainer_2 extends _i1.SmartFake
+ implements _i4.PlatformAdDisplayContainer {
+ _FakePlatformAdDisplayContainer_2(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakeWidget_3 extends _i1.SmartFake implements _i5.Widget {
+ _FakeWidget_3(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+
+ @override
+ String toString({_i5.DiagnosticLevel? minLevel = _i5.DiagnosticLevel.info}) =>
+ super.toString();
+}
+
+/// A class which mocks [InteractiveMediaAdsPlatform].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockInteractiveMediaAdsPlatform extends _i1.Mock
+ implements _i6.InteractiveMediaAdsPlatform {
+ MockInteractiveMediaAdsPlatform() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i2.PlatformAdsLoader createPlatformAdsLoader(
+ _i2.PlatformAdsLoaderCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdsLoader,
+ [params],
+ ),
+ returnValue: _FakePlatformAdsLoader_0(
+ this,
+ Invocation.method(
+ #createPlatformAdsLoader,
+ [params],
+ ),
+ ),
+ ) as _i2.PlatformAdsLoader);
+
+ @override
+ _i3.PlatformAdsManagerDelegate createPlatformAdsManagerDelegate(
+ _i3.PlatformAdsManagerDelegateCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdsManagerDelegate,
+ [params],
+ ),
+ returnValue: _FakePlatformAdsManagerDelegate_1(
+ this,
+ Invocation.method(
+ #createPlatformAdsManagerDelegate,
+ [params],
+ ),
+ ),
+ ) as _i3.PlatformAdsManagerDelegate);
+
+ @override
+ _i4.PlatformAdDisplayContainer createPlatformAdDisplayContainer(
+ _i4.PlatformAdDisplayContainerCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdDisplayContainer,
+ [params],
+ ),
+ returnValue: _FakePlatformAdDisplayContainer_2(
+ this,
+ Invocation.method(
+ #createPlatformAdDisplayContainer,
+ [params],
+ ),
+ ),
+ ) as _i4.PlatformAdDisplayContainer);
+}
+
+/// A class which mocks [PlatformAdDisplayContainer].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdDisplayContainer extends _i1.Mock
+ implements _i4.PlatformAdDisplayContainer {
+ MockPlatformAdDisplayContainer() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i4.PlatformAdDisplayContainerCreationParams get params =>
+ (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue:
+ _i7.dummyValue<_i4.PlatformAdDisplayContainerCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i4.PlatformAdDisplayContainerCreationParams);
+
+ @override
+ _i5.Widget build(_i5.BuildContext? context) => (super.noSuchMethod(
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ returnValue: _FakeWidget_3(
+ this,
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ ),
+ ) as _i5.Widget);
+}
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
index 897c62d5096a..e81233f22cc3 100644
--- a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
@@ -51,15 +51,6 @@ void main() {
expect(PlatformAdsLoader(createEmptyParams()), isNotNull);
});
- test('Can be mocked with `MockPlatformInterfaceMixin`', () {
- when((InteractiveMediaAdsPlatform.instance!
- as MockInteractiveMediaAdsPlatform)
- .createPlatformAdsLoader(any))
- .thenReturn(MockPlatformAdsLoader());
-
- expect(PlatformAdsLoader(createEmptyParams()), isNotNull);
- });
-
test(
'Default implementation of contentComplete should throw unimplemented error',
() {
@@ -95,7 +86,3 @@ class ImplementsPlatformAdsLoader implements PlatformAdsLoader {
class ExtendsPlatformAdsLoader extends PlatformAdsLoader {
ExtendsPlatformAdsLoader(super.params) : super.implementation();
}
-
-class MockPlatformAdsLoader extends Mock
- with MockPlatformInterfaceMixin
- implements PlatformAdsLoader {}
From e9f92dbf1f81c9a2265ed622b7fb7b9e1a5d88c9 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 22:19:40 -0500
Subject: [PATCH 19/76] ads manager delegate tests
---
...est.dart => platform_ads_loader_test.dart} | 2 +-
...rt => platform_ads_loader_test.mocks.dart} | 2 +-
.../platform_ads_manager_delegate_test.dart | 65 ++++++++
...tform_ads_manager_delegate_test.mocks.dart | 143 ++++++++++++++++++
4 files changed, 210 insertions(+), 2 deletions(-)
rename packages/interactive_media_ads/test/platform_interface/{platform_ads_manager_loader_test.dart => platform_ads_loader_test.dart} (98%)
rename packages/interactive_media_ads/test/platform_interface/{platform_ads_manager_loader_test.mocks.dart => platform_ads_loader_test.mocks.dart} (99%)
create mode 100644 packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.dart
create mode 100644 packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.mocks.dart
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_loader_test.dart
similarity index 98%
rename from packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
rename to packages/interactive_media_ads/test/platform_interface/platform_ads_loader_test.dart
index e81233f22cc3..423d98970fad 100644
--- a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_loader_test.dart
@@ -9,7 +9,7 @@ import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-import 'platform_ads_manager_loader_test.mocks.dart';
+import 'platform_ads_loader_test.mocks.dart';
@GenerateMocks([
InteractiveMediaAdsPlatform,
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_loader_test.mocks.dart
similarity index 99%
rename from packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart
rename to packages/interactive_media_ads/test/platform_interface/platform_ads_loader_test.mocks.dart
index 44438118a126..0c57d2cb19b0 100644
--- a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.mocks.dart
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_loader_test.mocks.dart
@@ -1,5 +1,5 @@
// Mocks generated by Mockito 5.4.4 from annotations
-// in interactive_media_ads/test/platform_interface/platform_ads_manager_loader_test.dart.
+// in interactive_media_ads/test/platform_interface/platform_ads_loader_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.dart
new file mode 100644
index 000000000000..6333ab8a8ad3
--- /dev/null
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.dart
@@ -0,0 +1,65 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+import 'package:mockito/annotations.dart';
+import 'package:mockito/mockito.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+import 'platform_ads_manager_delegate_test.mocks.dart';
+
+@GenerateMocks([
+ InteractiveMediaAdsPlatform,
+ PlatformAdsManagerDelegate,
+])
+void main() {
+ setUp(() {
+ InteractiveMediaAdsPlatform.instance =
+ MockInteractiveMediaAdsPlatformWithMixin();
+ });
+
+ test('Cannot be implemented with `implements`', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdsManagerDelegate(any))
+ .thenReturn(ImplementsPlatformAdsManagerDelegate());
+
+ expect(
+ () => PlatformAdsManagerDelegate(
+ const PlatformAdsManagerDelegateCreationParams(),
+ ),
+ throwsAssertionError,
+ );
+ });
+
+ test('Can be extended', () {
+ when((InteractiveMediaAdsPlatform.instance!
+ as MockInteractiveMediaAdsPlatform)
+ .createPlatformAdsManagerDelegate(any))
+ .thenReturn(ExtendsPlatformAdsManagerDelegate(
+ const PlatformAdsManagerDelegateCreationParams(),
+ ));
+
+ expect(
+ PlatformAdsManagerDelegate(
+ const PlatformAdsManagerDelegateCreationParams(),
+ ),
+ isNotNull,
+ );
+ });
+}
+
+class MockInteractiveMediaAdsPlatformWithMixin
+ extends MockInteractiveMediaAdsPlatform with MockPlatformInterfaceMixin {}
+
+class ImplementsPlatformAdsManagerDelegate
+ implements PlatformAdsManagerDelegate {
+ @override
+ dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
+
+class ExtendsPlatformAdsManagerDelegate extends PlatformAdsManagerDelegate {
+ ExtendsPlatformAdsManagerDelegate(super.params) : super.implementation();
+}
diff --git a/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.mocks.dart b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.mocks.dart
new file mode 100644
index 000000000000..398712eb8993
--- /dev/null
+++ b/packages/interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.mocks.dart
@@ -0,0 +1,143 @@
+// Mocks generated by Mockito 5.4.4 from annotations
+// in interactive_media_ads/test/platform_interface/platform_ads_manager_delegate_test.dart.
+// Do not manually edit this file.
+
+// ignore_for_file: no_leading_underscores_for_library_prefixes
+import 'package:interactive_media_ads/src/platform_interface/interactive_media_ads_platform.dart'
+ as _i5;
+import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
+ as _i4;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_loader.dart'
+ as _i2;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_manager_delegate.dart'
+ as _i3;
+import 'package:mockito/mockito.dart' as _i1;
+import 'package:mockito/src/dummies.dart' as _i6;
+
+// ignore_for_file: type=lint
+// ignore_for_file: avoid_redundant_argument_values
+// ignore_for_file: avoid_setters_without_getters
+// ignore_for_file: comment_references
+// ignore_for_file: deprecated_member_use
+// ignore_for_file: deprecated_member_use_from_same_package
+// ignore_for_file: implementation_imports
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+// ignore_for_file: prefer_const_constructors
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: camel_case_types
+// ignore_for_file: subtype_of_sealed_class
+
+class _FakePlatformAdsLoader_0 extends _i1.SmartFake
+ implements _i2.PlatformAdsLoader {
+ _FakePlatformAdsLoader_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakePlatformAdsManagerDelegate_1 extends _i1.SmartFake
+ implements _i3.PlatformAdsManagerDelegate {
+ _FakePlatformAdsManagerDelegate_1(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+class _FakePlatformAdDisplayContainer_2 extends _i1.SmartFake
+ implements _i4.PlatformAdDisplayContainer {
+ _FakePlatformAdDisplayContainer_2(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+}
+
+/// A class which mocks [InteractiveMediaAdsPlatform].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockInteractiveMediaAdsPlatform extends _i1.Mock
+ implements _i5.InteractiveMediaAdsPlatform {
+ MockInteractiveMediaAdsPlatform() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i2.PlatformAdsLoader createPlatformAdsLoader(
+ _i2.PlatformAdsLoaderCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdsLoader,
+ [params],
+ ),
+ returnValue: _FakePlatformAdsLoader_0(
+ this,
+ Invocation.method(
+ #createPlatformAdsLoader,
+ [params],
+ ),
+ ),
+ ) as _i2.PlatformAdsLoader);
+
+ @override
+ _i3.PlatformAdsManagerDelegate createPlatformAdsManagerDelegate(
+ _i3.PlatformAdsManagerDelegateCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdsManagerDelegate,
+ [params],
+ ),
+ returnValue: _FakePlatformAdsManagerDelegate_1(
+ this,
+ Invocation.method(
+ #createPlatformAdsManagerDelegate,
+ [params],
+ ),
+ ),
+ ) as _i3.PlatformAdsManagerDelegate);
+
+ @override
+ _i4.PlatformAdDisplayContainer createPlatformAdDisplayContainer(
+ _i4.PlatformAdDisplayContainerCreationParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #createPlatformAdDisplayContainer,
+ [params],
+ ),
+ returnValue: _FakePlatformAdDisplayContainer_2(
+ this,
+ Invocation.method(
+ #createPlatformAdDisplayContainer,
+ [params],
+ ),
+ ),
+ ) as _i4.PlatformAdDisplayContainer);
+}
+
+/// A class which mocks [PlatformAdsManagerDelegate].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdsManagerDelegate extends _i1.Mock
+ implements _i3.PlatformAdsManagerDelegate {
+ MockPlatformAdsManagerDelegate() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i3.PlatformAdsManagerDelegateCreationParams get params =>
+ (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue:
+ _i6.dummyValue<_i3.PlatformAdsManagerDelegateCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i3.PlatformAdsManagerDelegateCreationParams);
+}
From 9c8ee614b95a48756f804fdd18fa173d77741a3b Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 22:59:31 -0500
Subject: [PATCH 20/76] add app facing tests
---
.../example/test/widget_test.dart | 27 ----
.../example/test_driver/integration_test.dart | 7 ++
.../lib/src/ads_loader.dart | 10 ++
.../platform_interface.dart | 1 +
.../test/ad_display_container_test.dart | 62 +++++++++
.../test/ad_display_container_test.mocks.dart | 73 +++++++++++
.../test/ads_loader_test.dart | 36 ++++++
.../test/ads_loader_test.mocks.dart | 118 ++++++++++++++++++
.../test/ads_manager_delegate_test.dart | 38 ++++++
.../test/ads_manager_test.dart | 0
10 files changed, 345 insertions(+), 27 deletions(-)
delete mode 100644 packages/interactive_media_ads/example/test/widget_test.dart
create mode 100644 packages/interactive_media_ads/example/test_driver/integration_test.dart
create mode 100644 packages/interactive_media_ads/test/ad_display_container_test.dart
create mode 100644 packages/interactive_media_ads/test/ad_display_container_test.mocks.dart
create mode 100644 packages/interactive_media_ads/test/ads_loader_test.dart
create mode 100644 packages/interactive_media_ads/test/ads_loader_test.mocks.dart
create mode 100644 packages/interactive_media_ads/test/ads_manager_delegate_test.dart
create mode 100644 packages/interactive_media_ads/test/ads_manager_test.dart
diff --git a/packages/interactive_media_ads/example/test/widget_test.dart b/packages/interactive_media_ads/example/test/widget_test.dart
deleted file mode 100644
index bc01bb34eef3..000000000000
--- a/packages/interactive_media_ads/example/test/widget_test.dart
+++ /dev/null
@@ -1,27 +0,0 @@
-// This is a basic Flutter widget test.
-//
-// To perform an interaction with a widget in your test, use the WidgetTester
-// utility in the flutter_test package. For example, you can send tap and scroll
-// gestures. You can also use WidgetTester to find child widgets in the widget
-// tree, read text, and verify that the values of widget properties are correct.
-
-import 'package:flutter/material.dart';
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:interactive_media_ads_example/main.dart';
-
-void main() {
- testWidgets('Verify Platform version', (WidgetTester tester) async {
- // Build our app and trigger a frame.
- await tester.pumpWidget(const MyApp());
-
- // Verify that platform version is retrieved.
- expect(
- find.byWidgetPredicate(
- (Widget widget) => widget is Text &&
- widget.data!.startsWith('Running on:'),
- ),
- findsOneWidget,
- );
- });
-}
diff --git a/packages/interactive_media_ads/example/test_driver/integration_test.dart b/packages/interactive_media_ads/example/test_driver/integration_test.dart
new file mode 100644
index 000000000000..7ee1c103ea34
--- /dev/null
+++ b/packages/interactive_media_ads/example/test_driver/integration_test.dart
@@ -0,0 +1,7 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:integration_test/integration_test_driver.dart';
+
+Future main() => integrationDriver();
\ No newline at end of file
diff --git a/packages/interactive_media_ads/lib/src/ads_loader.dart b/packages/interactive_media_ads/lib/src/ads_loader.dart
index 01b318dff0ee..a1dbb58bb68a 100644
--- a/packages/interactive_media_ads/lib/src/ads_loader.dart
+++ b/packages/interactive_media_ads/lib/src/ads_loader.dart
@@ -85,6 +85,16 @@ class AdsLoader {
/// Implementation of [PlatformAdsLoader] for the current platform.
final PlatformAdsLoader platform;
+
+ /// Signal to the SDK that the content has completed.
+ Future contentComplete() {
+ return platform.contentComplete();
+ }
+
+ /// Requests ads from a server.
+ Future requestAds(AdsRequest request) {
+ return platform.requestAds(request);
+ }
}
/// Data when ads are successfully loaded from the ad server through an
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
index 9f551ebb50cd..ad8896480443 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart
@@ -4,6 +4,7 @@
export 'ad_error.dart';
export 'ad_event.dart';
+export 'ads_request.dart';
export 'interactive_media_ads_platform.dart';
export 'platform_ad_display_container.dart';
export 'platform_ads_loader.dart';
diff --git a/packages/interactive_media_ads/test/ad_display_container_test.dart b/packages/interactive_media_ads/test/ad_display_container_test.dart
new file mode 100644
index 000000000000..1d2a2ff5e7b7
--- /dev/null
+++ b/packages/interactive_media_ads/test/ad_display_container_test.dart
@@ -0,0 +1,62 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+import 'package:interactive_media_ads/src/ad_display_container.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+import 'package:mockito/annotations.dart';
+import 'package:mockito/mockito.dart';
+
+import 'ad_display_container_test.mocks.dart';
+
+@GenerateMocks([PlatformAdDisplayContainer])
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ testWidgets('build', (WidgetTester tester) async {
+ final MockPlatformAdDisplayContainer mockPlatformAdDisplayContainer =
+ MockPlatformAdDisplayContainer();
+ when(mockPlatformAdDisplayContainer.build(any)).thenReturn(Container());
+
+ await tester.pumpWidget(AdDisplayContainer.fromPlatform(
+ platform: mockPlatformAdDisplayContainer,
+ ));
+
+ expect(find.byType(Container), findsOneWidget);
+ });
+
+ testWidgets('constructor parameters are correctly passed to creation params',
+ (WidgetTester tester) async {
+ InteractiveMediaAdsPlatform.instance = TestInteractiveMediaAdsPlatform();
+
+ final AdDisplayContainer adDisplayContainer = AdDisplayContainer(
+ key: GlobalKey(),
+ onContainerAdded: (_) {},
+ );
+
+ // The key passed to the default constructor is used by the super class
+ // and not passed to the platform implementation.
+ expect(adDisplayContainer.platform.params.key, isNull);
+ });
+}
+
+class TestInteractiveMediaAdsPlatform extends InteractiveMediaAdsPlatform {
+ @override
+ PlatformAdDisplayContainer createPlatformAdDisplayContainer(
+ PlatformAdDisplayContainerCreationParams params,
+ ) {
+ return TestPlatformAdDisplayContainer(params);
+ }
+}
+
+class TestPlatformAdDisplayContainer extends PlatformAdDisplayContainer {
+ TestPlatformAdDisplayContainer(super.params) : super.implementation();
+
+ @override
+ Widget build(BuildContext context) {
+ throw UnimplementedError();
+ }
+}
diff --git a/packages/interactive_media_ads/test/ad_display_container_test.mocks.dart b/packages/interactive_media_ads/test/ad_display_container_test.mocks.dart
new file mode 100644
index 000000000000..d5df15031646
--- /dev/null
+++ b/packages/interactive_media_ads/test/ad_display_container_test.mocks.dart
@@ -0,0 +1,73 @@
+// Mocks generated by Mockito 5.4.4 from annotations
+// in interactive_media_ads/test/ad_display_container_test.dart.
+// Do not manually edit this file.
+
+// ignore_for_file: no_leading_underscores_for_library_prefixes
+import 'package:flutter/cupertino.dart' as _i2;
+import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
+ as _i3;
+import 'package:mockito/mockito.dart' as _i1;
+import 'package:mockito/src/dummies.dart' as _i4;
+
+// ignore_for_file: type=lint
+// ignore_for_file: avoid_redundant_argument_values
+// ignore_for_file: avoid_setters_without_getters
+// ignore_for_file: comment_references
+// ignore_for_file: deprecated_member_use
+// ignore_for_file: deprecated_member_use_from_same_package
+// ignore_for_file: implementation_imports
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+// ignore_for_file: prefer_const_constructors
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: camel_case_types
+// ignore_for_file: subtype_of_sealed_class
+
+class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget {
+ _FakeWidget_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+
+ @override
+ String toString({_i2.DiagnosticLevel? minLevel = _i2.DiagnosticLevel.info}) =>
+ super.toString();
+}
+
+/// A class which mocks [PlatformAdDisplayContainer].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdDisplayContainer extends _i1.Mock
+ implements _i3.PlatformAdDisplayContainer {
+ MockPlatformAdDisplayContainer() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i3.PlatformAdDisplayContainerCreationParams get params =>
+ (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue:
+ _i4.dummyValue<_i3.PlatformAdDisplayContainerCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i3.PlatformAdDisplayContainerCreationParams);
+
+ @override
+ _i2.Widget build(_i2.BuildContext? context) => (super.noSuchMethod(
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ returnValue: _FakeWidget_0(
+ this,
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ ),
+ ) as _i2.Widget);
+}
diff --git a/packages/interactive_media_ads/test/ads_loader_test.dart b/packages/interactive_media_ads/test/ads_loader_test.dart
new file mode 100644
index 000000000000..44f166247c72
--- /dev/null
+++ b/packages/interactive_media_ads/test/ads_loader_test.dart
@@ -0,0 +1,36 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+import 'package:mockito/annotations.dart';
+import 'package:mockito/mockito.dart';
+
+import 'ads_loader_test.mocks.dart';
+
+@GenerateMocks([PlatformAdsLoader, PlatformAdDisplayContainer])
+void main() {
+ test('contentComplete', () async {
+ final MockPlatformAdsLoader mockPlatformAdsLoader = MockPlatformAdsLoader();
+
+ final AdsLoader loader = AdsLoader.fromPlatform(
+ mockPlatformAdsLoader,
+ );
+
+ await loader.contentComplete();
+ verify(mockPlatformAdsLoader.contentComplete());
+ });
+
+ test('requestAds', () async {
+ final MockPlatformAdsLoader mockPlatformAdsLoader = MockPlatformAdsLoader();
+
+ final AdsLoader loader = AdsLoader.fromPlatform(
+ mockPlatformAdsLoader,
+ );
+
+ await loader.requestAds(AdsRequest(adTagUrl: ''));
+ verify(mockPlatformAdsLoader.requestAds(any));
+ });
+}
diff --git a/packages/interactive_media_ads/test/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/ads_loader_test.mocks.dart
new file mode 100644
index 000000000000..646b5fcb7ac6
--- /dev/null
+++ b/packages/interactive_media_ads/test/ads_loader_test.mocks.dart
@@ -0,0 +1,118 @@
+// Mocks generated by Mockito 5.4.4 from annotations
+// in interactive_media_ads/test/ads_loader_test.dart.
+// Do not manually edit this file.
+
+// ignore_for_file: no_leading_underscores_for_library_prefixes
+import 'dart:async' as _i6;
+
+import 'package:flutter/cupertino.dart' as _i2;
+import 'package:flutter/foundation.dart' as _i3;
+import 'package:interactive_media_ads/src/platform_interface/ads_request.dart'
+ as _i7;
+import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
+ as _i8;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_loader.dart'
+ as _i4;
+import 'package:mockito/mockito.dart' as _i1;
+import 'package:mockito/src/dummies.dart' as _i5;
+
+// ignore_for_file: type=lint
+// ignore_for_file: avoid_redundant_argument_values
+// ignore_for_file: avoid_setters_without_getters
+// ignore_for_file: comment_references
+// ignore_for_file: deprecated_member_use
+// ignore_for_file: deprecated_member_use_from_same_package
+// ignore_for_file: implementation_imports
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+// ignore_for_file: prefer_const_constructors
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: camel_case_types
+// ignore_for_file: subtype_of_sealed_class
+
+class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget {
+ _FakeWidget_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+
+ @override
+ String toString({_i3.DiagnosticLevel? minLevel = _i3.DiagnosticLevel.info}) =>
+ super.toString();
+}
+
+/// A class which mocks [PlatformAdsLoader].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdsLoader extends _i1.Mock implements _i4.PlatformAdsLoader {
+ MockPlatformAdsLoader() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i4.PlatformAdsLoaderCreationParams get params => (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue: _i5.dummyValue<_i4.PlatformAdsLoaderCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i4.PlatformAdsLoaderCreationParams);
+
+ @override
+ _i6.Future contentComplete() => (super.noSuchMethod(
+ Invocation.method(
+ #contentComplete,
+ [],
+ ),
+ returnValue: _i6.Future.value(),
+ returnValueForMissingStub: _i6.Future.value(),
+ ) as _i6.Future);
+
+ @override
+ _i6.Future requestAds(_i7.AdsRequest? request) => (super.noSuchMethod(
+ Invocation.method(
+ #requestAds,
+ [request],
+ ),
+ returnValue: _i6.Future.value(),
+ returnValueForMissingStub: _i6.Future.value(),
+ ) as _i6.Future);
+}
+
+/// A class which mocks [PlatformAdDisplayContainer].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdDisplayContainer extends _i1.Mock
+ implements _i8.PlatformAdDisplayContainer {
+ MockPlatformAdDisplayContainer() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i8.PlatformAdDisplayContainerCreationParams get params =>
+ (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue:
+ _i5.dummyValue<_i8.PlatformAdDisplayContainerCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i8.PlatformAdDisplayContainerCreationParams);
+
+ @override
+ _i2.Widget build(_i2.BuildContext? context) => (super.noSuchMethod(
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ returnValue: _FakeWidget_0(
+ this,
+ Invocation.method(
+ #build,
+ [context],
+ ),
+ ),
+ ) as _i2.Widget);
+}
diff --git a/packages/interactive_media_ads/test/ads_manager_delegate_test.dart b/packages/interactive_media_ads/test/ads_manager_delegate_test.dart
new file mode 100644
index 000000000000..4d460cc892f1
--- /dev/null
+++ b/packages/interactive_media_ads/test/ads_manager_delegate_test.dart
@@ -0,0 +1,38 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+
+void main() {
+ test('passes params to platform instance', () async {
+ InteractiveMediaAdsPlatform.instance = TestInteractiveMediaAdsPlatform();
+
+ void onAdEvent(AdEvent event) {}
+ void onAdErrorEvent(AdErrorEvent event) {}
+
+ final AdsManagerDelegate delegate = AdsManagerDelegate(
+ onAdEvent: onAdEvent,
+ onAdErrorEvent: onAdErrorEvent,
+ );
+
+ expect(delegate.platform.params.onAdEvent, onAdEvent);
+ expect(delegate.platform.params.onAdErrorEvent, onAdErrorEvent);
+ });
+}
+
+class TestInteractiveMediaAdsPlatform extends InteractiveMediaAdsPlatform {
+ @override
+ PlatformAdsManagerDelegate createPlatformAdsManagerDelegate(
+ PlatformAdsManagerDelegateCreationParams params,
+ ) {
+ return TestPlatformPlatformAdsManagerDelegate(params);
+ }
+}
+
+class TestPlatformPlatformAdsManagerDelegate
+ extends PlatformAdsManagerDelegate {
+ TestPlatformPlatformAdsManagerDelegate(super.params) : super.implementation();
+}
diff --git a/packages/interactive_media_ads/test/ads_manager_test.dart b/packages/interactive_media_ads/test/ads_manager_test.dart
new file mode 100644
index 000000000000..e69de29bb2d1
From 8ae248ae6ae93298d04a127584251ba2bd94532c Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 7 Feb 2024 23:20:01 -0500
Subject: [PATCH 21/76] finish tests
---
.../platform_ads_manager.dart | 2 +-
.../test/ads_loader_test.dart | 2 +-
.../test/ads_loader_test.mocks.dart | 86 ++------
.../test/ads_manager_test.dart | 102 +++++++++
.../test/ads_manager_test.mocks.dart | 197 ++++++++++++++++++
5 files changed, 317 insertions(+), 72 deletions(-)
create mode 100644 packages/interactive_media_ads/test/ads_manager_test.mocks.dart
diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
index e832626c9f01..d80a17a6a730 100644
--- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
+++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_manager.dart
@@ -14,7 +14,7 @@ base class AdsManagerInitParams {}
base class AdsManagerStartParams {}
/// Interface for a platform implementation of a `AdsManager`.
-abstract base class PlatformAdsManager {
+abstract class PlatformAdsManager {
/// Creates a [PlatformAdsManager].
@protected
PlatformAdsManager();
diff --git a/packages/interactive_media_ads/test/ads_loader_test.dart b/packages/interactive_media_ads/test/ads_loader_test.dart
index 44f166247c72..497797c68346 100644
--- a/packages/interactive_media_ads/test/ads_loader_test.dart
+++ b/packages/interactive_media_ads/test/ads_loader_test.dart
@@ -10,7 +10,7 @@ import 'package:mockito/mockito.dart';
import 'ads_loader_test.mocks.dart';
-@GenerateMocks([PlatformAdsLoader, PlatformAdDisplayContainer])
+@GenerateMocks([PlatformAdsLoader])
void main() {
test('contentComplete', () async {
final MockPlatformAdsLoader mockPlatformAdsLoader = MockPlatformAdsLoader();
diff --git a/packages/interactive_media_ads/test/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/ads_loader_test.mocks.dart
index 646b5fcb7ac6..921f24e93800 100644
--- a/packages/interactive_media_ads/test/ads_loader_test.mocks.dart
+++ b/packages/interactive_media_ads/test/ads_loader_test.mocks.dart
@@ -3,18 +3,14 @@
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
-import 'dart:async' as _i6;
+import 'dart:async' as _i4;
-import 'package:flutter/cupertino.dart' as _i2;
-import 'package:flutter/foundation.dart' as _i3;
import 'package:interactive_media_ads/src/platform_interface/ads_request.dart'
- as _i7;
-import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
- as _i8;
+ as _i5;
import 'package:interactive_media_ads/src/platform_interface/platform_ads_loader.dart'
- as _i4;
+ as _i2;
import 'package:mockito/mockito.dart' as _i1;
-import 'package:mockito/src/dummies.dart' as _i5;
+import 'package:mockito/src/dummies.dart' as _i3;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
@@ -29,90 +25,40 @@ import 'package:mockito/src/dummies.dart' as _i5;
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
-class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget {
- _FakeWidget_0(
- Object parent,
- Invocation parentInvocation,
- ) : super(
- parent,
- parentInvocation,
- );
-
- @override
- String toString({_i3.DiagnosticLevel? minLevel = _i3.DiagnosticLevel.info}) =>
- super.toString();
-}
-
/// A class which mocks [PlatformAdsLoader].
///
/// See the documentation for Mockito's code generation for more information.
-class MockPlatformAdsLoader extends _i1.Mock implements _i4.PlatformAdsLoader {
+class MockPlatformAdsLoader extends _i1.Mock implements _i2.PlatformAdsLoader {
MockPlatformAdsLoader() {
_i1.throwOnMissingStub(this);
}
@override
- _i4.PlatformAdsLoaderCreationParams get params => (super.noSuchMethod(
+ _i2.PlatformAdsLoaderCreationParams get params => (super.noSuchMethod(
Invocation.getter(#params),
- returnValue: _i5.dummyValue<_i4.PlatformAdsLoaderCreationParams>(
+ returnValue: _i3.dummyValue<_i2.PlatformAdsLoaderCreationParams>(
this,
Invocation.getter(#params),
),
- ) as _i4.PlatformAdsLoaderCreationParams);
+ ) as _i2.PlatformAdsLoaderCreationParams);
@override
- _i6.Future contentComplete() => (super.noSuchMethod(
+ _i4.Future contentComplete() => (super.noSuchMethod(
Invocation.method(
#contentComplete,
[],
),
- returnValue: _i6.Future.value(),
- returnValueForMissingStub: _i6.Future.value(),
- ) as _i6.Future);
+ returnValue: _i4.Future.value(),
+ returnValueForMissingStub: _i4.Future.value(),
+ ) as _i4.Future);
@override
- _i6.Future requestAds(_i7.AdsRequest? request) => (super.noSuchMethod(
+ _i4.Future requestAds(_i5.AdsRequest? request) => (super.noSuchMethod(
Invocation.method(
#requestAds,
[request],
),
- returnValue: _i6.Future.value(),
- returnValueForMissingStub: _i6.Future.value(),
- ) as _i6.Future);
-}
-
-/// A class which mocks [PlatformAdDisplayContainer].
-///
-/// See the documentation for Mockito's code generation for more information.
-class MockPlatformAdDisplayContainer extends _i1.Mock
- implements _i8.PlatformAdDisplayContainer {
- MockPlatformAdDisplayContainer() {
- _i1.throwOnMissingStub(this);
- }
-
- @override
- _i8.PlatformAdDisplayContainerCreationParams get params =>
- (super.noSuchMethod(
- Invocation.getter(#params),
- returnValue:
- _i5.dummyValue<_i8.PlatformAdDisplayContainerCreationParams>(
- this,
- Invocation.getter(#params),
- ),
- ) as _i8.PlatformAdDisplayContainerCreationParams);
-
- @override
- _i2.Widget build(_i2.BuildContext? context) => (super.noSuchMethod(
- Invocation.method(
- #build,
- [context],
- ),
- returnValue: _FakeWidget_0(
- this,
- Invocation.method(
- #build,
- [context],
- ),
- ),
- ) as _i2.Widget);
+ returnValue: _i4.Future.value(),
+ returnValueForMissingStub: _i4.Future.value(),
+ ) as _i4.Future);
}
diff --git a/packages/interactive_media_ads/test/ads_manager_test.dart b/packages/interactive_media_ads/test/ads_manager_test.dart
index e69de29bb2d1..721ec07a8f1b 100644
--- a/packages/interactive_media_ads/test/ads_manager_test.dart
+++ b/packages/interactive_media_ads/test/ads_manager_test.dart
@@ -0,0 +1,102 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:interactive_media_ads/interactive_media_ads.dart';
+import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart';
+import 'package:mockito/annotations.dart';
+import 'package:mockito/mockito.dart';
+
+import 'ads_manager_test.mocks.dart';
+
+@GenerateMocks([
+ PlatformAdsManager,
+ PlatformAdsManagerDelegate,
+ PlatformAdsLoader,
+ PlatformAdDisplayContainer,
+])
+void main() {
+ AdsManager createAdsManagerWithMockPlatform(
+ MockPlatformAdsManager mockManager,
+ ) {
+ InteractiveMediaAdsPlatform.instance = TestInteractiveMediaAdsPlatform();
+
+ late final AdsManager manager;
+
+ final AdsLoader loader = AdsLoader(
+ container: AdDisplayContainer.fromPlatform(
+ platform: MockPlatformAdDisplayContainer(),
+ ),
+ onAdsLoaded: (OnAdsLoadedData data) {
+ manager = data.manager;
+ },
+ onAdsLoadError: (_) {},
+ );
+
+ loader.platform.params.onAdsLoaded(PlatformOnAdsLoadedData(
+ manager: mockManager,
+ ));
+
+ return manager;
+ }
+
+ test('init', () async {
+ final MockPlatformAdsManager mockPlatformAdsManager =
+ MockPlatformAdsManager();
+ final AdsManager manager = createAdsManagerWithMockPlatform(
+ mockPlatformAdsManager,
+ );
+
+ await manager.init();
+ verify(mockPlatformAdsManager.init(any));
+ });
+
+ test('start', () async {
+ final MockPlatformAdsManager mockPlatformAdsManager =
+ MockPlatformAdsManager();
+ final AdsManager manager = createAdsManagerWithMockPlatform(
+ mockPlatformAdsManager,
+ );
+
+ await manager.start();
+ verify(mockPlatformAdsManager.start(any));
+ });
+
+ test('setAdsManagerDelegate', () async {
+ final MockPlatformAdsManager mockPlatformAdsManager =
+ MockPlatformAdsManager();
+ final AdsManager manager = createAdsManagerWithMockPlatform(
+ mockPlatformAdsManager,
+ );
+
+ await manager.setAdsManagerDelegate(AdsManagerDelegate.fromPlatform(
+ MockPlatformAdsManagerDelegate(),
+ ));
+ verify(mockPlatformAdsManager.setAdsManagerDelegate(any));
+ });
+
+ test('destroy', () async {
+ final MockPlatformAdsManager mockPlatformAdsManager =
+ MockPlatformAdsManager();
+ final AdsManager manager = createAdsManagerWithMockPlatform(
+ mockPlatformAdsManager,
+ );
+
+ await manager.destroy();
+ verify(mockPlatformAdsManager.destroy());
+ });
+}
+
+class TestInteractiveMediaAdsPlatform extends InteractiveMediaAdsPlatform {
+ @override
+ PlatformAdsLoader createPlatformAdsLoader(
+ PlatformAdsLoaderCreationParams params,
+ ) {
+ return TestPlatformAdsLoader(params);
+ }
+}
+
+class TestPlatformAdsLoader extends PlatformAdsLoader {
+ TestPlatformAdsLoader(super.params) : super.implementation();
+}
diff --git a/packages/interactive_media_ads/test/ads_manager_test.mocks.dart b/packages/interactive_media_ads/test/ads_manager_test.mocks.dart
new file mode 100644
index 000000000000..597c0637e8fe
--- /dev/null
+++ b/packages/interactive_media_ads/test/ads_manager_test.mocks.dart
@@ -0,0 +1,197 @@
+// Mocks generated by Mockito 5.4.4 from annotations
+// in interactive_media_ads/test/ads_manager_test.dart.
+// Do not manually edit this file.
+
+// ignore_for_file: no_leading_underscores_for_library_prefixes
+import 'dart:async' as _i5;
+
+import 'package:flutter/cupertino.dart' as _i2;
+import 'package:flutter/foundation.dart' as _i3;
+import 'package:interactive_media_ads/src/platform_interface/ads_request.dart'
+ as _i9;
+import 'package:interactive_media_ads/src/platform_interface/platform_ad_display_container.dart'
+ as _i10;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_loader.dart'
+ as _i8;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_manager.dart'
+ as _i4;
+import 'package:interactive_media_ads/src/platform_interface/platform_ads_manager_delegate.dart'
+ as _i6;
+import 'package:mockito/mockito.dart' as _i1;
+import 'package:mockito/src/dummies.dart' as _i7;
+
+// ignore_for_file: type=lint
+// ignore_for_file: avoid_redundant_argument_values
+// ignore_for_file: avoid_setters_without_getters
+// ignore_for_file: comment_references
+// ignore_for_file: deprecated_member_use
+// ignore_for_file: deprecated_member_use_from_same_package
+// ignore_for_file: implementation_imports
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+// ignore_for_file: prefer_const_constructors
+// ignore_for_file: unnecessary_parenthesis
+// ignore_for_file: camel_case_types
+// ignore_for_file: subtype_of_sealed_class
+
+class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget {
+ _FakeWidget_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
+
+ @override
+ String toString({_i3.DiagnosticLevel? minLevel = _i3.DiagnosticLevel.info}) =>
+ super.toString();
+}
+
+/// A class which mocks [PlatformAdsManager].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdsManager extends _i1.Mock
+ implements _i4.PlatformAdsManager {
+ MockPlatformAdsManager() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i5.Future init(_i4.AdsManagerInitParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #init,
+ [params],
+ ),
+ returnValue: _i5.Future.value(),
+ returnValueForMissingStub: _i5.Future.value(),
+ ) as _i5.Future);
+
+ @override
+ _i5.Future start(_i4.AdsManagerStartParams? params) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #start,
+ [params],
+ ),
+ returnValue: _i5.Future.value(),
+ returnValueForMissingStub: _i5.Future.value(),
+ ) as _i5.Future);
+
+ @override
+ _i5.Future setAdsManagerDelegate(
+ _i6.PlatformAdsManagerDelegate? delegate) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #setAdsManagerDelegate,
+ [delegate],
+ ),
+ returnValue: _i5.Future.value(),
+ returnValueForMissingStub: _i5.Future.value(),
+ ) as _i5.Future);
+
+ @override
+ _i5.Future destroy() => (super.noSuchMethod(
+ Invocation.method(
+ #destroy,
+ [],
+ ),
+ returnValue: _i5.Future.value(),
+ returnValueForMissingStub: _i5.Future.value(),
+ ) as _i5.Future);
+}
+
+/// A class which mocks [PlatformAdsManagerDelegate].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdsManagerDelegate extends _i1.Mock
+ implements _i6.PlatformAdsManagerDelegate {
+ MockPlatformAdsManagerDelegate() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i6.PlatformAdsManagerDelegateCreationParams get params =>
+ (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue:
+ _i7.dummyValue<_i6.PlatformAdsManagerDelegateCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i6.PlatformAdsManagerDelegateCreationParams);
+}
+
+/// A class which mocks [PlatformAdsLoader].
+///
+/// See the documentation for Mockito's code generation for more information.
+class MockPlatformAdsLoader extends _i1.Mock implements _i8.PlatformAdsLoader {
+ MockPlatformAdsLoader() {
+ _i1.throwOnMissingStub(this);
+ }
+
+ @override
+ _i8.PlatformAdsLoaderCreationParams get params => (super.noSuchMethod(
+ Invocation.getter(#params),
+ returnValue: _i7.dummyValue<_i8.PlatformAdsLoaderCreationParams>(
+ this,
+ Invocation.getter(#params),
+ ),
+ ) as _i8.PlatformAdsLoaderCreationParams);
+
+ @override
+ _i5.Future contentComplete() => (super.noSuchMethod(
+ Invocation.method(
+ #contentComplete,
+ [],
+ ),
+ returnValue: _i5.Future.value(),
+ returnValueForMissingStub: _i5.Future