|
@@ -23,8 +23,11 @@ package com.owncloud.android.ui.fragment
|
|
|
|
|
|
import android.Manifest
|
|
|
import androidx.test.core.app.ActivityScenario
|
|
|
+import androidx.test.espresso.intent.rule.IntentsTestRule
|
|
|
+import androidx.test.platform.app.InstrumentationRegistry
|
|
|
import androidx.test.rule.GrantPermissionRule
|
|
|
import com.evernote.android.job.JobRequest
|
|
|
+import com.facebook.testing.screenshot.Screenshot
|
|
|
import com.nextcloud.client.account.UserAccountManagerImpl
|
|
|
import com.nextcloud.client.device.PowerManagementService
|
|
|
import com.nextcloud.client.network.ConnectivityService
|
|
@@ -36,16 +39,25 @@ import com.owncloud.android.MainApp
|
|
|
import com.owncloud.android.datamodel.UploadsStorageManager
|
|
|
import com.owncloud.android.db.OCUpload
|
|
|
import com.owncloud.android.files.services.FileUploader
|
|
|
+import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation
|
|
|
+import com.owncloud.android.lib.resources.shares.GetShareesRemoteOperation
|
|
|
+import com.owncloud.android.lib.resources.shares.OCShare
|
|
|
+import com.owncloud.android.lib.resources.shares.ShareType
|
|
|
import com.owncloud.android.operations.CreateFolderOperation
|
|
|
import com.owncloud.android.operations.RefreshFolderOperation
|
|
|
import com.owncloud.android.operations.UploadFileOperation
|
|
|
import com.owncloud.android.ui.activity.FileDisplayActivity
|
|
|
import com.owncloud.android.utils.FileStorageUtils
|
|
|
-import junit.framework.Assert.assertTrue
|
|
|
+import junit.framework.TestCase
|
|
|
+import org.json.JSONObject
|
|
|
+import org.junit.Assert.assertTrue
|
|
|
import org.junit.Rule
|
|
|
import org.junit.Test
|
|
|
|
|
|
class OCFileListFragmentIT : AbstractIT() {
|
|
|
+ @get:Rule
|
|
|
+ val activityRule = IntentsTestRule(FileDisplayActivity::class.java, true, false)
|
|
|
+
|
|
|
@get:Rule
|
|
|
val permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
|
|
@@ -92,10 +104,9 @@ class OCFileListFragmentIT : AbstractIT() {
|
|
|
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
|
|
targetContext,
|
|
|
false,
|
|
|
- false
|
|
|
- )
|
|
|
- newUpload.addRenameUploadListener {}
|
|
|
+ false)
|
|
|
|
|
|
+ newUpload.addRenameUploadListener {}
|
|
|
newUpload.setRemoteFolderToBeCreated()
|
|
|
|
|
|
assertTrue(newUpload.execute(client, storageManager).isSuccess)
|
|
@@ -114,7 +125,7 @@ class OCFileListFragmentIT : AbstractIT() {
|
|
|
Thread.sleep(2000)
|
|
|
|
|
|
sut.onActivity { activity ->
|
|
|
- com.facebook.testing.screenshot.Screenshot.snapActivity(activity).setName("richworkspaces_light").record()
|
|
|
+ Screenshot.snapActivity(activity).setName("richworkspaces_light").record()
|
|
|
}
|
|
|
|
|
|
val preferences: AppPreferences = AppPreferencesImpl.fromContext(targetContext)
|
|
@@ -130,7 +141,7 @@ class OCFileListFragmentIT : AbstractIT() {
|
|
|
Thread.sleep(2000)
|
|
|
|
|
|
sut.onActivity { activity ->
|
|
|
- com.facebook.testing.screenshot.Screenshot.snapActivity(activity).setName("richworkspaces_dark").record()
|
|
|
+ Screenshot.snapActivity(activity).setName("richworkspaces_dark").record()
|
|
|
}
|
|
|
|
|
|
// switch back to light mode
|
|
@@ -141,4 +152,99 @@ class OCFileListFragmentIT : AbstractIT() {
|
|
|
|
|
|
sut.recreate()
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ fun createAndShowShareToUser() {
|
|
|
+ val path = "/shareToAdmin/"
|
|
|
+ TestCase.assertTrue(CreateFolderOperation(path, true).execute(client, storageManager).isSuccess)
|
|
|
+
|
|
|
+ // share folder to user "admin"
|
|
|
+ TestCase.assertTrue(CreateShareRemoteOperation(path,
|
|
|
+ ShareType.USER,
|
|
|
+ "admin",
|
|
|
+ false,
|
|
|
+ "",
|
|
|
+ OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
|
|
|
+ .execute(client).isSuccess)
|
|
|
+
|
|
|
+ val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
|
|
+ sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
|
|
+
|
|
|
+ Thread.sleep(2000)
|
|
|
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
|
|
+ Screenshot.snapActivity(sut).record()
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ fun createAndShowShareToGroup() {
|
|
|
+ val path = "/shareToGroup/"
|
|
|
+ TestCase.assertTrue(CreateFolderOperation(path, true).execute(client, storageManager).isSuccess)
|
|
|
+
|
|
|
+ // share folder to group
|
|
|
+ assertTrue(CreateShareRemoteOperation("/shareToGroup/",
|
|
|
+ ShareType.GROUP,
|
|
|
+ "users",
|
|
|
+ false,
|
|
|
+ "",
|
|
|
+ OCShare.DEFAULT_PERMISSION)
|
|
|
+ .execute(client).isSuccess)
|
|
|
+
|
|
|
+ val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
|
|
+ sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
|
|
+
|
|
|
+ Thread.sleep(2000)
|
|
|
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
|
|
+ Screenshot.snapActivity(sut).record()
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ fun createAndShowShareToCircle() {
|
|
|
+ val path = "/shareToCircle/"
|
|
|
+ TestCase.assertTrue(CreateFolderOperation(path, true).execute(client, storageManager).isSuccess)
|
|
|
+
|
|
|
+ // share folder to circle
|
|
|
+ // get circleId
|
|
|
+ val searchResult = GetShareesRemoteOperation("publicCircle", 1, 50).execute(client)
|
|
|
+ assertTrue(searchResult.logMessage, searchResult.isSuccess)
|
|
|
+
|
|
|
+ val resultJson: JSONObject = searchResult.data[0] as JSONObject
|
|
|
+ val circleId: String = resultJson.getJSONObject("value").getString("shareWith")
|
|
|
+
|
|
|
+ assertTrue(CreateShareRemoteOperation("/shareToCircle/",
|
|
|
+ ShareType.CIRCLE,
|
|
|
+ circleId,
|
|
|
+ false,
|
|
|
+ "",
|
|
|
+ OCShare.DEFAULT_PERMISSION)
|
|
|
+ .execute(client).isSuccess)
|
|
|
+
|
|
|
+ val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
|
|
+ sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
|
|
+
|
|
|
+ Thread.sleep(2000)
|
|
|
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
|
|
+ Screenshot.snapActivity(sut).record()
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ fun createAndShowShareViaLink() {
|
|
|
+ val path = "/shareViaLink/"
|
|
|
+ TestCase.assertTrue(CreateFolderOperation(path, true).execute(client, storageManager).isSuccess)
|
|
|
+
|
|
|
+ // share folder via public link
|
|
|
+ TestCase.assertTrue(CreateShareRemoteOperation("/shareViaLink/",
|
|
|
+ ShareType.PUBLIC_LINK,
|
|
|
+ "",
|
|
|
+ true,
|
|
|
+ "",
|
|
|
+ OCShare.READ_PERMISSION_FLAG)
|
|
|
+ .execute(client).isSuccess)
|
|
|
+
|
|
|
+ val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
|
|
+ sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
|
|
+
|
|
|
+ Thread.sleep(2000)
|
|
|
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
|
|
+ Screenshot.snapActivity(sut).record()
|
|
|
+ }
|
|
|
}
|