mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Updated CreateFolderTest to work with an empty OC server
This commit is contained in:
parent
596c793243
commit
b3e3eb74f0
@ -24,7 +24,10 @@
|
|||||||
package com.owncloud.android.lib.test_project.test;
|
package com.owncloud.android.lib.test_project.test;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||||
@ -35,18 +38,26 @@ import android.test.ActivityInstrumentationTestCase2;
|
|||||||
/**
|
/**
|
||||||
* Class to test Create Folder Operation
|
* Class to test Create Folder Operation
|
||||||
* @author masensio
|
* @author masensio
|
||||||
|
* @author David A. Velasco
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
|
||||||
|
|
||||||
|
|
||||||
|
private static final String LOG_TAG = CreateFolderTest.class.getCanonicalName();
|
||||||
|
|
||||||
|
private static final String FOLDER_PATH_BASE = "/testCreateFolder";
|
||||||
|
|
||||||
private TestActivity mActivity;
|
private TestActivity mActivity;
|
||||||
private String mCurrentDate;
|
private String mCurrentDate;
|
||||||
|
private List<String> mCreatedFolderPaths;
|
||||||
|
|
||||||
public CreateFolderTest() {
|
public CreateFolderTest() {
|
||||||
super(TestActivity.class);
|
super(TestActivity.class);
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||||
mCurrentDate = sdf.format(new Date());
|
mCurrentDate = sdf.format(new Date());
|
||||||
|
mCreatedFolderPaths = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,24 +65,22 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActiv
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
setActivityInitialTouchMode(false);
|
setActivityInitialTouchMode(false);
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
|
mCreatedFolderPaths.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Create Folder
|
* Test Create Folder
|
||||||
*/
|
*/
|
||||||
public void testCreateFolder() {
|
public void testCreateFolder() {
|
||||||
|
String remotePath = FOLDER_PATH_BASE + mCurrentDate;
|
||||||
String remotePath = "/testCreateFolder" + mCurrentDate;
|
mCreatedFolderPaths.add(remotePath);
|
||||||
boolean createFullPath = true;
|
RemoteOperationResult result = mActivity.createFolder(remotePath, true);
|
||||||
|
|
||||||
RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
|
|
||||||
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
|
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
|
||||||
|
|
||||||
// Create Subfolder
|
// Create Subfolder
|
||||||
remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + mCurrentDate + FOLDER_PATH_BASE + mCurrentDate;
|
||||||
createFullPath = true;
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
|
||||||
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
|
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,40 +89,60 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActiv
|
|||||||
* Test to Create Folder with special characters: / \ < > : " | ? *
|
* Test to Create Folder with special characters: / \ < > : " | ? *
|
||||||
*/
|
*/
|
||||||
public void testCreateFolderSpecialCharacters() {
|
public void testCreateFolderSpecialCharacters() {
|
||||||
boolean createFullPath = true;
|
|
||||||
|
|
||||||
String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
|
String remotePath = FOLDER_PATH_BASE + "_\\" + mCurrentDate;
|
||||||
RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
RemoteOperationResult result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_<" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_<" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_>" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_>" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_:" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_:" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_\"" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_|" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_|" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_?" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_?" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
|
|
||||||
remotePath = "/testSpecialCharacters_*" + mCurrentDate;
|
remotePath = FOLDER_PATH_BASE + "_*" + mCurrentDate;
|
||||||
result = mActivity.createFolder(remotePath, createFullPath);
|
mCreatedFolderPaths.add(remotePath);
|
||||||
|
result = mActivity.createFolder(remotePath, true);
|
||||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
Iterator<String> it = mCreatedFolderPaths.iterator();
|
||||||
|
RemoteOperationResult removeResult = null;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
removeResult = mActivity.removeFile(it.next());
|
||||||
|
if (!removeResult.isSuccess()) {
|
||||||
|
Utils.logAndThrow(LOG_TAG, removeResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user