1
1
package org .openobservatory .ooniprobe .ui .resultdetails ;
2
2
3
+ import static androidx .test .espresso .Espresso .onData ;
4
+ import static androidx .test .espresso .Espresso .onView ;
5
+ import static androidx .test .espresso .action .ViewActions .click ;
6
+ import static androidx .test .espresso .action .ViewActions .swipeLeft ;
7
+ import static androidx .test .espresso .assertion .ViewAssertions .matches ;
8
+ import static androidx .test .espresso .matcher .ViewMatchers .isDisplayed ;
9
+ import static androidx .test .espresso .matcher .ViewMatchers .withId ;
10
+ import static androidx .test .espresso .matcher .ViewMatchers .withText ;
11
+ import static org .hamcrest .Matchers .allOf ;
12
+ import static org .hamcrest .Matchers .anything ;
13
+ import static org .hamcrest .Matchers .containsString ;
14
+
15
+ import androidx .test .espresso .assertion .ViewAssertions ;
3
16
import androidx .test .ext .junit .runners .AndroidJUnit4 ;
4
17
5
18
import com .schibsted .spain .barista .rule .flaky .AllowFlaky ;
20
33
import org .openobservatory .ooniprobe .test .test .Ndt ;
21
34
import org .openobservatory .ooniprobe .utils .FormattingUtils ;
22
35
23
- import static androidx .test .espresso .Espresso .onView ;
24
- import static androidx .test .espresso .action .ViewActions .click ;
25
- import static androidx .test .espresso .action .ViewActions .swipeLeft ;
26
- import static androidx .test .espresso .assertion .ViewAssertions .matches ;
27
- import static androidx .test .espresso .contrib .RecyclerViewActions .actionOnItemAtPosition ;
28
- import static androidx .test .espresso .contrib .RecyclerViewActions .scrollToPosition ;
29
- import static androidx .test .espresso .matcher .ViewMatchers .isDisplayed ;
30
- import static androidx .test .espresso .matcher .ViewMatchers .withId ;
31
- import static androidx .test .espresso .matcher .ViewMatchers .withText ;
32
- import static org .hamcrest .Matchers .allOf ;
33
- import static org .hamcrest .Matchers .containsString ;
34
- import static org .openobservatory .ooniprobe .ui .utils .RecyclerViewMatcher .withRecyclerView ;
35
-
36
36
@ RunWith (AndroidJUnit4 .class )
37
37
public class PerformanceTest extends MeasurementAbstractTest {
38
38
@@ -112,35 +112,34 @@ public void testListOfMeasurements() {
112
112
launchDetails (testResult .id );
113
113
114
114
// Assert
115
- onView (withId (R .id .recyclerView ))
116
- .perform (scrollToPosition (0 ));
117
-
118
- onView (withRecyclerView (R .id .recyclerView )
119
- .atPositionOnView (0 , R .id .data1 ))
120
- .check (matches (withText (download + " " + downloadUnity )));
121
- onView (withRecyclerView (R .id .recyclerView )
122
- .atPositionOnView (0 , R .id .data2 ))
123
- .check (matches (withText (upload + " " + uploadUnity )));
124
-
125
- onView (withId (R .id .recyclerView ))
126
- .perform (scrollToPosition (1 ));
127
-
128
- onView (withRecyclerView (R .id .recyclerView )
129
- .atPositionOnView (1 , R .id .data1 ))
115
+ onData (anything ())
116
+ .inAdapterView (withId (R .id .recyclerView ))
117
+ .atPosition (0 )
118
+ .onChildView (withId (R .id .data1 ))
119
+ .check (ViewAssertions .matches (withText (download + " " + downloadUnity )));
120
+
121
+ onData (anything ())
122
+ .inAdapterView (withId (R .id .recyclerView ))
123
+ .atPosition (0 )
124
+ .onChildView (withId (R .id .data2 ))
125
+ .check (matches (withText (upload + " " + uploadUnity )));
126
+
127
+ onData (anything ())
128
+ .inAdapterView (withId (R .id .recyclerView ))
129
+ .atPosition (1 )
130
+ .onChildView (withId (R .id .data1 ))
130
131
.check (matches (withText (videoQuality )));
131
132
132
- onView (withId (R .id .recyclerView ))
133
- .perform (scrollToPosition (2 ));
134
-
135
- onView (withRecyclerView (R .id .recyclerView )
136
- .atPositionOnView (2 , R .id .data1 ))
133
+ onData (anything ())
134
+ .inAdapterView (withId (R .id .recyclerView ))
135
+ .atPosition (2 )
136
+ .onChildView (withId (R .id .data1 ))
137
137
.check (matches (withText (notDetected )));
138
138
139
- onView (withId (R .id .recyclerView ))
140
- .perform (scrollToPosition (3 ));
141
-
142
- onView (withRecyclerView (R .id .recyclerView )
143
- .atPositionOnView (3 , R .id .data1 ))
139
+ onData (anything ())
140
+ .inAdapterView (withId (R .id .recyclerView ))
141
+ .atPosition (3 )
142
+ .onChildView (withId (R .id .data1 ))
144
143
.check (matches (withText (notDetected )));
145
144
}
146
145
@@ -174,7 +173,7 @@ public void testNDT() {
174
173
175
174
// Act
176
175
launchDetails (testResult .id );
177
- onView ( withId (R .id .recyclerView )).perform ( actionOnItemAtPosition ( 0 , click () ));
176
+ onData ( anything ()). inAdapterView ( withId (R .id .recyclerView )).atPosition ( 0 ). perform ( click ());
178
177
179
178
// Assert
180
179
onView (withText (download + downloadUnity )).check (matches (isDisplayed ()));
@@ -202,7 +201,7 @@ public void testStreaming() {
202
201
203
202
// Act
204
203
launchDetails (testResult .id );
205
- onView ( withId (R .id .recyclerView )).perform ( actionOnItemAtPosition ( 1 , click () ));
204
+ onData ( anything ()). inAdapterView ( withId (R .id .recyclerView )).atPosition ( 1 ). perform ( click ());
206
205
207
206
// Assert
208
207
onView (withText (containsString (videoQuality ))).check (matches (isDisplayed ()));
@@ -219,7 +218,7 @@ public void testRequestLine() {
219
218
220
219
// Act
221
220
launchDetails (testResult .id );
222
- onView ( withId (R .id .recyclerView )).perform ( actionOnItemAtPosition ( 2 , click () ));
221
+ onData ( anything ()). inAdapterView ( withId (R .id .recyclerView )).atPosition ( 2 ). perform ( click ());
223
222
224
223
// Assert
225
224
onView (withText (getResourceString (R .string .TestResults_Details_Middleboxes_HTTPInvalidRequestLine_NotFound_Hero_Title ))).check (matches (isDisplayed ()));
@@ -234,7 +233,7 @@ public void testRequestLineDetection() {
234
233
235
234
// Act
236
235
launchDetails (testResult .id );
237
- onView ( withId (R .id .recyclerView )).perform ( actionOnItemAtPosition ( 2 , click () ));
236
+ onData ( anything ()). inAdapterView ( withId (R .id .recyclerView )).atPosition ( 2 ). perform ( click ());
238
237
239
238
// Assert
240
239
onView (withText (getResourceString (R .string .TestResults_Details_Middleboxes_HTTPInvalidRequestLine_Found_Hero_Title ))).check (matches (isDisplayed ()));
@@ -249,7 +248,7 @@ public void testFieldManipulation() {
249
248
250
249
// Act
251
250
launchDetails (testResult .id );
252
- onView ( withId (R .id .recyclerView )).perform ( actionOnItemAtPosition ( 3 , click () ));
251
+ onData ( anything ()). inAdapterView ( withId (R .id .recyclerView )).atPosition ( 3 ). perform ( click ());
253
252
254
253
// Assert
255
254
onView (withText (getResourceString (R .string .TestResults_Details_Middleboxes_HTTPHeaderFieldManipulation_NotFound_Hero_Title ))).check (matches (isDisplayed ()));
@@ -264,7 +263,7 @@ public void testFieldManipulationDetection() {
264
263
265
264
// Act
266
265
launchDetails (testResult .id );
267
- onView ( withId (R .id .recyclerView )).perform ( actionOnItemAtPosition ( 3 , click () ));
266
+ onData ( anything ()). inAdapterView ( withId (R .id .recyclerView )).atPosition ( 3 ). perform ( click ());
268
267
269
268
// Assert
270
269
onView (withText (getResourceString (R .string .TestResults_Details_Middleboxes_HTTPHeaderFieldManipulation_Found_Hero_Title ))).check (matches (isDisplayed ()));
0 commit comments