mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
OC-2256: Adapt Unit Test to the new result
This commit is contained in:
parent
007ca522ec
commit
9a8b89bea1
6 changed files with 30 additions and 22 deletions
|
@ -6,18 +6,22 @@ import com.owncloud.android.oc_framework_test_project.TestActivity;
|
|||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
public class ReadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
||||
/**
|
||||
* Class to test Read Folder Operation
|
||||
* @author masensio
|
||||
*
|
||||
*/
|
||||
|
||||
public class ReadFolderTest 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() {
|
||||
public ReadFolderTest() {
|
||||
super(TestActivity.class);
|
||||
}
|
||||
|
||||
|
@ -34,15 +38,10 @@ public class ReadFileTest extends ActivityInstrumentationTestCase2<TestActivity>
|
|||
public void testReadFolder() {
|
||||
|
||||
RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
|
||||
assertTrue(result.getFile() != null);
|
||||
assertTrue(result.getData().size() > 0);
|
||||
assertTrue(result.getData().size() == 3);
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Read File
|
||||
*/
|
||||
public void testReadFile() {
|
||||
|
||||
RemoteOperationResult result = mActivity.readFile(mRemoteFilePath);
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
}
|
|
@ -6,6 +6,12 @@ import com.owncloud.android.oc_framework_test_project.TestActivity;
|
|||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
/**
|
||||
* Class to test Rename File Operation
|
||||
* @author masensio
|
||||
*
|
||||
*/
|
||||
|
||||
public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
||||
|
||||
/* Folder data to rename. This folder must exist on the account */
|
||||
|
|
|
@ -4,7 +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.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.oc_framework.operations.remote.RemoveRemoteFileOperation;
|
||||
import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation;
|
||||
|
||||
|
@ -92,14 +92,14 @@ public class TestActivity extends Activity {
|
|||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Read a File or Folder (PROPFIND DEPTH 1)
|
||||
* Access to the library method to Read a Folder (PROPFIND DEPTH 1)
|
||||
* @param remotePath
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult readFile(String remotePath) {
|
||||
|
||||
ReadRemoteFileOperation readOperation= new ReadRemoteFileOperation(remotePath);
|
||||
ReadRemoteFolderOperation readOperation= new ReadRemoteFolderOperation(remotePath);
|
||||
RemoteOperationResult result = readOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -7,6 +7,11 @@ import android.os.Parcelable;
|
|||
|
||||
import com.owncloud.android.oc_framework.utils.FileUtils;
|
||||
|
||||
/**
|
||||
* Contains the data of a Remote File from a WebDavEntry
|
||||
*
|
||||
* @author masensio
|
||||
*/
|
||||
|
||||
public class RemoteFile implements Parcelable, Serializable{
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
|
|||
* @author masensio
|
||||
*/
|
||||
|
||||
public class ReadRemoteFileOperation extends RemoteOperation {
|
||||
public class ReadRemoteFolderOperation extends RemoteOperation {
|
||||
|
||||
private static final String TAG = ReadRemoteFileOperation.class.getSimpleName();
|
||||
private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName();
|
||||
|
||||
private String mRemotePath;
|
||||
private RemoteFile mFolder;
|
||||
|
@ -36,7 +36,7 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
|||
*
|
||||
* @param remotePath Remote path of the file.
|
||||
*/
|
||||
public ReadRemoteFileOperation(String remotePath) {
|
||||
public ReadRemoteFolderOperation(String remotePath) {
|
||||
mRemotePath = remotePath;
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,6 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
|||
WebdavEntry we = new WebdavEntry(dataInServer.getResponses()[0], client.getBaseUri().getPath());
|
||||
mFolder = fillOCFile(we);
|
||||
|
||||
Log.d(TAG, "Remote folder " + mRemotePath + " changed - starting update of local data ");
|
||||
|
||||
|
||||
// loop to update every child
|
||||
RemoteFile remoteFile = null;
|
|
@ -45,7 +45,7 @@ import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
|
|||
import com.owncloud.android.oc_framework.operations.RemoteOperation;
|
||||
import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFileOperation;
|
||||
import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.oc_framework.operations.RemoteFile;
|
||||
import com.owncloud.android.syncadapter.FileSyncService;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
@ -244,7 +244,7 @@ public class SynchronizeFolderOperation extends RemoteOperation {
|
|||
|
||||
private RemoteOperationResult fetchAndSyncRemoteFolder(WebdavClient client) {
|
||||
String remotePath = mLocalFolder.getRemotePath();
|
||||
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
|
||||
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
|
||||
|
||||
|
|
Loading…
Reference in a new issue