mirror of
https://github.com/nextcloud/android.git
synced 2024-10-23 04:26:01 +03:00
wip
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
8b6171361a
commit
4dfefee31a
9 changed files with 117 additions and 16 deletions
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ import java.util.Set;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
|
||||
public class FileDataStorageManager {
|
||||
|
@ -1347,7 +1348,8 @@ public class FileDataStorageManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void cleanShares() {
|
||||
@VisibleForTesting
|
||||
public void cleanShares() {
|
||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ import third_parties.daveKoeller.AlphanumComparator;
|
|||
|
||||
public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S";
|
||||
private final static String PERMISSION_CAN_RESHARE = "R";
|
||||
@VisibleForTesting
|
||||
public final static String PERMISSION_CAN_RESHARE = "R";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
|
|
|
@ -62,19 +62,23 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
|||
switch (share.getShareType()) {
|
||||
case GROUP:
|
||||
name = context.getString(R.string.share_group_clarification, name);
|
||||
setImage(binding.icon, name, R.drawable.ic_group);
|
||||
setImage(binding.icon, share.getSharedWithDisplayName(), R.drawable.ic_group);
|
||||
break;
|
||||
case EMAIL:
|
||||
name = context.getString(R.string.share_email_clarification, name);
|
||||
setImage(binding.icon, name, R.drawable.ic_email);
|
||||
setImage(binding.icon, share.getSharedWithDisplayName(), R.drawable.ic_email);
|
||||
break;
|
||||
case ROOM:
|
||||
name = context.getString(R.string.share_room_clarification, name);
|
||||
setImage(binding.icon, name, R.drawable.ic_chat_bubble);
|
||||
setImage(binding.icon, share.getSharedWithDisplayName(), R.drawable.ic_chat_bubble);
|
||||
break;
|
||||
case CIRCLE:
|
||||
binding.icon.setImageResource(R.drawable.ic_circles);
|
||||
break;
|
||||
case FEDERATED:
|
||||
name = context.getString(R.string.share_remote_clarification, name);
|
||||
setImage(binding.icon, share.getSharedWithDisplayName(), R.drawable.ic_user);
|
||||
break;
|
||||
default:
|
||||
setImage(binding.icon, name, R.drawable.ic_user);
|
||||
break;
|
||||
|
|
|
@ -196,6 +196,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
|
||||
if (file.canReshare()) {
|
||||
refreshSharesFromDB();
|
||||
binding.searchView.setQueryHint(getResources().getString(R.string.share_search));
|
||||
} else {
|
||||
binding.searchView.setQueryHint(getResources().getString(R.string.reshare_not_allowed));
|
||||
binding.searchView.setInputType(InputType.TYPE_NULL);
|
||||
|
|
Loading…
Reference in a new issue