4
4
import android .os .Bundle ;
5
5
6
6
import com .atinternet .tracker .ATInternet ;
7
+ import com .atinternet .tracker .CustomVar ;
8
+ import com .atinternet .tracker .CustomVars ;
7
9
import com .atinternet .tracker .Publisher ;
8
10
import com .atinternet .tracker .Publishers ;
9
11
import com .atinternet .tracker .Screen ;
@@ -74,6 +76,7 @@ public void testNotificationDisplay() {
74
76
Mockito .when (screens .add ("DisplayedBatchPushNotification" )).thenReturn (screen );
75
77
76
78
TestEventPayload payload = new TestEventPayload (null ,
79
+ null ,
77
80
null ,
78
81
new Bundle ());
79
82
@@ -103,6 +106,7 @@ public void testNotificationDisplayCampaignLabelFragment() {
103
106
Mockito .when (screens .add ("DisplayedBatchPushNotification" )).thenReturn (screen );
104
107
105
108
TestEventPayload payload = new TestEventPayload (null ,
109
+ null ,
106
110
"https://batch.com.com/test#xtor=" + xtor ,
107
111
new Bundle ());
108
112
@@ -133,6 +137,7 @@ public void testNotificationDisplayCampaignLabelFragmentEncode() {
133
137
Mockito .when (screens .add ("DisplayedBatchPushNotification" )).thenReturn (screen );
134
138
135
139
TestEventPayload payload = new TestEventPayload (null ,
140
+ null ,
136
141
"https://batch.com/test#xtor=" + xtor ,
137
142
new Bundle ());
138
143
@@ -162,6 +167,7 @@ public void testNotificationDisplayHostLessDeeplinkQuery() {
162
167
Mockito .when (screens .add ("DisplayedBatchPushNotification" )).thenReturn (screen );
163
168
164
169
TestEventPayload payload = new TestEventPayload (null ,
170
+ null ,
165
171
"batch://?xtor=" + xtor ,
166
172
new Bundle ());
167
173
@@ -191,6 +197,7 @@ public void testNotificationDisplayHostLessDeeplinkFragment() {
191
197
Mockito .when (screens .add ("DisplayedBatchPushNotification" )).thenReturn (screen );
192
198
193
199
TestEventPayload payload = new TestEventPayload (null ,
200
+ null ,
194
201
"batch://#xtor=" + xtor ,
195
202
new Bundle ());
196
203
@@ -220,6 +227,7 @@ public void testNotificationOpenCampaignLabelQuery() {
220
227
Mockito .when (screens .add ("OpenedBatchPushNotification" )).thenReturn (screen );
221
228
222
229
TestEventPayload payload = new TestEventPayload (null ,
230
+ null ,
223
231
"https://batch.com/test?xtor=" + xtor ,
224
232
new Bundle (), true );
225
233
@@ -250,6 +258,7 @@ public void testNotificationOpenCampaignLabelQueryEncode() {
250
258
Mockito .when (screens .add ("OpenedBatchPushNotification" )).thenReturn (screen );
251
259
252
260
TestEventPayload payload = new TestEventPayload (null ,
261
+ null ,
253
262
"https://batch.com/test?xtor=" + xtor ,
254
263
new Bundle (), true );
255
264
@@ -281,6 +290,7 @@ public void testNotificationOpenCampaignLabelCustomPayload() {
281
290
Bundle customPayload = new Bundle ();
282
291
customPayload .putString ("xtor" , xtor );
283
292
TestEventPayload payload = new TestEventPayload (null ,
293
+ null ,
284
294
null ,
285
295
customPayload , true );
286
296
@@ -311,6 +321,7 @@ public void testNotificationOpenCampaignLabelTrackingID() {
311
321
312
322
Bundle customPayload = new Bundle ();
313
323
TestEventPayload payload = new TestEventPayload (xtor ,
324
+ null ,
314
325
null ,
315
326
customPayload , true );
316
327
@@ -338,6 +349,7 @@ public void testNotificationOpenNonPositive() {
338
349
339
350
Bundle customPayload = new Bundle ();
340
351
TestEventPayload payload = new TestEventPayload (null ,
352
+ null ,
341
353
null ,
342
354
customPayload , false );
343
355
@@ -365,6 +377,7 @@ public void testNotificationOpenCampaignLabelPriority() {
365
377
Bundle customPayload = new Bundle ();
366
378
customPayload .putString ("xtor" , xtor );
367
379
TestEventPayload payload = new TestEventPayload (null ,
380
+ null ,
368
381
"https://batch.com/test?xtor=AD-[fake]#xtor=CS8-[fake2]" ,
369
382
customPayload , true );
370
383
@@ -394,6 +407,7 @@ public void testNotificationOpenCampaignLabelNonTrimmed() {
394
407
395
408
Bundle customPayload = new Bundle ();
396
409
TestEventPayload payload = new TestEventPayload (null ,
410
+ null ,
397
411
" \n https://batch.com/test?xtor=AD-[fake] \n " ,
398
412
customPayload , true );
399
413
@@ -420,6 +434,7 @@ public void testNotificationOpen() {
420
434
Mockito .when (screens .add ("OpenedBatchPushNotification" )).thenReturn (screen );
421
435
422
436
TestEventPayload payload = new TestEventPayload (null ,
437
+ null ,
423
438
null ,
424
439
new Bundle (), true );
425
440
@@ -446,6 +461,7 @@ public void testNotificationDismiss() {
446
461
Mockito .when (screens .add ("DismissedBatchPushNotification" )).thenReturn (screen );
447
462
448
463
TestEventPayload payload = new TestEventPayload (null ,
464
+ null ,
449
465
null ,
450
466
new Bundle (), true );
451
467
@@ -468,6 +484,7 @@ public void testInAppShow() {
468
484
Mockito .when (screens .add ("ShowedBatchInAppMessage" )).thenReturn (screen );
469
485
470
486
TestEventPayload payload = new TestEventPayload (null ,
487
+ null ,
471
488
null ,
472
489
new Bundle ());
473
490
@@ -495,6 +512,7 @@ public void testInAppShowCampaignId() {
495
512
Mockito .when (screens .add ("ShowedBatchInAppMessage" )).thenReturn (screen );
496
513
497
514
TestEventPayload payload = new TestEventPayload (xtor ,
515
+ null ,
498
516
null ,
499
517
new Bundle ());
500
518
@@ -524,6 +542,7 @@ public void testInAppShowCampaignLabelFragmentUppercase() {
524
542
Mockito .when (screens .add ("ShowedBatchInAppMessage" )).thenReturn (screen );
525
543
526
544
TestEventPayload payload = new TestEventPayload (null ,
545
+ null ,
527
546
"https://batch.com/test#XtOr=" + xtor ,
528
547
new Bundle ());
529
548
@@ -553,6 +572,7 @@ public void testInAppShowCampaignLabelQueryUppercase() {
553
572
Mockito .when (screens .add ("ShowedBatchInAppMessage" )).thenReturn (screen );
554
573
555
574
TestEventPayload payload = new TestEventPayload (null ,
575
+ null ,
556
576
"https://batch.com/test?XTor=" + xtor ,
557
577
new Bundle ());
558
578
@@ -581,6 +601,7 @@ public void testInAppClickCampaignLabel() {
581
601
Mockito .when (screens .add ("ClickedBatchInAppMessage" )).thenReturn (screen );
582
602
583
603
TestEventPayload payload = new TestEventPayload (xtor ,
604
+ null ,
584
605
null ,
585
606
new Bundle (), true );
586
607
@@ -597,6 +618,42 @@ public void testInAppClickCampaignLabel() {
597
618
Mockito .verify (screen ).sendView ();
598
619
}
599
620
621
+ @ Test
622
+ public void testInAppWebViewClickCampaignLabel () {
623
+ String xtor = "EPR-[mylabel]-totot-titi" ;
624
+ String campaignExpected = "[mylabel]" ;
625
+ String webViewButtonIdExpected = "jesuisunbouton" ;
626
+
627
+ Publisher publisher = PowerMockito .mock (Publisher .class );
628
+ Mockito .when (publishers .add (campaignExpected )).thenReturn (publisher );
629
+
630
+ Screen screen = PowerMockito .mock (Screen .class );
631
+ CustomVars customVars = PowerMockito .mock (CustomVars .class );
632
+ Mockito .when (screens .add ("WebViewClickedBatchInAppMessage" )).thenReturn (screen );
633
+ Mockito .when (screen .CustomVars ()).thenReturn (customVars );
634
+
635
+ TestEventPayload payload = new TestEventPayload (xtor ,
636
+ webViewButtonIdExpected ,
637
+ null ,
638
+ new Bundle (), true );
639
+
640
+ atInternetDispatcher .dispatchEvent (Batch .EventDispatcher .Type .MESSAGING_WEBVIEW_CLICK , payload );
641
+
642
+ Mockito .verify (publishers ).add (Mockito .eq (campaignExpected ));
643
+ Mockito .verify (publisher ).setAdvertiserId (Mockito .eq ("[batch]" ));
644
+ Mockito .verify (publisher ).setFormat (Mockito .eq ("[in-app]" ));
645
+ Mockito .verify (publisher ).setVariant (Mockito .eq ("[" + webViewButtonIdExpected + "]" ));
646
+ Mockito .verify (publisher ).sendTouch ();
647
+ Mockito .verify (publisher , Mockito .never ()).sendImpression ();
648
+
649
+ Mockito .verify (screens ).add (Mockito .eq ("WebViewClickedBatchInAppMessage" ));
650
+ Mockito .verify (screen ).Campaign (xtor );
651
+ Mockito .verify (screen ).sendView ();
652
+
653
+ Mockito .verify (screen ).CustomVars ();
654
+ Mockito .verify (customVars ).add (1 , webViewButtonIdExpected , CustomVar .CustomVarType .Screen );
655
+ }
656
+
600
657
@ Test
601
658
public void testInAppClickNonPositive () {
602
659
@@ -607,6 +664,7 @@ public void testInAppClickNonPositive() {
607
664
Mockito .when (screens .add ("ClickedBatchInAppMessage" )).thenReturn (screen );
608
665
609
666
TestEventPayload payload = new TestEventPayload (null ,
667
+ null ,
610
668
null ,
611
669
new Bundle (), false );
612
670
@@ -630,6 +688,7 @@ public void testInAppGlobalTap() {
630
688
Mockito .when (screens .add ("ClickedBatchInAppMessage" )).thenReturn (screen );
631
689
632
690
TestEventPayload payload = new TestEventPayload (null ,
691
+ null ,
633
692
null ,
634
693
new Bundle (), true );
635
694
@@ -656,6 +715,7 @@ public void testInAppClose() {
656
715
Mockito .when (screens .add ("ClosedBatchInAppMessage" )).thenReturn (screen );
657
716
658
717
TestEventPayload payload = new TestEventPayload (null ,
718
+ null ,
659
719
null ,
660
720
new Bundle ());
661
721
@@ -668,6 +728,29 @@ public void testInAppClose() {
668
728
Mockito .verify (screen ).sendView ();
669
729
}
670
730
731
+ @ Test
732
+ public void testInAppCloseError () {
733
+
734
+ Publisher publisher = PowerMockito .mock (Publisher .class );
735
+ Mockito .when (publishers .add ("[batch-default-campaign]" )).thenReturn (publisher );
736
+
737
+ Screen screen = PowerMockito .mock (Screen .class );
738
+ Mockito .when (screens .add ("ClosedErrorBatchInAppMessage" )).thenReturn (screen );
739
+
740
+ TestEventPayload payload = new TestEventPayload (null ,
741
+ null ,
742
+ null ,
743
+ new Bundle ());
744
+
745
+ atInternetDispatcher .dispatchEvent (Batch .EventDispatcher .Type .MESSAGING_CLOSE_ERROR , payload );
746
+ Mockito .verify (publisher , Mockito .never ()).sendImpression ();
747
+ Mockito .verify (publisher , Mockito .never ()).sendTouch ();
748
+
749
+ Mockito .verify (screens ).add (Mockito .eq ("ClosedErrorBatchInAppMessage" ));
750
+ Mockito .verify (screen , Mockito .never ()).Campaign (Mockito .anyString ());
751
+ Mockito .verify (screen ).sendView ();
752
+ }
753
+
671
754
@ Test
672
755
public void testInAppAutoClose () {
673
756
@@ -678,6 +761,7 @@ public void testInAppAutoClose() {
678
761
Mockito .when (screens .add ("AutoClosedBatchInAppMessage" )).thenReturn (screen );
679
762
680
763
TestEventPayload payload = new TestEventPayload (null ,
764
+ null ,
681
765
null ,
682
766
new Bundle ());
683
767
0 commit comments