mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
OC-2736: Create unit tests for GetShares Operation
This commit is contained in:
parent
ccb079935f
commit
a42ac0e5ad
32
tests/res/values/setup.xml
Normal file
32
tests/res/values/setup.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<string name="server_base_url"></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="username"></string>
|
||||||
|
<string name="password"></string>
|
||||||
|
<bool name="chunked">true</bool>
|
||||||
|
</resources>
|
@ -1,17 +1,24 @@
|
|||||||
/* ownCloud Android client application
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2012-2013 ownCloud Inc.
|
* Copyright (C) 2014 ownCloud (http://www.owncloud.org/)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* it under the terms of the GNU General Public License version 2,
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* as published by the Free Software Foundation.
|
* in the Software without restriction, including without limitation the rights
|
||||||
*
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* This program is distributed in the hope that it will be useful,
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* furnished to do so, subject to the following conditions:
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
*
|
||||||
* GNU General Public License for more details.
|
* The above copyright notice and this permission notice shall be included in
|
||||||
*
|
* all copies or substantial portions of the Software.
|
||||||
* You should have received a copy of the GNU General Public License
|
*
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* 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.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -26,6 +33,7 @@ import com.owncloud.android.lib.operations.common.RemoteOperationResult;
|
|||||||
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.DownloadRemoteFileOperation;
|
import com.owncloud.android.lib.operations.remote.DownloadRemoteFileOperation;
|
||||||
|
import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation;
|
import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.RemoveRemoteFileOperation;
|
import com.owncloud.android.lib.operations.remote.RemoveRemoteFileOperation;
|
||||||
import com.owncloud.android.lib.operations.remote.RenameRemoteFileOperation;
|
import com.owncloud.android.lib.operations.remote.RenameRemoteFileOperation;
|
||||||
@ -46,11 +54,12 @@ import android.view.Menu;
|
|||||||
|
|
||||||
public class TestActivity extends Activity {
|
public class TestActivity extends Activity {
|
||||||
|
|
||||||
// This account must exists on the simulator / device
|
// This account must exists on the server side
|
||||||
private static final String mServerUri = "https://beta.owncloud.com/owncloud/remote.php/webdav";
|
private String mServerUri;
|
||||||
private static final String mUser = "testandroid";
|
private String mWebdavPath;
|
||||||
private static final String mPass = "testandroid";
|
private String mUser;
|
||||||
private static final boolean mChunked = true;
|
private String mPass;
|
||||||
|
private boolean mChunked;
|
||||||
|
|
||||||
//private Account mAccount = null;
|
//private Account mAccount = null;
|
||||||
private OwnCloudClient mClient;
|
private OwnCloudClient mClient;
|
||||||
@ -59,9 +68,18 @@ public class TestActivity extends Activity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_test);
|
setContentView(R.layout.activity_test);
|
||||||
Uri uri = Uri.parse(mServerUri);
|
|
||||||
|
mServerUri = getString(R.string.server_base_url);
|
||||||
|
mWebdavPath = getString(R.string.webdav_path);
|
||||||
|
mUser = getString(R.string.username);
|
||||||
|
mPass = getString(R.string.password);
|
||||||
|
mChunked = getResources().getBoolean(R.bool.chunked);
|
||||||
|
|
||||||
|
Uri uri = Uri.parse(mServerUri + mWebdavPath);
|
||||||
mClient = OwnCloudClientFactory.createOwnCloudClient(uri ,getApplicationContext(), true);
|
mClient = OwnCloudClientFactory.createOwnCloudClient(uri ,getApplicationContext(), true);
|
||||||
mClient.setBasicCredentials(mUser, mPass);
|
mClient.setBasicCredentials(mUser, mPass);
|
||||||
|
mClient.setBaseUri(Uri.parse(mServerUri));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -171,4 +189,12 @@ public class TestActivity extends Activity {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RemoteOperationResult getShares(){
|
||||||
|
|
||||||
|
GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation();
|
||||||
|
RemoteOperationResult result = getOperation.execute(mClient);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,4 +127,6 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2<TestActiv
|
|||||||
RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
|
RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
|
||||||
assertFalse(result.isSuccess());
|
assertFalse(result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
/* 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.test_project.TestActivity;
|
||||||
|
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to test Get Shares Operation
|
||||||
|
*
|
||||||
|
* @author masensio
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GetSharesTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
||||||
|
|
||||||
|
private TestActivity mActivity;
|
||||||
|
|
||||||
|
public GetSharesTest() {
|
||||||
|
super(TestActivity.class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
setActivityInitialTouchMode(false);
|
||||||
|
mActivity = getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Get Shares: the server must support SHARE API
|
||||||
|
*/
|
||||||
|
public void testGetShares() {
|
||||||
|
RemoteOperationResult result = mActivity.getShares();
|
||||||
|
assertTrue(result.isSuccess());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user