Skip to content

Commit

Permalink
Hide software keyboard to avoid security exception on older Android b…
Browse files Browse the repository at this point in the history
…uilds

The Dialog tests are currently failing on Android API 15 due to a Java
SecurityException related to a missing permission of INJECT_EVENTS.
Hopefully, hiding the keyboard will avoid the exception.
  • Loading branch information
penguin359 committed Jan 5, 2022
1 parent 5da5eec commit 8cd6299
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions androidTest/java/org/aprsdroid/app/FirstRunDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
Expand Down Expand Up @@ -50,10 +51,10 @@ public void givenAFirstTimeRun_whenProvidedABadPasscode_ThenDialogStaysOpen() {
hasDescendant(withId(R.id.passcode)))));
onView(withId(R.id.callsign))
.check(matches(withHint(containsString("Callsign"))))
.perform(typeText("XA1AAA"));
.perform(closeSoftKeyboard(), typeText("XA1AAA"));
onView(withId(R.id.passcode))
.check(matches(withHint(containsString("Passcode"))))
.perform(typeText("12345"));
.perform(closeSoftKeyboard(), typeText("12345"));
onView(withId(android.R.id.button1)).perform(click()); // OK Button
onView(isRoot())
.inRoot(isDialog())
Expand All @@ -78,10 +79,10 @@ public void givenAFirstTimeRun_whenProvidedAGoodPasscode_ThenDialogCloses() {
hasDescendant(withId(R.id.passcode)))));
onView(withId(R.id.callsign))
.check(matches(withHint(containsString("Callsign"))))
.perform(typeText("XA1AAA"));
.perform(closeSoftKeyboard(), typeText("XA1AAA"));
onView(withId(R.id.passcode))
.check(matches(withHint(containsString("Passcode"))))
.perform(typeText("23459"));
.perform(closeSoftKeyboard(), typeText("23459"));
onView(withId(android.R.id.button1)).perform(click()); // OK Button
onView(allOf(
isRoot(),
Expand All @@ -100,10 +101,10 @@ public void givenAFirstTimeRun_whenProvidedAGoodPasscode_ThenPrefsSaved() {
Assert.assertNull("Passcode", prefs.getString(pref_passcode, null));
onView(withId(R.id.callsign))
.check(matches(withHint(containsString("Callsign"))))
.perform(typeText(expected_callsign));
.perform(closeSoftKeyboard(), typeText(expected_callsign));
onView(withId(R.id.passcode))
.check(matches(withHint(containsString("Passcode"))))
.perform(typeText(expected_passcode));
.perform(closeSoftKeyboard(), typeText(expected_passcode));
onView(withId(android.R.id.button1)).perform(click()); // OK Button
Assert.assertEquals("Callsign", expected_callsign, prefs.getString(pref_callsign, null));
Assert.assertEquals("Passcode", expected_passcode, prefs.getString(pref_passcode, null));
Expand Down

0 comments on commit 8cd6299

Please sign in to comment.