mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
OC-2737: Unit Tests for Create Share
This commit is contained in:
parent
a42ac0e5ad
commit
aec92fcb12
@ -24,9 +24,9 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<string name="server_base_url"></string> <!-- the server url, without webdav path -->
|
<string name="server_base_url">https://daily.owncloud.com/master/owncloud</string> <!-- the server url, without webdav path -->
|
||||||
<string name="webdav_path">/remote.php/webdav</string> <!-- default value for webdav path (owncloud version > = 4)-->
|
<string name="webdav_path">/remote.php/webdav</string> <!-- default value for webdav path (owncloud version > = 4)-->
|
||||||
<string name="username"></string>
|
<string name="username">maria</string>
|
||||||
<string name="password"></string>
|
<string name="password">maria</string>
|
||||||
<bool name="chunked">true</bool>
|
<bool name="chunked">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -30,8 +30,10 @@ import com.owncloud.android.lib.network.OwnCloudClientFactory;
|
|||||||
import com.owncloud.android.lib.network.OwnCloudClient;
|
import com.owncloud.android.lib.network.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.operations.common.RemoteFile;
|
import com.owncloud.android.lib.operations.common.RemoteFile;
|
||||||
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
|
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
|
||||||
|
import com.owncloud.android.lib.operations.common.ShareType;
|
||||||
import com.owncloud.android.lib.operations.remote.ChunkedUploadRemoteFileOperation;
|
import com.owncloud.android.lib.operations.remote.ChunkedUploadRemoteFileOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.CreateRemoteFolderOperation;
|
import com.owncloud.android.lib.operations.remote.CreateRemoteFolderOperation;
|
||||||
|
import com.owncloud.android.lib.operations.remote.CreateShareRemoteOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.DownloadRemoteFileOperation;
|
import com.owncloud.android.lib.operations.remote.DownloadRemoteFileOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation;
|
import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation;
|
import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation;
|
||||||
@ -190,6 +192,11 @@ public class TestActivity extends Activity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Access to the library method to Get Shares
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public RemoteOperationResult getShares(){
|
public RemoteOperationResult getShares(){
|
||||||
|
|
||||||
GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation();
|
GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation();
|
||||||
@ -197,4 +204,32 @@ public class TestActivity extends Activity {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Access to the library method to Create Share
|
||||||
|
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||||
|
* @param shareType ‘0’ = user, ‘1’ = group, ‘3’ = Public link. Mandatory argument
|
||||||
|
* @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1
|
||||||
|
* @param publicUpload If ‘false’ (default) public cannot upload to a public shared folder.
|
||||||
|
* If ‘true’ public can upload to a shared folder. Only available for public link shares
|
||||||
|
* @param password Password to protect a public link share. Only available for public link shares
|
||||||
|
* @param permissions 1 - Read only – Default for “public” shares
|
||||||
|
* 2 - Update
|
||||||
|
* 4 - Create
|
||||||
|
* 8 - Delete
|
||||||
|
* 16- Re-share
|
||||||
|
* 31- All above – Default for “private” shares
|
||||||
|
* For user or group shares.
|
||||||
|
* To obtain combinations, add the desired values together.
|
||||||
|
* For instance, for “Re-Share”, “delete”, “read”, “update”, add 16+8+2+1 = 27.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RemoteOperationResult createShare(String path, ShareType shareType, String shareWith, boolean publicUpload,
|
||||||
|
String password, int permissions){
|
||||||
|
|
||||||
|
CreateShareRemoteOperation createOperation = new CreateShareRemoteOperation(path, shareType, shareWith, publicUpload, password, permissions);
|
||||||
|
RemoteOperationResult result = createOperation.execute(mClient);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
/* ownCloud Android Library is available under MIT license
|
||||||
|
* Copyright (C) 2014 ownCloud (http://www.owncloud.org/)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.test_project.test;
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
|
||||||
|
import com.owncloud.android.lib.operations.common.ShareType;
|
||||||
|
import com.owncloud.android.lib.test_project.TestActivity;
|
||||||
|
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
|
||||||
|
public class CreateShareTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
||||||
|
|
||||||
|
/* File to share.*/
|
||||||
|
private final String mFileToShare = "/fileToShare.png";
|
||||||
|
|
||||||
|
private TestActivity mActivity;
|
||||||
|
|
||||||
|
public CreateShareTest() {
|
||||||
|
super(TestActivity.class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
setActivityInitialTouchMode(false);
|
||||||
|
mActivity = getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Create Share: the server must support SHARE API
|
||||||
|
*/
|
||||||
|
public void testCreateShare() {
|
||||||
|
RemoteOperationResult result = mActivity.createShare(mFileToShare, ShareType.PUBLIC_LINK, "", false, "", 1);
|
||||||
|
assertTrue(result.isSuccess());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user