mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 06:35:48 +03:00
test to fix checkToolbarTitleOnNavigation
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
cc3cff6f62
commit
94ed70d4b5
1 changed files with 59 additions and 0 deletions
|
@ -21,6 +21,8 @@ import androidx.test.espresso.contrib.RecyclerViewActions
|
||||||
import androidx.test.espresso.matcher.ViewMatchers
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
|
@ -37,11 +39,19 @@ import com.owncloud.android.operations.CreateFolderOperation
|
||||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||||
import com.owncloud.android.ui.adapter.OCFileListItemViewHolder
|
import com.owncloud.android.ui.adapter.OCFileListItemViewHolder
|
||||||
import com.owncloud.android.utils.EspressoIdlingResource
|
import com.owncloud.android.utils.EspressoIdlingResource
|
||||||
|
import org.hamcrest.Matchers.allOf
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import android.view.View
|
||||||
|
import androidx.test.espresso.PerformException
|
||||||
|
import androidx.test.espresso.UiController
|
||||||
|
import androidx.test.espresso.ViewAction
|
||||||
|
import androidx.test.espresso.util.HumanReadables
|
||||||
|
import org.hamcrest.Matcher
|
||||||
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
class FileDisplayActivityIT : AbstractOnServerIT() {
|
class FileDisplayActivityIT : AbstractOnServerIT() {
|
||||||
|
|
||||||
|
@ -58,6 +68,45 @@ class FileDisplayActivityIT : AbstractOnServerIT() {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val retryRule = RetryTestRule()
|
val retryRule = RetryTestRule()
|
||||||
|
|
||||||
|
private fun waitForView(matcher: Matcher<View>, timeout: Long): ViewAction {
|
||||||
|
return object : ViewAction {
|
||||||
|
override fun getConstraints(): Matcher<View> {
|
||||||
|
return isRoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getDescription(): String {
|
||||||
|
return "wait for a specific view with timeout $timeout millis"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun perform(uiController: UiController, view: View) {
|
||||||
|
uiController.loopMainThreadUntilIdle()
|
||||||
|
val startTime = System.currentTimeMillis()
|
||||||
|
val endTime = startTime + timeout
|
||||||
|
|
||||||
|
do {
|
||||||
|
val viewFound = try {
|
||||||
|
onView(matcher).check { _, _ -> /* view exists */ }
|
||||||
|
true
|
||||||
|
} catch (e: Exception) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewFound) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uiController.loopMainThreadForAtLeast(50)
|
||||||
|
} while (System.currentTimeMillis() < endTime)
|
||||||
|
|
||||||
|
throw PerformException.Builder()
|
||||||
|
.withActionDescription(description)
|
||||||
|
.withViewDescription(HumanReadables.describe(view))
|
||||||
|
.withCause(TimeoutException())
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@Test
|
@Test
|
||||||
fun showShares() {
|
fun showShares() {
|
||||||
|
@ -169,6 +218,16 @@ class FileDisplayActivityIT : AbstractOnServerIT() {
|
||||||
CreateFolderOperation("/$topFolder/$childFolder/", user, targetContext, storageManager)
|
CreateFolderOperation("/$topFolder/$childFolder/", user, targetContext, storageManager)
|
||||||
.execute(client)
|
.execute(client)
|
||||||
|
|
||||||
|
onView(isRoot()).perform(waitForView(withText(topFolder), 5000))
|
||||||
|
|
||||||
|
onView(
|
||||||
|
allOf(
|
||||||
|
withText(topFolder),
|
||||||
|
isDisplayed(),
|
||||||
|
isEnabled()
|
||||||
|
)
|
||||||
|
).perform(click())
|
||||||
|
|
||||||
EspressoIdlingResource.decrement()
|
EspressoIdlingResource.decrement()
|
||||||
|
|
||||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||||
|
|
Loading…
Reference in a new issue