mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 06:51:55 +03:00
Merge pull request #14097 from nextcloud/fix-backup-list-fragment-ss-test
Fix BackupListFragmentIT SS Tests
This commit is contained in:
commit
2ec38321b7
1 changed files with 107 additions and 47 deletions
|
@ -7,94 +7,154 @@
|
|||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.Manifest
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.ContactsPreferenceActivity
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class BackupListFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(ContactsPreferenceActivity::class.java, true, false)
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(Manifest.permission.READ_CALENDAR)
|
||||
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.BackupListFragmentIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showLoading() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val file = OCFile("/")
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
launchActivity<ContactsPreferenceActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val file = OCFile("/")
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(file, user))
|
||||
transaction.commit()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(file, user))
|
||||
transaction.commit()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showLoading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showContactList() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
val file = getFile("vcard.vcf")
|
||||
val ocFile = OCFile("/vcard.vcf")
|
||||
ocFile.storagePath = file.absolutePath
|
||||
ocFile.mimeType = "text/vcard"
|
||||
launchActivity<ContactsPreferenceActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
val file = getFile("vcard.vcf")
|
||||
val ocFile = OCFile("/vcard.vcf").apply {
|
||||
storagePath = file.absolutePath
|
||||
mimeType = "text/vcard"
|
||||
}
|
||||
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(ocFile, user))
|
||||
transaction.commit()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
screenshot(sut)
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(ocFile, user))
|
||||
transaction.commit()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showContactList", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showCalendarList() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
val file = getFile("calendar.ics")
|
||||
val ocFile = OCFile("/Private calender_2020-09-01_10-45-20.ics.ics")
|
||||
ocFile.storagePath = file.absolutePath
|
||||
ocFile.mimeType = "text/calendar"
|
||||
launchActivity<ContactsPreferenceActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
val file = getFile("calendar.ics")
|
||||
val ocFile = OCFile("/Private calender_2020-09-01_10-45-20.ics.ics").apply {
|
||||
storagePath = file.absolutePath
|
||||
mimeType = "text/calendar"
|
||||
}
|
||||
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(ocFile, user))
|
||||
transaction.commit()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(ocFile, user))
|
||||
transaction.commit()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showCalendarList", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showCalendarAndContactsList() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
launchActivity<ContactsPreferenceActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val transaction = sut.supportFragmentManager.beginTransaction()
|
||||
val calendarFile = getFile("calendar.ics")
|
||||
val calendarOcFile = OCFile("/Private calender_2020-09-01_10-45-20.ics.ics").apply {
|
||||
storagePath = calendarFile.absolutePath
|
||||
mimeType = "text/calendar"
|
||||
}
|
||||
|
||||
val calendarFile = getFile("calendar.ics")
|
||||
val calendarOcFile = OCFile("/Private calender_2020-09-01_10-45-20.ics")
|
||||
calendarOcFile.storagePath = calendarFile.absolutePath
|
||||
calendarOcFile.mimeType = "text/calendar"
|
||||
val contactFile = getFile("vcard.vcf")
|
||||
val contactOcFile = OCFile("/vcard.vcf").apply {
|
||||
storagePath = contactFile.absolutePath
|
||||
mimeType = "text/vcard"
|
||||
}
|
||||
|
||||
val contactFile = getFile("vcard.vcf")
|
||||
val contactOcFile = OCFile("/vcard.vcf")
|
||||
contactOcFile.storagePath = contactFile.absolutePath
|
||||
contactOcFile.mimeType = "text/vcard"
|
||||
val files = arrayOf(calendarOcFile, contactOcFile)
|
||||
|
||||
val files = arrayOf(calendarOcFile, contactOcFile)
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(files, user))
|
||||
transaction.commit()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
transaction.replace(R.id.frame_container, BackupListFragment.newInstance(files, user))
|
||||
transaction.commit()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showCalendarAndContactsList", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue