Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/android-library.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobiasKaminsky <tobias@kaminsky.me>2022-07-29 13:58:50 +0300
committerÁlvaro Brey <alvaro.brey@nextcloud.com>2022-10-24 14:19:47 +0300
commit07204dc54563b7b1c1fc107c5ba9fd88e8fc5fcf (patch)
treeb4b8dcb32cbf6a71ba449d08dd570ba7fd6a84df
parent5e06a6fad6e566ab0d5ffbad6cffc919573d1c5f (diff)
Test: share a file, favorite it and search then for favorites
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
-rw-r--r--library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java
index f0d1a2b3..8b718002 100644
--- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java
+++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java
@@ -40,6 +40,8 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
+import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
+import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
import com.owncloud.android.lib.resources.status.OCCapability;
@@ -180,6 +182,48 @@ public class SearchRemoteOperationIT extends AbstractIT {
assertEquals(path, remoteFile.getRemotePath());
}
+ @Test
+ public void favoriteFiles() throws IOException {
+ // share a file by second user to test user
+ String sharedFile = createFile("sharedFavoriteImage.jpg");
+ String sharedRemotePath = "/sharedFavoriteImage.jpg";
+ assertTrue(new UploadFileRemoteOperation(sharedFile, sharedRemotePath, "image/jpg", RANDOM_MTIME)
+ .execute(client2).isSuccess());
+
+ // share
+ assertTrue(new CreateShareRemoteOperation(sharedRemotePath,
+ ShareType.USER,
+ client.getUserId(),
+ false,
+ "",
+ 31).execute(client2)
+ .isSuccess()
+ );
+
+ // test user: favorite it
+ assertTrue(new ToggleFavoriteRemoteOperation(true, sharedRemotePath).execute(client).isSuccess());
+
+ String filePath = createFile("favoriteImage.jpg");
+ String remotePath = "/favoriteImage.jpg";
+ assertTrue(new UploadFileRemoteOperation(filePath, remotePath, "image/jpg", RANDOM_MTIME)
+ .execute(client).isSuccess());
+
+ assertTrue(new ToggleFavoriteRemoteOperation(true, remotePath).execute(client).isSuccess());
+
+ SearchRemoteOperation sut = new SearchRemoteOperation("",
+ SearchRemoteOperation.SearchType.FAVORITE_SEARCH,
+ false,
+ capability);
+ RemoteOperationResult<List<RemoteFile>> result = sut.execute(client);
+
+ // test
+ assertTrue(result.isSuccess());
+ assertEquals(2, result.getResultData().size());
+
+ assertEquals(remotePath, result.getResultData().get(0).getRemotePath());
+ assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath());
+ }
+
/**
* shows just all files, but sorted by date
*/