Search in sources :

Example 26 with OCUpload

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());
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) OCUpload(com.owncloud.android.db.OCUpload) OCFile(com.owncloud.android.datamodel.OCFile) File(java.io.File) Test(org.junit.Test)

Example 27 with OCUpload

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);
}
Also used : OCUpload(com.owncloud.android.db.OCUpload) Test(org.junit.Test)

Example 28 with 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);
}
Also used : OCUpload(com.owncloud.android.db.OCUpload) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) UploadFileOperation(com.owncloud.android.operations.UploadFileOperation) RemoveFileOperation(com.owncloud.android.operations.RemoveFileOperation) Test(org.junit.Test)

Example 29 with OCUpload

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;
}
Also used : OCUpload(com.owncloud.android.db.OCUpload) Random(java.util.Random)

Example 30 with OCUpload

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")));
}
Also used : OCUpload(com.owncloud.android.db.OCUpload) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

OCUpload (com.owncloud.android.db.OCUpload)49 Test (org.junit.Test)29 OCFile (com.owncloud.android.datamodel.OCFile)22 File (java.io.File)15 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)8 UploadFileOperation (com.owncloud.android.operations.UploadFileOperation)8 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)7 Intent (android.content.Intent)6 SmallTest (androidx.test.filters.SmallTest)5 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)4 Account (android.accounts.Account)3 Context (android.content.Context)3 Cursor (android.database.Cursor)3 DialogFragment (androidx.fragment.app.DialogFragment)3 BatteryStatus (com.nextcloud.client.device.BatteryStatus)3 Connectivity (com.nextcloud.client.network.Connectivity)3 ConnectivityService (com.nextcloud.client.network.ConnectivityService)3 RemoteFile (com.owncloud.android.lib.resources.files.model.RemoteFile)3 RandomAccessFile (java.io.RandomAccessFile)3 SuppressLint (android.annotation.SuppressLint)2