Search in sources :

Example 16 with FileDisplayActivity

use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.

the class DialogFragmentIT method showDialog.

private FileDisplayActivity showDialog(DialogFragment dialog) {
    Intent intent = new Intent(targetContext, FileDisplayActivity.class);
    FileDisplayActivity sut = activityRule.getActivity();
    if (sut == null) {
        sut = activityRule.launchActivity(intent);
    }
    return showDialog(sut, dialog);
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Intent(android.content.Intent)

Example 17 with FileDisplayActivity

use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.

the class DialogFragmentIT method testProfileBottomSheet.

@Test
@ScreenshotTest
public void testProfileBottomSheet() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    // Fixed values for HoverCard
    List<Action> actions = new ArrayList<>();
    actions.add(new Action("profile", "View profile", "https://dev.nextcloud.com/core/img/actions/profile.svg", "https://dev.nextcloud.com/index.php/u/christine"));
    actions.add(new Action("core", "christine.scott@nextcloud.com", "https://dev.nextcloud.com/core/img/actions/mail.svg", "mailto:christine.scott@nextcloud.com"));
    actions.add(new Action("spreed", "Talk to Christine", "https://dev.nextcloud.com/apps/spreed/img/app-dark.svg", "https://dev.nextcloud.com/apps/spreed/?callUser=christine"));
    HoverCard hoverCard = new HoverCard("christine", "Christine Scott", actions);
    // show dialog
    Intent intent = new Intent(targetContext, FileDisplayActivity.class);
    FileDisplayActivity fda = activityRule.launchActivity(intent);
    ProfileBottomSheetDialog sut = new ProfileBottomSheetDialog(fda, user, hoverCard);
    fda.runOnUiThread(sut::show);
    waitForIdleSync();
    screenshot(sut.getWindow().getDecorView());
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Action(com.nextcloud.android.lib.resources.profile.Action) ArrayList(java.util.ArrayList) Intent(android.content.Intent) HoverCard(com.nextcloud.android.lib.resources.profile.HoverCard) ProfileBottomSheetDialog(com.owncloud.android.ui.fragment.ProfileBottomSheetDialog) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 18 with FileDisplayActivity

use of com.owncloud.android.ui.activity.FileDisplayActivity 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 19 with FileDisplayActivity

use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.

the class PreviewTextFileFragmentTest method displayJavaSnippetFile.

@Test
public // @ScreenshotTest // todo run without real server
void displayJavaSnippetFile() throws IOException {
    FileDisplayActivity sut = activityRule.launchActivity(null);
    shortSleep();
    File file = getFile("java.md");
    OCFile test = new OCFile("/java.md");
    test.setMimeType(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN);
    test.setStoragePath(file.getAbsolutePath());
    sut.startTextPreview(test, false);
    shortSleep();
    screenshot(sut);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) OCFile(com.owncloud.android.datamodel.OCFile) File(java.io.File) Test(org.junit.Test)

Example 20 with FileDisplayActivity

use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.

the class FileDisplayActivityIT method allFiles.

@Test
public void allFiles() {
    FileDisplayActivity sut = activityRule.launchActivity(null);
    // given test folder
    assertTrue(new CreateFolderOperation("/test/", user, targetContext, getStorageManager()).execute(client).isSuccess());
    // navigate into it
    OCFile test = getStorageManager().getFileByPath("/test/");
    sut.setFile(test);
    sut.startSyncFolderOperation(test, false);
    assertEquals(getStorageManager().getFileByPath("/test/"), sut.getCurrentDir());
    // open drawer
    onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
    // click "all files"
    onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_all_files));
    // then should be in root again
    shortSleep();
    assertEquals(getStorageManager().getFileByPath("/"), sut.getCurrentDir());
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) CreateFolderOperation(com.owncloud.android.operations.CreateFolderOperation) Test(org.junit.Test)

Aggregations

FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)26 OCFile (com.owncloud.android.datamodel.OCFile)11 Test (org.junit.Test)9 Intent (android.content.Intent)8 FolderPickerActivity (com.owncloud.android.ui.activity.FolderPickerActivity)7 Activity (android.app.Activity)4 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)4 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)4 UploadFilesActivity (com.owncloud.android.ui.activity.UploadFilesActivity)4 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)4 View (android.view.View)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 User (com.nextcloud.client.account.User)3 ArrayList (java.util.ArrayList)3 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 Bundle (android.os.Bundle)2 Handler (android.os.Handler)2 MenuItem (android.view.MenuItem)2 AdapterView (android.widget.AdapterView)2