Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky committed Apr 29, 2024
1 parent 78adb08 commit 53bfec3
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.BeforeClass;
import org.junit.Test;

public class DirectEditingCreateFileRemoteOperationIT extends AbstractIT {
@BeforeClass
public static void beforeClass() {
testOnlyOnServer(OwnCloudVersion.nextcloud_18);
}

@Test
public void createEmptyFile() {
RemoteOperationResult<String> result = new DirectEditingCreateFileRemoteOperation("/test.md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.TemplateList;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.BeforeClass;
import org.junit.Test;

public class DirectEditingObtainListOfTemplatesRemoteOperationIT extends AbstractIT {
@BeforeClass
public static void beforeClass() {
testOnlyOnServer(OwnCloudVersion.nextcloud_18);
}

@Test
public void testGetAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
package com.nextcloud.android.lib.resources.directediting

import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.status.OwnCloudVersion
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertNotNull
import junit.framework.Assert.assertTrue
import org.junit.Before
import org.junit.Test

class DirectEditingObtainRemoteOperationIT : AbstractIT() {
@Before
fun before() {
testOnlyOnServer(OwnCloudVersion.nextcloud_18)
}

@Test
fun testGetAll() {
val result = DirectEditingObtainRemoteOperation().execute(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import junit.framework.TestCase;

import org.junit.BeforeClass;
import org.junit.Test;

import java.io.IOException;

public class DirectEditingOpenFileRemoteOperationIT extends AbstractIT {
@BeforeClass
public static void beforeClass() {
testOnlyOnServer(OwnCloudVersion.nextcloud_18);
}

@Test
public void openFile() throws IOException {
// create file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.owncloud.android.lib.resources.status.OwnCloudVersion
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.BeforeClass
import org.junit.Test

class UnifiedSearchRemoteOperationIT : AbstractIT() {
Expand Down Expand Up @@ -76,4 +78,12 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() {
assertTrue(data.entries.isNotEmpty())
assertNotNull(data.entries.find { it.title == "test Folder" })
}

companion object {
@BeforeClass
@JvmStatic
fun before() {
testOnlyOnServer(OwnCloudVersion.nextcloud_20)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

public class RichWorkspaceDirectEditingRemoteOperationIT extends AbstractIT {
@BeforeClass
public static void beforeClass() {
testOnlyOnServer(OwnCloudVersion.nextcloud_18);
}

@Test
public void getEditLinkForRoot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ protected void longSleep() {
}
}

protected void testOnlyOnServer(OwnCloudVersion version) {
static protected void testOnlyOnServer(OwnCloudVersion version) {
OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
.execute(nextcloudClient)
.getSingleData();
Expand Down
9 changes: 9 additions & 0 deletions library/src/androidTest/java/com/owncloud/android/FileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
import com.owncloud.android.lib.resources.status.NextcloudVersion;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.Test;

Expand Down Expand Up @@ -146,6 +147,8 @@ public void testShareViaLinkSharees() {

@Test
public void testShareToGroupSharees() {
testOnlyOnServer(OwnCloudVersion.nextcloud_17);

// create & verify folder
String path = "/testFolder/";
assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());
Expand Down Expand Up @@ -188,6 +191,8 @@ public void testShareToGroupSharees() {

@Test
public void testOneSharees() {
testOnlyOnServer(OwnCloudVersion.nextcloud_17);

// create & verify folder
String path = "/testFolder/";
assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());
Expand Down Expand Up @@ -223,6 +228,8 @@ public void testOneSharees() {

@Test
public void testTwoShareesOnParent() {
testOnlyOnServer(OwnCloudVersion.nextcloud_17);

// create & verify folder
String path = "/testFolder/";
assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());
Expand Down Expand Up @@ -271,6 +278,8 @@ public void testTwoShareesOnParent() {

@Test
public void testTwoSharees() {
testOnlyOnServer(OwnCloudVersion.nextcloud_17);

// create & verify folder
String path = "/testFolder/";
assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
import com.owncloud.android.lib.resources.status.E2EVersion;
Expand All @@ -19,13 +26,6 @@

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

/**
* Class to test GetRemoteCapabilitiesOperation
*/
Expand Down Expand Up @@ -112,10 +112,12 @@ private void checkCapability(OCCapability capability, String userId) {
assertTrue(capability.getFilesVersioning().isTrue());
assertTrue(capability.getFilesUndelete().isTrue());
assertNotNull(capability.getVersion());
assertFalse(capability.getEtag().isEmpty());
assertSame(CapabilityBooleanType.FALSE, capability.getRichDocuments());
assertFalse(capability.getDirectEditingEtag().isEmpty());
assertSame(CapabilityBooleanType.UNKNOWN, capability.getDropAccount());
if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_17)) {
assertFalse(capability.getEtag().isEmpty());
assertFalse(capability.getDirectEditingEtag().isEmpty());
}
assertSame(CapabilityBooleanType.FALSE, capability.getRichDocuments());

// user status
if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_20)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class UpdateMetadataRemoteOperationIT extends AbstractIT {
//@Test
public void uploadAndModifyV1() {
// tests only for NC19+
testOnlyOnServer(OwnCloudVersion.nextcloud_20);
testOnlyOnServer(OwnCloudVersion.nextcloud_19);

// E2E server app checks for official NC client with >=3.13.0,
// and blocks all other clients, e.g. 3rd party apps using this lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class ReadFileRemoteOperationIT : AbstractIT() {

@Test
fun testMetadata() {
testOnlyOnServer(NextcloudVersion.nextcloud_27)

val filePath = getFile("gps.jpg").absolutePath
val remotePath = "/gps.jpg"

Expand All @@ -113,8 +115,6 @@ class ReadFileRemoteOperationIT : AbstractIT() {
@Suppress("Detekt.MagicNumber")
assertEquals(ImageDimension(451f, 529f), remoteFile.imageDimension)

testOnlyOnServer(NextcloudVersion.nextcloud_27)

val ocCapability =
GetCapabilitiesRemoteOperation()
.execute(nextcloudClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
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.NextcloudVersion;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -94,6 +96,12 @@ public void testFileSearchEmpty() throws IOException {

@Test
public void testFileSearchEverything() throws IOException {
// on newer server we have Talk folder
int offset = 0;
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20)) {
offset = 1;
}

for (int i = 0; i < 10; i++) {
String filePath = createFile("image" + i);
String remotePath = "/image" + i + ".jpg";
Expand All @@ -108,7 +116,7 @@ public void testFileSearchEverything() throws IOException {

RemoteOperationResult<List<RemoteFile>> result = sut.execute(client);
assertTrue(result.isSuccess());
assertEquals(11, result.getResultData().size());
assertEquals(offset + 10, result.getResultData().size());
}

@Test
Expand Down Expand Up @@ -202,14 +210,27 @@ public void favoriteFiles() throws IOException {
assertEquals(2, result.getResultData().size());

assertEquals(remotePath, result.getResultData().get(0).getRemotePath());
assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath());

if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_17)) {
assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath());
} else {
// on NC16 we have a bug that each file ends with "/"
sharedRemotePath += "/";
assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath());
}
}

/**
* shows just all files, but sorted by date
*/
@Test
public void testRecentlyModifiedSearch() throws IOException {
// on newer server we have Talk folder
int offset = 0;
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20)) {
offset = 1;
}

long now = System.currentTimeMillis() / MILLI_TO_SECOND;
String filePath = createFile("image");
assertTrue(new UploadFileRemoteOperation(filePath, "/image.jpg", "image/jpg", now - 50)
Expand All @@ -234,7 +255,7 @@ public void testRecentlyModifiedSearch() throws IOException {

RemoteOperationResult<List<RemoteFile>> result = sut.execute(client);
assertTrue(result.isSuccess());
assertEquals(4, result.getResultData().size());
assertEquals(offset + 3, result.getResultData().size());

assertEquals("/video.mp4", result.getResultData().get(0).getRemotePath());
assertEquals("/pdf.pdf", result.getResultData().get(1).getRemotePath());
Expand Down Expand Up @@ -399,6 +420,8 @@ public void testPhotoSearchLimitAndTimestamp() throws IOException {

@Test
public void testGallerySearch() throws IOException {
testOnlyOnServer(OwnCloudVersion.nextcloud_18);

for (int i = 0; i < 10; i++) {
String filePath = createFile("image" + i);
String remotePath = "/image" + i + ".jpg";
Expand All @@ -425,6 +448,12 @@ public void testGallerySearch() throws IOException {

@Test
public void showOnlyFolders() throws IOException {
// on newer server we have Talk folder
int offset = 0;
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20)) {
offset = 1;
}

for (int i = 0; i < 10; i++) {
String filePath = createFile("image" + i);
String remotePath = "/image" + i + ".jpg";
Expand All @@ -438,13 +467,13 @@ public void showOnlyFolders() throws IOException {

RemoteOperationResult<List<RemoteFile>> result = sut.execute(client);
assertTrue(result.isSuccess());
assertEquals(1, result.getResultData().size());
assertEquals(0 + offset, result.getResultData().size());

assertTrue(new CreateFolderRemoteOperation("/folder/", false).execute(client).isSuccess());

result = sut.execute(client);
assertTrue(result.isSuccess());
assertEquals(2, result.getResultData().size());
assertEquals(1 + offset, result.getResultData().size());
assertEquals("/folder/", result.getResultData().get(0).getRemotePath());
}

Expand Down
Loading

0 comments on commit 53bfec3

Please sign in to comment.