From b3e3eb74f0248a394ad35ef5123038a45981f15c Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 15 Apr 2014 13:48:01 +0200 Subject: [PATCH] Updated CreateFolderTest to work with an empty OC server --- .../test_project/test/CreateFolderTest.java | 81 +++++++++++++------ 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java index 325c8aea..30a5aa0f 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java @@ -24,7 +24,10 @@ package com.owncloud.android.lib.test_project.test; import java.text.SimpleDateFormat; +import java.util.ArrayList; 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.ResultCode; @@ -35,18 +38,26 @@ import android.test.ActivityInstrumentationTestCase2; /** * Class to test Create Folder Operation * @author masensio + * @author David A. Velasco * */ public class CreateFolderTest extends ActivityInstrumentationTestCase2 { + + private static final String LOG_TAG = CreateFolderTest.class.getCanonicalName(); + + private static final String FOLDER_PATH_BASE = "/testCreateFolder"; + private TestActivity mActivity; private String mCurrentDate; + private List mCreatedFolderPaths; public CreateFolderTest() { super(TestActivity.class); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); mCurrentDate = sdf.format(new Date()); + mCreatedFolderPaths = new ArrayList(); } @Override @@ -54,24 +65,22 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 : " | ? * */ public void testCreateFolderSpecialCharacters() { - boolean createFullPath = true; - String remotePath = "/testSpecialCharacters_\\" + mCurrentDate; - RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath); + String remotePath = FOLDER_PATH_BASE + "_\\" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + RemoteOperationResult result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_<" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_<" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_>" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_>" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_:" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_:" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_\"" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_\"" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_|" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_|" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_?" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_?" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = "/testSpecialCharacters_*" + mCurrentDate; - result = mActivity.createFolder(remotePath, createFullPath); + remotePath = FOLDER_PATH_BASE + "_*" + mCurrentDate; + mCreatedFolderPaths.add(remotePath); + result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); } + @Override + protected void tearDown() throws Exception { + Iterator it = mCreatedFolderPaths.iterator(); + RemoteOperationResult removeResult = null; + while (it.hasNext()) { + removeResult = mActivity.removeFile(it.next()); + if (!removeResult.isSuccess()) { + Utils.logAndThrow(LOG_TAG, removeResult); + } + } + super.tearDown(); + } + }