Search in sources :

Example 1 with ScreenshotTest

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

the class SyncedFoldersActivityIT method open.

@Test
@ScreenshotTest
public void open() {
    Activity sut = activityRule.launchActivity(null);
    screenshot(sut);
}
Also used : SyncedFoldersActivity(com.owncloud.android.ui.activity.SyncedFoldersActivity) Activity(android.app.Activity) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 2 with ScreenshotTest

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

the class DialogFragmentIT method testRemoveFileDialog.

@Test
@ScreenshotTest
public void testRemoveFileDialog() {
    RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(new OCFile("/Test.md"));
    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 3 with ScreenshotTest

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

the class DialogFragmentIT method testAccountChooserDialogWithStatusDisabled.

@Test
@ScreenshotTest
public void testAccountChooserDialogWithStatusDisabled() throws AccountUtils.AccountNotFoundException {
    AccountManager accountManager = AccountManager.get(targetContext);
    for (Account account : accountManager.getAccounts()) {
        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");
    FileDisplayActivity fda = getFileDisplayActivity();
    UserAccountManager userAccountManager = fda.getUserAccountManager();
    User newUser = userAccountManager.getUser(newAccount.name).get();
    FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser, targetContext.getContentResolver());
    OCCapability capability = new OCCapability();
    capability.setUserStatus(CapabilityBooleanType.FALSE);
    fileDataStorageManager.saveCapabilities(capability);
    ChooseAccountDialogFragment sut = ChooseAccountDialogFragment.newInstance(new RegisteredUser(newAccount, new OwnCloudAccount(newAccount, targetContext), new Server(URI.create(SERVER_URL), OwnCloudVersion.nextcloud_20)));
    showDialog(fda, sut);
}
Also used : UserAccountManager(com.nextcloud.client.account.UserAccountManager) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) 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) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) ChooseAccountDialogFragment(com.nextcloud.ui.ChooseAccountDialogFragment) UserAccountManager(com.nextcloud.client.account.UserAccountManager) AccountManager(android.accounts.AccountManager) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) RegisteredUser(com.nextcloud.client.account.RegisteredUser) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 4 with ScreenshotTest

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

the class DialogFragmentIT method testBottomSheet.

@Test
@ScreenshotTest
public void testBottomSheet() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    OCFileListBottomSheetActions action = new OCFileListBottomSheetActions() {

        @Override
        public void createFolder() {
        }

        @Override
        public void uploadFromApp() {
        }

        @Override
        public void uploadFiles() {
        }

        @Override
        public void newDocument() {
        }

        @Override
        public void newSpreadsheet() {
        }

        @Override
        public void newPresentation() {
        }

        @Override
        public void directCameraUpload() {
        }

        @Override
        public void scanDocUpload() {
        }

        @Override
        public void showTemplate(Creator creator, String headline) {
        }

        @Override
        public void createRichWorkspace() {
        }
    };
    DeviceInfo info = new DeviceInfo();
    OCFile ocFile = new OCFile("/test.md");
    Intent intent = new Intent(targetContext, FileDisplayActivity.class);
    FileDisplayActivity fda = activityRule.launchActivity(intent);
    // add direct editing info
    DirectEditing directEditing = new DirectEditing();
    directEditing.getCreators().put("1", new Creator("1", "text", "text file", ".md", "application/octet-stream", false));
    directEditing.getCreators().put("2", new Creator("2", "md", "markdown file", ".md", "application/octet-stream", false));
    directEditing.getEditors().put("text", new Editor("1", "Text", new ArrayList<>(Collections.singletonList(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)), new ArrayList<>(), false));
    String json = new Gson().toJson(directEditing);
    new ArbitraryDataProvider(targetContext.getContentResolver()).storeOrUpdateKeyValue(user.getAccountName(), ArbitraryDataProvider.DIRECT_EDITING, json);
    // activate templates
    OCCapability capability = fda.getCapabilities();
    capability.setRichDocuments(CapabilityBooleanType.TRUE);
    capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
    capability.setRichDocumentsTemplatesAvailable(CapabilityBooleanType.TRUE);
    OCFileListBottomSheetDialog sut = new OCFileListBottomSheetDialog(fda, action, info, user, ocFile);
    fda.runOnUiThread(sut::show);
    waitForIdleSync();
    screenshot(sut.getWindow().getDecorView());
}
Also used : DirectEditing(com.owncloud.android.lib.common.DirectEditing) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) OCFileListBottomSheetDialog(com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog) ArrayList(java.util.ArrayList) OCFileListBottomSheetActions(com.owncloud.android.ui.fragment.OCFileListBottomSheetActions) Gson(com.google.gson.Gson) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) Intent(android.content.Intent) Creator(com.owncloud.android.lib.common.Creator) OCFile(com.owncloud.android.datamodel.OCFile) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) DeviceInfo(com.nextcloud.client.device.DeviceInfo) Editor(com.owncloud.android.lib.common.Editor) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 5 with ScreenshotTest

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

the class DialogFragmentIT method testEnforcedPasswordDialog.

@Test
@ScreenshotTest
public void testEnforcedPasswordDialog() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, false);
    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)

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