Search in sources :

Example 21 with ScreenshotTest

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);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) ArrayList(java.util.ArrayList) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 22 with ScreenshotTest

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);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) ArrayList(java.util.ArrayList) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 23 with ScreenshotTest

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");
}
Also used : Status(com.owncloud.android.lib.resources.users.Status) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) User(com.nextcloud.client.account.User) RegisteredUser(com.nextcloud.client.account.RegisteredUser) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) Server(com.nextcloud.client.account.Server) ChooseAccountDialogFragment(com.nextcloud.ui.ChooseAccountDialogFragment) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) RegisteredUser(com.nextcloud.client.account.RegisteredUser) UserAccountManager(com.nextcloud.client.account.UserAccountManager) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) UserAccountManager(com.nextcloud.client.account.UserAccountManager) AccountManager(android.accounts.AccountManager) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 24 with ScreenshotTest

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);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 25 with ScreenshotTest

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);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) OCUpload(com.owncloud.android.db.OCUpload) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) DialogFragment(androidx.fragment.app.DialogFragment) Intent(android.content.Intent) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Aggregations

ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)26 Test (org.junit.Test)26 OCFile (com.owncloud.android.datamodel.OCFile)15 Intent (android.content.Intent)9 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)7 Activity (android.app.Activity)4 OCUpload (com.owncloud.android.db.OCUpload)4 FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)4 ArrayList (java.util.ArrayList)4 DialogFragment (androidx.fragment.app.DialogFragment)3 User (com.nextcloud.client.account.User)3 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)3 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 RegisteredUser (com.nextcloud.client.account.RegisteredUser)2 Server (com.nextcloud.client.account.Server)2 UserAccountManager (com.nextcloud.client.account.UserAccountManager)2 ChooseAccountDialogFragment (com.nextcloud.ui.ChooseAccountDialogFragment)2 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)2 UserInfo (com.owncloud.android.lib.common.UserInfo)2