mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
OC-2172: Unit Test for ReadRemoteFileOperation
This commit is contained in:
parent
8303c902d9
commit
40798f69ee
2 changed files with 63 additions and 0 deletions
|
@ -0,0 +1,48 @@
|
|||
package com.owncloud.android.oc_framework_test_project.test;
|
||||
|
||||
|
||||
import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.oc_framework_test_project.TestActivity;
|
||||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
public class ReadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
||||
|
||||
|
||||
/* Folder data to read. This folder must exist on the account */
|
||||
private final String mRemoteFolderPath = "/folderToRead";
|
||||
|
||||
/* File data to rename. This file must exist on the account */
|
||||
private final String mRemoteFilePath = "/fileToRead.txt";
|
||||
|
||||
private TestActivity mActivity;
|
||||
|
||||
public ReadFileTest() {
|
||||
super(TestActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
setActivityInitialTouchMode(false);
|
||||
mActivity = getActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Read Folder
|
||||
*/
|
||||
public void testReadFolder() {
|
||||
|
||||
RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Read File
|
||||
*/
|
||||
public void testReadFile() {
|
||||
|
||||
RemoteOperationResult result = mActivity.readFile(mRemoteFilePath);
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
|
|||
import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
|
||||
import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation;
|
||||
import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFileOperation;
|
||||
import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation;
|
||||
|
||||
import android.net.Uri;
|
||||
|
@ -75,4 +76,18 @@ public class TestActivity extends Activity {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Read a File or Folder (PROPFIND DEPTH 1)
|
||||
* @param remotePath
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult readFile(String remotePath) {
|
||||
|
||||
ReadRemoteFileOperation readOperation= new ReadRemoteFileOperation(remotePath);
|
||||
RemoteOperationResult result = readOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue