@@ -19,28 +19,26 @@ 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.senseofprotection.SenseOfProtectionExperiment
22
23
import com.duckduckgo.app.global.model.PrivacyShield.MALICIOUS
23
24
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
24
25
import com.duckduckgo.app.global.model.PrivacyShield.UNPROTECTED
25
- import com.duckduckgo.common.ui.experiments.visual.AppPersonalityFeature
26
26
import com.duckduckgo.common.ui.store.AppTheme
27
- import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
28
- import com.duckduckgo.feature.toggles.api.Toggle.State
29
27
import org.junit.Test
30
28
import org.mockito.kotlin.mock
31
29
import org.mockito.kotlin.verify
32
30
import org.mockito.kotlin.whenever
33
31
34
32
class LottiePrivacyShieldAnimationHelperTest {
35
33
36
- private val fakeAppPersonalityFeature = FakeFeatureToggleFactory .create( AppPersonalityFeature :: class .java )
34
+ private val senseOfProtectionExperiment : SenseOfProtectionExperiment = mock( )
37
35
38
36
@Test
39
37
fun whenLightModeAndPrivacyShieldProtectedThenSetLightShieldAnimation () {
40
38
val holder: LottieAnimationView = mock()
41
39
val appTheme: AppTheme = mock()
42
40
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
43
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
41
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
44
42
45
43
testee.setAnimationView(holder, PROTECTED )
46
44
@@ -52,7 +50,7 @@ class LottiePrivacyShieldAnimationHelperTest {
52
50
val holder: LottieAnimationView = mock()
53
51
val appTheme: AppTheme = mock()
54
52
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
55
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
53
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
56
54
57
55
testee.setAnimationView(holder, PROTECTED )
58
56
@@ -64,7 +62,7 @@ class LottiePrivacyShieldAnimationHelperTest {
64
62
val holder: LottieAnimationView = mock()
65
63
val appTheme: AppTheme = mock()
66
64
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
67
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
65
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
68
66
69
67
testee.setAnimationView(holder, UNPROTECTED )
70
68
@@ -77,7 +75,7 @@ class LottiePrivacyShieldAnimationHelperTest {
77
75
val holder: LottieAnimationView = mock()
78
76
val appTheme: AppTheme = mock()
79
77
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
80
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
78
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
81
79
82
80
testee.setAnimationView(holder, UNPROTECTED )
83
81
@@ -90,7 +88,7 @@ class LottiePrivacyShieldAnimationHelperTest {
90
88
val holder: LottieAnimationView = mock()
91
89
val appTheme: AppTheme = mock()
92
90
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
93
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
91
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
94
92
95
93
testee.setAnimationView(holder, MALICIOUS )
96
94
@@ -103,7 +101,7 @@ class LottiePrivacyShieldAnimationHelperTest {
103
101
val holder: LottieAnimationView = mock()
104
102
val appTheme: AppTheme = mock()
105
103
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
106
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
104
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
107
105
108
106
testee.setAnimationView(holder, MALICIOUS )
109
107
@@ -113,18 +111,14 @@ class LottiePrivacyShieldAnimationHelperTest {
113
111
114
112
@SuppressLint(" DenyListedApi" )
115
113
@Test
116
- fun whenLightModeAndProtectedAndSelfEnabledAndVariant1DisabledThenUseExperimentAssets () {
114
+ fun whenLightModeAndProtectedAndSelfEnabledAndShouldShowNewShieldThenUseExperimentAssets () {
115
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(true )
116
+
117
117
val holder: LottieAnimationView = mock()
118
118
val appTheme: AppTheme = mock()
119
119
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
120
- // Variant 2 is enabled
121
- fakeAppPersonalityFeature.self().setRawStoredState(State (enable = true ))
122
- fakeAppPersonalityFeature.variant2().setRawStoredState(State (enable = true ))
123
- // All other variants are disabled, including Variant 1
124
- fakeAppPersonalityFeature.variant1().setRawStoredState(State (enable = false ))
125
- fakeAppPersonalityFeature.variant3().setRawStoredState(State (enable = false ))
126
120
127
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
121
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
128
122
129
123
testee.setAnimationView(holder, PROTECTED )
130
124
@@ -133,18 +127,14 @@ class LottiePrivacyShieldAnimationHelperTest {
133
127
134
128
@SuppressLint(" DenyListedApi" )
135
129
@Test
136
- fun whenLightModeAndUnprotectedAndSelfEnabledAndVariant1DisabledThenUseExperimentAssets () {
130
+ fun whenLightModeAndUnprotectedAndSelfEnabledAndShouldShowNewShieldThenUseExperimentAssets () {
131
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(true )
132
+
137
133
val holder: LottieAnimationView = mock()
138
134
val appTheme: AppTheme = mock()
139
135
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
140
- // Variant 2 is enabled
141
- fakeAppPersonalityFeature.self().setRawStoredState(State (enable = true ))
142
- fakeAppPersonalityFeature.variant2().setRawStoredState(State (enable = true ))
143
- // All other variants are disabled, including Variant 1
144
- fakeAppPersonalityFeature.variant1().setRawStoredState(State (enable = false ))
145
- fakeAppPersonalityFeature.variant3().setRawStoredState(State (enable = false ))
146
136
147
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
137
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
148
138
149
139
testee.setAnimationView(holder, UNPROTECTED )
150
140
@@ -153,18 +143,14 @@ class LottiePrivacyShieldAnimationHelperTest {
153
143
154
144
@SuppressLint(" DenyListedApi" )
155
145
@Test
156
- fun whenDarkModeAndProtectedAndSelfEnabledAndVariant1DisabledThenUseExperimentAssets () {
146
+ fun whenDarkModeAndProtectedAndSelfEnabledAndShouldShowNewShieldThenUseExperimentAssets () {
147
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(true )
148
+
157
149
val holder: LottieAnimationView = mock()
158
150
val appTheme: AppTheme = mock()
159
151
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
160
- // Variant 2 is enabled
161
- fakeAppPersonalityFeature.self().setRawStoredState(State (enable = true ))
162
- fakeAppPersonalityFeature.variant2().setRawStoredState(State (enable = true ))
163
- // All other variants are disabled, including Variant 1
164
- fakeAppPersonalityFeature.variant1().setRawStoredState(State (enable = false ))
165
- fakeAppPersonalityFeature.variant3().setRawStoredState(State (enable = false ))
166
152
167
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
153
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
168
154
169
155
testee.setAnimationView(holder, PROTECTED )
170
156
@@ -173,18 +159,14 @@ class LottiePrivacyShieldAnimationHelperTest {
173
159
174
160
@SuppressLint(" DenyListedApi" )
175
161
@Test
176
- fun whenDarkModeAndUnprotectedAndSelfEnabledAndVariant1DisabledThenUseExperimentAssets () {
162
+ fun whenDarkModeAndUnprotectedAndSelfEnabledAndShouldShowNewShieldThenUseExperimentAssets () {
163
+ whenever(senseOfProtectionExperiment.shouldShowNewPrivacyShield()).thenReturn(true )
164
+
177
165
val holder: LottieAnimationView = mock()
178
166
val appTheme: AppTheme = mock()
179
167
whenever(appTheme.isLightModeEnabled()).thenReturn(false )
180
- // Variant 2 is enabled
181
- fakeAppPersonalityFeature.self().setRawStoredState(State (enable = true ))
182
- fakeAppPersonalityFeature.variant2().setRawStoredState(State (enable = true ))
183
- // All other variants are disabled, including Variant 1
184
- fakeAppPersonalityFeature.variant1().setRawStoredState(State (enable = false ))
185
- fakeAppPersonalityFeature.variant3().setRawStoredState(State (enable = false ))
186
168
187
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature )
169
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment )
188
170
189
171
testee.setAnimationView(holder, UNPROTECTED )
190
172
@@ -193,18 +175,14 @@ class LottiePrivacyShieldAnimationHelperTest {
193
175
194
176
@SuppressLint(" DenyListedApi" )
195
177
@Test
196
- fun whenLightModeAndProtectedAndSelfEnabledAndVariant1EnabledThenUseNonExperimentAssets () {
178
+ fun whenLightModeAndProtectedAndSelfEnabledAndShouldShowNotNewShieldThenUseNonExperimentAssets () {
179
+ whenever(senseOfProtectionExperiment.isUserEnrolledInAVariantAndExperimentEnabled()).thenReturn(false )
180
+
197
181
val holder: LottieAnimationView = mock()
198
182
val appTheme: AppTheme = mock()
199
183
whenever(appTheme.isLightModeEnabled()).thenReturn(true )
200
- // Variant 1 is enabled
201
- fakeAppPersonalityFeature.self().setRawStoredState(State (enable = true ))
202
- fakeAppPersonalityFeature.variant1().setRawStoredState(State (enable = true ))
203
- // All other variants are disabled
204
- fakeAppPersonalityFeature.variant2().setRawStoredState(State (enable = false ))
205
- fakeAppPersonalityFeature.variant3().setRawStoredState(State (enable = false ))
206
-
207
- val testee = LottiePrivacyShieldAnimationHelper (appTheme, fakeAppPersonalityFeature)
184
+
185
+ val testee = LottiePrivacyShieldAnimationHelper (appTheme, senseOfProtectionExperiment)
208
186
209
187
testee.setAnimationView(holder, PROTECTED )
210
188
0 commit comments