diff options
author | Kenny Root <kenny@the-b.org> | 2015-08-29 22:49:14 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-08-29 22:49:14 -0700 |
commit | 027fc24477fa1ffbf8c3cd4e9295e5c523b72f7d (patch) | |
tree | 5e05f178e3a58bf2a2e541fe684e1aaf11b9531b /app/src/androidTest | |
parent | 1b09070fbf3f1224a5d509c5954ef9560eaf9ba1 (diff) | |
parent | 6b1537f524a4463ac8655ec8dd54dda9eff0b875 (diff) | |
download | connectbot-027fc24477fa1ffbf8c3cd4e9295e5c523b72f7d.tar.gz connectbot-027fc24477fa1ffbf8c3cd4e9295e5c523b72f7d.tar.bz2 connectbot-027fc24477fa1ffbf8c3cd4e9295e5c523b72f7d.zip |
Merge pull request #160 from kruton/state-race
Fix race condition in updating the HostListActivity with current host statuses
Diffstat (limited to 'app/src/androidTest')
-rw-r--r-- | app/src/androidTest/java/org/connectbot/StartupTest.java | 31 |
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))); } } |