repo updated
This commit is contained in:
parent
436e10d74f
commit
3d33d3fe49
624 changed files with 354 additions and 16919 deletions
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.nextcloud.test.GrantStoragePermissionRule;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.CommunityActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestRule;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
|
||||
public class CommunityActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<CommunityActivity> activityRule = new IntentsTestRule<>(CommunityActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final TestRule permissionRule = GrantStoragePermissionRule.grant();
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
public class FirstRunActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FirstRunActivity> activityRule = new IntentsTestRule<>(FirstRunActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.nextcloud.client.preferences.SubFolderRule;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.databinding.SyncedFoldersLayoutBinding;
|
||||
import com.owncloud.android.datamodel.MediaFolderType;
|
||||
import com.owncloud.android.datamodel.SyncedFolder;
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
|
||||
public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
SyncedFoldersActivity activity = activityRule.launchActivity(null);
|
||||
activity.adapter.clear();
|
||||
SyncedFoldersLayoutBinding sut = activity.binding;
|
||||
shortSleep();
|
||||
screenshot(sut.emptyList.emptyListView);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testSyncedFolderDialog() {
|
||||
SyncedFolderDisplayItem item = new SyncedFolderDisplayItem(1,
|
||||
"/sdcard/DCIM/",
|
||||
"/InstantUpload/",
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
"test@https://nextcloud.localhost",
|
||||
0,
|
||||
0,
|
||||
true,
|
||||
1000,
|
||||
"Name",
|
||||
MediaFolderType.IMAGE,
|
||||
false,
|
||||
SubFolderRule.YEAR_MONTH,
|
||||
false,
|
||||
SyncedFolder.NOT_SCANNED_YET);
|
||||
SyncedFolderPreferencesDialogFragment sut = SyncedFolderPreferencesDialogFragment.newInstance(item, 0);
|
||||
|
||||
Intent intent = new Intent(targetContext, SyncedFoldersActivity.class);
|
||||
SyncedFoldersActivity activity = activityRule.launchActivity(intent);
|
||||
|
||||
sut.show(activity.getSupportFragmentManager(), "");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
screenshot(Objects.requireNonNull(sut.requireDialog().getWindow()).getDecorView());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.client;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.UploadListActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
|
||||
public class UploadListActivityActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<UploadListActivity> activityRule = new IntentsTestRule<>(UploadListActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.users.ClearAt
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SetStatusDialogFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
var activityRule = IntentsTestRule(FileDisplayActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
fun open() {
|
||||
val sut = SetStatusDialogFragment.newInstance(user, Status(StatusType.DND, "Working hard…", "🤖", -1))
|
||||
val activity = activityRule.launchActivity(null)
|
||||
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
activity.runOnUiThread { sut.setPredefinedStatus(predefinedStatus) }
|
||||
|
||||
longSleep()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2018 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android;
|
||||
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import androidx.test.core.app.ActivityScenario;
|
||||
import androidx.test.espresso.action.ViewActions;
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions;
|
||||
import androidx.test.espresso.matcher.PreferenceMatchers;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import tools.fastlane.screengrab.Screengrab;
|
||||
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;
|
||||
import tools.fastlane.screengrab.locale.LocaleTestRule;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onData;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.Espresso.pressBack;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.core.AnyOf.anyOf;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(JUnit4.class)
|
||||
public class ScreenshotsIT extends AbstractOnServerIT {
|
||||
@ClassRule
|
||||
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeScreenshot() {
|
||||
Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gridViewScreenshot() {
|
||||
ActivityScenario.launch(FileDisplayActivity.class);
|
||||
|
||||
onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.switch_grid_view_button))).perform(click());
|
||||
|
||||
shortSleep();
|
||||
|
||||
Screengrab.screenshot("01_gridView");
|
||||
|
||||
onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.switch_grid_view_button))).perform(click());
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listViewScreenshot() {
|
||||
String path = "/Camera/";
|
||||
|
||||
// folder does not exist yet
|
||||
if (getStorageManager().getFileByEncryptedRemotePath(path) == null) {
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext, getStorageManager());
|
||||
RemoteOperationResult result = syncOp.execute(client);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
ActivityScenario.launch(FileDisplayActivity.class);
|
||||
|
||||
// go into work folder
|
||||
onView(withId(R.id.list_root)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
|
||||
|
||||
Screengrab.screenshot("02_listView");
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawerScreenshot() {
|
||||
ActivityScenario.launch(FileDisplayActivity.class);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
Screengrab.screenshot("03_drawer");
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleAccountsScreenshot() {
|
||||
ActivityScenario.launch(FileDisplayActivity.class);
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
|
||||
Screengrab.screenshot("04_accounts");
|
||||
|
||||
pressBack();
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoUploadScreenshot() {
|
||||
ActivityScenario.launch(SyncedFoldersActivity.class);
|
||||
|
||||
Screengrab.screenshot("05_autoUpload");
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void davdroidScreenshot() {
|
||||
ActivityScenario.launch(SettingsActivity.class);
|
||||
|
||||
onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo());
|
||||
|
||||
shortSleep();
|
||||
|
||||
Screengrab.screenshot("06_davdroid");
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2022 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.files.services
|
||||
|
||||
class LegacyFileUploaderIT : FileUploaderIT()
|
||||
|
|
@ -1,318 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ConflictsResolveActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<ConflictsResolveActivity> activityRule =
|
||||
new IntentsTestRule<>(ConflictsResolveActivity.class, true, false);
|
||||
private boolean returnCode;
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void screenshotTextFiles() {
|
||||
OCFile newFile = new OCFile("/newFile.txt");
|
||||
newFile.setFileLength(56000);
|
||||
newFile.setModificationTimestamp(1522019340);
|
||||
newFile.setStoragePath(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt");
|
||||
|
||||
OCFile existingFile = new OCFile("/newFile.txt");
|
||||
existingFile.setFileLength(1024000);
|
||||
existingFile.setModificationTimestamp(1582019340);
|
||||
|
||||
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);
|
||||
|
||||
ConflictsResolveActivity sut = activityRule.launchActivity(intent);
|
||||
|
||||
ConflictsResolveDialog dialog = ConflictsResolveDialog.newInstance(existingFile,
|
||||
newFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser()
|
||||
);
|
||||
dialog.showDialog(sut);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
shortSleep();
|
||||
shortSleep();
|
||||
shortSleep();
|
||||
shortSleep();
|
||||
|
||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
||||
}
|
||||
|
||||
// @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);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void keepExisting() {
|
||||
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_SERVER);
|
||||
returnCode = true;
|
||||
};
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
onView(withId(R.id.existing_checkbox)).perform(click());
|
||||
|
||||
DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog");
|
||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
||||
|
||||
onView(withText("OK")).perform(click());
|
||||
|
||||
assertTrue(returnCode);
|
||||
}
|
||||
|
||||
@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("00000123abc");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
getStorageManager().deleteAllFiles();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.test.RetryTestRule;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DrawerActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final RetryTestRule retryTestRule = new RetryTestRule();
|
||||
|
||||
private static Account account1;
|
||||
private static User user1;
|
||||
private static Account account2;
|
||||
private static String account2Name;
|
||||
private static String account2DisplayName;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
|
||||
Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
|
||||
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
|
||||
for (Account account : platformAccountManager.getAccounts()) {
|
||||
platformAccountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
|
||||
String loginName = "user1";
|
||||
String password = "user1";
|
||||
|
||||
Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(UserAccountManager.ACCOUNT_VERSION));
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
|
||||
account1 = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
user1 = userAccountManager.getUser(account1.name).orElseThrow(IllegalAccessError::new);
|
||||
|
||||
loginName = "user2";
|
||||
password = "user2";
|
||||
|
||||
temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(UserAccountManager.ACCOUNT_VERSION));
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
|
||||
account2 = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
account2Name = loginName + "@" + baseUrl;
|
||||
account2DisplayName = "User Two@" + baseUrl;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void switchAccountViaAccountList() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
sut.setUser(user1);
|
||||
|
||||
assertEquals(account1, sut.getUser().get().toPlatformAccount());
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
|
||||
onView(anyOf(withText(account2Name), withText(account2DisplayName))).perform(click());
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
assertEquals(account2, sut.getUser().get().toPlatformAccount());
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
onView(withText(account1.name)).perform(click());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Kilian Périsset <kilian.perisset@infomaniak.com>
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
//@LargeTest
|
||||
public class FolderPickerActivityIT extends AbstractIT {
|
||||
@Rule
|
||||
public ActivityTestRule<FolderPickerActivity> activityRule =
|
||||
new ActivityTestRule<>(FolderPickerActivity.class);
|
||||
|
||||
@Test
|
||||
public void getActivityFile() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/file.test");
|
||||
origin.setRemotePath("/remotePath/test");
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
OCFile target = targetActivity.getFile();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder_isNotRootFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/");
|
||||
origin.setFileId(1);
|
||||
origin.setRemotePath("/test/");
|
||||
origin.setStoragePath("/test/");
|
||||
origin.setFolder();
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
OCFile target = targetActivity.getCurrentFolder();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder_isRootFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/");
|
||||
origin.setFileId(1);
|
||||
origin.setRemotePath("/");
|
||||
origin.setStoragePath("/");
|
||||
origin.setFolder();
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
OCFile target = targetActivity.getCurrentFolder();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullFile() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile rootFolder = targetActivity.getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(null);
|
||||
OCFile target = targetActivity.getCurrentFolder();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(rootFolder, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/file.test");
|
||||
origin.setRemotePath("/test/file.test");
|
||||
|
||||
OCFile target = new OCFile("/test/");
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
FolderPickerActivity sut = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/file.txt");
|
||||
sut.setFile(origin);
|
||||
|
||||
sut.runOnUiThread(() -> {
|
||||
sut.findViewById(R.id.folder_picker_btn_copy).requestFocus();
|
||||
});
|
||||
waitForIdleSync();
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testMoveOrCopy() {
|
||||
Intent intent = new Intent();
|
||||
FolderPickerActivity targetActivity = activityRule.launchActivity(intent);
|
||||
|
||||
waitForIdleSync();
|
||||
screenshot(targetActivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testChooseLocationAction() {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.CHOOSE_LOCATION);
|
||||
FolderPickerActivity targetActivity = activityRule.launchActivity(intent);
|
||||
|
||||
waitForIdleSync();
|
||||
screenshot(targetActivity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.lib.common.Quota;
|
||||
import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
public class ManageAccountsActivityIT extends AbstractIT {
|
||||
@Rule
|
||||
public IntentsTestRule<ManageAccountsActivity> activityRule = new IntentsTestRule<>(ManageAccountsActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void userInfoDetail() {
|
||||
ManageAccountsActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
User user = sut.accountManager.getUser();
|
||||
|
||||
UserInfo userInfo = new UserInfo("test",
|
||||
true,
|
||||
"Test User",
|
||||
"test@nextcloud.com",
|
||||
"+49 123 456",
|
||||
"Address 123, Berlin",
|
||||
"https://www.nextcloud.com",
|
||||
"https://twitter.com/Nextclouders",
|
||||
new Quota(),
|
||||
new ArrayList<>());
|
||||
|
||||
sut.showUser(user, userInfo);
|
||||
|
||||
shortSleep();
|
||||
shortSleep();
|
||||
|
||||
screenshot(getCurrentActivity());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
public class UserInfoActivityIT extends AbstractIT {
|
||||
@Rule
|
||||
public IntentsTestRule<UserInfoActivity> activityRule = new IntentsTestRule<>(UserInfoActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,630 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Intent;
|
||||
import android.net.http.SslCertificate;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.gson.Gson;
|
||||
import com.nextcloud.android.common.ui.color.ColorUtil;
|
||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes;
|
||||
import com.nextcloud.android.common.ui.theme.MaterialSchemesImpl;
|
||||
import com.nextcloud.android.lib.resources.profile.Action;
|
||||
import com.nextcloud.android.lib.resources.profile.HoverCard;
|
||||
import com.nextcloud.client.account.RegisteredUser;
|
||||
import com.nextcloud.client.account.Server;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.device.DeviceInfo;
|
||||
import com.nextcloud.client.documentscan.AppScanOptionalFeature;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
|
||||
import com.nextcloud.utils.EditorUtils;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.Creator;
|
||||
import com.owncloud.android.lib.common.DirectEditing;
|
||||
import com.owncloud.android.lib.common.Editor;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.Status;
|
||||
import com.owncloud.android.lib.resources.users.StatusType;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog;
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
import com.owncloud.android.utils.theme.MaterialSchemesProvider;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.activity.result.contract.ActivityResultContract;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import kotlin.Unit;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
public class DialogFragmentIT extends AbstractIT {
|
||||
|
||||
private final String SERVER_URL = "https://nextcloud.localhost";
|
||||
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule =
|
||||
new IntentsTestRule<>(FileDisplayActivity.class, true, false);
|
||||
|
||||
private FileDisplayActivity getFileDisplayActivity() {
|
||||
Intent intent = new Intent(targetContext, FileDisplayActivity.class);
|
||||
return activityRule.launchActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void quitLooperIfNeeded() {
|
||||
if (Looper.myLooper() != null) {
|
||||
Looper.myLooper().quitSafely();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRenameFileDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(new OCFile("/Test/"),
|
||||
new OCFile("/"));
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testLoadingDialog() {
|
||||
LoadingDialog dialog = LoadingDialog.newInstance("Wait…");
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithOneAction() {
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[]{}, R.string.filedetails_sync_file, R.string.common_ok, -1, -1);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithTwoAction() {
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[]{}, R.string.filedetails_sync_file, R.string.common_ok, R.string.common_cancel, -1);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithThreeAction() {
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[]{}, R.string.filedetails_sync_file, R.string.common_ok, R.string.common_cancel, R.string.common_confirm);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithThreeActionRTL() {
|
||||
enableRTL();
|
||||
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[] { }, -1, R.string.common_ok, R.string.common_cancel, R.string.common_confirm);
|
||||
showDialog(dialog);
|
||||
|
||||
resetLocale();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRemoveFileDialog() {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(new OCFile("/Test.md"));
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRemoveFolderDialog() {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(new OCFile("/Folder/"));
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testNewFolderDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
CreateFolderDialogFragment sut = CreateFolderDialogFragment.newInstance(new OCFile("/"));
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testEnforcedPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, false);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testOptionalPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, true);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@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);
|
||||
userAccountManager.setCurrentOwnCloudAccount(newAccount.name);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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 ArbitraryDataProviderImpl(targetContext).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);
|
||||
capability.setAccountName(user.getAccountName());
|
||||
|
||||
CapabilityUtils.updateCapability(capability);
|
||||
|
||||
AppScanOptionalFeature appScanOptionalFeature = new AppScanOptionalFeature() {
|
||||
@NonNull
|
||||
@Override
|
||||
public ActivityResultContract<Unit, String> getScanContract() {
|
||||
throw new UnsupportedOperationException("Document scan is not available");
|
||||
}
|
||||
};
|
||||
|
||||
MaterialSchemesProvider materialSchemesProvider = new MaterialSchemesProvider() {
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForUser(@NonNull User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCapability(@NonNull OCCapability capability) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCurrentUser() {
|
||||
return new MaterialSchemesImpl(R.color.primary, false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getDefaultMaterialSchemes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForPrimaryBackground() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
ViewThemeUtils viewThemeUtils = new ViewThemeUtils(materialSchemesProvider.getMaterialSchemesForCurrentUser(),
|
||||
new ColorUtil(targetContext));
|
||||
|
||||
EditorUtils editorUtils = new EditorUtils(new ArbitraryDataProviderImpl(targetContext));
|
||||
|
||||
|
||||
OCFileListBottomSheetDialog sut = new OCFileListBottomSheetDialog(fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature);
|
||||
|
||||
fda.runOnUiThread(sut::show);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
sut.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
ViewGroup viewGroup = sut.getWindow().findViewById(android.R.id.content);
|
||||
hideCursors(viewGroup);
|
||||
|
||||
screenshot(Objects.requireNonNull(sut.getWindow()).getDecorView());
|
||||
|
||||
}
|
||||
|
||||
@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.viewThemeUtils);
|
||||
|
||||
fda.runOnUiThread(sut::show);
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut.getWindow().getDecorView());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testSslUntrustedCertDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
final SslCertificate certificate = new SslCertificate("foo", "bar", "2022/01/10", "2022/01/30");
|
||||
final SslError sslError = new SslError(SslError.SSL_UNTRUSTED, certificate);
|
||||
|
||||
final SslErrorHandler handler = Mockito.mock(SslErrorHandler.class);
|
||||
|
||||
SslUntrustedCertDialog sut = SslUntrustedCertDialog.newInstanceForEmptySslError(sslError, handler);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testStoragePermissionDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
StoragePermissionDialogFragment sut = StoragePermissionDialogFragment.Companion.newInstance(false);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testFileActionsBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
OCFile ocFile = new OCFile("/test.md");
|
||||
final FileActionsBottomSheet sut = FileActionsBottomSheet.newInstance(ocFile, false);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private FileDisplayActivity showDialog(FileDisplayActivity sut, DialogFragment dialog) {
|
||||
dialog.show(sut.getSupportFragmentManager(), "");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
ViewGroup viewGroup = dialog.requireDialog().getWindow().findViewById(android.R.id.content);
|
||||
hideCursors(viewGroup);
|
||||
|
||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
||||
|
||||
return sut;
|
||||
}
|
||||
|
||||
private void hideCursors(ViewGroup viewGroup) {
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
View child = viewGroup.getChildAt(i);
|
||||
|
||||
if (child instanceof ViewGroup) {
|
||||
hideCursors((ViewGroup) child);
|
||||
}
|
||||
|
||||
if (child instanceof TextView) {
|
||||
((TextView) child).setCursorVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
public class SyncFileNotEnoughSpaceDialogFragmentTest extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void showNotEnoughSpaceDialogForFolder() {
|
||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
||||
OCFile ocFile = new OCFile("/Document/");
|
||||
ocFile.setFileLength(5000000);
|
||||
ocFile.setFolder();
|
||||
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 1000);
|
||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "1");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void showNotEnoughSpaceDialogForFile() {
|
||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
||||
OCFile ocFile = new OCFile("/Video.mp4");
|
||||
ocFile.setFileLength(1000000);
|
||||
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 2000);
|
||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "2");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import org.junit.Rule
|
||||
|
||||
class PreviewImageFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
// Disabled for now due to strange failing when using entire test suite
|
||||
// Findings so far:
|
||||
// PreviewImageFragmentIT runs fine when only running this
|
||||
// running it in whole test suite fails
|
||||
// manually tried to execute LoadBitmapTask, but this does not start "doInBackground", but only creates class
|
||||
|
||||
// @Test
|
||||
// @ScreenshotTest
|
||||
// fun corruptImage() {
|
||||
// val activity = testActivityRule.launchActivity(null)
|
||||
//
|
||||
// val ocFile = OCFile("/test.png")
|
||||
// val sut = PreviewImageFragment.newInstance(ocFile, true, false)
|
||||
//
|
||||
// activity.addFragment(sut)
|
||||
//
|
||||
// while (!sut.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
// shortSleep()
|
||||
// }
|
||||
//
|
||||
// screenshot(activity)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @ScreenshotTest
|
||||
// fun validImage() {
|
||||
// val activity = testActivityRule.launchActivity(null)
|
||||
//
|
||||
// val ocFile = OCFile("/test.png")
|
||||
// ocFile.storagePath = getFile("imageFile.png").absolutePath
|
||||
//
|
||||
// val sut = PreviewImageFragment.newInstance(ocFile, true, false)
|
||||
//
|
||||
// activity.addFragment(sut)
|
||||
//
|
||||
// while (!sut.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
// shortSleep()
|
||||
// }
|
||||
//
|
||||
// screenshot(activity)
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.preview;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
public class PreviewTextFileFragmentTest extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void displaySimpleTextFile() throws IOException {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
File file = getDummyFile("nonEmpty.txt");
|
||||
OCFile test = new OCFile("/text.md");
|
||||
test.setMimeType(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN);
|
||||
test.setStoragePath(file.getAbsolutePath());
|
||||
sut.startTextPreview(test, false);
|
||||
|
||||
shortSleep();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue