mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 14:45:47 +03:00
Merge pull request #6580 from nextcloud/bige2eTest
E2E test with random files that are big enought to use chunked uploads
This commit is contained in:
commit
5f426223b2
3 changed files with 14 additions and 20 deletions
|
@ -42,7 +42,6 @@ import com.owncloud.android.operations.GetCapabilitiesOperation;
|
||||||
import com.owncloud.android.operations.RemoveFileOperation;
|
import com.owncloud.android.operations.RemoveFileOperation;
|
||||||
import com.owncloud.android.utils.CsrHelper;
|
import com.owncloud.android.utils.CsrHelper;
|
||||||
import com.owncloud.android.utils.EncryptionUtils;
|
import com.owncloud.android.utils.EncryptionUtils;
|
||||||
import com.owncloud.android.utils.FileStorageUtils;
|
|
||||||
|
|
||||||
import net.bytebuddy.utility.RandomString;
|
import net.bytebuddy.utility.RandomString;
|
||||||
|
|
||||||
|
@ -271,15 +270,22 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||||
|
|
||||||
private void uploadFile(int i) throws IOException {
|
private void uploadFile(int i) throws IOException {
|
||||||
String fileName = RandomString.make(5) + ".txt";
|
String fileName = RandomString.make(5) + ".txt";
|
||||||
createFile(fileName, new Random().nextInt(50000));
|
|
||||||
String path = currentFolder.getRemotePath() + fileName;
|
File file;
|
||||||
|
if (new Random().nextBoolean()) {
|
||||||
|
file = createFile(fileName, new Random().nextInt(50000));
|
||||||
|
} else {
|
||||||
|
file = createFile(fileName, 500000 + new Random().nextInt(50000));
|
||||||
|
}
|
||||||
|
|
||||||
|
String remotePath = currentFolder.getRemotePath() + fileName;
|
||||||
|
|
||||||
Log_OC.d(this,
|
Log_OC.d(this,
|
||||||
"[" + i + "/" + actionCount + "] " +
|
"[" + i + "/" + actionCount + "] " +
|
||||||
"Upload file to: " + currentFolder.getDecryptedRemotePath() + fileName);
|
"Upload file to: " + currentFolder.getDecryptedRemotePath() + fileName);
|
||||||
|
|
||||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + File.separator + fileName,
|
OCUpload ocUpload = new OCUpload(file.getAbsolutePath(),
|
||||||
path,
|
remotePath,
|
||||||
account.name);
|
account.name);
|
||||||
uploadOCUpload(ocUpload);
|
uploadOCUpload(ocUpload);
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ public abstract class AbstractIT {
|
||||||
return AccountManager.get(targetContext).getAccounts();
|
return AccountManager.get(targetContext).getAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createFile(String name, int iteration) throws IOException {
|
public static File createFile(String name, int iteration) throws IOException {
|
||||||
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
|
||||||
|
@ -196,6 +196,8 @@ public abstract class AbstractIT {
|
||||||
}
|
}
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getFile(String filename) throws IOException {
|
protected File getFile(String filename) throws IOException {
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -148,19 +147,6 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||||
createFile("chunkedFile.txt", 500000);
|
createFile("chunkedFile.txt", 500000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createFile(String name, int iteration) throws IOException {
|
|
||||||
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
|
||||||
file.createNewFile();
|
|
||||||
|
|
||||||
FileWriter writer = new FileWriter(file);
|
|
||||||
|
|
||||||
for (int i = 0; i < iteration; i++) {
|
|
||||||
writer.write("123123123123123123123123123\n");
|
|
||||||
}
|
|
||||||
writer.flush();
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
|
private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
|
||||||
GetMethod get = new GetMethod(baseUrl + "/status.php");
|
GetMethod get = new GetMethod(baseUrl + "/status.php");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue