mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Fix git conflicts
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
f86d0a1e86
commit
80c46b8d21
6 changed files with 130 additions and 72 deletions
|
@ -391,6 +391,7 @@ dependencies {
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
||||||
|
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
|
||||||
|
|
||||||
// Mocking support
|
// Mocking support
|
||||||
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
||||||
|
|
|
@ -301,6 +301,10 @@ public abstract class AbstractIT {
|
||||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onIdleSync(Runnable recipient) {
|
||||||
|
InstrumentationRegistry.getInstrumentation().waitForIdle(recipient);
|
||||||
|
}
|
||||||
|
|
||||||
protected void openDrawer(IntentsTestRule activityRule) {
|
protected void openDrawer(IntentsTestRule activityRule) {
|
||||||
Activity sut = activityRule.launchActivity(null);
|
Activity sut = activityRule.launchActivity(null);
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,17 @@ package com.owncloud.android.ui.trashbin
|
||||||
import android.accounts.Account
|
import android.accounts.Account
|
||||||
import android.accounts.AccountManager
|
import android.accounts.AccountManager
|
||||||
import android.content.Intent
|
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.AbstractIT
|
||||||
import com.owncloud.android.MainApp
|
import com.owncloud.android.MainApp
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||||
import com.owncloud.android.utils.ScreenshotTest
|
import com.owncloud.android.utils.ScreenshotTest
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
@ -25,92 +31,92 @@ class TrashbinActivityIT : AbstractIT() {
|
||||||
FILES
|
FILES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var scenario: ActivityScenario<TrashbinActivity>? = null
|
||||||
|
val intent = Intent(ApplicationProvider.getApplicationContext(), TrashbinActivity::class.java)
|
||||||
|
|
||||||
@get:Rule
|
@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
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
fun error() {
|
fun error() {
|
||||||
val sut: TrashbinActivity = activityRule.launchActivity(null)
|
scenario = activityRule.scenario
|
||||||
|
scenario?.onActivity { sut ->
|
||||||
val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
||||||
|
|
||||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||||
|
onIdleSync {
|
||||||
sut.runOnUiThread { sut.loadFolder() }
|
sut.runOnUiThread { sut.loadFolder() }
|
||||||
|
|
||||||
shortSleep()
|
|
||||||
|
|
||||||
screenshot(sut)
|
screenshot(sut)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
fun files() {
|
fun files() {
|
||||||
val sut: TrashbinActivity = activityRule.launchActivity(null)
|
scenario = activityRule.scenario
|
||||||
|
scenario?.onActivity { sut ->
|
||||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||||
|
|
||||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||||
|
onIdleSync {
|
||||||
sut.runOnUiThread { sut.loadFolder() }
|
sut.runOnUiThread { sut.loadFolder() }
|
||||||
|
|
||||||
waitForIdleSync()
|
|
||||||
shortSleep()
|
|
||||||
shortSleep()
|
|
||||||
|
|
||||||
screenshot(sut)
|
screenshot(sut)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
fun empty() {
|
fun empty() {
|
||||||
val sut: TrashbinActivity = activityRule.launchActivity(null)
|
scenario = activityRule.scenario
|
||||||
|
scenario?.onActivity { sut ->
|
||||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||||
|
|
||||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||||
|
onIdleSync {
|
||||||
sut.runOnUiThread { sut.loadFolder() }
|
sut.runOnUiThread { sut.loadFolder() }
|
||||||
|
screenshot(sut)
|
||||||
shortSleep()
|
}
|
||||||
shortSleep()
|
}
|
||||||
waitForIdleSync()
|
|
||||||
|
|
||||||
screenshot(sut.binding.emptyList.emptyListView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
fun loading() {
|
fun loading() {
|
||||||
val sut: TrashbinActivity = activityRule.launchActivity(null)
|
scenario = activityRule.scenario
|
||||||
|
scenario?.onActivity { sut ->
|
||||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||||
|
|
||||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||||
|
onIdleSync {
|
||||||
sut.runOnUiThread { sut.showInitialLoading() }
|
sut.runOnUiThread { sut.showInitialLoading() }
|
||||||
|
screenshot(sut)
|
||||||
shortSleep()
|
}
|
||||||
|
}
|
||||||
screenshot(sut.binding.listFragmentLayout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
fun normalUser() {
|
fun normalUser() {
|
||||||
val sut: TrashbinActivity = activityRule.launchActivity(null)
|
scenario = activityRule.scenario
|
||||||
|
scenario?.onActivity { sut ->
|
||||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||||
|
|
||||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||||
|
onIdleSync {
|
||||||
sut.runOnUiThread { sut.showUser() }
|
sut.runOnUiThread { sut.showUser() }
|
||||||
|
|
||||||
shortSleep()
|
|
||||||
|
|
||||||
screenshot(sut)
|
screenshot(sut)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
|
@ -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_OC_BASE_URL, "https://nextcloud.localhost")
|
||||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "differentUser")
|
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")
|
intent.putExtra(Intent.EXTRA_USER, "differentUser@https://nextcloud.localhost")
|
||||||
val sut: TrashbinActivity = activityRule.launchActivity(intent)
|
|
||||||
|
|
||||||
|
val sutScenario = ActivityScenario.launch<TrashbinActivity>(intent)
|
||||||
|
sutScenario.onActivity { sut ->
|
||||||
|
sut.intent = intent
|
||||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||||
|
|
||||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||||
|
onIdleSync {
|
||||||
sut.runOnUiThread { sut.showUser() }
|
sut.runOnUiThread { sut.showUser() }
|
||||||
|
|
||||||
shortSleep()
|
|
||||||
|
|
||||||
screenshot(sut)
|
screenshot(sut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Nextcloud - Android Client
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.utils
|
||||||
|
|
||||||
|
import androidx.test.espresso.idling.CountingIdlingResource
|
||||||
|
|
||||||
|
object EspressoIdlingResource {
|
||||||
|
|
||||||
|
private const val RESOURCE = "GLOBAL"
|
||||||
|
|
||||||
|
@JvmField val countingIdlingResource = CountingIdlingResource(RESOURCE)
|
||||||
|
|
||||||
|
fun increment() {
|
||||||
|
countingIdlingResource.increment()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun decrement() {
|
||||||
|
if (!countingIdlingResource.isIdleNow) {
|
||||||
|
countingIdlingResource.decrement()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ import com.nextcloud.client.account.CurrentAccountProvider
|
||||||
import com.nextcloud.client.di.Injectable
|
import com.nextcloud.client.di.Injectable
|
||||||
import com.nextcloud.client.network.ClientFactory
|
import com.nextcloud.client.network.ClientFactory
|
||||||
import com.nextcloud.client.preferences.AppPreferences
|
import com.nextcloud.client.preferences.AppPreferences
|
||||||
|
import com.nextcloud.utils.EspressoIdlingResource
|
||||||
import com.owncloud.android.R
|
import com.owncloud.android.R
|
||||||
import com.owncloud.android.databinding.TrashbinActivityBinding
|
import com.owncloud.android.databinding.TrashbinActivityBinding
|
||||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||||
|
@ -177,6 +178,7 @@ class TrashbinActivity :
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadFolder() {
|
fun loadFolder() {
|
||||||
|
EspressoIdlingResource.increment()
|
||||||
trashbinListAdapter?.let {
|
trashbinListAdapter?.let {
|
||||||
if (it.itemCount > EMPTY_LIST_COUNT) {
|
if (it.itemCount > EMPTY_LIST_COUNT) {
|
||||||
binding.swipeContainingList.isRefreshing = true
|
binding.swipeContainingList.isRefreshing = true
|
||||||
|
@ -186,6 +188,7 @@ class TrashbinActivity :
|
||||||
|
|
||||||
trashbinPresenter?.loadFolder()
|
trashbinPresenter?.loadFolder()
|
||||||
}
|
}
|
||||||
|
EspressoIdlingResource.decrement()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
@ -285,19 +288,23 @@ class TrashbinActivity :
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
fun showInitialLoading() {
|
fun showInitialLoading() {
|
||||||
|
EspressoIdlingResource.increment()
|
||||||
binding.emptyList.emptyListView.visibility = View.GONE
|
binding.emptyList.emptyListView.visibility = View.GONE
|
||||||
binding.list.visibility = View.GONE
|
binding.list.visibility = View.GONE
|
||||||
binding.loadingContent.visibility = View.VISIBLE
|
binding.loadingContent.visibility = View.VISIBLE
|
||||||
|
EspressoIdlingResource.decrement()
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
fun showUser() {
|
fun showUser() {
|
||||||
|
EspressoIdlingResource.increment()
|
||||||
binding.loadingContent.visibility = View.GONE
|
binding.loadingContent.visibility = View.GONE
|
||||||
binding.list.visibility = View.VISIBLE
|
binding.list.visibility = View.VISIBLE
|
||||||
binding.swipeContainingList.isRefreshing = false
|
binding.swipeContainingList.isRefreshing = false
|
||||||
binding.emptyList.emptyListViewText.text = user.get().accountName
|
binding.emptyList.emptyListViewText.text = user.get().accountName
|
||||||
binding.emptyList.emptyListViewText.visibility = View.VISIBLE
|
binding.emptyList.emptyListViewText.visibility = View.VISIBLE
|
||||||
binding.emptyList.emptyListView.visibility = View.VISIBLE
|
binding.emptyList.emptyListView.visibility = View.VISIBLE
|
||||||
|
EspressoIdlingResource.decrement()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showError(message: Int) {
|
override fun showError(message: Int) {
|
||||||
|
|
|
@ -6384,6 +6384,14 @@
|
||||||
<sha256 value="e4bb54753c36a27a0e5d70154a5034fedd8feac4282295034bfd483d6c7aae78" origin="Generated by Gradle"/>
|
<sha256 value="e4bb54753c36a27a0e5d70154a5034fedd8feac4282295034bfd483d6c7aae78" origin="Generated by Gradle"/>
|
||||||
</artifact>
|
</artifact>
|
||||||
</component>
|
</component>
|
||||||
|
<component group="com.google.android.apps.common.testing.accessibility.framework" name="accessibility-test-framework" version="3.1">
|
||||||
|
<artifact name="accessibility-test-framework-3.1.aar">
|
||||||
|
<sha256 value="e641e2a2c7287afd41b85310dd8f1344a8668034bbbfc4b02f58a48fd9c05ec7" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="accessibility-test-framework-3.1.pom">
|
||||||
|
<sha256 value="80567228cdbd44d61e5320cd090883de7232dbc1ed7ebf5ab5c9810c11cd67e0" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
<component group="com.google.android.apps.common.testing.accessibility.framework" name="accessibility-test-framework" version="3.1.2">
|
<component group="com.google.android.apps.common.testing.accessibility.framework" name="accessibility-test-framework" version="3.1.2">
|
||||||
<artifact name="accessibility-test-framework-3.1.2.aar">
|
<artifact name="accessibility-test-framework-3.1.2.aar">
|
||||||
<sha256 value="9b586dc8eeeb4f601038e23ef8ffd6a1deeca1163276d02797b0d2b8f9764b62" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
<sha256 value="9b586dc8eeeb4f601038e23ef8ffd6a1deeca1163276d02797b0d2b8f9764b62" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
||||||
|
@ -7567,6 +7575,11 @@
|
||||||
<sha256 value="47f0635b33c969e5f55ac9f1a4a8e10c120b8bab2cb3f06faaabc0e82057e276" origin="Generated by Gradle"/>
|
<sha256 value="47f0635b33c969e5f55ac9f1a4a8e10c120b8bab2cb3f06faaabc0e82057e276" origin="Generated by Gradle"/>
|
||||||
</artifact>
|
</artifact>
|
||||||
</component>
|
</component>
|
||||||
|
<component group="com.h3xstream.findsecbugs" name="findsecbugs-root-pom" version="1.13.0">
|
||||||
|
<artifact name="findsecbugs-root-pom-1.13.0.pom">
|
||||||
|
<sha256 value="da8755645ba7ae39588598e548f62eb0be1d2f47a6eee57efc5eb2865a4a556b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
<component group="com.intellij" name="annotations" version="12.0">
|
<component group="com.intellij" name="annotations" version="12.0">
|
||||||
<artifact name="annotations-12.0.jar">
|
<artifact name="annotations-12.0.jar">
|
||||||
<sha256 value="f8ab13b14be080fe2f617f90e55599760e4a1b4deeea5c595df63d0d6375ed6d" origin="Generated by Gradle"/>
|
<sha256 value="f8ab13b14be080fe2f617f90e55599760e4a1b4deeea5c595df63d0d6375ed6d" origin="Generated by Gradle"/>
|
||||||
|
|
Loading…
Reference in a new issue