mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-28 00:48:50 +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 | ||||
|  *   Copyright (C) 2012-2013 ownCloud Inc. | ||||
|  * | ||||
|  *   This program is free software: you can redistribute it and/or modify | ||||
|  *   it under the terms of the GNU General Public License version 2, | ||||
|  *   as published by the Free Software Foundation. | ||||
|  * | ||||
|  *   This program is distributed in the hope that it will be useful, | ||||
|  *   but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *   GNU General Public License for more details. | ||||
|  * | ||||
|  *   You should have received a copy of the GNU General Public License | ||||
|  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| /* 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. | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| @ -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.CreateRemoteFolderOperation; | ||||
| 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.RemoveRemoteFileOperation; | ||||
| import com.owncloud.android.lib.operations.remote.RenameRemoteFileOperation; | ||||
| @ -46,11 +54,12 @@ import android.view.Menu; | ||||
| 
 | ||||
| public class TestActivity extends Activity { | ||||
| 	 | ||||
| 	// This account must exists on the simulator / device | ||||
| 	private static final String mServerUri = "https://beta.owncloud.com/owncloud/remote.php/webdav"; | ||||
| 	private static final String mUser = "testandroid"; | ||||
| 	private static final String mPass = "testandroid"; | ||||
| 	private static final boolean mChunked = true; | ||||
| 	// This account must exists on the server side | ||||
| 	private String mServerUri; | ||||
| 	private String mWebdavPath; | ||||
| 	private String mUser; | ||||
| 	private String mPass; | ||||
| 	private boolean mChunked; | ||||
| 	 | ||||
| 	//private Account mAccount = null; | ||||
| 	private OwnCloudClient mClient; | ||||
| @ -59,9 +68,18 @@ public class TestActivity extends Activity { | ||||
| 	protected void onCreate(Bundle savedInstanceState) { | ||||
| 		super.onCreate(savedInstanceState); | ||||
| 		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.setBasicCredentials(mUser, mPass); | ||||
|     	mClient.setBaseUri(Uri.parse(mServerUri)); | ||||
|     	 | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| @ -171,4 +189,12 @@ public class TestActivity extends Activity { | ||||
| 		 | ||||
| 		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); | ||||
| 		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