OC-2256: Adapt Unit Test to the new result

This commit is contained in:
masensio 2013-11-28 13:33:05 +01:00
parent 007ca522ec
commit 9a8b89bea1
6 changed files with 30 additions and 22 deletions

View file

@ -6,18 +6,22 @@ import com.owncloud.android.oc_framework_test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2; 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 */ /* Folder data to read. This folder must exist on the account */
private final String mRemoteFolderPath = "/folderToRead"; 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; private TestActivity mActivity;
public ReadFileTest() { public ReadFolderTest() {
super(TestActivity.class); super(TestActivity.class);
} }
@ -34,15 +38,10 @@ public class ReadFileTest extends ActivityInstrumentationTestCase2<TestActivity>
public void testReadFolder() { public void testReadFolder() {
RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath); RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
assertTrue(result.getFile() != null);
assertTrue(result.getData().size() > 0);
assertTrue(result.getData().size() == 3);
assertTrue(result.isSuccess()); assertTrue(result.isSuccess());
} }
/**
* Test Read File
*/
public void testReadFile() {
RemoteOperationResult result = mActivity.readFile(mRemoteFilePath);
assertTrue(result.isSuccess());
}
} }

View file

@ -6,6 +6,12 @@ import com.owncloud.android.oc_framework_test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
/**
* Class to test Rename File Operation
* @author masensio
*
*/
public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivity> { public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* Folder data to rename. This folder must exist on the account */ /* Folder data to rename. This folder must exist on the account */

View file

@ -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.network.webdav.WebdavClient;
import com.owncloud.android.oc_framework.operations.RemoteOperationResult; 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.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.RemoveRemoteFileOperation;
import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation; 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 * @param remotePath
* *
* @return * @return
*/ */
public RemoteOperationResult readFile(String remotePath) { public RemoteOperationResult readFile(String remotePath) {
ReadRemoteFileOperation readOperation= new ReadRemoteFileOperation(remotePath); ReadRemoteFolderOperation readOperation= new ReadRemoteFolderOperation(remotePath);
RemoteOperationResult result = readOperation.execute(mClient); RemoteOperationResult result = readOperation.execute(mClient);
return result; return result;

View file

@ -7,6 +7,11 @@ import android.os.Parcelable;
import com.owncloud.android.oc_framework.utils.FileUtils; 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{ public class RemoteFile implements Parcelable, Serializable{

View file

@ -23,9 +23,9 @@ import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
* @author masensio * @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 String mRemotePath;
private RemoteFile mFolder; private RemoteFile mFolder;
@ -36,7 +36,7 @@ public class ReadRemoteFileOperation extends RemoteOperation {
* *
* @param remotePath Remote path of the file. * @param remotePath Remote path of the file.
*/ */
public ReadRemoteFileOperation(String remotePath) { public ReadRemoteFolderOperation(String remotePath) {
mRemotePath = remotePath; mRemotePath = remotePath;
} }
@ -116,8 +116,6 @@ public class ReadRemoteFileOperation extends RemoteOperation {
WebdavEntry we = new WebdavEntry(dataInServer.getResponses()[0], client.getBaseUri().getPath()); WebdavEntry we = new WebdavEntry(dataInServer.getResponses()[0], client.getBaseUri().getPath());
mFolder = fillOCFile(we); mFolder = fillOCFile(we);
Log.d(TAG, "Remote folder " + mRemotePath + " changed - starting update of local data ");
// loop to update every child // loop to update every child
RemoteFile remoteFile = null; RemoteFile remoteFile = null;

View file

@ -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.RemoteOperation;
import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; 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.oc_framework.operations.RemoteFile;
import com.owncloud.android.syncadapter.FileSyncService; import com.owncloud.android.syncadapter.FileSyncService;
import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.FileStorageUtils;
@ -244,7 +244,7 @@ public class SynchronizeFolderOperation extends RemoteOperation {
private RemoteOperationResult fetchAndSyncRemoteFolder(WebdavClient client) { private RemoteOperationResult fetchAndSyncRemoteFolder(WebdavClient client) {
String remotePath = mLocalFolder.getRemotePath(); String remotePath = mLocalFolder.getRemotePath();
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath); ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
RemoteOperationResult result = operation.execute(client); RemoteOperationResult result = operation.execute(client);
Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath); Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);