6
6
7
7
package org.mozilla.fenix.ui.robots
8
8
9
+ import android.util.Log
9
10
import androidx.test.espresso.Espresso.onView
10
11
import androidx.test.espresso.assertion.ViewAssertions.matches
11
12
import androidx.test.espresso.matcher.RootMatchers
@@ -21,6 +22,7 @@ import org.hamcrest.Matchers.allOf
21
22
import org.hamcrest.Matchers.containsString
22
23
import org.hamcrest.Matchers.not
23
24
import org.mozilla.fenix.R
25
+ import org.mozilla.fenix.helpers.Constants.TAG
24
26
import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
25
27
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
26
28
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
@@ -43,7 +45,8 @@ class EnhancedTrackingProtectionRobot {
43
45
44
46
fun verifyCrossSiteCookiesBlocked (isBlocked : Boolean ) {
45
47
assertUIObjectExists(itemWithResId(" $packageName :id/cross_site_tracking" ))
46
- crossSiteCookiesBlockListButton.click()
48
+ crossSiteCookiesBlockListButton().click()
49
+ Log .i(TAG , " verifyCrossSiteCookiesBlocked: Clicked cross site cookies block list button" )
47
50
// Verifies the trackers block/allow list
48
51
onView(withId(R .id.details_blocking_header))
49
52
.check(
@@ -57,11 +60,13 @@ class EnhancedTrackingProtectionRobot {
57
60
),
58
61
),
59
62
)
63
+ Log .i(TAG , " verifyCrossSiteCookiesBlocked: Verified cross site cookies are blocked: $isBlocked " )
60
64
}
61
65
62
66
fun verifySocialMediaTrackersBlocked (isBlocked : Boolean ) {
63
67
assertUIObjectExists(itemWithResId(" $packageName :id/social_media_trackers" ))
64
- socialTrackersBlockListButton.click()
68
+ socialTrackersBlockListButton().click()
69
+ Log .i(TAG , " verifySocialMediaTrackersBlocked: Clicked social trackers block list button" )
65
70
// Verifies the trackers block/allow list
66
71
onView(withId(R .id.details_blocking_header))
67
72
.check(
@@ -75,12 +80,15 @@ class EnhancedTrackingProtectionRobot {
75
80
),
76
81
),
77
82
)
83
+ Log .i(TAG , " verifySocialMediaTrackersBlocked: Verified social trackers are blocked: $isBlocked " )
78
84
onView(withId(R .id.blocking_text_list)).check(matches(isDisplayed()))
85
+ Log .i(TAG , " verifySocialMediaTrackersBlocked: Verified blocked social trackers list is displayed" )
79
86
}
80
87
81
88
fun verifyFingerprintersBlocked (isBlocked : Boolean ) {
82
89
assertUIObjectExists(itemWithResId(" $packageName :id/fingerprinters" ))
83
- fingerprintersBlockListButton.click()
90
+ fingerprintersBlockListButton().click()
91
+ Log .i(TAG , " verifyFingerprintersBlocked: Clicked fingerprinters block list button" )
84
92
// Verifies the trackers block/allow list
85
93
onView(withId(R .id.details_blocking_header))
86
94
.check(
@@ -94,12 +102,15 @@ class EnhancedTrackingProtectionRobot {
94
102
),
95
103
),
96
104
)
105
+ Log .i(TAG , " verifyFingerprintersBlocked: Verified fingerprinters are blocked: $isBlocked " )
97
106
onView(withId(R .id.blocking_text_list)).check(matches(isDisplayed()))
107
+ Log .i(TAG , " verifyFingerprintersBlocked: Verified blocked fingerprinter trackers list is displayed" )
98
108
}
99
109
100
110
fun verifyCryptominersBlocked (isBlocked : Boolean ) {
101
111
assertUIObjectExists(itemWithResId(" $packageName :id/cryptominers" ))
102
- cryptominersBlockListButton.click()
112
+ cryptominersBlockListButton().click()
113
+ Log .i(TAG , " verifyCryptominersBlocked: Clicked cryptominers block list button" )
103
114
// Verifies the trackers block/allow list
104
115
onView(withId(R .id.details_blocking_header))
105
116
.check(
@@ -113,12 +124,15 @@ class EnhancedTrackingProtectionRobot {
113
124
),
114
125
),
115
126
)
127
+ Log .i(TAG , " verifyCryptominersBlocked: Verified cryptominers are blocked: $isBlocked " )
116
128
onView(withId(R .id.blocking_text_list)).check(matches(isDisplayed()))
129
+ Log .i(TAG , " verifyCryptominersBlocked: Verified blocked cryptominers trackers list is displayed" )
117
130
}
118
131
119
132
fun verifyTrackingContentBlocked (isBlocked : Boolean ) {
120
133
assertUIObjectExists(itemWithText(" Tracking Content" ))
121
- trackingContentBlockListButton.click()
134
+ trackingContentBlockListButton().click()
135
+ Log .i(TAG , " verifyTrackingContentBlocked: Clicked tracking content block list button" )
122
136
// Verifies the trackers block/allow list
123
137
onView(withId(R .id.details_blocking_header))
124
138
.check(
@@ -132,7 +146,9 @@ class EnhancedTrackingProtectionRobot {
132
146
),
133
147
),
134
148
)
149
+ Log .i(TAG , " verifyTrackingContentBlocked: Verified tracking content is blocked: $isBlocked " )
135
150
onView(withId(R .id.blocking_text_list)).check(matches(isDisplayed()))
151
+ Log .i(TAG , " verifyTrackingContentBlocked: Verified blocked tracking content trackers list is displayed" )
136
152
}
137
153
138
154
fun viewTrackingContentBlockList () {
@@ -148,6 +164,7 @@ class EnhancedTrackingProtectionRobot {
148
164
),
149
165
),
150
166
)
167
+ Log .i(TAG , " viewTrackingContentBlockList: Verified blocked tracking content trackers" )
151
168
}
152
169
153
170
fun verifyETPSectionIsDisplayedInQuickSettingsSheet (isDisplayed : Boolean ) =
@@ -158,12 +175,15 @@ class EnhancedTrackingProtectionRobot {
158
175
159
176
fun navigateBackToDetails () {
160
177
onView(withId(R .id.details_back)).click()
178
+ Log .i(TAG , " navigateBackToDetails: Clicked details list back button" )
161
179
}
162
180
163
181
class Transition {
164
182
fun openEnhancedTrackingProtectionSheet (interact : EnhancedTrackingProtectionRobot .() -> Unit ): Transition {
183
+ Log .i(TAG , " openEnhancedTrackingProtectionSheet: Looking for site security button" )
165
184
pageSecurityIndicator().waitForExists(waitingTime)
166
185
pageSecurityIndicator().click()
186
+ Log .i(TAG , " openEnhancedTrackingProtectionSheet: Clicked site security button" )
167
187
assertSecuritySheetIsCompletelyDisplayed()
168
188
169
189
EnhancedTrackingProtectionRobot ().interact()
@@ -173,30 +193,37 @@ class EnhancedTrackingProtectionRobot {
173
193
fun closeEnhancedTrackingProtectionSheet (interact : BrowserRobot .() -> Unit ): BrowserRobot .Transition {
174
194
// Back out of the Enhanced Tracking Protection sheet
175
195
mDevice.pressBack()
196
+ Log .i(TAG , " closeEnhancedTrackingProtectionSheet: Clicked device back button" )
176
197
177
198
BrowserRobot ().interact()
178
199
return BrowserRobot .Transition ()
179
200
}
180
201
181
202
fun toggleEnhancedTrackingProtectionFromSheet (interact : EnhancedTrackingProtectionRobot .() -> Unit ): Transition {
182
203
enhancedTrackingProtectionSwitch().click()
204
+ Log .i(TAG , " toggleEnhancedTrackingProtectionFromSheet: Clicked ETP switch" )
183
205
184
206
EnhancedTrackingProtectionRobot ().interact()
185
207
return Transition ()
186
208
}
187
209
188
210
fun openProtectionSettings (interact : SettingsSubMenuEnhancedTrackingProtectionRobot .() -> Unit ): SettingsSubMenuEnhancedTrackingProtectionRobot .Transition {
211
+ Log .i(TAG , " openProtectionSettings: Looking for ETP sheet \" Details\" button" )
189
212
openEnhancedTrackingProtectionDetails().waitForExists(waitingTime)
190
213
openEnhancedTrackingProtectionDetails().click()
214
+ Log .i(TAG , " openProtectionSettings: Clicked ETP sheet \" Details\" button" )
191
215
trackingProtectionSettingsButton().click()
216
+ Log .i(TAG , " openProtectionSettings: Clicked \" Protection Settings\" button" )
192
217
193
218
SettingsSubMenuEnhancedTrackingProtectionRobot ().interact()
194
219
return SettingsSubMenuEnhancedTrackingProtectionRobot .Transition ()
195
220
}
196
221
197
222
fun openDetails (interact : EnhancedTrackingProtectionRobot .() -> Unit ): Transition {
223
+ Log .i(TAG , " openDetails: Looking for ETP sheet \" Details\" button" )
198
224
openEnhancedTrackingProtectionDetails().waitForExists(waitingTime)
199
225
openEnhancedTrackingProtectionDetails().click()
226
+ Log .i(TAG , " openDetails: Clicked ETP sheet \" Details\" button" )
200
227
201
228
EnhancedTrackingProtectionRobot ().interact()
202
229
return Transition ()
@@ -213,9 +240,11 @@ private fun assertETPSwitchVisibility(visible: Boolean) {
213
240
if (visible) {
214
241
enhancedTrackingProtectionSwitch()
215
242
.check(matches(isDisplayed()))
243
+ Log .i(TAG , " assertETPSwitchVisibility: Verified ETP toggle is displayed" )
216
244
} else {
217
245
enhancedTrackingProtectionSwitch()
218
246
.check(matches(not (isDisplayed())))
247
+ Log .i(TAG , " assertETPSwitchVisibility: Verified ETP toggle is not displayed" )
219
248
}
220
249
}
221
250
@@ -228,6 +257,7 @@ private fun assertEnhancedTrackingProtectionSheetStatus(status: String, state: B
228
257
),
229
258
),
230
259
)
260
+ Log .i(TAG , " assertEnhancedTrackingProtectionSheetStatus: Verified ETP toggle is checked: $state " )
231
261
}
232
262
233
263
private fun pageSecurityIndicator () =
@@ -246,39 +276,39 @@ private fun trackingProtectionSettingsButton() =
246
276
private fun openEnhancedTrackingProtectionDetails () =
247
277
mDevice.findObject(UiSelector ().resourceId(" $packageName :id/trackingProtectionDetails" ))
248
278
249
- private val trackingContentBlockListButton =
279
+ private fun trackingContentBlockListButton () =
250
280
onView(
251
281
allOf(
252
282
withText(" Tracking Content" ),
253
283
withEffectiveVisibility(ViewMatchers .Visibility .VISIBLE ),
254
284
),
255
285
)
256
286
257
- private val socialTrackersBlockListButton =
287
+ private fun socialTrackersBlockListButton () =
258
288
onView(
259
289
allOf(
260
290
withId(R .id.social_media_trackers),
261
291
withText(" Social Media Trackers" ),
262
292
),
263
293
)
264
294
265
- private val crossSiteCookiesBlockListButton =
295
+ private fun crossSiteCookiesBlockListButton () =
266
296
onView(
267
297
allOf(
268
298
withId(R .id.cross_site_tracking),
269
299
withText(" Cross-Site Cookies" ),
270
300
),
271
301
)
272
302
273
- private val cryptominersBlockListButton =
303
+ private fun cryptominersBlockListButton () =
274
304
onView(
275
305
allOf(
276
306
withId(R .id.cryptominers),
277
307
withText(" Cryptominers" ),
278
308
),
279
309
)
280
310
281
- private val fingerprintersBlockListButton =
311
+ private fun fingerprintersBlockListButton () =
282
312
onView(
283
313
allOf(
284
314
withId(R .id.fingerprinters),
@@ -287,6 +317,7 @@ private val fingerprintersBlockListButton =
287
317
)
288
318
289
319
private fun assertSecuritySheetIsCompletelyDisplayed () {
320
+ Log .i(TAG , " assertSecuritySheetIsCompletelyDisplayed: Looking for quick actions sheet" )
290
321
mDevice.findObject(UiSelector ().description(getStringResource(R .string.quick_settings_sheet)))
291
322
.waitForExists(waitingTime)
292
323
assertUIObjectExists(itemWithResId(" $packageName :id/quick_action_sheet" ))
0 commit comments