|
@@ -10,11 +10,17 @@ package com.owncloud.android.ui.trashbin
|
|
|
import android.accounts.Account
|
|
|
import android.accounts.AccountManager
|
|
|
import android.content.Intent
|
|
|
-import androidx.test.espresso.intent.rule.IntentsTestRule
|
|
|
+import androidx.test.core.app.ActivityScenario
|
|
|
+import androidx.test.core.app.ApplicationProvider
|
|
|
+import androidx.test.espresso.IdlingRegistry
|
|
|
+import androidx.test.ext.junit.rules.ActivityScenarioRule
|
|
|
+import com.nextcloud.utils.EspressoIdlingResource
|
|
|
import com.owncloud.android.AbstractIT
|
|
|
import com.owncloud.android.MainApp
|
|
|
import com.owncloud.android.lib.common.accounts.AccountUtils
|
|
|
import com.owncloud.android.utils.ScreenshotTest
|
|
|
+import org.junit.After
|
|
|
+import org.junit.Before
|
|
|
import org.junit.Rule
|
|
|
import org.junit.Test
|
|
|
|
|
@@ -25,91 +31,91 @@ class TrashbinActivityIT : AbstractIT() {
|
|
|
FILES
|
|
|
}
|
|
|
|
|
|
+ private var scenario: ActivityScenario<TrashbinActivity>? = null
|
|
|
+ val intent = Intent(ApplicationProvider.getApplicationContext(), TrashbinActivity::class.java)
|
|
|
+
|
|
|
@get:Rule
|
|
|
- var activityRule = IntentsTestRule(TrashbinActivity::class.java, true, false)
|
|
|
+ val activityRule = ActivityScenarioRule<TrashbinActivity>(intent)
|
|
|
+
|
|
|
+ @Before
|
|
|
+ fun registerIdlingResource() {
|
|
|
+ IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
|
|
+ }
|
|
|
+
|
|
|
+ @After
|
|
|
+ fun unregisterIdlingResource() {
|
|
|
+ IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
|
|
+ scenario?.close()
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
@ScreenshotTest
|
|
|
fun error() {
|
|
|
- val sut: TrashbinActivity = activityRule.launchActivity(null)
|
|
|
-
|
|
|
- val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
|
|
-
|
|
|
- sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
-
|
|
|
- sut.runOnUiThread { sut.loadFolder() }
|
|
|
-
|
|
|
- shortSleep()
|
|
|
-
|
|
|
- screenshot(sut)
|
|
|
+ scenario = activityRule.scenario
|
|
|
+ scenario?.onActivity { sut ->
|
|
|
+ val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
|
|
+ sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
+ onIdleSync {
|
|
|
+ sut.runOnUiThread { sut.loadFolder() }
|
|
|
+ screenshot(sut)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@ScreenshotTest
|
|
|
fun files() {
|
|
|
- val sut: TrashbinActivity = activityRule.launchActivity(null)
|
|
|
-
|
|
|
- val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
|
|
-
|
|
|
- sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
-
|
|
|
- sut.runOnUiThread { sut.loadFolder() }
|
|
|
-
|
|
|
- waitForIdleSync()
|
|
|
- shortSleep()
|
|
|
- shortSleep()
|
|
|
-
|
|
|
- screenshot(sut)
|
|
|
+ scenario = activityRule.scenario
|
|
|
+ scenario?.onActivity { sut ->
|
|
|
+ val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
|
|
+ sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
+ onIdleSync {
|
|
|
+ sut.runOnUiThread { sut.loadFolder() }
|
|
|
+ screenshot(sut)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@ScreenshotTest
|
|
|
fun empty() {
|
|
|
- val sut: TrashbinActivity = activityRule.launchActivity(null)
|
|
|
-
|
|
|
- val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
-
|
|
|
- sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
-
|
|
|
- sut.runOnUiThread { sut.loadFolder() }
|
|
|
-
|
|
|
- shortSleep()
|
|
|
- shortSleep()
|
|
|
- waitForIdleSync()
|
|
|
-
|
|
|
- screenshot(sut.binding.emptyList.emptyListView)
|
|
|
+ scenario = activityRule.scenario
|
|
|
+ scenario?.onActivity { sut ->
|
|
|
+ val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
+ sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
+ onIdleSync {
|
|
|
+ sut.runOnUiThread { sut.loadFolder() }
|
|
|
+ screenshot(sut)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@ScreenshotTest
|
|
|
fun loading() {
|
|
|
- val sut: TrashbinActivity = activityRule.launchActivity(null)
|
|
|
-
|
|
|
- val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
-
|
|
|
- sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
-
|
|
|
- sut.runOnUiThread { sut.showInitialLoading() }
|
|
|
-
|
|
|
- shortSleep()
|
|
|
-
|
|
|
- screenshot(sut.binding.listFragmentLayout)
|
|
|
+ scenario = activityRule.scenario
|
|
|
+ scenario?.onActivity { sut ->
|
|
|
+ val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
+ sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
+ onIdleSync {
|
|
|
+ sut.runOnUiThread { sut.showInitialLoading() }
|
|
|
+ screenshot(sut)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@ScreenshotTest
|
|
|
fun normalUser() {
|
|
|
- val sut: TrashbinActivity = activityRule.launchActivity(null)
|
|
|
-
|
|
|
- val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
-
|
|
|
- sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
-
|
|
|
- sut.runOnUiThread { sut.showUser() }
|
|
|
-
|
|
|
- shortSleep()
|
|
|
-
|
|
|
- screenshot(sut)
|
|
|
+ scenario = activityRule.scenario
|
|
|
+ scenario?.onActivity { sut ->
|
|
|
+ val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
+ sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
+ onIdleSync {
|
|
|
+ sut.runOnUiThread { sut.showUser() }
|
|
|
+ screenshot(sut)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -122,18 +128,18 @@ class TrashbinActivityIT : AbstractIT() {
|
|
|
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "https://nextcloud.localhost")
|
|
|
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "differentUser")
|
|
|
|
|
|
- val intent = Intent()
|
|
|
+ val intent = Intent(targetContext, TrashbinActivity::class.java)
|
|
|
intent.putExtra(Intent.EXTRA_USER, "differentUser@https://nextcloud.localhost")
|
|
|
- val sut: TrashbinActivity = activityRule.launchActivity(intent)
|
|
|
-
|
|
|
- val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
-
|
|
|
- sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
-
|
|
|
- sut.runOnUiThread { sut.showUser() }
|
|
|
-
|
|
|
- shortSleep()
|
|
|
|
|
|
- screenshot(sut)
|
|
|
+ val sutScenario = ActivityScenario.launch<TrashbinActivity>(intent)
|
|
|
+ sutScenario.onActivity { sut ->
|
|
|
+ sut.intent = intent
|
|
|
+ val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
|
|
+ sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
|
|
+ onIdleSync {
|
|
|
+ sut.runOnUiThread { sut.showUser() }
|
|
|
+ screenshot(sut)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|