diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt index fb6e26f6c78..c743014f4b1 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt @@ -27,6 +27,7 @@ import android.os.Parcelable import androidx.lifecycle.MutableLiveData import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.matches @@ -260,6 +261,39 @@ class CreatePublicShareTest { onView(withText(newPublicShare3.name)).check(matches(isDisplayed())) } + @Test + fun loadingCreateShares(){ + + loadCapabilitiesSuccessfully() + loadSharesSuccessfully(arrayListOf()) + + val newPublicShare = publicShares[0] + + `when`( + ocShareViewModel.insertPublicShareForFile( + 1, + newPublicShare.name!!, + "", + -1, + false + ) + ).thenReturn(sharesLiveData) + + // 1. Open dialog to create new public share + onView(withId(R.id.addPublicLinkButton)).perform(click()) + + // 2. Save share + onView(withId(R.id.saveButton)).perform(click()) + + sharesLiveData.postValue( + Resource.loading( + arrayListOf(newPublicShare) + ) + ) + + onView(withText(R.string.common_loading)).check(matches(isDisplayed())) + } + private fun getOCFileForTesting(name: String = "default") = OCFile("/Photos").apply { availableOfflineStatus = OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE fileName = name diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt index 8e50f7565b7..daf56144be2 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt @@ -42,6 +42,7 @@ import com.owncloud.android.capabilities.db.OCCapability import com.owncloud.android.capabilities.viewmodel.OCCapabilityViewModel import com.owncloud.android.datamodel.OCFile import com.owncloud.android.lib.common.accounts.AccountUtils +import com.owncloud.android.lib.common.operations.RemoteOperationResult import com.owncloud.android.lib.resources.status.CapabilityBooleanType import com.owncloud.android.lib.resources.status.OwnCloudVersion import com.owncloud.android.shares.db.OCShare @@ -237,6 +238,24 @@ class DeletePublicShareTest { } + @Test + fun loadingDeleteShares(){ + loadCapabilitiesSuccessfully() + + val existingPublicShare = publicShares[0] + loadSharesSuccessfully(arrayListOf(existingPublicShare)) + + onView(withId(R.id.deletePublicLinkButton)).perform(click()) + + sharesLiveData.postValue( + Resource.loading( + publicShares + ) + ) + + onView(withText(R.string.common_loading)).check(matches(isDisplayed())) + } + private fun getOCFileForTesting(name: String = "default"): OCFile { val file = OCFile("/Photos/image.jpg") file.availableOfflineStatus = OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt index fce494726f4..25ddc1369f3 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt @@ -427,6 +427,40 @@ class EditPublicShareTest { onView(withId(R.id.shareViaLinkExpirationSwitch)).check(matches(isNotChecked())) } + @Test + fun loadingEditShares(){ + loadCapabilitiesSuccessfully() + + val existingPublicShare = publicShares[0] + loadSharesSuccessfully(arrayListOf(existingPublicShare)) + + val updatedPublicShare = publicShares[1] + + `when`( + ocShareViewModel.updatePublicShareForFile( + 1, + updatedPublicShare.name!!, + "", + -1, + 1, + false + ) + ).thenReturn(sharesLiveData) + + //Edit name is performed + onView(withId(R.id.editPublicLinkButton)).perform(click()) + onView(withId(R.id.shareViaLinkNameValue)).perform(replaceText(updatedPublicShare.name)) + onView(withId(R.id.saveButton)).perform(click()) + + sharesLiveData.postValue( + Resource.loading( + arrayListOf(updatedPublicShare) + ) + ) + + onView(withText(R.string.common_loading)).check(matches(isDisplayed())) + } + private fun getOCFileForTesting(name: String = "default") = OCFile("/Photos").apply { availableOfflineStatus = OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE fileName = name