1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com.owncloud.android.oc_framework_test_project.test;
20 import java.text.SimpleDateFormat;
21 import java.util.Date;
23 import com.owncloud.android.oc_framework.operations.RemoteFile;
24 import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
25 import com.owncloud.android.oc_framework_test_project.TestActivity;
27 import android.test.ActivityInstrumentationTestCase2;
30 * Class to test Download File Operation
35 public class DownloadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
37 /* Files to download. This folder must exist on the account */
38 private final String mRemoteFilePng = "/fileToDownload.png";
39 private final String mRemoteFileChunks = "/fileToDownload.mp4";
40 private final String mRemoteFileSpecialChars = "/@file@download.png";
41 private final String mRemoteFileSpecialCharsChunks = "/@file@download.mp4";
43 private String mCurrentDate;
46 private TestActivity mActivity;
48 public DownloadFileTest() {
49 super(TestActivity.class);
51 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
52 mCurrentDate = sdf.format(new Date());
56 protected void setUp() throws Exception {
58 setActivityInitialTouchMode(false);
59 mActivity = getActivity();
63 * Test Download a File
65 public void testDownloadFile() {
66 String temporalFolder = "/download" + mCurrentDate;
68 RemoteFile remoteFile= new RemoteFile(mRemoteFilePng);
70 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
71 assertTrue(result.isSuccess());
75 * Test Download a File with chunks
77 public void testDownloadFileChunks() {
78 String temporalFolder = "/download" + mCurrentDate;
80 RemoteFile remoteFile= new RemoteFile(mRemoteFileChunks);
82 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
83 assertTrue(result.isSuccess());
87 * Test Download a File with special chars
89 public void testDownloadFileSpecialChars() {
90 String temporalFolder = "/download" + mCurrentDate;
92 RemoteFile remoteFile= new RemoteFile(mRemoteFileSpecialChars);
94 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
95 assertTrue(result.isSuccess());
99 * Test Download a File with special chars and chunks
101 public void testDownloadFileSpecialCharsChunks() {
102 String temporalFolder = "/download" + mCurrentDate;
104 RemoteFile remoteFile= new RemoteFile(mRemoteFileSpecialCharsChunks);
106 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
107 assertTrue(result.isSuccess());