From 846d90d44d94c5cd9e3e4dc4e92fa5ab91de4c2e Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 11 Dec 2013 09:35:57 +0100 Subject: [PATCH] OC-2328: Unit Tests for Download a file: New DownloadFileTest --- .../test/DownloadFileTest.java | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DownloadFileTest.java diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DownloadFileTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DownloadFileTest.java new file mode 100644 index 0000000000..f981f0b2cb --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DownloadFileTest.java @@ -0,0 +1,109 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package com.owncloud.android.oc_framework_test_project.test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.owncloud.android.oc_framework.operations.RemoteFile; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework_test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; + +/** + * Class to test Download File Operation + * @author masensio + * + */ + +public class DownloadFileTest extends ActivityInstrumentationTestCase2 { + + /* Files to download. This folder 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 String mCurrentDate; + + + private TestActivity mActivity; + + public DownloadFileTest() { + super(TestActivity.class); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); + mCurrentDate = sdf.format(new Date()); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Download a File + */ + public void testDownloadFile() { + String temporalFolder = "/download" + mCurrentDate; + + RemoteFile remoteFile= new RemoteFile(mRemoteFilePng); + + RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder); + assertTrue(result.isSuccess()); + } + + /** + * Test Download a File with chunks + */ + public void testDownloadFileChunks() { + String temporalFolder = "/download" + mCurrentDate; + + RemoteFile remoteFile= new RemoteFile(mRemoteFileChunks); + + RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder); + assertTrue(result.isSuccess()); + } + + /** + * Test Download a File with special chars + */ + public void testDownloadFileSpecialChars() { + String temporalFolder = "/download" + mCurrentDate; + + RemoteFile remoteFile= new RemoteFile(mRemoteFileSpecialChars); + + RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder); + assertTrue(result.isSuccess()); + } + + /** + * Test Download a File with special chars and chunks + */ + public void testDownloadFileSpecialCharsChunks() { + String temporalFolder = "/download" + mCurrentDate; + + RemoteFile remoteFile= new RemoteFile(mRemoteFileSpecialCharsChunks); + + RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder); + assertTrue(result.isSuccess()); + } +}