@@ -7,6 +7,7 @@ void main() {
77
88 late AppsflyerSdk instance;
99 String selectedMethod = "" ;
10+ dynamic capturedArguments;
1011 const MethodChannel methodChannel = MethodChannel ('af-api' );
1112 const MethodChannel callbacksChannel = MethodChannel ('callbacks' );
1213 const EventChannel eventChannel = EventChannel ('af-events' );
@@ -63,6 +64,7 @@ void main() {
6364 case 'disableSKAdNetwork' :
6465 case 'setDisableAdvertisingIdentifiers' :
6566 selectedMethod = method;
67+ capturedArguments = methodCall.arguments;
6668 break ;
6769 }
6870 return null ;
@@ -73,9 +75,18 @@ void main() {
7375 String method = methodCall.method;
7476 if (method == 'listen' ) {
7577 selectedMethod = method;
78+ capturedArguments = methodCall.arguments;
7679 }
7780 return null ;
7881 });
82+
83+ // Mock handler for callbacks channel to avoid MissingPluginException during startListening
84+ TestDefaultBinaryMessengerBinding .instance.defaultBinaryMessenger
85+ .setMockMethodCallHandler (callbacksChannel, (methodCall) async {
86+ selectedMethod = methodCall.method;
87+ capturedArguments = methodCall.arguments;
88+ return null ;
89+ });
7990 });
8091
8192 test ('check initSdk call' , () async {
@@ -90,11 +101,14 @@ void main() {
90101 group ('AppsFlyerSdk' , () {
91102 setUp (() {
92103 selectedMethod = "" ;
104+ capturedArguments = null ;
93105 });
94106
95107 tearDown (() {
96108 TestDefaultBinaryMessengerBinding .instance.defaultBinaryMessenger
97109 .setMockMethodCallHandler (methodChannel, null );
110+ TestDefaultBinaryMessengerBinding .instance.defaultBinaryMessenger
111+ .setMockMethodCallHandler (callbacksChannel, null );
98112 });
99113
100114 test ('check logEvent call' , () async {
@@ -104,45 +118,56 @@ void main() {
104118 });
105119
106120 test ('check setHost call' , () async {
107- instance.setHost ("" , "" );
121+ instance.setHost ("prefix " , "hostname " );
108122
109123 expect (selectedMethod, 'setHost' );
124+ expect (capturedArguments['hostPrefix' ], 'prefix' );
125+ expect (capturedArguments['hostName' ], 'hostname' );
110126 });
111127
112128 test ('check setCurrencyCode call' , () async {
113- instance.setCurrencyCode ("currencyCode " );
129+ instance.setCurrencyCode ("USD " );
114130
115131 expect (selectedMethod, 'setCurrencyCode' );
132+ expect (capturedArguments['currencyCode' ], 'USD' );
116133 });
117134
118135 test ('check setIsUpdate call' , () async {
119136 instance.setIsUpdate (true );
120137
121138 expect (selectedMethod, 'setIsUpdate' );
139+ expect (capturedArguments['isUpdate' ], true );
122140 });
123141
124142 test ('check stop call' , () async {
125143 instance.stop (true );
126144
127145 expect (selectedMethod, 'stop' );
146+ expect (capturedArguments['isStopped' ], true );
128147 });
129148
130149 test ('check updateServerUninstallToken call' , () async {
131- instance.updateServerUninstallToken ("token " );
150+ instance.updateServerUninstallToken ("token123 " );
132151
133152 expect (selectedMethod, 'updateServerUninstallToken' );
153+ expect (capturedArguments['token' ], 'token123' );
134154 });
135155
136156 test ('check setOneLinkCustomDomain call' , () async {
137157 instance.setOneLinkCustomDomain (["brandDomains" ]);
138158
139159 expect (selectedMethod, 'setOneLinkCustomDomain' );
160+ expect (capturedArguments, isA <List >());
161+ expect (capturedArguments, contains ('brandDomains' ));
140162 });
141163
142164 test ('check logCrossPromotionAndOpenStore call' , () async {
143- instance.logCrossPromotionAndOpenStore ("appId " , "campaign " , null );
165+ instance.logCrossPromotionAndOpenStore ("appId123 " , "campaignA " , null );
144166
145167 expect (selectedMethod, 'logCrossPromotionAndOpenStore' );
168+ expect (capturedArguments['appId' ], 'appId123' );
169+ expect (capturedArguments['campaign' ], 'campaignA' );
170+ expect (capturedArguments['params' ], null );
146171 });
147172
148173 test ('check logCrossPromotionImpression call' , () async {
@@ -177,9 +202,12 @@ void main() {
177202
178203 test ('check validateAndLogInAppPurchase call' , () async {
179204 instance.validateAndLogInAppAndroidPurchase (
180- "publicKey" , "signature" , "purchaseData" , "price " , "currency " , null );
205+ "publicKey" , "signature" , "purchaseData" , "9.99 " , "EUR " , null );
181206
182207 expect (selectedMethod, 'validateAndLogInAppAndroidPurchase' );
208+ expect (capturedArguments['publicKey' ], 'publicKey' );
209+ expect (capturedArguments['price' ], '9.99' );
210+ expect (capturedArguments['currency' ], 'EUR' );
183211 });
184212
185213 test ('check setMinTimeBetweenSessions call' , () async {
@@ -213,9 +241,13 @@ void main() {
213241 });
214242
215243 test ('check setUserEmails call' , () async {
216- instance.setUserEmails (["emails" ], EmailCryptType .EmailCryptTypeNone );
244+ instance.setUserEmails (
245+ [
"[email protected] " ],
EmailCryptType .
EmailCryptTypeSHA256 );
217246
218247 expect (selectedMethod, 'setUserEmails' );
248+ expect (capturedArguments[
'emails' ],
contains (
'[email protected] ' ));
249+ expect (capturedArguments['cryptType' ],
250+ EmailCryptType .values.indexOf (EmailCryptType .EmailCryptTypeSHA256 ));
219251 });
220252
221253 test ('check setAdditionalData call' , () async {
@@ -262,17 +294,14 @@ void main() {
262294
263295 test ('check logAdRevenue call' , () async {
264296 final adRevenueData = AdRevenueData (
265- monetizationNetwork: 'GoogleAdMob ' ,
266- mediationNetwork: AFMediationNetwork .googleAdMob .value,
297+ monetizationNetwork: 'Applovin ' ,
298+ mediationNetwork: AFMediationNetwork .applovinMax .value,
267299 currencyIso4217Code: 'USD' ,
268- revenue: 1.23 ,
269- additionalParameters: {
270- 'adUnitId' : 'ca-app-pub-XXXX/YYYY' ,
271- 'ad_network_click_id' : '12345'
272- });
300+ revenue: 0.99 );
273301 instance.logAdRevenue (adRevenueData);
274302
275303 expect (selectedMethod, 'logAdRevenue' );
304+ expect (capturedArguments['mediationNetwork' ], 'applovin_max' );
276305 });
277306
278307 test ('check setConsentData call' , () async {
@@ -301,12 +330,15 @@ void main() {
301330 instance.setPartnerData ('partnerId' , {'key' : 'value' });
302331
303332 expect (selectedMethod, 'setPartnerData' );
333+ expect (capturedArguments['partnerId' ], 'partnerId' );
334+ expect (capturedArguments['partnersData' ]['key' ], 'value' );
304335 });
305336
306337 test ('check setResolveDeepLinkURLs call' , () async {
307338 instance.setResolveDeepLinkURLs (['https://example.com' ]);
308339
309340 expect (selectedMethod, 'setResolveDeepLinkURLs' );
341+ expect (capturedArguments, contains ('https://example.com' ));
310342 });
311343
312344 test ('check setPushNotification call' , () async {
@@ -319,12 +351,14 @@ void main() {
319351 instance.sendPushNotificationData ({'key' : 'value' });
320352
321353 expect (selectedMethod, 'sendPushNotificationData' );
354+ expect (capturedArguments['key' ], 'value' );
322355 });
323356
324357 test ('check enableFacebookDeferredApplinks call' , () async {
325358 instance.enableFacebookDeferredApplinks (true );
326359
327360 expect (selectedMethod, 'enableFacebookDeferredApplinks' );
361+ expect (capturedArguments['isFacebookDeferredApplinksEnabled' ], true );
328362 });
329363
330364 test ('check disableSKAdNetwork call' , () async {
@@ -337,6 +371,7 @@ void main() {
337371 instance.setDisableAdvertisingIdentifiers (true );
338372
339373 expect (selectedMethod, 'setDisableAdvertisingIdentifiers' );
374+ expect (capturedArguments, true );
340375 });
341376 });
342377}
0 commit comments