mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Let the setup() - testXXX() - tearDown() flow normally
This commit is contained in:
parent
fcf3bd2769
commit
a5a2b2890f
@ -30,8 +30,6 @@ 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.util.Log;
|
||||
|
||||
/**
|
||||
* Class to test Delete a File Operation
|
||||
* @author masensio
|
||||
@ -48,8 +46,6 @@ public class DeleteFileTest extends RemoteTest {
|
||||
/* File to delete. */
|
||||
private static final String FILE_PATH = "/fileToDelete.txt";
|
||||
|
||||
private static boolean mGlobalSetupDone = false;
|
||||
|
||||
private TestActivity mActivity;
|
||||
private String mFullPath2Folder;
|
||||
private String mFullPath2File;
|
||||
@ -62,26 +58,19 @@ public class DeleteFileTest extends RemoteTest {
|
||||
mFullPath2Folder = mBaseFolderPath + FOLDER_PATH;
|
||||
mFullPath2File = mBaseFolderPath + FILE_PATH;
|
||||
|
||||
if (!mGlobalSetupDone) {
|
||||
|
||||
Log.v(LOG_TAG, "Starting global set up");
|
||||
RemoteOperationResult result = mActivity.createFolder(mFullPath2Folder, true);
|
||||
if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME);
|
||||
result = mActivity.uploadFile(
|
||||
textFile.getAbsolutePath(),
|
||||
mFullPath2File,
|
||||
"txt/plain");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
Log.v(LOG_TAG, "Global set up done");
|
||||
mGlobalSetupDone = true;
|
||||
}
|
||||
RemoteOperationResult result = mActivity.createFolder(mFullPath2Folder, true);
|
||||
if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME);
|
||||
result = mActivity.uploadFile(
|
||||
textFile.getAbsolutePath(),
|
||||
mFullPath2File,
|
||||
"txt/plain");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,6 @@ 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.util.Log;
|
||||
|
||||
/**
|
||||
* Class to test Download File Operation
|
||||
* @author masensio
|
||||
@ -49,8 +47,6 @@ public class DownloadFileTest extends RemoteTest {
|
||||
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;
|
||||
@ -68,35 +64,29 @@ public class DownloadFileTest extends RemoteTest {
|
||||
mFullPath2ImageWitSpecialChars = mBaseFolderPath + IMAGE_PATH_WITH_SPECIAL_CHARS;
|
||||
mFullPath2ImageNotFound = mBaseFolderPath + IMAGE_NOT_FOUND;
|
||||
|
||||
if (!mGlobalSetupDone) {
|
||||
|
||||
File imageFile = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME);
|
||||
File imageFile = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME);
|
||||
|
||||
RemoteOperationResult result = mActivity.uploadFile(
|
||||
imageFile.getAbsolutePath(),
|
||||
mFullPath2Image,
|
||||
"image/png");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
result = mActivity.uploadFile(
|
||||
imageFile.getAbsolutePath(),
|
||||
mFullPath2ImageWitSpecialChars,
|
||||
"image/png");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
result = mActivity.removeFile(mFullPath2ImageNotFound);
|
||||
if (!result.isSuccess() && result.getCode() != ResultCode.FILE_NOT_FOUND) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
Log.v(LOG_TAG, "Global set up done");
|
||||
mGlobalSetupDone = true;
|
||||
}
|
||||
|
||||
RemoteOperationResult result = mActivity.uploadFile(
|
||||
imageFile.getAbsolutePath(),
|
||||
mFullPath2Image,
|
||||
"image/png");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
result = mActivity.uploadFile(
|
||||
imageFile.getAbsolutePath(),
|
||||
mFullPath2ImageWitSpecialChars,
|
||||
"image/png");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
result = mActivity.removeFile(mFullPath2ImageNotFound);
|
||||
if (!result.isSuccess() && result.getCode() != ResultCode.FILE_NOT_FOUND) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,8 +31,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.test_project.TestActivity;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Class to test Rename File Operation
|
||||
* @author masensio
|
||||
@ -56,8 +54,6 @@ public class RenameFileTest extends RemoteTest {
|
||||
private static final String NEW_FILE_PATH = FileUtils.PATH_SEPARATOR + NEW_FILE_NAME;
|
||||
|
||||
|
||||
private static boolean mGlobalSetupDone = false;
|
||||
|
||||
private String mToCleanUpInServer;
|
||||
private TestActivity mActivity;
|
||||
private String mFullPath2OldFolder;
|
||||
@ -74,28 +70,20 @@ public class RenameFileTest extends RemoteTest {
|
||||
mFullPath2NewFolder = mBaseFolderPath + NEW_FOLDER_PATH;
|
||||
mFullPath2OldFile = mBaseFolderPath + OLD_FILE_PATH;
|
||||
mFullPath2NewFile = mBaseFolderPath + NEW_FILE_PATH;
|
||||
|
||||
|
||||
if (!mGlobalSetupDone) {
|
||||
|
||||
Log.v(LOG_TAG, "Starting global set up");
|
||||
RemoteOperationResult result = mActivity.createFolder(mFullPath2OldFolder, true);
|
||||
if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
File imageFile = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME);
|
||||
result = mActivity.uploadFile(
|
||||
imageFile.getAbsolutePath(),
|
||||
mFullPath2OldFile,
|
||||
"image/png");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
Log.v(LOG_TAG, "Global set up done");
|
||||
mGlobalSetupDone = true;
|
||||
}
|
||||
RemoteOperationResult result = mActivity.createFolder(mFullPath2OldFolder, true);
|
||||
if (!result.isSuccess() && result.getCode() != ResultCode.TIMEOUT) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
File imageFile = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME);
|
||||
result = mActivity.uploadFile(
|
||||
imageFile.getAbsolutePath(),
|
||||
mFullPath2OldFile,
|
||||
"image/png");
|
||||
if (!result.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, result);
|
||||
}
|
||||
|
||||
mToCleanUpInServer = null;
|
||||
}
|
||||
@ -232,14 +220,12 @@ public class RenameFileTest extends RemoteTest {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
/*
|
||||
if (mToCleanUpInServer != null) {
|
||||
RemoteOperationResult removeResult = mActivity.removeFile(mToCleanUpInServer);
|
||||
if (!removeResult.isSuccess()) {
|
||||
Utils.logAndThrow(LOG_TAG, removeResult);
|
||||
}
|
||||
}
|
||||
*/
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user