Skip to content

Commit

Permalink
Test: share a file, favorite it and search then for favorites
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky authored and AlvaroBrey committed Oct 17, 2022
1 parent 0c3c874 commit 41ae820
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
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;

Expand Down Expand Up @@ -180,6 +182,48 @@ public void oneFavorite() {
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
*/
Expand Down

0 comments on commit 41ae820

Please sign in to comment.