diff --git a/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java b/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java index aeb40fb4d8..1bf97dd178 100644 --- a/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java +++ b/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java @@ -29,6 +29,7 @@ import com.facebook.testing.screenshot.Screenshot; import com.owncloud.android.AbstractIT; import com.owncloud.android.R; import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation; +import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation; import com.owncloud.android.lib.resources.files.SearchRemoteOperation; import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation; import com.owncloud.android.lib.resources.shares.OCShare; @@ -81,7 +82,8 @@ public class FileDisplayActivityIT extends AbstractIT { @Test public void showShares() { - assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", false).execute(client).isSuccess()); + assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess()); + assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess()); assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(client).isSuccess()); assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(client).isSuccess()); assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(client).isSuccess()); diff --git a/src/androidTest/java/com/owncloud/android/AbstractIT.java b/src/androidTest/java/com/owncloud/android/AbstractIT.java index c47da86dd1..0135077574 100644 --- a/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -17,11 +17,16 @@ import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientFactory; import com.owncloud.android.lib.common.accounts.AccountUtils; +import com.owncloud.android.lib.common.operations.RemoteOperationResult; +import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation; +import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation; +import com.owncloud.android.lib.resources.files.model.RemoteFile; import com.owncloud.android.utils.FileStorageUtils; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.io.FileUtils; +import org.junit.After; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.runner.RunWith; @@ -39,6 +44,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import static androidx.test.InstrumentationRegistry.getInstrumentation; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static org.junit.Assert.assertTrue; /** @@ -97,6 +103,22 @@ public abstract class AbstractIT { } } + @After + public void after() { + RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client); + assertTrue(result.getLogMessage(), result.isSuccess()); + + for (Object object : result.getData()) { + RemoteFile remoteFile = (RemoteFile) object; + + if (!remoteFile.getRemotePath().equals("/")) { + assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath()) + .execute(client).isSuccess()); + } + } + } + + FileDataStorageManager getStorageManager() { return new FileDataStorageManager(account, targetContext.getContentResolver()); }