mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
OC-2328: Unit Tests for Download a file: New DownloadFileTest
This commit is contained in:
parent
3ca4607629
commit
846d90d44d
1 changed files with 109 additions and 0 deletions
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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<TestActivity> {
|
||||
|
||||
/* 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());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue