aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/androidTest
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-08-29 11:08:44 -0700
committerKenny Root <kenny@the-b.org>2015-08-29 11:09:38 -0700
commit8b181e9087b292dd6311ea2939393cd9493147e6 (patch)
tree67d16f05c9254b52508f486a344f8ba2d2c40a43 /app/src/androidTest
parent35aea80ce7ec8cf6d169c1a1385533ba82706376 (diff)
downloadconnectbot-8b181e9087b292dd6311ea2939393cd9493147e6.tar.gz
connectbot-8b181e9087b292dd6311ea2939393cd9493147e6.tar.bz2
connectbot-8b181e9087b292dd6311ea2939393cd9493147e6.zip
Update StartupTest to be a bit more fluent
Diffstat (limited to 'app/src/androidTest')
-rw-r--r--app/src/androidTest/java/org/connectbot/StartupTest.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/app/src/androidTest/java/org/connectbot/StartupTest.java b/app/src/androidTest/java/org/connectbot/StartupTest.java
index ea5b584..0eb9c11 100644
--- a/app/src/androidTest/java/org/connectbot/StartupTest.java
+++ b/app/src/androidTest/java/org/connectbot/StartupTest.java
@@ -13,12 +13,10 @@ import org.junit.runner.RunWith;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
-import android.support.test.espresso.ViewAssertion;
import android.support.test.espresso.intent.Intents;
import android.support.test.espresso.matcher.BoundedMatcher;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
@@ -28,7 +26,7 @@ import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.longClick;
import static android.support.test.espresso.action.ViewActions.pressBack;
-import static android.support.test.espresso.action.ViewActions.pressKey;
+import static android.support.test.espresso.action.ViewActions.pressImeActionButton;
import static android.support.test.espresso.action.ViewActions.pressMenuKey;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
@@ -64,7 +62,7 @@ public class StartupTest {
// Make sure we're still connected.
onData(withHostNickname("Local")).inAdapterView(withId(android.R.id.list))
- .check(hostConnected())
+ .check(matches(hostConnected()))
.perform(longClick());
// Click on the disconnect context menu item.
@@ -72,7 +70,7 @@ public class StartupTest {
// Now make sure we're disconnected.
onData(withHostNickname("Local")).inAdapterView(withId(android.R.id.list))
- .check(hostDisconnected());
+ .check(matches(hostDisconnected()));
}
@Test
@@ -86,7 +84,7 @@ public class StartupTest {
// Now make sure we're disconnected.
onData(withHostNickname("Local")).inAdapterView(withId(android.R.id.list))
- .check(hostDisconnected());
+ .check(matches(hostDisconnected()));
}
private void startNewLocalConnection() {
@@ -95,9 +93,12 @@ public class StartupTest {
onView(withId(R.id.front_quickconnect)).perform(typeText("Local"));
Intents.init();
- onView(withId(R.id.front_quickconnect)).perform(pressKey(KeyEvent.KEYCODE_ENTER));
- intended(hasComponent(ConsoleActivity.class.getName()));
- Intents.release();
+ try {
+ onView(withId(R.id.front_quickconnect)).perform(pressImeActionButton());
+ intended(hasComponent(ConsoleActivity.class.getName()));
+ } finally {
+ Intents.release();
+ }
onView(withId(R.id.console_flip)).check(matches(
hasDescendant(allOf(isDisplayed(), withId(R.id.terminal_view)))));
@@ -148,14 +149,14 @@ public class StartupTest {
}
@NonNull
- private ViewAssertion hostDisconnected() {
- return matches(hasDescendant(allOf(withId(android.R.id.icon),
- withDrawableState(android.R.attr.state_expanded))));
+ private Matcher<View> hostDisconnected() {
+ return hasDescendant(allOf(withId(android.R.id.icon),
+ withDrawableState(android.R.attr.state_expanded)));
}
@NonNull
- private ViewAssertion hostConnected() {
- return matches(hasDescendant(allOf(withId(android.R.id.icon),
- withDrawableState(android.R.attr.state_checked))));
+ private Matcher<View> hostConnected() {
+ return hasDescendant(allOf(withId(android.R.id.icon),
+ withDrawableState(android.R.attr.state_checked)));
}
}