-
-
Notifications
You must be signed in to change notification settings - Fork 238
Expand file tree
/
Copy pathLanguageChangeUITest.java
More file actions
158 lines (136 loc) · 6.96 KB
/
LanguageChangeUITest.java
File metadata and controls
158 lines (136 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package protect.card_locker;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withParent;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.is;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.test.espresso.DataInteraction;
import androidx.test.espresso.ViewInteraction;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class LanguageChangeUITest {
@Rule
public ActivityScenarioRule<MainActivity> mActivityScenarioRule =
new ActivityScenarioRule<>(MainActivity.class);
@Test
public void languageChangeUITest() {
ViewInteraction overflowMenuButton = onView(
allOf(withContentDescription(R.string.action_more_options),
isDisplayed()));
overflowMenuButton.perform(click());
ViewInteraction materialTextView = onView(
allOf(withId(androidx.recyclerview.R.id.title), withText("Settings"),
childAtPosition(
childAtPosition(
withId(androidx.appcompat.R.id.content),
0),
0),
isDisplayed()));
materialTextView.perform(click());
ViewInteraction recyclerView = onView(
allOf(withId(com.jaredrummler.android.colorpicker.R.id.recycler_view),
childAtPosition(
withId(android.R.id.list_container),
0)));
recyclerView.perform(actionOnItemAtPosition(4, click()));
DataInteraction appCompatCheckedTextView = onData(anything())
.inAdapterView(allOf(withId(androidx.appcompat.R.id.select_dialog_listview),
childAtPosition(
withId(androidx.appcompat.R.id.contentPanel),
0)))
.atPosition(8);
appCompatCheckedTextView.perform(click());
ViewInteraction textView = onView(
allOf(withText("Einstellungen"),
withParent(allOf(withId(R.id.toolbar),
withParent(IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class)))),
isDisplayed()));
textView.check(matches(withText("Einstellungen")));
ViewInteraction recyclerView2 = onView(
allOf(withId(com.jaredrummler.android.colorpicker.R.id.recycler_view),
childAtPosition(
withId(android.R.id.list_container),
0)));
recyclerView2.perform(actionOnItemAtPosition(4, click()));
DataInteraction appCompatCheckedTextView2 = onData(anything())
.inAdapterView(allOf(withId(androidx.appcompat.R.id.select_dialog_listview),
childAtPosition(
withId(androidx.appcompat.R.id.contentPanel),
0)))
.atPosition(9);
appCompatCheckedTextView2.perform(click());
ViewInteraction textView2 = onView(
allOf(withText("Ρυθμίσεις"),
withParent(allOf(withId(R.id.toolbar),
withParent(IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class)))),
isDisplayed()));
textView2.check(matches(withText("Ρυθμίσεις")));
ViewInteraction recyclerView3 = onView(
allOf(withId(com.jaredrummler.android.colorpicker.R.id.recycler_view),
childAtPosition(
withId(android.R.id.list_container),
0)));
recyclerView3.perform(actionOnItemAtPosition(4, click()));
DataInteraction appCompatCheckedTextView3 = onData(anything())
.inAdapterView(allOf(withId(androidx.appcompat.R.id.select_dialog_listview),
childAtPosition(
withId(androidx.appcompat.R.id.contentPanel),
0)))
.atPosition(0);
appCompatCheckedTextView3.perform(click());
ViewInteraction appCompatImageButton = onView(
allOf(withContentDescription("Navigate up"),
childAtPosition(
allOf(withId(R.id.toolbar),
childAtPosition(
withClassName(is("com.google.android.material.appbar.AppBarLayout")),
0)),
1),
isDisplayed()));
appCompatImageButton.perform(click());
ViewInteraction textView3 = onView(
allOf(withId(R.id.welcome_text), withText("Welcome to Catima"),
withParent(allOf(withId(R.id.helpSection),
withParent(withId(R.id.include)))),
isDisplayed()));
textView3.check(matches(withText("Welcome to Catima")));
}
private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent)
&& view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
}