Search in sources :

Example 6 with ScreenshotTest

use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.

the class DialogFragmentIT method testRenameFileDialog.

@Test
@ScreenshotTest
public void testRenameFileDialog() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(new OCFile("/Test/"));
    showDialog(dialog);
}
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 7 with ScreenshotTest

use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.

the class FolderPickerActivityIT method open.

@Test
@ScreenshotTest
public void open() {
    FolderPickerActivity sut = activityRule.getActivity();
    OCFile origin = new OCFile("/test/file.txt");
    sut.setFile(origin);
    screenshot(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 8 with ScreenshotTest

use of com.owncloud.android.utils.ScreenshotTest in project android by nextcloud.

the class UserInfoActivityIT method fullUserInfoDetail.

@Test
@ScreenshotTest
public void fullUserInfoDetail() {
    final Intent intent = new Intent(targetContext, UserInfoActivity.class);
    intent.putExtra(UserInfoActivity.KEY_ACCOUNT, user);
    UserInfo userInfo = new UserInfo("test", true, "Firstname Familyname", "oss@rocks.com", "+49 7613 672 255", "Awesome Place Av.", "https://www.nextcloud.com", "nextclouders", null, null);
    intent.putExtra(UserInfoActivity.KEY_USER_DATA, userInfo);
    UserInfoActivity sut = activityRule.launchActivity(intent);
    shortSleep();
    shortSleep();
    screenshot(sut);
}
Also used : Intent(android.content.Intent) UserInfo(com.owncloud.android.lib.common.UserInfo) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 9 with ScreenshotTest

use of com.owncloud.android.utils.ScreenshotTest 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);
}
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)

Example 10 with ScreenshotTest

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