|
@@ -1,10 +1,7 @@
|
|
|
package com.owncloud.android.oc_framework_test_project.test;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-
|
|
|
import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
|
|
|
import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
|
|
|
-import com.owncloud.android.oc_framework.utils.FileUtils;
|
|
|
import com.owncloud.android.oc_framework_test_project.TestActivity;
|
|
|
|
|
|
import android.test.ActivityInstrumentationTestCase2;
|
|
@@ -13,16 +10,16 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|
|
|
|
|
/* Folder data to rename. This folder must exist on the account */
|
|
|
private final String mOldFolderName = "folderToRename";
|
|
|
- private final String mOldFolderPath = "/folderToRename/";
|
|
|
+ private final String mOldFolderPath = "/folderToRename";
|
|
|
private final String mNewFolderName = "renamedFolder";
|
|
|
- private final String mNewFolderPath = "/renameFolder";
|
|
|
+ private final String mNewFolderPath = "/renamedFolder";
|
|
|
|
|
|
/* File data to rename. This file must exist on the account */
|
|
|
private final String mOldFileName = "fileToRename.png";
|
|
|
private final String mOldFilePath = "/fileToRename.png";
|
|
|
private final String mNewFileName = "renamedFile";
|
|
|
- private final String mNewFilePath = "/renamedFile";
|
|
|
private final String mFileExtension = ".png";
|
|
|
+ private final String mNewFilePath ="/renamedFile.png";
|
|
|
|
|
|
|
|
|
private TestActivity mActivity;
|
|
@@ -45,49 +42,45 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|
|
public void testRenameFolder() {
|
|
|
|
|
|
RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName, mNewFolderPath + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName, true);
|
|
|
assertTrue(result.isSuccess());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Test Rename Folder with forbidden characters : / \ < > : " | ? *
|
|
|
+ * Test Rename Folder with forbidden characters : \ < > : " | ? *
|
|
|
*/
|
|
|
public void testRenameFolderForbiddenChars() {
|
|
|
-
|
|
|
- RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "//", mNewFolderPath + "//" + FileUtils.PATH_SEPARATOR);
|
|
|
- assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
- result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "\\", mNewFolderPath + "\\" + FileUtils.PATH_SEPARATOR);
|
|
|
+ RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
+ mNewFolderName + "\\", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "<", mNewFolderPath + "<" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + "<", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + ">", mNewFolderPath + ">" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + ">", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + ":", mNewFolderPath + ":" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + ":", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "\"", mNewFolderPath + "\"" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + "\"", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "|", mNewFolderPath + "|" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + "|", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "?", mNewFolderPath + "?" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + "?", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
|
|
|
- mNewFolderName + "*", mNewFolderPath + "*" + FileUtils.PATH_SEPARATOR);
|
|
|
+ mNewFolderName + "*", true);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
}
|
|
|
|
|
@@ -96,49 +89,45 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|
|
*/
|
|
|
public void testRenameFile() {
|
|
|
RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + mFileExtension, mNewFilePath + mFileExtension);
|
|
|
+ mNewFileName + mFileExtension, false);
|
|
|
assertTrue(result.isSuccess());
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * Test Rename Folder with forbidden characters: / \ < > : " | ? *
|
|
|
+ * Test Rename Folder with forbidden characters: \ < > : " | ? *
|
|
|
*/
|
|
|
- public void testRenameFileForbiddenChars() {
|
|
|
+ public void testRenameFileForbiddenChars() {
|
|
|
RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "//" + mFileExtension, mNewFilePath + "//" + mFileExtension);
|
|
|
- assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
-
|
|
|
- result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "\\" + mFileExtension, mNewFilePath + "\\" + mFileExtension);
|
|
|
+ mNewFileName + "\\" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "<" + mFileExtension, mNewFilePath + "<" + mFileExtension);
|
|
|
+ mNewFileName + "<" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + ">" + mFileExtension, mNewFilePath + ">" + mFileExtension);
|
|
|
+ mNewFileName + ">" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + ":" + mFileExtension, mNewFilePath + ":" + mFileExtension);
|
|
|
+ mNewFileName + ":" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "\"" + mFileExtension, mNewFilePath + "\"" + mFileExtension);
|
|
|
+ mNewFileName + "\"" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "|" + mFileExtension, mNewFilePath + "|" + mFileExtension);
|
|
|
+ mNewFileName + "|" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "?" + mFileExtension, mNewFilePath + "?" + mFileExtension);
|
|
|
+ mNewFileName + "?" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
result = mActivity.renameFile(mOldFileName, mOldFilePath,
|
|
|
- mNewFileName + "*" + mFileExtension, mNewFilePath + "*" + mFileExtension);
|
|
|
+ mNewFileName + "*" + mFileExtension, false);
|
|
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
|
|
|
|
|
}
|
|
@@ -148,10 +137,10 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivit
|
|
|
* Restore initial conditions
|
|
|
*/
|
|
|
public void testRestoreInitialConditions() {
|
|
|
- RemoteOperationResult result = mActivity.renameFile(mNewFolderName, mNewFolderPath, mOldFolderName, mOldFolderPath);
|
|
|
+ RemoteOperationResult result = mActivity.renameFile(mNewFolderName, mNewFolderPath, mOldFolderName, true);
|
|
|
assertTrue(result.isSuccess());
|
|
|
|
|
|
- result = mActivity.renameFile(mNewFileName + mFileExtension, mNewFilePath + mFileExtension, mOldFileName, mOldFilePath);
|
|
|
+ result = mActivity.renameFile(mNewFileName + mFileExtension, mNewFilePath, mOldFileName, false);
|
|
|
assertTrue(result.isSuccess());
|
|
|
}
|
|
|
|