Skip to content

Commit 400a7a0

Browse files
renovate[bot]renovate-botNinjaman494
authored
Update dependency org.mockito:mockito-core to v3 (#82)
* Update dependency org.mockito:mockito-core to v3 * Update dependency org.mockito:mockito-core to v3 * Updated test * Bump up api to 29 * Bump up api to 30 * back to 28 * Downgrade to 23 * Upgrade to 27 and remove unneeded overflow tests * Update api-level and set arch * Downgrade back to 27 * Add 90% check * undid changes * Add arch back in * Added custom scroll to Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Akash Eldo <[email protected]>
1 parent dd248ee commit 400a7a0

File tree

8 files changed

+79
-26
lines changed

8 files changed

+79
-26
lines changed

.github/workflows/instrumentedTest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
with:
3737
api-level: 27
3838
profile: pixel_3_xl
39+
arch: x86_64
3940
disable-animations: true
4041
script: ./gradlew connectedDebugAndroidTest --stacktrace --scan
4142

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ dependencies {
151151
implementation 'androidx.test.espresso:espresso-contrib:3.4.0' // Needed for idler
152152
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
153153
testImplementation 'junit:junit:4.13'
154-
testImplementation 'org.mockito:mockito-core:1.10.19'
154+
testImplementation 'org.mockito:mockito-core:3.11.2'
155155
testImplementation 'org.robolectric:robolectric:4.2.1' // Can't be upgraded until #5454 is fixed
156156
testImplementation 'androidx.test:core:1.4.0'
157157
testImplementation 'androidx.test:rules:1.4.0'

app/src/androidTest/java/com/a494studios/koreanconjugator/tests/ConjInfoActivityTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ protected Intent getActivityIntent() {
6161
@Rule
6262
public StubIntentsRule intentsRule = new StubIntentsRule(ConjInfoActivity.class.getName());
6363

64-
@Test
65-
public void overflowOptions() {
66-
testActionBar();
67-
}
68-
6964
@Test
7065
public void test_displaysData() {
7166
checkUI();

app/src/androidTest/java/com/a494studios/koreanconjugator/tests/ConjugationActivityTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ public void tearDown() {
8787
IdlingRegistry.getInstance().unregister(idler);
8888
}
8989

90-
@Test
91-
public void overflowOptions() {
92-
testActionBar();
93-
}
94-
9590
@Test
9691
public void test_displayAfterRotation() {
9792
activityRule.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

app/src/androidTest/java/com/a494studios/koreanconjugator/tests/ConjugatorActivityTest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
import static androidx.test.espresso.matcher.ViewMatchers.withText;
3636
import static com.a494studios.koreanconjugator.MockReader.readStringFromFile;
3737
import static com.a494studios.koreanconjugator.Utils.assertBodyContains;
38-
import static com.a494studios.koreanconjugator.Utils.testActionBar;
38+
import static com.a494studios.koreanconjugator.Utils.nestedScrollTo;
39+
import static org.hamcrest.Matchers.allOf;
3940

4041
@RunWith(AndroidJUnit4.class)
4142
@LargeTest
@@ -80,11 +81,6 @@ public void tearDown() {
8081
IdlingRegistry.getInstance().unregister(idler);
8182
}
8283

83-
@Test
84-
public void overflowOptions() {
85-
testActionBar();
86-
}
87-
8884
@Test
8985
public void stems_areDisplayed() {
9086
onView(withId(R.id.conjugator_stemSpinner)).check(matches(withSpinnerText("노랄다")));
@@ -112,13 +108,13 @@ public void changingParams_causesNewRequest() throws InterruptedException {
112108
"\"stem\":\"노랗다\"");
113109

114110
// Change POS
115-
onView(withId(R.id.conjugator_posSpinner)).perform(click());
111+
onView(allOf(withId(R.id.conjugator_posSpinner))).perform(nestedScrollTo(), click());
116112
onView(withText("Adjective")).perform(click());
117113
assertBodyContains(serverRule.server.takeRequest(2, TimeUnit.SECONDS),
118114
"\"isAdj\":true");
119115

120116
// Change regularity
121-
onView(withId(R.id.conjugator_regSpinner)).perform(click());
117+
onView(allOf(withId(R.id.conjugator_regSpinner))).perform(nestedScrollTo(), click());
122118
onView(withText("Irregular verb/adjective")).perform(click());
123119
assertBodyContains(serverRule.server.takeRequest(2, TimeUnit.SECONDS),
124120
"\"regular\":false");

app/src/androidTest/java/com/a494studios/koreanconjugator/tests/SearchResultsActivityTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ public void setup() {
8888
testApp.setAdFree(true);
8989
}
9090

91-
@Test
92-
public void overflowOptions() {
93-
activityRule.launchActivity(null);
94-
testActionBar();
95-
}
96-
9791
@After
9892
public void teardown() {
9993
IdlingRegistry.getInstance().unregister(idler);

app/src/sharedTest/java/com/a494studios/koreanconjugator/Utils.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22

33
import android.view.View;
44
import android.view.ViewGroup;
5+
import android.view.ViewParent;
56
import android.widget.Checkable;
7+
import android.widget.FrameLayout;
68

9+
import androidx.core.widget.NestedScrollView;
10+
import androidx.test.espresso.PerformException;
711
import androidx.test.espresso.UiController;
812
import androidx.test.espresso.ViewAction;
913
import androidx.test.espresso.ViewInteraction;
14+
import androidx.test.espresso.matcher.ViewMatchers;
15+
import androidx.test.espresso.util.HumanReadables;
1016

1117
import com.a494studios.koreanconjugator.settings.SettingsActivity;
1218
import com.eggheadgames.aboutbox.activity.AboutActivity;
1319

1420
import org.hamcrest.BaseMatcher;
1521
import org.hamcrest.Description;
1622
import org.hamcrest.Matcher;
23+
import org.hamcrest.Matchers;
1724
import org.hamcrest.TypeSafeMatcher;
1825

1926
import okhttp3.mockwebserver.RecordedRequest;
@@ -23,8 +30,11 @@
2330
import static androidx.test.espresso.assertion.ViewAssertions.matches;
2431
import static androidx.test.espresso.intent.Intents.intended;
2532
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
33+
import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom;
34+
import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA;
2635
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
2736
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
37+
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
2838
import static androidx.test.espresso.matcher.ViewMatchers.withText;
2939
import static junit.framework.TestCase.assertNotNull;
3040
import static junit.framework.TestCase.assertTrue;
@@ -109,4 +119,66 @@ public static void assertBodyContains(RecordedRequest request, String contains)
109119
String requestBody = request.getBody().clone().readUtf8();
110120
assertTrue(requestBody.contains(contains));
111121
}
122+
123+
public static ViewAction nestedScrollTo() {
124+
return new ViewAction() {
125+
126+
@Override
127+
public Matcher<View> getConstraints() {
128+
return Matchers.allOf(
129+
isDescendantOfA(isAssignableFrom(NestedScrollView.class)),
130+
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE));
131+
}
132+
133+
@Override
134+
public String getDescription() {
135+
return "View is not NestedScrollView";
136+
}
137+
138+
@Override
139+
public void perform(UiController uiController, View view) {
140+
try {
141+
NestedScrollView nestedScrollView = (NestedScrollView)
142+
findFirstParentLayoutOfClass(view, NestedScrollView.class);
143+
if (nestedScrollView != null) {
144+
nestedScrollView.scrollTo(0, view.getTop());
145+
} else {
146+
throw new Exception("Unable to find NestedScrollView parent.");
147+
}
148+
} catch (Exception e) {
149+
throw new PerformException.Builder()
150+
.withActionDescription(this.getDescription())
151+
.withViewDescription(HumanReadables.describe(view))
152+
.withCause(e)
153+
.build();
154+
}
155+
uiController.loopMainThreadUntilIdle();
156+
}
157+
158+
};
159+
}
160+
161+
private static View findFirstParentLayoutOfClass(View view, Class<? extends View> parentClass) {
162+
ViewParent parent = new FrameLayout(view.getContext());
163+
ViewParent incrementView = null;
164+
int i = 0;
165+
while (parent != null && !(parent.getClass() == parentClass)) {
166+
if (i == 0) {
167+
parent = findParent(view);
168+
} else {
169+
parent = findParent(incrementView);
170+
}
171+
incrementView = parent;
172+
i++;
173+
}
174+
return (View) parent;
175+
}
176+
177+
private static ViewParent findParent(View view) {
178+
return view.getParent();
179+
}
180+
181+
private static ViewParent findParent(ViewParent view) {
182+
return view.getParent();
183+
}
112184
}

app/src/test/java/com/a494studios/koreanconjugator/display/DisplayCardViewUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void test_setCardBody() {
8383
TextView headingView = view.findViewById(HEADING_ID);
8484

8585
when(cardBody.addBodyView(any(), any(), any())).then(invocation -> {
86-
DisplayCardView cardView = invocation.getArgumentAt(2, DisplayCardView.class);
86+
DisplayCardView cardView = invocation.getArgument(2);
8787
cardView.setButtonText(btnText);
8888
return null;
8989
});

0 commit comments

Comments
 (0)