From: masensio Date: Fri, 22 Nov 2013 13:07:59 +0000 (+0100) Subject: OC-2165: Create Unit Test for RemoveRemoteFileOperation X-Git-Tag: oc-android-1.5.5~118^2~3 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/dd4bcae0cf6e69a985c64cb63b65ee8f4f043b73?ds=sidebyside;hp=--cc OC-2165: Create Unit Test for RemoveRemoteFileOperation --- dd4bcae0cf6e69a985c64cb63b65ee8f4f043b73 diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DeleteFileTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DeleteFileTest.java new file mode 100644 index 00000000..b8ab2b0c --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DeleteFileTest.java @@ -0,0 +1,57 @@ +package com.owncloud.android.oc_framework_test_project.test; + +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework_test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; + +public class DeleteFileTest extends ActivityInstrumentationTestCase2 { + + /* Folder data to delete. */ + private final String mFolderPath = "/folderToDelete"; + + /* File to delete. */ + private final String mFilePath = "fileToDelete.png"; + + private TestActivity mActivity; + + public DeleteFileTest() { + super(TestActivity.class); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Remove Folder + */ + public void testRemoveFolder() { + + RemoteOperationResult result = mActivity.removeFile(mFolderPath); + assertTrue(result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND); + } + + /** + * Test Remove File + */ + public void testRemoveFile() { + + RemoteOperationResult result = mActivity.removeFile(mFilePath); + assertTrue(result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND); + } + + /** + * Restore initial conditions + */ + public void testRestoreInitialConditions() { + RemoteOperationResult result = mActivity.createFolder(mFolderPath, true); + assertTrue(result.isSuccess()); + + } +} diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index 7687bb2f..12330a9a 100644 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -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.RemoveRemoteFileOperation; import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation; import android.net.Uri; @@ -44,8 +45,8 @@ public class TestActivity extends Activity { /** * Access to the library method to Create a Folder - * @param remotePath - * @param createFullPath + * @param remotePath Full path to the new directory to create in the remote server. + * @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet. * * @return */ @@ -75,4 +76,19 @@ public class TestActivity extends Activity { return result; } + /** + * Access to the library method to Remove a File or Folder + * + * @param remotePath Remote path of the file or folder in the server. + * @return + */ + public RemoteOperationResult removeFile(String remotePath) { + + RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath); + RemoteOperationResult result = removeOperation.execute(mClient); + + return result; + } + + }