1
0
mirror of https://github.com/owncloud/android-library.git synced 2026-08-11 16:33:03 +00:00

Updated layout of test projects

This commit is contained in:
David A. Velasco
2014-04-08 13:29:27 +02:00
parent bda94d02aa
commit 7f8da4cce6
47 changed files with 210 additions and 16 deletions
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/ownCloud Android library test project"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ownCloud Android library test cases</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ownCloud Android Library is available under MIT license
Copyright (C) 2014 ownCloud Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.owncloud.android.lib.test_project.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:label="Tests for com.owncloud.android.lib.test_project"
android:targetPackage="com.owncloud.android.lib.test_project" />
</manifest>
+18
View File
@@ -0,0 +1,18 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
tested.project.dir=..
+92
View File
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ownCloud Android library test cases" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
+14
View File
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ownCloud Android Library is available under MIT license
Copyright (C) 2014 ownCloud Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<resources>
<string name="app_name">Oc_framework-testTest</string>
</resources>
@@ -0,0 +1,119 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import java.text.SimpleDateFormat;
import java.util.Date;
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;
/**
* Class to test Create Folder Operation
* @author masensio
*
*/
public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
private TestActivity mActivity;
private String mCurrentDate;
public CreateFolderTest() {
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 Create Folder
*/
public void testCreateFolder() {
String remotePath = "/testCreateFolder" + mCurrentDate;
boolean createFullPath = true;
RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
// Create Subfolder
remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
createFullPath = true;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
}
/**
* Test to Create Folder with special characters: / \ < > : " | ? *
*/
public void testCreateFolderSpecialCharacters() {
boolean createFullPath = true;
String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_<" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_>" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_:" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_|" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_?" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
remotePath = "/testSpecialCharacters_*" + mCurrentDate;
result = mActivity.createFolder(remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
}
}
@@ -0,0 +1,59 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2;
public class CreateShareTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* File to share.*/
private final String mFileToShare = "/fileToShare.png";
private TestActivity mActivity;
public CreateShareTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Create Share: the server must support SHARE API
*/
public void testCreateShare() {
RemoteOperationResult result = mActivity.createShare(mFileToShare, ShareType.PUBLIC_LINK, "", false, "", 1);
assertTrue(result.isSuccess());
}
}
@@ -0,0 +1,87 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
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;
/**
* Class to test Delete a File Operation
* @author masensio
*
*/
public class DeleteFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* Folder data to delete. */
private final String mFolderPath = "/folderToDelete";
/* File to delete. */
private final String mFilePath = "fileToDelete.png";
private TestActivity mActivity;
public DeleteFileTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Remove Folder
*/
public void testRemoveFolder() {
RemoteOperationResult result = mActivity.removeFile(mFolderPath);
assertTrue(result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND);
}
/**
* Test Remove File
*/
public void testRemoveFile() {
RemoteOperationResult result = mActivity.removeFile(mFilePath);
assertTrue(result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND);
}
/**
* Restore initial conditions
*/
public void testRestoreInitialConditions() {
RemoteOperationResult result = mActivity.createFolder(mFolderPath, true);
assertTrue(result.isSuccess());
}
}
@@ -0,0 +1,132 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2;
/**
* Class to test Download File Operation
* @author masensio
*
*/
public class DownloadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* 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 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());
}
/**
* Test Download a Not Found File
*/
public void testDownloadFileNotFound() {
String temporalFolder = "/download" + mCurrentDate;
RemoteFile remoteFile = new RemoteFile(mRemoteFileNotFound);
RemoteOperationResult result = mActivity.downloadFile(remoteFile, temporalFolder);
assertFalse(result.isSuccess());
}
}
@@ -0,0 +1,62 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2;
/**
* Class to test Get Shares Operation
*
* @author masensio
*
*/
public class GetSharesTest extends ActivityInstrumentationTestCase2<TestActivity> {
private TestActivity mActivity;
public GetSharesTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Get Shares: the server must support SHARE API
*/
public void testGetShares() {
RemoteOperationResult result = mActivity.getShares();
assertTrue(result.isSuccess());
}
}
@@ -0,0 +1,67 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2;
/**
* Class to test Read File Operation
* @author masensio
*
*/
public class ReadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* File data to read. This file must exist on the account */
private final String mRemoteFolderPath = "/fileToRead.txt";
private TestActivity mActivity;
public ReadFileTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Read File
*/
public void testReadFile() {
RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
assertTrue(result.getData().size() == 1);
assertTrue(result.isSuccess());
}
}
@@ -0,0 +1,69 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2;
/**
* Class to test Read Folder Operation
* @author masensio
*
*/
public class ReadFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* Folder data to read. This folder must exist on the account */
private final String mRemoteFolderPath = "/folderToRead";
private TestActivity mActivity;
public ReadFolderTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Read Folder
*/
public void testReadFolder() {
RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
assertTrue(result.getData().size() > 1);
assertTrue(result.getData().size() == 4);
assertTrue(result.isSuccess());
}
}
@@ -0,0 +1,74 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.test_project.TestActivity;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
public class RemoveShareTest extends ActivityInstrumentationTestCase2<TestActivity> {
private static final String TAG = RemoveShareTest.class.getSimpleName();
private TestActivity mActivity;
public RemoveShareTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Remove Share: the server must support SHARE API
*/
public void testRemoveShare() {
// Get the shares
RemoteOperationResult result = mActivity.getShares();
if (result.isSuccess()) {
int size = result.getData().size();
if (size > 0) {
OCShare share = ((OCShare) result.getData().get(size -1));
long id = share.getIdRemoteShared();
Log.d(TAG, "File to unshare: " + share.getPath() );
result = mActivity.removeShare((int) id); // Unshare
assertTrue(result.isSuccess());
} else {
assertTrue(true);
}
} else {
assertTrue(true);
}
}
}
@@ -0,0 +1,177 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
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;
/**
* Class to test Rename File Operation
* @author masensio
*
*/
public class RenameFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* Folder data to rename. This folder must exist on the account */
private final String mOldFolderName = "folderToRename";
private final String mOldFolderPath = "/folderToRename";
private final String mNewFolderName = "renamedFolder";
private final String mNewFolderPath = "/renamedFolder";
/* File data to rename. This file must exist on the account */
private final String mOldFileName = "fileToRename.png";
private final String mOldFilePath = "/fileToRename.png";
private final String mNewFileName = "renamedFile";
private final String mFileExtension = ".png";
private final String mNewFilePath ="/renamedFile.png";
private TestActivity mActivity;
public RenameFileTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
}
/**
* Test Rename Folder
*/
public void testRenameFolder() {
RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName, true);
assertTrue(result.isSuccess());
}
/**
* Test Rename Folder with forbidden characters : \ < > : " | ? *
*/
public void testRenameFolderForbiddenChars() {
RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + "\\", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + "<", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + ">", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + ":", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + "\"", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + "|", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + "?", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFolderName, mOldFolderPath,
mNewFolderName + "*", true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
}
/**
* Test Rename File
*/
public void testRenameFile() {
RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + mFileExtension, false);
assertTrue(result.isSuccess());
}
/**
* Test Rename Folder with forbidden characters: \ < > : " | ? *
*/
public void testRenameFileForbiddenChars() {
RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + "\\" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + "<" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + ">" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + ":" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + "\"" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + "|" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + "?" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
result = mActivity.renameFile(mOldFileName, mOldFilePath,
mNewFileName + "*" + mFileExtension, false);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
}
/**
* Restore initial conditions
*/
public void testRestoreInitialConditions() {
RemoteOperationResult result = mActivity.renameFile(mNewFolderName, mNewFolderPath, mOldFolderName, true);
assertTrue(result.isSuccess());
result = mActivity.renameFile(mNewFileName + mFileExtension, mNewFilePath, mOldFileName, false);
assertTrue(result.isSuccess());
}
}
@@ -0,0 +1,168 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2014 ownCloud Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.test_project.test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.res.AssetManager;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.test_project.TestActivity;
/**
* Class to test Update File Operation
* @author masensio
*
*/
public class UploadFileTest extends ActivityInstrumentationTestCase2<TestActivity> {
/* Files to upload. These files must exists on the device */
private final String mFileToUpload = "fileToUpload.png";
private final String mMimeType = "image/png";
private final String mFileToUploadWithChunks = "fileToUploadChunks.MP4";
private final String mMimeTypeWithChunks = "video/mp4";
private final String mFileNotFound = "fileNotFound.png";
private final String mStoragePath = "/owncloud/tmp/uploadTest";
private String mPath;
private String mCurrentDate;
private TestActivity mActivity;
public UploadFileTest() {
super(TestActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(false);
mActivity = getActivity();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
mCurrentDate = sdf.format(new Date());
File sdCard = Environment.getExternalStorageDirectory();
mPath = sdCard.getAbsolutePath() + "/" + mStoragePath + mCurrentDate;
//mActivity.createFolder(mPath, true);
copyAssets();
}
/**
* Copy Files to ulpload to SdCard
*/
private void copyAssets() {
AssetManager assetManager = getActivity().getAssets();
String[] files = { mFileToUpload, mFileToUploadWithChunks };
// Folder with contents
File folder = new File(mPath);
folder.mkdirs();
for(String filename : files) {
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open(filename);
File outFile = new File(folder, filename);
out = new FileOutputStream(outFile);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(IOException e) {
Log.e("tag", "Failed to copy asset file: " + filename, e);
}
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
}
/**
* Test Upload File without chunks
*/
public void testUploadFile() {
String storagePath = mPath + "/" + mFileToUpload;
//String remotePath = "/uploadTest" + mCurrentDate + "/" + mFileToUpload;
String remotePath = "/" + mFileToUpload;
RemoteOperationResult result = mActivity.uploadFile(storagePath, remotePath, mMimeType);
assertTrue(result.isSuccess());
}
/**
* Test Upload File with chunks
*/
public void testUploadFileWithChunks() {
String storagePath = mPath + "/" + mFileToUploadWithChunks;
//String remotePath = "/uploadTest" + mCurrentDate + "/" +mFileToUploadWithChunks;
String remotePath = "/" + mFileToUploadWithChunks;
RemoteOperationResult result = mActivity.uploadFile(storagePath, remotePath, mMimeTypeWithChunks);
assertTrue(result.isSuccess());
}
/**
* Test Upload Not Found File
*/
public void testUploadFileNotFound() {
String storagePath = mPath + "/" + mFileNotFound;
//String remotePath = "/uploadTest" + mCurrentDate + "/" + mFileToUpload;
String remotePath = "/" + mFileNotFound;
RemoteOperationResult result = mActivity.uploadFile(storagePath, remotePath, mMimeType);
assertFalse(result.isSuccess());
}
}