9
9
import android .support .test .filters .LargeTest ;
10
10
import android .support .test .rule .ActivityTestRule ;
11
11
import android .support .test .runner .AndroidJUnit4 ;
12
- import android .view .View ;
13
12
14
- import org .hamcrest .Matcher ;
13
+ import org .hamcrest .Matchers ;
15
14
import org .junit .Rule ;
16
15
import org .junit .Test ;
17
16
import org .junit .runner .RunWith ;
20
19
21
20
import fr .free .nrw .commons .settings .SettingsActivity ;
22
21
23
- import static org .hamcrest .Matchers .allOf ;
24
- import static org .hamcrest .Matchers .anything ;
25
-
26
22
@ LargeTest
27
23
@ RunWith (AndroidJUnit4 .class )
28
24
public class SettingsActivityTest {
@@ -65,8 +61,8 @@ protected void afterActivityFinished() {
65
61
@ Test
66
62
public void oneLicenseIsChecked () {
67
63
// click "License" (the first item)
68
- Espresso .onData (anything ())
69
- .inAdapterView (findPreferenceList ( ))
64
+ Espresso .onData (Matchers . anything ())
65
+ .inAdapterView (ViewMatchers . withId ( android . R . id . list ))
70
66
.atPosition (0 )
71
67
.perform (ViewActions .click ());
72
68
@@ -78,8 +74,8 @@ public void oneLicenseIsChecked() {
78
74
@ Test
79
75
public void afterClickingCcby4ItWillStay () {
80
76
// click "License" (the first item)
81
- Espresso .onData (anything ())
82
- .inAdapterView (findPreferenceList ( ))
77
+ Espresso .onData (Matchers . anything ())
78
+ .inAdapterView (ViewMatchers . withId ( android . R . id . list ))
83
79
.atPosition (0 )
84
80
.perform (ViewActions .click ());
85
81
@@ -89,8 +85,8 @@ public void afterClickingCcby4ItWillStay() {
89
85
).perform (ViewActions .click ());
90
86
91
87
// click "License" (the first item)
92
- Espresso .onData (anything ())
93
- .inAdapterView (findPreferenceList ( ))
88
+ Espresso .onData (Matchers . anything ())
89
+ .inAdapterView (ViewMatchers . withId ( android . R . id . list ))
94
90
.atPosition (0 )
95
91
.perform (ViewActions .click ());
96
92
@@ -100,12 +96,4 @@ public void afterClickingCcby4ItWillStay() {
100
96
ViewMatchers .withText (R .string .license_name_cc_by_four )
101
97
));
102
98
}
103
-
104
- private static Matcher <View > findPreferenceList () {
105
- return allOf (
106
- ViewMatchers .isDescendantOfA (ViewMatchers .withId (R .id .settingsFragment )),
107
- ViewMatchers .withResourceName ("list" ),
108
- ViewMatchers .hasFocus ()
109
- );
110
- }
111
- }
99
+ }
0 commit comments