f981f0b2cb07d3df9c91b64790cc4876d91511a4
[pub/Android/ownCloud.git] /
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 */
17
18 package com.owncloud.android.oc_framework_test_project.test;
19
20 import java.text.SimpleDateFormat;
21 import java.util.Date;
22
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;
26
27 import android.test.ActivityInstrumentationTestCase2;
28
29 /**
30 * Class to test Download File Operation
31 * @author masensio
32 *
33 */
34
35 public class DownloadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
36
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";
42
43 private String mCurrentDate;
44
45
46 private TestActivity mActivity;
47
48 public DownloadFileTest() {
49 super(TestActivity.class);
50
51 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
52 mCurrentDate = sdf.format(new Date());
53 }
54
55 @Override
56 protected void setUp() throws Exception {
57 super.setUp();
58 setActivityInitialTouchMode(false);
59 mActivity = getActivity();
60 }
61
62 /**
63 * Test Download a File
64 */
65 public void testDownloadFile() {
66 String temporalFolder = "/download" + mCurrentDate;
67
68 RemoteFile remoteFile= new RemoteFile(mRemoteFilePng);
69
70 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
71 assertTrue(result.isSuccess());
72 }
73
74 /**
75 * Test Download a File with chunks
76 */
77 public void testDownloadFileChunks() {
78 String temporalFolder = "/download" + mCurrentDate;
79
80 RemoteFile remoteFile= new RemoteFile(mRemoteFileChunks);
81
82 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
83 assertTrue(result.isSuccess());
84 }
85
86 /**
87 * Test Download a File with special chars
88 */
89 public void testDownloadFileSpecialChars() {
90 String temporalFolder = "/download" + mCurrentDate;
91
92 RemoteFile remoteFile= new RemoteFile(mRemoteFileSpecialChars);
93
94 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
95 assertTrue(result.isSuccess());
96 }
97
98 /**
99 * Test Download a File with special chars and chunks
100 */
101 public void testDownloadFileSpecialCharsChunks() {
102 String temporalFolder = "/download" + mCurrentDate;
103
104 RemoteFile remoteFile= new RemoteFile(mRemoteFileSpecialCharsChunks);
105
106 RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
107 assertTrue(result.isSuccess());
108 }
109 }