diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java index 33ed878b..a63f191e 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java @@ -24,41 +24,45 @@ package com.owncloud.android.lib.test_project.test; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import com.owncloud.android.lib.resources.files.RemoteFile; 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; +import android.util.Log; /** * Class to test Download File Operation * @author masensio - * + * @author David A. Velasco */ public class DownloadFileTest extends ActivityInstrumentationTestCase2 { + private static final String LOG_TAG = DownloadFileTest.class.getCanonicalName(); + /* Files to download. These files must exist on the account */ - private final String mRemoteFilePng = "/fileToDownload.png"; - private final String mRemoteFileChunks = "/fileToDownload.mp4"; - private final String mRemoteFileSpecialChars = "/@file@download.png"; - private final String mRemoteFileSpecialCharsChunks = "/@file@download.mp4"; - private final String mRemoteFileNotFound = "/fileNotFound.png"; /* This file mustn't exist on the account */ - - private String mCurrentDate; + 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 final String [] FILE_PATHS = { IMAGE_PATH, IMAGE_PATH_WITH_SPECIAL_CHARS }; + private static boolean mGlobalSetupDone = false; + private List mDownloadedFilesPaths; private TestActivity mActivity; + public DownloadFileTest() { super(TestActivity.class); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); - mCurrentDate = sdf.format(new Date()); + mDownloadedFilesPaths = new ArrayList(); } @Override @@ -66,67 +70,88 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2 it = mDownloadedFilesPaths.iterator(); + RemoteOperationResult removeResult = null; + while (it.hasNext()) { + removeResult = mActivity.removeFile(it.next()); + if (!removeResult.isSuccess()) { + Utils.logAndThrow(LOG_TAG, removeResult); + } + } + File[] files = mActivity.getFilesDir().listFiles(); + for (File file : files) { + file.delete(); + } + super.tearDown(); + } + + }