|
@@ -29,7 +29,12 @@ import androidx.test.rule.GrantPermissionRule
|
|
|
import com.nextcloud.client.TestActivity
|
|
|
import com.owncloud.android.AbstractIT
|
|
|
import com.owncloud.android.R
|
|
|
+import com.owncloud.android.datamodel.OCFile
|
|
|
import com.owncloud.android.lib.resources.shares.OCShare
|
|
|
+import com.owncloud.android.lib.resources.shares.ShareType
|
|
|
+import com.owncloud.android.utils.ScreenshotTest
|
|
|
+import org.junit.After
|
|
|
+import org.junit.Before
|
|
|
import org.junit.Rule
|
|
|
import org.junit.Test
|
|
|
|
|
@@ -40,28 +45,111 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
|
|
@get:Rule
|
|
|
val permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
|
|
|
+ lateinit var file: OCFile
|
|
|
+ lateinit var folder: OCFile
|
|
|
+ lateinit var activity: TestActivity
|
|
|
+
|
|
|
+ @Before
|
|
|
+ fun before() {
|
|
|
+ activity = testActivityRule.launchActivity(null)
|
|
|
+ file = OCFile("/test.md").apply {
|
|
|
+ parentId = activity.storageManager.getFileByEncryptedRemotePath("/").fileId
|
|
|
+ permissions = OCFile.PERMISSION_CAN_RESHARE
|
|
|
+ }
|
|
|
+
|
|
|
+ folder = OCFile("/test").apply {
|
|
|
+ setFolder()
|
|
|
+ parentId = activity.storageManager.getFileByEncryptedRemotePath("/").fileId
|
|
|
+ permissions = OCFile.PERMISSION_CAN_RESHARE
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
+ @ScreenshotTest
|
|
|
fun listShares_file_none() {
|
|
|
- val sut = testActivityRule.launchActivity(null)
|
|
|
- sut.addFragment(FileDetailSharingFragment())
|
|
|
+ // todo search hint is not shown!?
|
|
|
|
|
|
+ show(file)
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- fun listShares_file_all() {
|
|
|
- // with multiple public share links
|
|
|
- throw NotImplementedError()
|
|
|
+ @ScreenshotTest
|
|
|
+ fun listShares_file_resharing_not_allowed() {
|
|
|
+ file.permissions = ""
|
|
|
+
|
|
|
+ show(file)
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- fun listShares_folder_none() {
|
|
|
- throw NotImplementedError()
|
|
|
+ @ScreenshotTest
|
|
|
+ fun listShares_file_allShareTypes() {
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 1
|
|
|
+ shareType = ShareType.USER
|
|
|
+ sharedWithDisplayName = "Admin"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 2
|
|
|
+ shareType = ShareType.GROUP
|
|
|
+ sharedWithDisplayName = "Group"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 3
|
|
|
+ shareType = ShareType.EMAIL
|
|
|
+ sharedWithDisplayName = "admin@nextcloud.server.com"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 4
|
|
|
+ shareType = ShareType.PUBLIC_LINK
|
|
|
+ sharedWithDisplayName = "Customer"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 5
|
|
|
+ shareType = ShareType.PUBLIC_LINK
|
|
|
+ sharedWithDisplayName = "Colleagues"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 6
|
|
|
+ shareType = ShareType.FEDERATED
|
|
|
+ sharedWithDisplayName = "admin@nextcloud.remoteserver.com"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 7
|
|
|
+ shareType = ShareType.CIRCLE
|
|
|
+ sharedWithDisplayName = "Private circle"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ OCShare(file.decryptedRemotePath).apply {
|
|
|
+ remoteId = 8
|
|
|
+ shareType = ShareType.ROOM
|
|
|
+ sharedWithDisplayName = "Meeting"
|
|
|
+ activity.storageManager.saveShare(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ show(file)
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
- fun listShares_folder_all() {
|
|
|
- // with multiple public share links
|
|
|
- throw NotImplementedError()
|
|
|
+ private fun show(file: OCFile) {
|
|
|
+ val fragment = FileDetailSharingFragment.newInstance(file, user);
|
|
|
+
|
|
|
+ activity.addFragment(fragment)
|
|
|
+
|
|
|
+ waitForIdleSync()
|
|
|
+
|
|
|
+ screenshot(activity)
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -79,4 +167,9 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
|
|
|
|
|
// scenarios: public link, email, …, both for file/folder
|
|
|
}
|
|
|
+
|
|
|
+ @After
|
|
|
+ fun after() {
|
|
|
+ activity.storageManager.cleanShares()
|
|
|
+ }
|
|
|
}
|