use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.
the class DialogFragmentIT method testRemoveFoldersDialog.
@Test
@ScreenshotTest
public void testRemoveFoldersDialog() {
ArrayList<OCFile> toDelete = new ArrayList<>();
toDelete.add(new OCFile("/Folder/"));
toDelete.add(new OCFile("/Documents/"));
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(toDelete);
showDialog(dialog);
}
use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.
the class DialogFragmentIT method testRemoveFilesDialog.
@Test
@ScreenshotTest
public void testRemoveFilesDialog() {
ArrayList<OCFile> toDelete = new ArrayList<>();
toDelete.add(new OCFile("/Test.md"));
toDelete.add(new OCFile("/Document.odt"));
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(toDelete);
showDialog(dialog);
}
use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.
the class DialogFragmentIT method testAccountChooserDialog.
@Test
@ScreenshotTest
public void testAccountChooserDialog() throws AccountUtils.AccountNotFoundException {
FileDisplayActivity activity = getFileDisplayActivity();
UserAccountManager userAccountManager = activity.getUserAccountManager();
AccountManager accountManager = AccountManager.get(targetContext);
for (Account account : accountManager.getAccountsByType(MainApp.getAccountType(targetContext))) {
accountManager.removeAccountExplicitly(account);
}
Account newAccount = new Account("test@https://nextcloud.localhost", MainApp.getAccountType(targetContext));
accountManager.addAccountExplicitly(newAccount, "password", null);
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, SERVER_URL);
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test");
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
User newUser = userAccountManager.getUser(newAccount.name).orElseThrow(RuntimeException::new);
Account newAccount2 = new Account("user1@nextcloud.localhost", MainApp.getAccountType(targetContext));
accountManager.addAccountExplicitly(newAccount2, "password", null);
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_OC_BASE_URL, SERVER_URL);
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_USER_ID, "user1");
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_OC_VERSION, "20.0.0");
accountManager.setAuthToken(newAccount2, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser, targetContext.getContentResolver());
OCCapability capability = new OCCapability();
capability.setUserStatus(CapabilityBooleanType.TRUE);
capability.setUserStatusSupportsEmoji(CapabilityBooleanType.TRUE);
fileDataStorageManager.saveCapabilities(capability);
ChooseAccountDialogFragment sut = ChooseAccountDialogFragment.newInstance(new RegisteredUser(newAccount, new OwnCloudAccount(newAccount, targetContext), new Server(URI.create(SERVER_URL), OwnCloudVersion.nextcloud_20)));
showDialog(activity, sut);
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.DND, "Busy fixing 🐛…", "", -1), targetContext));
waitForIdleSync();
shortSleep();
screenshot(sut, "dnd");
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.ONLINE, "", "", -1), targetContext));
waitForIdleSync();
shortSleep();
screenshot(sut, "online");
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.ONLINE, "Let's have some fun", "🎉", -1), targetContext));
waitForIdleSync();
shortSleep();
screenshot(sut, "fun");
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.OFFLINE, "", "", -1), targetContext));
waitForIdleSync();
shortSleep();
screenshot(sut, "offline");
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.AWAY, "Vacation", "🌴", -1), targetContext));
waitForIdleSync();
shortSleep();
screenshot(sut, "away");
}
use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.
the class DialogFragmentIT method testNewFolderDialog.
@Test
@ScreenshotTest
public void testNewFolderDialog() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
CreateFolderDialogFragment sut = CreateFolderDialogFragment.newInstance(new OCFile("/"));
showDialog(sut);
}
use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.
the class ConflictsResolveActivityIT method keepNew.
@Test
@ScreenshotTest
public void keepNew() {
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);
existingFile.setRemoteId("123abc");
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_LOCAL);
returnCode = true;
};
getInstrumentation().waitForIdleSync();
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);
}
Aggregations