Updated layout of test projects
@@ -0,0 +1,9 @@
|
||||
<?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 kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ownCloud Android library test project</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>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.owncloud.android.lib.test_project.TestActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="ownCloud Android library test client" 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>
|
||||
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,15 @@
|
||||
# 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
|
||||
android.library.reference.1=..
|
||||
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,39 @@
|
||||
<!-- 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.
|
||||
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".TestActivity" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello_world" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,32 @@
|
||||
<!-- 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.
|
||||
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
||||
@@ -0,0 +1,32 @@
|
||||
<!-- 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>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw600dp devices (e.g. 7" tablets) here.
|
||||
-->
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,33 @@
|
||||
<!-- 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>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">128dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<!-- 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>
|
||||
|
||||
<!--
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<!-- 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>
|
||||
|
||||
<!--
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,30 @@
|
||||
<!-- 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>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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="server_base_url"></string> <!-- the server url, without webdav path -->
|
||||
<string name="webdav_path">/remote.php/webdav</string> <!-- default value for webdav path (owncloud version > = 4)-->
|
||||
<string name="username"></string>
|
||||
<string name="password"></string>
|
||||
<bool name="chunked">true</bool>
|
||||
</resources>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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-test-project</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="test_account_not_found">The test account %1$s could not be found in the device</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!-- 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>
|
||||
|
||||
<!--
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,251 @@
|
||||
/* 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;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.ChunkedUploadRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.RenameRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation;
|
||||
import com.owncloud.android.lib.resources.shares.GetRemoteSharesOperation;
|
||||
import com.owncloud.android.lib.resources.shares.RemoveRemoteShareOperation;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.test_project.R;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
|
||||
/**
|
||||
* Activity to test OC framework
|
||||
* @author masensio
|
||||
* @author David A. Velasco
|
||||
*/
|
||||
|
||||
public class TestActivity extends Activity {
|
||||
|
||||
// This account must exists on the server side
|
||||
private String mServerUri;
|
||||
private String mWebdavPath;
|
||||
private String mUser;
|
||||
private String mPass;
|
||||
private boolean mChunked;
|
||||
|
||||
//private Account mAccount = null;
|
||||
private OwnCloudClient mClient;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_test);
|
||||
|
||||
mServerUri = getString(R.string.server_base_url);
|
||||
mWebdavPath = getString(R.string.webdav_path);
|
||||
mUser = getString(R.string.username);
|
||||
mPass = getString(R.string.password);
|
||||
mChunked = getResources().getBoolean(R.bool.chunked);
|
||||
|
||||
Uri uri = Uri.parse(mServerUri + mWebdavPath);
|
||||
mClient = OwnCloudClientFactory.createOwnCloudClient(uri ,getApplicationContext(), true);
|
||||
mClient.setBasicCredentials(mUser, mPass);
|
||||
mClient.setBaseUri(Uri.parse(mServerUri));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.test, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Create a Folder
|
||||
* @param remotePath Full path to the new directory to create in the remote server.
|
||||
* @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult createFolder(String remotePath, boolean createFullPath) {
|
||||
|
||||
CreateRemoteFolderOperation createOperation = new CreateRemoteFolderOperation(remotePath, createFullPath);
|
||||
RemoteOperationResult result = createOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Rename a File or Folder
|
||||
* @param oldName Old name of the file.
|
||||
* @param oldRemotePath Old remote path of the file. For folders it starts and ends by "/"
|
||||
* @param newName New name to set as the name of file.
|
||||
* @param isFolder 'true' for folder and 'false' for files
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public RemoteOperationResult renameFile(String oldName, String oldRemotePath, String newName, boolean isFolder) {
|
||||
|
||||
RenameRemoteFileOperation renameOperation = new RenameRemoteFileOperation(oldName, oldRemotePath, newName, isFolder);
|
||||
RemoteOperationResult result = renameOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Remove a File or Folder
|
||||
*
|
||||
* @param remotePath Remote path of the file or folder in the server.
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult removeFile(String remotePath) {
|
||||
|
||||
RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath);
|
||||
RemoteOperationResult result = removeOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Read a Folder (PROPFIND DEPTH 1)
|
||||
* @param remotePath
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult readFile(String remotePath) {
|
||||
|
||||
ReadRemoteFolderOperation readOperation= new ReadRemoteFolderOperation(remotePath);
|
||||
RemoteOperationResult result = readOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the library method to Download a File
|
||||
* @param remotePath
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult downloadFile(RemoteFile remoteFile, String temporalFolder) {
|
||||
// Create folder
|
||||
String path = "/owncloud/tmp/" + temporalFolder;
|
||||
File sdCard = Environment.getExternalStorageDirectory();
|
||||
File folder = new File(sdCard.getAbsolutePath() + "/" + path);
|
||||
folder.mkdirs();
|
||||
|
||||
DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remoteFile.getRemotePath(), folder.getAbsolutePath());
|
||||
RemoteOperationResult result = downloadOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Access to the library method to Upload a File
|
||||
* @param storagePath
|
||||
* @param remotePath
|
||||
* @param mimeType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult uploadFile(String storagePath, String remotePath, String mimeType) {
|
||||
|
||||
UploadRemoteFileOperation uploadOperation;
|
||||
if ( mChunked && (new File(storagePath)).length() > ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) {
|
||||
uploadOperation = new ChunkedUploadRemoteFileOperation(storagePath, remotePath, mimeType);
|
||||
} else {
|
||||
uploadOperation = new UploadRemoteFileOperation(storagePath, remotePath, mimeType);
|
||||
}
|
||||
|
||||
RemoteOperationResult result = uploadOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** Access to the library method to Get Shares
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult getShares(){
|
||||
|
||||
GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation();
|
||||
RemoteOperationResult result = getOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Access to the library method to Create Share
|
||||
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||
* @param shareType ‘0’ = user, ‘1’ = group, ‘3’ = Public link. Mandatory argument
|
||||
* @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1
|
||||
* @param publicUpload If ‘false’ (default) public cannot upload to a public shared folder.
|
||||
* If ‘true’ public can upload to a shared folder. Only available for public link shares
|
||||
* @param password Password to protect a public link share. Only available for public link shares
|
||||
* @param permissions 1 - Read only – Default for “public” shares
|
||||
* 2 - Update
|
||||
* 4 - Create
|
||||
* 8 - Delete
|
||||
* 16- Re-share
|
||||
* 31- All above – Default for “private” shares
|
||||
* For user or group shares.
|
||||
* To obtain combinations, add the desired values together.
|
||||
* For instance, for “Re-Share”, “delete”, “read”, “update”, add 16+8+2+1 = 27.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoteOperationResult createShare(String path, ShareType shareType, String shareWith, boolean publicUpload,
|
||||
String password, int permissions){
|
||||
|
||||
CreateRemoteShareOperation createOperation = new CreateRemoteShareOperation(path, shareType, shareWith, publicUpload, password, permissions);
|
||||
RemoteOperationResult result = createOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access to the library method to Remove Share
|
||||
*
|
||||
* @param idShare Share ID
|
||||
*/
|
||||
|
||||
public RemoteOperationResult removeShare(int idShare) {
|
||||
RemoveRemoteShareOperation removeOperation = new RemoveRemoteShareOperation(idShare);
|
||||
RemoteOperationResult result = removeOperation.execute(mClient);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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=..
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||