From 57173b175cfd4d55d5c29ece6b7a875b7a1f6b55 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 12 Nov 2014 18:18:04 +0100 Subject: [PATCH] REALLY use Travis build number to avoid parallel tests interfere each other --- test_client/tests/custom_rules.xml | 17 ++++ test_client/tests/res/values/setup.xml | 28 ++++++ .../test_project/test/CreateFolderTest.java | 37 ++++---- .../test_project/test/CreateShareTest.java | 23 ++--- .../lib/test_project/test/DeleteFileTest.java | 23 +++-- .../test_project/test/DownloadFileTest.java | 51 ++++++----- .../lib/test_project/test/GetSharesTest.java | 21 ++--- .../lib/test_project/test/MoveFileTest.java | 86 +++++++++---------- .../lib/test_project/test/ReadFileTest.java | 18 ++-- .../lib/test_project/test/ReadFolderTest.java | 20 ++--- .../lib/test_project/test/RemoteTest.java | 69 +++++++++++++++ .../test_project/test/RemoveShareTest.java | 20 ++--- .../lib/test_project/test/RenameFileTest.java | 75 ++++++++-------- .../lib/test_project/test/UploadFileTest.java | 29 +++---- .../android/lib/test_project/test/Utils.java | 8 +- 15 files changed, 306 insertions(+), 219 deletions(-) create mode 100644 test_client/tests/res/values/setup.xml create mode 100644 test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoteTest.java diff --git a/test_client/tests/custom_rules.xml b/test_client/tests/custom_rules.xml index c771dcd6..9b2ff335 100644 --- a/test_client/tests/custom_rules.xml +++ b/test_client/tests/custom_rules.xml @@ -1,5 +1,22 @@ + + + + + + + + + + + + + diff --git a/test_client/tests/res/values/setup.xml b/test_client/tests/res/values/setup.xml new file mode 100644 index 00000000..08bb772b --- /dev/null +++ b/test_client/tests/res/values/setup.xml @@ -0,0 +1,28 @@ + + + + + + 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 6c8871b3..a6c90b06 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 @@ -23,9 +23,7 @@ */ 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; @@ -33,52 +31,47 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.test_project.TestActivity; -import android.test.ActivityInstrumentationTestCase2; - /** * Class to test Create Folder Operation * @author masensio * @author David A. Velasco * */ -public class CreateFolderTest extends ActivityInstrumentationTestCase2 { +public class CreateFolderTest extends RemoteTest { private static final String LOG_TAG = CreateFolderTest.class.getCanonicalName(); - private static final String FOLDER_PATH_BASE = "/testCreateFolder" + Utils.getBuildNumber(); + private static final String FOLDER_PATH_BASE = "/testCreateFolder"; private TestActivity mActivity; - private String mCurrentDate; private List mCreatedFolderPaths; + private String mFullPath2FolderBase; public CreateFolderTest() { - super(TestActivity.class); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); - mCurrentDate = sdf.format(new Date()); + super(); mCreatedFolderPaths = new ArrayList(); } @Override protected void setUp() throws Exception { super.setUp(); - setActivityInitialTouchMode(false); mActivity = getActivity(); mCreatedFolderPaths.clear(); + mFullPath2FolderBase = mBaseFolderPath + FOLDER_PATH_BASE; } /** * Test Create Folder */ public void testCreateFolder() { - String remotePath = FOLDER_PATH_BASE + mCurrentDate; + String remotePath = mFullPath2FolderBase; mCreatedFolderPaths.add(remotePath); RemoteOperationResult result = mActivity.createFolder(remotePath, true); assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT); // Create Subfolder - remotePath = FOLDER_PATH_BASE + mCurrentDate + FOLDER_PATH_BASE + mCurrentDate; + remotePath = mFullPath2FolderBase + FOLDER_PATH_BASE; mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT); @@ -90,35 +83,35 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2" + mCurrentDate; + remotePath = mFullPath2FolderBase + "_>"; result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = FOLDER_PATH_BASE + "_:" + mCurrentDate; + remotePath = mFullPath2FolderBase + "_:"; result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = FOLDER_PATH_BASE + "_\"" + mCurrentDate; + remotePath = mFullPath2FolderBase + "_\""; result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = FOLDER_PATH_BASE + "_|" + mCurrentDate; + remotePath = mFullPath2FolderBase + "_|"; result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = FOLDER_PATH_BASE + "_?" + mCurrentDate; + remotePath = mFullPath2FolderBase + "_?"; result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - remotePath = FOLDER_PATH_BASE + "_*" + mCurrentDate; + remotePath = mFullPath2FolderBase + "_*"; result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); } diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java index 6e1ba11c..257e2ca5 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java @@ -31,32 +31,27 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.test_project.TestActivity; -import android.test.ActivityInstrumentationTestCase2; - -public class CreateShareTest extends ActivityInstrumentationTestCase2 { +public class CreateShareTest extends RemoteTest { private static final String LOG_TAG = CreateShareTest.class.getCanonicalName(); /* File to share.*/ - private static final String FILE_TO_SHARE = "/fileToShare" + Utils.getBuildNumber() + ".txt"; + private static final String FILE_TO_SHARE = "/fileToShare.txt"; private TestActivity mActivity; - - public CreateShareTest() { - super(TestActivity.class); - - } - + private String mFullPath2FileToShare; + @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(false); mActivity = getActivity(); - + mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; + File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); RemoteOperationResult result = mActivity.uploadFile( textFile.getAbsolutePath(), - FILE_TO_SHARE, + mFullPath2FileToShare, "txt/plain"); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); @@ -68,7 +63,7 @@ public class CreateShareTest extends ActivityInstrumentationTestCase2 { +public class DeleteFileTest extends RemoteTest { private static final String LOG_TAG = DeleteFileTest.class.getCanonicalName(); /* Folder data to delete. */ - private static final String FOLDER_PATH = "/folderToDelete" + Utils.getBuildNumber(); + private static final String FOLDER_PATH = "/folderToDelete"; /* File to delete. */ - private static final String FILE_PATH = "/fileToDelete" + Utils.getBuildNumber() + ".txt"; + private static final String FILE_PATH = "/fileToDelete.txt"; private static boolean mGlobalSetupDone = false; private TestActivity mActivity; - - public DeleteFileTest() { - super(TestActivity.class); - } + private String mFullPath2Folder; + private String mFullPath2File; @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(false); mActivity = getActivity(); + mFullPath2Folder = mBaseFolderPath + FOLDER_PATH; + mFullPath2File = mBaseFolderPath + FILE_PATH; if (!mGlobalSetupDone) { Log.v(LOG_TAG, "Starting global set up"); - RemoteOperationResult result = mActivity.createFolder(FOLDER_PATH, true); + RemoteOperationResult result = mActivity.createFolder(mFullPath2Folder, true); if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) { Utils.logAndThrow(LOG_TAG, result); } @@ -74,7 +73,7 @@ public class DeleteFileTest extends ActivityInstrumentationTestCase2 { +public class DownloadFileTest extends RemoteTest { private static final String LOG_TAG = DownloadFileTest.class.getCanonicalName(); /* Files to download. These files must exist on the account */ - private static final String IMAGE_PATH = "/fileToDownload" + Utils.getBuildNumber() + ".png"; - private static final String IMAGE_PATH_WITH_SPECIAL_CHARS = "/@file@download" + Utils.getBuildNumber() + ".png"; - private static final String IMAGE_NOT_FOUND = "/fileNotFound" + Utils.getBuildNumber() + ".png"; - private static final String [] FILE_PATHS = { IMAGE_PATH, IMAGE_PATH_WITH_SPECIAL_CHARS }; + private static final String IMAGE_PATH = "/fileToDownload.png"; + private static final String IMAGE_PATH_WITH_SPECIAL_CHARS = "/@file@download.png"; + private static final String IMAGE_NOT_FOUND = "/fileNotFound.png"; private static boolean mGlobalSetupDone = false; + private String mFullPath2Image; + private String mFullPath2ImageWitSpecialChars; + private String mFullPath2ImageNotFound; private String mDownloadedFilePath; private TestActivity mActivity; - public DownloadFileTest() { - super(TestActivity.class); - } - @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(false); mActivity = getActivity(); mDownloadedFilePath = null; + mFullPath2Image = mBaseFolderPath + IMAGE_PATH; + mFullPath2ImageWitSpecialChars = mBaseFolderPath + IMAGE_PATH_WITH_SPECIAL_CHARS; + mFullPath2ImageNotFound = mBaseFolderPath + IMAGE_NOT_FOUND; if (!mGlobalSetupDone) { - RemoteOperationResult result = null; File imageFile = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME); - for (int i=0; i { +public class GetSharesTest extends RemoteTest { private static final String LOG_TAG = GetSharesTest.class.getCanonicalName(); - private static final String SHARED_FILE = "/sharedFileToGet" + Utils.getBuildNumber() + ".txt"; + private static final String SHARED_FILE = "/sharedFileToGet.txt"; private TestActivity mActivity; + private String mFullPath2SharedFile; - public GetSharesTest() { - super(TestActivity.class); - - } - @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(false); mActivity = getActivity(); - + mFullPath2SharedFile = mBaseFolderPath + SHARED_FILE; + File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); RemoteOperationResult result = mActivity.uploadFile( textFile.getAbsolutePath(), - SHARED_FILE, + mFullPath2SharedFile, "txt/plain"); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } - result = mActivity.createShare(SHARED_FILE, ShareType.PUBLIC_LINK, "", false, "", 1); + result = mActivity.createShare(mFullPath2SharedFile, ShareType.PUBLIC_LINK, "", false, "", 1); if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) { Utils.logAndThrow(LOG_TAG, result); } @@ -87,7 +82,7 @@ public class GetSharesTest extends ActivityInstrumentationTestCase2 { +public class MoveFileTest extends RemoteTest { private static final String LOG_TAG = MoveFileTest.class.getCanonicalName(); /// Paths to files and folders in fixture - private static final String SRC_BASE_FOLDER = "/src" + Utils.getBuildNumber() + "/"; - private static final String TARGET_BASE_FOLDER = "/target" + Utils.getBuildNumber() + "/"; + private static final String SRC_BASE_FOLDER = "/src/"; + private static final String TARGET_BASE_FOLDER = "/target/"; private static final String NO_FILE = "nofile.txt"; private static final String FILE1 = "file1.txt"; private static final String FILE2 = "file2.txt"; @@ -209,7 +207,7 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 OwnCloudClient mClient = null; public MoveFileTest() { - super(TestActivity.class); + super(); Protocol pr = Protocol.getProtocol("https"); if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) { @@ -244,7 +242,7 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 RemoteOperationResult result = null; for (String folderPath : FOLDERS_IN_FIXTURE) { - result = TestActivity.createFolder(folderPath, true, mClient); + result = TestActivity.createFolder(mBaseFolderPath + folderPath, true, mClient); if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) { Utils.logAndThrow(LOG_TAG, result); } @@ -255,7 +253,7 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 ); for (String filePath : FILES_IN_FIXTURE) { result = TestActivity.uploadFile( - txtFile.getAbsolutePath(), filePath, "txt/plain", mClient + txtFile.getAbsolutePath(), mBaseFolderPath + filePath, "txt/plain", mClient ); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); @@ -277,8 +275,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move file MoveRemoteFileOperation moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_1, - TARGET_PATH_TO_FILE_1, + mBaseFolderPath + SRC_PATH_TO_FILE_1, + mBaseFolderPath + TARGET_PATH_TO_FILE_1, false ); RemoteOperationResult result = moveOperation.execute(mClient); @@ -286,8 +284,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move & rename file, different location moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_2, - TARGET_PATH_TO_FILE_2_RENAMED, + mBaseFolderPath + SRC_PATH_TO_FILE_2, + mBaseFolderPath + TARGET_PATH_TO_FILE_2_RENAMED, false ); result = moveOperation.execute(mClient); @@ -295,8 +293,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move & rename file, same location (rename file) moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_3, - SRC_PATH_TO_FILE_3_RENAMED, + mBaseFolderPath + SRC_PATH_TO_FILE_3, + mBaseFolderPath + SRC_PATH_TO_FILE_3_RENAMED, false ); result = moveOperation.execute(mClient); @@ -304,8 +302,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move empty folder moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_EMPTY_FOLDER, - TARGET_PATH_TO_EMPTY_FOLDER, + mBaseFolderPath + SRC_PATH_TO_EMPTY_FOLDER, + mBaseFolderPath + TARGET_PATH_TO_EMPTY_FOLDER, false ); result = moveOperation.execute(mClient); @@ -313,8 +311,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move non-empty folder moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FULL_FOLDER_1, - TARGET_PATH_TO_FULL_FOLDER_1, + mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_1, + mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_1, false ); result = moveOperation.execute(mClient); @@ -322,8 +320,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move & rename folder, different location moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FULL_FOLDER_2, - TARGET_PATH_TO_FULL_FOLDER_2_RENAMED, + mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_2, + mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_2_RENAMED, false ); result = moveOperation.execute(mClient); @@ -331,8 +329,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move & rename folder, same location (rename folder) moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FULL_FOLDER_3, - SRC_PATH_TO_FULL_FOLDER_3_RENAMED, + mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_3, + mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_3_RENAMED, false ); result = moveOperation.execute(mClient); @@ -340,8 +338,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move for nothing (success, but no interaction with network) moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_4, - SRC_PATH_TO_FILE_4, + mBaseFolderPath + SRC_PATH_TO_FILE_4, + mBaseFolderPath + SRC_PATH_TO_FILE_4, false ); result = moveOperation.execute(mClient); @@ -349,9 +347,9 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // move overwriting moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FULL_FOLDER_4, - TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, - true + mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_4, + mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, + true ); result = moveOperation.execute(mClient); assertTrue(result.isSuccess()); @@ -361,45 +359,45 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 // file to move does not exist moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_NON_EXISTENT_FILE, - TARGET_PATH_TO_NON_EXISTENT_FILE, - false + mBaseFolderPath + SRC_PATH_TO_NON_EXISTENT_FILE, + mBaseFolderPath + TARGET_PATH_TO_NON_EXISTENT_FILE, + false ); result = moveOperation.execute(mClient); assertTrue(result.getCode() == ResultCode.FILE_NOT_FOUND); // folder to move into does no exist moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_5, - TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER, - false + mBaseFolderPath + SRC_PATH_TO_FILE_5, + mBaseFolderPath + TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER, + false ); result = moveOperation.execute(mClient); assertTrue(result.getHttpCode() == HttpStatus.SC_CONFLICT); // target location (renaming) has invalid characters moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_6, - TARGET_PATH_RENAMED_WITH_INVALID_CHARS, - false + mBaseFolderPath + SRC_PATH_TO_FILE_6, + mBaseFolderPath + TARGET_PATH_RENAMED_WITH_INVALID_CHARS, + false ); result = moveOperation.execute(mClient); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); // name collision moveOperation = new MoveRemoteFileOperation( - SRC_PATH_TO_FILE_7, - TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7, - false + mBaseFolderPath + SRC_PATH_TO_FILE_7, + mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7, + false ); result = moveOperation.execute(mClient); assertTrue(result.getCode() == ResultCode.INVALID_OVERWRITE); // move a folder into a descendant moveOperation = new MoveRemoteFileOperation( - SRC_BASE_FOLDER, - SRC_PATH_TO_EMPTY_FOLDER, - false + mBaseFolderPath + SRC_BASE_FOLDER, + mBaseFolderPath + SRC_PATH_TO_EMPTY_FOLDER, + false ); result = moveOperation.execute(mClient); assertTrue(result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT); @@ -411,8 +409,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2 Log.v(LOG_TAG, "Deleting remote fixture..."); String[] mPathsToCleanUp = { - SRC_BASE_FOLDER, - TARGET_BASE_FOLDER + mBaseFolderPath + SRC_BASE_FOLDER, + mBaseFolderPath + TARGET_BASE_FOLDER }; for (String path : mPathsToCleanUp) { diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java index 93dacd92..ec828f2c 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java @@ -29,25 +29,20 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.test_project.TestActivity; -import android.test.ActivityInstrumentationTestCase2; - /** * Class to test Read File Operation * @author masensio * @author David A. Velasco */ -public class ReadFileTest extends ActivityInstrumentationTestCase2 { +public class ReadFileTest extends RemoteTest { private static final String LOG_TAG = ReadFileTest.class.getCanonicalName(); private TestActivity mActivity; - private String FILE_PATH = "/fileToRead" + Utils.getBuildNumber() + ".txt"; - - public ReadFileTest() { - super(TestActivity.class); - } + private String FILE_PATH = "/fileToRead.txt"; + private String mFullPath2File; @Override protected void setUp() throws Exception { @@ -55,11 +50,12 @@ public class ReadFileTest extends ActivityInstrumentationTestCase2 { +public class ReadFolderTest extends RemoteTest { private static final String LOG_TAG = ReadFolderTest.class.getCanonicalName(); - private static final String FOLDER_PATH = "/folderToRead" + Utils.getBuildNumber(); + private static final String FOLDER_PATH = "/folderToRead"; private static final String [] FILE_PATHS = { FOLDER_PATH + "/file1.txt", FOLDER_PATH + "/file2.txt", @@ -51,24 +49,22 @@ public class ReadFolderTest extends ActivityInstrumentationTestCase2 1); assertTrue(result.getData().size() == 4); @@ -94,7 +90,7 @@ public class ReadFolderTest extends ActivityInstrumentationTestCase2 { + + private static final String LOG_TAG = RemoteTest.class.getSimpleName(); + + protected String mBaseFolderPath = "/test_for_build_"; + + public RemoteTest() { + super(TestActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mBaseFolderPath += Utils.getBuildNumber(getActivity()); + + RemoteOperationResult result = getActivity().createFolder(mBaseFolderPath, true); + if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) { + Utils.logAndThrow(LOG_TAG, result); + } + } + + + @Override + protected void tearDown() throws Exception { + RemoteOperationResult removeResult = getActivity().removeFile(mBaseFolderPath); + if (!removeResult.isSuccess() && removeResult.getCode() != ResultCode.TIMEOUT) { + Utils.logAndThrow(LOG_TAG, removeResult); + } + super.tearDown(); + } + +} diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java index 2ea83a15..b9e8d6dd 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java @@ -32,39 +32,35 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.test_project.TestActivity; -import android.test.ActivityInstrumentationTestCase2; - -public class RemoveShareTest extends ActivityInstrumentationTestCase2 { +public class RemoveShareTest extends RemoteTest { private static final String LOG_TAG = RemoveShareTest.class.getCanonicalName(); - private static final String FILE_TO_UNSHARE = "/fileToUnshare" + Utils.getBuildNumber() + ".txt"; + private static final String FILE_TO_UNSHARE = "/fileToUnshare.txt"; private TestActivity mActivity; + + private String mFullPath2FileToUnshare; private long mShareId; - public RemoveShareTest() { - super(TestActivity.class); - - } - @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(false); mActivity = getActivity(); + mFullPath2FileToUnshare = mBaseFolderPath + FILE_TO_UNSHARE; File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); RemoteOperationResult result = mActivity.uploadFile( textFile.getAbsolutePath(), - FILE_TO_UNSHARE, + mFullPath2FileToUnshare, "txt/plain"); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } - result = mActivity.createShare(FILE_TO_UNSHARE, ShareType.PUBLIC_LINK, "", false, "", 1); + result = mActivity.createShare(mFullPath2FileToUnshare, ShareType.PUBLIC_LINK, "", false, "", 1); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } else { @@ -85,7 +81,7 @@ public class RemoveShareTest extends ActivityInstrumentationTestCase2 { +public class RenameFileTest extends RemoteTest { private static final String LOG_TAG = RenameFileTest.class.getCanonicalName(); /* Folder data to rename. This folder must exist on the account */ - private static final String OLD_FOLDER_NAME = "folderToRename" + Utils.getBuildNumber(); + private static final String OLD_FOLDER_NAME = "folderToRename"; private static final String OLD_FOLDER_PATH = FileUtils.PATH_SEPARATOR + OLD_FOLDER_NAME; - private static final String NEW_FOLDER_NAME = "renamedFolder" + Utils.getBuildNumber(); + private static final String NEW_FOLDER_NAME = "renamedFolder"; private static final String NEW_FOLDER_PATH = FileUtils.PATH_SEPARATOR + NEW_FOLDER_NAME; /* File data to rename. This file must exist on the account */ - private static final String OLD_FILE_NAME = "fileToRename" + Utils.getBuildNumber() + ".png"; + private static final String OLD_FILE_NAME = "fileToRename.png"; private static final String OLD_FILE_PATH = FileUtils.PATH_SEPARATOR + OLD_FILE_NAME; - private static final String NEW_FILE_NAME = "renamedFile" + Utils.getBuildNumber() + ".png"; + private static final String NEW_FILE_NAME = "renamedFile.png"; private static final String NEW_FILE_PATH = FileUtils.PATH_SEPARATOR + NEW_FILE_NAME; @@ -61,22 +60,26 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + ":", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "\"", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "|", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "?", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "*", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); } @@ -154,14 +157,14 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2" + NEW_FILE_NAME, false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); result = mActivity.renameFile( OLD_FILE_NAME, - OLD_FILE_PATH, + mFullPath2OldFile, ":" + NEW_FILE_NAME, false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); result = mActivity.renameFile( OLD_FILE_NAME, - OLD_FILE_PATH, + mFullPath2OldFile, "\"" + NEW_FILE_NAME, false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); result = mActivity.renameFile( OLD_FILE_NAME, - OLD_FILE_PATH, + mFullPath2OldFile, "|" + NEW_FILE_NAME, false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); result = mActivity.renameFile( OLD_FILE_NAME, - OLD_FILE_PATH, + mFullPath2OldFile, "?" + NEW_FILE_NAME, false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); result = mActivity.renameFile( OLD_FILE_NAME, - OLD_FILE_PATH, + mFullPath2OldFile, "*" + NEW_FILE_NAME, false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java index 8330e208..08cf686f 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java @@ -26,8 +26,6 @@ package com.owncloud.android.lib.test_project.test; import java.io.File; -import android.test.ActivityInstrumentationTestCase2; - import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.test_project.TestActivity; @@ -39,15 +37,15 @@ import com.owncloud.android.lib.test_project.TestActivity; * */ -public class UploadFileTest extends ActivityInstrumentationTestCase2 { +public class UploadFileTest extends RemoteTest { private static final String LOG_TAG = UploadFileTest.class.getCanonicalName(); - private static final String UPLOAD_PATH = "/uploadedImage" + Utils.getBuildNumber() + ".png"; + private static final String UPLOAD_PATH = "/uploadedImage.png"; - private static final String CHUNKED_UPLOAD_PATH = "/uploadedVideo" + Utils.getBuildNumber() + ".MP4"; + private static final String CHUNKED_UPLOAD_PATH = "/uploadedVideo.MP4"; - private static final String FILE_NOT_FOUND_PATH = "/notFoundShouldNotBeHere" + Utils.getBuildNumber() + ".png"; + private static final String FILE_NOT_FOUND_PATH = "/notFoundShouldNotBeHere.png"; private TestActivity mActivity; @@ -55,10 +53,6 @@ public class UploadFileTest extends ActivityInstrumentationTestCase2