use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadStorageManagerTest method getById.
@Test
public void getById() {
OCUpload upload = createUpload(account);
long id = uploadsStorageManager.storeUpload(upload);
OCUpload newUpload = uploadsStorageManager.getUploadById(id);
assertNotNull(newUpload);
assertEquals(upload.getLocalAction(), newUpload.getLocalAction());
assertEquals(upload.getFolderUnlockToken(), newUpload.getFolderUnlockToken());
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadStorageManagerTest method getByIdNull.
@Test
public void getByIdNull() {
OCUpload newUpload = uploadsStorageManager.getUploadById(-1);
assertNull(newUpload);
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class UploadStorageManagerTest method corruptedUpload.
@Test(expected = IllegalArgumentException.class)
public void corruptedUpload() {
OCUpload corruptUpload = new OCUpload(File.separator + "LocalPath", OCFile.PATH_SEPARATOR + "RemotePath", account.name);
corruptUpload.setLocalPath(null);
uploadsStorageManager.storeUpload(corruptUpload);
uploadsStorageManager.getAllStoredUploads();
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class ConflictsResolveActivityIT method keepBoth.
@Test
@ScreenshotTest
public void keepBoth() {
returnCode = false;
OCUpload newUpload = new OCUpload(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt", "/newFile.txt", user.getAccountName());
OCFile existingFile = new OCFile("/newFile.txt");
existingFile.setFileLength(1024000);
existingFile.setModificationTimestamp(1582019340);
OCFile newFile = new OCFile("/newFile.txt");
newFile.setFileLength(56000);
newFile.setModificationTimestamp(1522019340);
newFile.setStoragePath(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt");
FileDataStorageManager storageManager = new FileDataStorageManager(user, targetContext.getContentResolver());
storageManager.saveNewFile(existingFile);
Intent intent = new Intent(targetContext, ConflictsResolveActivity.class);
intent.putExtra(ConflictsResolveActivity.EXTRA_FILE, newFile);
intent.putExtra(ConflictsResolveActivity.EXTRA_EXISTING_FILE, existingFile);
intent.putExtra(ConflictsResolveActivity.EXTRA_CONFLICT_UPLOAD_ID, newUpload.getUploadId());
ConflictsResolveActivity sut = activityRule.launchActivity(intent);
sut.listener = decision -> {
assertEquals(decision, ConflictsResolveDialog.Decision.KEEP_BOTH);
returnCode = true;
};
getInstrumentation().waitForIdleSync();
onView(withId(R.id.existing_checkbox)).perform(click());
onView(withId(R.id.new_checkbox)).perform(click());
DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog");
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
onView(withText("OK")).perform(click());
assertTrue(returnCode);
}
use of com.owncloud.android.db.OCUpload in project android by nextcloud.
the class ConflictsResolveActivityIT method cancel.
// @Test
// @ScreenshotTest // todo run without real server
// public void screenshotImages() throws IOException {
// FileDataStorageManager storageManager = new FileDataStorageManager(user,
// targetContext.getContentResolver());
//
// OCFile newFile = new OCFile("/newFile.txt");
// newFile.setFileLength(56000);
// newFile.setModificationTimestamp(1522019340);
// newFile.setStoragePath(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt");
//
// File image = getFile("image.jpg");
//
// assertTrue(new UploadFileRemoteOperation(image.getAbsolutePath(),
// "/image.jpg",
// "image/jpg",
// "10000000").execute(client).isSuccess());
//
// assertTrue(new RefreshFolderOperation(storageManager.getFileByPath("/"),
// System.currentTimeMillis(),
// false,
// true,
// storageManager,
// user.toPlatformAccount(),
// targetContext
// ).execute(client).isSuccess());
//
// OCFile existingFile = storageManager.getFileByPath("/image.jpg");
//
// Intent intent = new Intent(targetContext, ConflictsResolveActivity.class);
// intent.putExtra(ConflictsResolveActivity.EXTRA_FILE, newFile);
// intent.putExtra(ConflictsResolveActivity.EXTRA_EXISTING_FILE, existingFile);
//
// ConflictsResolveActivity sut = activityRule.launchActivity(intent);
//
// ConflictsResolveDialog.OnConflictDecisionMadeListener listener = decision -> {
//
// };
//
// ConflictsResolveDialog dialog = ConflictsResolveDialog.newInstance(existingFile,
// newFile,
// UserAccountManagerImpl
// .fromContext(targetContext)
// .getUser()
// );
// dialog.showDialog(sut);
// dialog.listener = listener;
//
// getInstrumentation().waitForIdleSync();
// shortSleep();
//
// screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
// }
@Test
public void cancel() {
returnCode = false;
OCUpload newUpload = new OCUpload(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt", "/newFile.txt", user.getAccountName());
OCFile existingFile = new OCFile("/newFile.txt");
existingFile.setFileLength(1024000);
existingFile.setModificationTimestamp(1582019340);
OCFile newFile = new OCFile("/newFile.txt");
newFile.setFileLength(56000);
newFile.setModificationTimestamp(1522019340);
newFile.setStoragePath(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt");
FileDataStorageManager storageManager = new FileDataStorageManager(user, targetContext.getContentResolver());
storageManager.saveNewFile(existingFile);
Intent intent = new Intent(targetContext, ConflictsResolveActivity.class);
intent.putExtra(ConflictsResolveActivity.EXTRA_FILE, newFile);
intent.putExtra(ConflictsResolveActivity.EXTRA_EXISTING_FILE, existingFile);
intent.putExtra(ConflictsResolveActivity.EXTRA_CONFLICT_UPLOAD_ID, newUpload.getUploadId());
ConflictsResolveActivity sut = activityRule.launchActivity(intent);
sut.listener = decision -> {
assertEquals(decision, ConflictsResolveDialog.Decision.CANCEL);
returnCode = true;
};
getInstrumentation().waitForIdleSync();
shortSleep();
onView(withText("Cancel")).perform(click());
assertTrue(returnCode);
}
Aggregations