use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class EndToEndRandomIT method testUploadWithForget.
@Test
public void testUploadWithForget() throws Exception {
init();
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt", currentFolder.getRemotePath() + "nonEmpty.txt", account.name);
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_FORGET);
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() + "nonEmpty.txt");
assertTrue(originalFile.exists());
assertFalse(new File(uploadedFile.getStoragePath()).exists());
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadIT method testChunkedUpload.
@Test
public void testChunkedUpload() {
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/chunkedFile.txt", FOLDER + "chunkedFile.txt", account.name);
uploadOCUpload(ocUpload);
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadIT method testUploadOnWifiOnlyAndWifi.
@Test
public void testUploadOnWifiOnlyAndWifi() {
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt", FOLDER + "wifi.txt", account.name);
ocUpload.setWhileChargingOnly(true);
UploadFileOperation newUpload = new UploadFileOperation(uploadsStorageManager, connectivityServiceMock, powerManagementServiceMock, user, null, ocUpload, NameCollisionPolicy.DEFAULT, FileUploader.LOCAL_BEHAVIOUR_COPY, targetContext, true, false, getStorageManager());
newUpload.setRemoteFolderToBeCreated();
newUpload.addRenameUploadListener(() -> {
// dummy
});
RemoteOperationResult result = newUpload.execute(client);
assertTrue(result.toString(), result.isSuccess());
// cleanup
new RemoveFileOperation(getStorageManager().getFileByDecryptedRemotePath(FOLDER), false, account, false, targetContext, getStorageManager()).execute(client);
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadStorageManagerTest method createUpload.
private OCUpload createUpload(Account account) {
OCUpload upload = new OCUpload(File.separator + "very long long long long long long long long long long long " + "long long long long long long long long long long long long long long " + "long long long long long long long long long long long long long long " + "long long long long long long long LocalPath", OCFile.PATH_SEPARATOR + "very long long long long long long long long long " + "long long long long long long long long long long long long long long " + "long long long long long long long long long long long long long long " + "long long long long long long long long long long long long RemotePath", account.name);
upload.setFileSize(new Random().nextInt(20000) * 10000);
upload.setUploadStatus(UploadsStorageManager.UploadStatus.UPLOAD_IN_PROGRESS);
upload.setLocalAction(2);
upload.setNameCollisionPolicy(NameCollisionPolicy.ASK_USER);
upload.setCreateRemoteFolder(false);
upload.setUploadEndTimestamp(System.currentTimeMillis());
upload.setLastResult(UploadResult.DELAYED_FOR_WIFI);
upload.setCreatedBy(UploadFileOperation.CREATED_BY_USER);
upload.setUseWifiOnly(true);
upload.setWhileChargingOnly(false);
upload.setFolderUnlockToken(RandomString.make(10));
return upload;
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadStorageManagerTest method testIsSame.
@Test
public void testIsSame() {
OCUpload upload1 = new OCUpload("/test", "/test", account.name);
upload1.setUseWifiOnly(true);
OCUpload upload2 = new OCUpload("/test", "/test", account.name);
upload2.setUseWifiOnly(true);
assertTrue(upload1.isSame(upload2));
upload2.setUseWifiOnly(false);
assertFalse(upload1.isSame(upload2));
assertFalse(upload1.isSame(null));
assertFalse(upload1.isSame(new OCFile("/test")));
}
Aggregations