@@ -19,6 +19,7 @@ package com.duckduckgo.app.browser.omnibar.animations
19
19
import android.annotation.SuppressLint
20
20
import com.airbnb.lottie.LottieAnimationView
21
21
import com.duckduckgo.app.browser.R
22
+ import com.duckduckgo.app.browser.omnibar.Omnibar
22
23
import com.duckduckgo.app.browser.senseofprotection.SenseOfProtectionExperiment
23
24
import com.duckduckgo.app.global.model.PrivacyShield.MALICIOUS
24
25
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
@@ -40,6 +41,9 @@ class LottiePrivacyShieldAnimationHelperTest {
40
41
private val enabledVisualExperimentStateFlow = MutableStateFlow (true )
41
42
private val disabledVisualExperimentStateFlow = MutableStateFlow (false )
42
43
44
+ private val browserViewMode = Omnibar .ViewMode .Browser (" cnn.com" )
45
+ private val customTabViewMode = Omnibar .ViewMode .CustomTab (0 , " cnn.com" , " cnn.com" )
46
+
43
47
@Before
44
48
fun setup () {
45
49
whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
@@ -56,7 +60,7 @@ class LottiePrivacyShieldAnimationHelperTest {
56
60
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
57
61
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
58
62
59
- testee.setAnimationView(holder, PROTECTED )
63
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
60
64
61
65
verify(holder).setAnimation(R .raw.protected_shield)
62
66
}
@@ -70,7 +74,7 @@ class LottiePrivacyShieldAnimationHelperTest {
70
74
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
71
75
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
72
76
73
- testee.setAnimationView(holder, PROTECTED )
77
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
74
78
75
79
verify(holder).setAnimation(R .raw.dark_protected_shield)
76
80
}
@@ -84,7 +88,7 @@ class LottiePrivacyShieldAnimationHelperTest {
84
88
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
85
89
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
86
90
87
- testee.setAnimationView(holder, UNPROTECTED )
91
+ testee.setAnimationView(holder, UNPROTECTED , browserViewMode )
88
92
89
93
verify(holder).setAnimation(R .raw.unprotected_shield)
90
94
verify(holder).progress = 1.0f
@@ -99,7 +103,7 @@ class LottiePrivacyShieldAnimationHelperTest {
99
103
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
100
104
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
101
105
102
- testee.setAnimationView(holder, UNPROTECTED )
106
+ testee.setAnimationView(holder, UNPROTECTED , browserViewMode )
103
107
104
108
verify(holder).setAnimation(R .raw.dark_unprotected_shield)
105
109
verify(holder).progress = 1.0f
@@ -114,7 +118,7 @@ class LottiePrivacyShieldAnimationHelperTest {
114
118
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
115
119
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
116
120
117
- testee.setAnimationView(holder, MALICIOUS )
121
+ testee.setAnimationView(holder, MALICIOUS , browserViewMode )
118
122
119
123
verify(holder).setAnimation(R .raw.alert_red)
120
124
verify(holder).progress = 0.0f
@@ -129,7 +133,7 @@ class LottiePrivacyShieldAnimationHelperTest {
129
133
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
130
134
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
131
135
132
- testee.setAnimationView(holder, MALICIOUS )
136
+ testee.setAnimationView(holder, MALICIOUS , browserViewMode )
133
137
134
138
verify(holder).setAnimation(R .raw.alert_red_dark)
135
139
verify(holder).progress = 0.0f
@@ -146,7 +150,7 @@ class LottiePrivacyShieldAnimationHelperTest {
146
150
147
151
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
148
152
149
- testee.setAnimationView(holder, PROTECTED )
153
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
150
154
151
155
verify(holder).setAnimation(R .raw.protected_shield_experiment)
152
156
}
@@ -162,7 +166,7 @@ class LottiePrivacyShieldAnimationHelperTest {
162
166
163
167
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
164
168
165
- testee.setAnimationView(holder, UNPROTECTED )
169
+ testee.setAnimationView(holder, UNPROTECTED , browserViewMode )
166
170
167
171
verify(holder).setAnimation(R .raw.unprotected_shield_experiment)
168
172
}
@@ -178,7 +182,7 @@ class LottiePrivacyShieldAnimationHelperTest {
178
182
179
183
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
180
184
181
- testee.setAnimationView(holder, PROTECTED )
185
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
182
186
183
187
verify(holder).setAnimation(R .raw.protected_shield_experiment)
184
188
}
@@ -194,7 +198,7 @@ class LottiePrivacyShieldAnimationHelperTest {
194
198
195
199
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
196
200
197
- testee.setAnimationView(holder, UNPROTECTED )
201
+ testee.setAnimationView(holder, UNPROTECTED , browserViewMode )
198
202
199
203
verify(holder).setAnimation(R .raw.unprotected_shield_experiment_dark)
200
204
}
@@ -211,7 +215,7 @@ class LottiePrivacyShieldAnimationHelperTest {
211
215
212
216
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
213
217
214
- testee.setAnimationView(holder, PROTECTED )
218
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
215
219
216
220
verify(holder).setAnimation(R .raw.protected_shield)
217
221
}
@@ -230,7 +234,7 @@ class LottiePrivacyShieldAnimationHelperTest {
230
234
231
235
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
232
236
233
- testee.setAnimationView(holder, PROTECTED )
237
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
234
238
235
239
verify(holder).setAnimation(R .raw.protected_shield_new_design)
236
240
}
@@ -249,7 +253,7 @@ class LottiePrivacyShieldAnimationHelperTest {
249
253
250
254
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
251
255
252
- testee.setAnimationView(holder, UNPROTECTED )
256
+ testee.setAnimationView(holder, UNPROTECTED , browserViewMode )
253
257
254
258
verify(holder).setAnimation(R .raw.unprotected_shield_visual_updates)
255
259
}
@@ -268,7 +272,7 @@ class LottiePrivacyShieldAnimationHelperTest {
268
272
269
273
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
270
274
271
- testee.setAnimationView(holder, PROTECTED )
275
+ testee.setAnimationView(holder, PROTECTED , browserViewMode )
272
276
273
277
verify(holder).setAnimation(R .raw.dark_protected_shield_new_design)
274
278
}
@@ -287,8 +291,141 @@ class LottiePrivacyShieldAnimationHelperTest {
287
291
288
292
val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
289
293
290
- testee.setAnimationView(holder, UNPROTECTED )
294
+ testee.setAnimationView(holder, UNPROTECTED , browserViewMode )
291
295
292
296
verify(holder).setAnimation(R .raw.dark_unprotected_shield_visual_updates)
293
297
}
298
+
299
+ @SuppressLint(" DenyListedApi" )
300
+ @Test
301
+ fun whenLightModeAndProtectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeThenUseCustomTabAssets () = runTest {
302
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
303
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
304
+ enabledVisualExperimentStateFlow,
305
+ )
306
+
307
+ val holder: LottieAnimationView = mock()
308
+ val appTheme: AppTheme = mock()
309
+ whenever(appTheme.isLightModeEnabled()).thenReturn(true )
310
+
311
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
312
+
313
+ testee.setAnimationView(holder, PROTECTED , customTabViewMode)
314
+
315
+ verify(holder).setAnimation(R .raw.protected_shield_custom_tab)
316
+ }
317
+
318
+ @SuppressLint(" DenyListedApi" )
319
+ @Test
320
+ fun whenDarkModeAndProtectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeThenUseCustomTabAssets () = runTest {
321
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
322
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
323
+ enabledVisualExperimentStateFlow,
324
+ )
325
+
326
+ val holder: LottieAnimationView = mock()
327
+ val appTheme: AppTheme = mock()
328
+ whenever(appTheme.isLightModeEnabled()).thenReturn(false )
329
+
330
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
331
+
332
+ testee.setAnimationView(holder, PROTECTED , customTabViewMode)
333
+
334
+ verify(holder).setAnimation(R .raw.dark_protected_shield_custom_tab)
335
+ }
336
+
337
+ @SuppressLint(" DenyListedApi" )
338
+ @Test
339
+ fun whenLightModeAndUnprotectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeThenUseVisualUpdatesAssets () = runTest {
340
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
341
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
342
+ enabledVisualExperimentStateFlow,
343
+ )
344
+
345
+ val holder: LottieAnimationView = mock()
346
+ val appTheme: AppTheme = mock()
347
+ whenever(appTheme.isLightModeEnabled()).thenReturn(true )
348
+
349
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
350
+
351
+ testee.setAnimationView(holder, UNPROTECTED , customTabViewMode)
352
+
353
+ verify(holder).setAnimation(R .raw.unprotected_shield_visual_updates)
354
+ }
355
+
356
+ @SuppressLint(" DenyListedApi" )
357
+ @Test
358
+ fun whenDarkModeAndUnprotectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeAndExperimentDisabledThenUseDefaultAssets () = runTest {
359
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
360
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
361
+ disabledVisualExperimentStateFlow,
362
+ )
363
+
364
+ val holder: LottieAnimationView = mock()
365
+ val appTheme: AppTheme = mock()
366
+ whenever(appTheme.isLightModeEnabled()).thenReturn(false )
367
+
368
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
369
+
370
+ testee.setAnimationView(holder, UNPROTECTED , customTabViewMode)
371
+
372
+ verify(holder).setAnimation(R .raw.dark_unprotected_shield)
373
+ }
374
+
375
+ @SuppressLint(" DenyListedApi" )
376
+ @Test
377
+ fun whenLightModeAndProtectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeAndExperimentDisabledThenUseDefaultAssets () = runTest {
378
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
379
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
380
+ disabledVisualExperimentStateFlow,
381
+ )
382
+
383
+ val holder: LottieAnimationView = mock()
384
+ val appTheme: AppTheme = mock()
385
+ whenever(appTheme.isLightModeEnabled()).thenReturn(true )
386
+
387
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
388
+
389
+ testee.setAnimationView(holder, PROTECTED , customTabViewMode)
390
+
391
+ verify(holder).setAnimation(R .raw.protected_shield)
392
+ }
393
+
394
+ @SuppressLint(" DenyListedApi" )
395
+ @Test
396
+ fun whenDarkModeAndProtectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeAndExperimentDisabledThenUseDefaultAssets () = runTest {
397
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
398
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
399
+ disabledVisualExperimentStateFlow,
400
+ )
401
+
402
+ val holder: LottieAnimationView = mock()
403
+ val appTheme: AppTheme = mock()
404
+ whenever(appTheme.isLightModeEnabled()).thenReturn(false )
405
+
406
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
407
+
408
+ testee.setAnimationView(holder, PROTECTED , customTabViewMode)
409
+
410
+ verify(holder).setAnimation(R .raw.dark_protected_shield)
411
+ }
412
+
413
+ @SuppressLint(" DenyListedApi" )
414
+ @Test
415
+ fun whenLightModeAndUnprotectedAndNewSingleOmnibarDesignEnabledAndCustomTabViewModeAndExperimentDisabledThenUseDefaultAssets () = runTest {
416
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(false )
417
+ whenever(experimentalThemingDataStore.isSingleOmnibarEnabled).thenReturn(
418
+ disabledVisualExperimentStateFlow,
419
+ )
420
+
421
+ val holder: LottieAnimationView = mock()
422
+ val appTheme: AppTheme = mock()
423
+ whenever(appTheme.isLightModeEnabled()).thenReturn(true )
424
+
425
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment, experimentalThemingDataStore)
426
+
427
+ testee.setAnimationView(holder, UNPROTECTED , customTabViewMode)
428
+
429
+ verify(holder).setAnimation(R .raw.unprotected_shield)
430
+ }
294
431
}
0 commit comments