Compare commits
1 Commits
8a7743a6fb
...
f7f75dcdc7
Author | SHA1 | Date | |
---|---|---|---|
f7f75dcdc7 |
@ -6,7 +6,6 @@ import androidx.test.espresso.IdlingRegistry
|
|||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isSelected
|
import androidx.test.espresso.matcher.ViewMatchers.isSelected
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
@ -97,7 +96,6 @@ class `3-SettingsActivityTest` : WithANRException() {
|
|||||||
@Test
|
@Test
|
||||||
fun testAbout() {
|
fun testAbout() {
|
||||||
onView(withText(R.string.action_about)).perform(click())
|
onView(withText(R.string.action_about)).perform(click())
|
||||||
onView(isRoot()).perform(waitUntilShown("ACRA", 30000))
|
|
||||||
onView(withText("ACRA")).check(matches(isDisplayed()))
|
onView(withText("ACRA")).check(matches(isDisplayed()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ fun testAddSourceWithUrl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkHomeLoadingDone() {
|
fun checkHomeLoadingDone() {
|
||||||
onView(withId(R.id.swipeRefreshLayout)).inRoot(not(isDialog())).perform(waitForRecyclerViewToStopLoading(300000))
|
onView(withId(R.id.swipeRefreshLayout)).inRoot(not(isDialog())).perform(waitUntilNotLoading(300000))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("detekt:UtilityClassWithPublicConstructor")
|
@Suppress("detekt:UtilityClassWithPublicConstructor")
|
||||||
|
@ -18,7 +18,6 @@ import androidx.test.espresso.UiController
|
|||||||
import androidx.test.espresso.ViewAction
|
import androidx.test.espresso.ViewAction
|
||||||
import androidx.test.espresso.matcher.RootMatchers.isPlatformPopup
|
import androidx.test.espresso.matcher.RootMatchers.isPlatformPopup
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withClassName
|
import androidx.test.espresso.matcher.ViewMatchers.withClassName
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
@ -54,50 +53,11 @@ fun withError(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun waitUntilShown(
|
fun waitUntilNotLoading(millis: Long): ViewAction {
|
||||||
viewText: String,
|
|
||||||
millis: Long,
|
|
||||||
): ViewAction {
|
|
||||||
return object : ViewAction {
|
|
||||||
override fun getConstraints(): Matcher<View> = isRoot()
|
|
||||||
|
|
||||||
override fun getDescription(): String = "wait for $millis millis, for a specific view with text <$viewText> to be visible."
|
|
||||||
|
|
||||||
override fun perform(
|
|
||||||
uiController: UiController,
|
|
||||||
view: View,
|
|
||||||
) {
|
|
||||||
uiController.loopMainThreadUntilIdle()
|
|
||||||
val startTime = System.currentTimeMillis()
|
|
||||||
val endTime = startTime + millis
|
|
||||||
val viewMatcher = withText(viewText)
|
|
||||||
|
|
||||||
do {
|
|
||||||
for (child in TreeIterables.breadthFirstViewTraversal(view)) {
|
|
||||||
if (viewMatcher.matches(child) && child.isShown) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uiController.loopMainThreadForAtLeast(100)
|
|
||||||
} while (System.currentTimeMillis() < endTime)
|
|
||||||
|
|
||||||
// timeout happens
|
|
||||||
throw PerformException
|
|
||||||
.Builder()
|
|
||||||
.withActionDescription(this.description)
|
|
||||||
.withViewDescription(HumanReadables.describe(view))
|
|
||||||
.withCause(TimeoutException())
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun waitForRecyclerViewToStopLoading(millis: Long): ViewAction {
|
|
||||||
return object : ViewAction {
|
return object : ViewAction {
|
||||||
override fun getConstraints(): Matcher<View> = any(View::class.java)
|
override fun getConstraints(): Matcher<View> = any(View::class.java)
|
||||||
|
|
||||||
override fun getDescription(): String = "wait for $millis millis for the recyclerview to stop loading."
|
override fun getDescription(): String = "wait for a specific view is not loading during $millis millis."
|
||||||
|
|
||||||
override fun perform(
|
override fun perform(
|
||||||
uiController: UiController,
|
uiController: UiController,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user