diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..9f906ec0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,27 @@
+language: java
+jdk: oraclejdk7
+before_install:
+- sudo apt-get update -qq
+- sudo apt-get install -qq libstdc++6:i386 lib32z1
+- curl -3L https://raw.github.com/embarkmobile/android-sdk-installer/version-1/android-sdk-installer
+ | bash /dev/stdin --install=$COMPONENTS
+- source ~/.android-sdk-installer/env
+- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -c 20M
+- emulator -avd test -no-skin -no-audio -no-window &
+- rm pom.xml
+- android update project -p .
+before_script:
+- chmod +x ./wait_for_emulator.sh
+- ./wait_for_emulator.sh
+script:
+- ant clean
+- ant debug
+- cd test_client/tests
+- ant acceptance-test
+env:
+ global:
+ - secure: f4Kms/mzkYRG4Kp8k6hsvG3Y0ztbJnA2J79OBw3VdqJOKVTzwsxMd1Yh325YDYO7I4HeHxGXy0H4p3rAPzIWr/nrOJ4wmcDwQYDQtVjF7S1ARWsX51FrCEV6A9ec2LAqNCQ8ZC0SoGb+HsmpFCE3uKAxRQt+B5MzOZvKNcvYpMA=
+ - secure: aF4U20Xlu/rfrbxCmoJAiGh1doYTAZ10UEDmajuinT+ZGSJLivuqD7DDY/00sI6IXWg+J1vL+7jJm4JSYusHPg38UHZ4q92k6RmZycW2ATUzZnGT54O5FRnY67MfVwgVpIMK9UOL/6NEciBHEjlIOL0wbKQiJB++1YtBZOQLGL4=
+ - secure: N+ECSwNg8v2GsAFJ2y/tCiffauHDpN76zuFI2pDqf0fjmCtJZHu4BH5ArXBHjyHKmgn20a/8eZXcwJaH1HsJ80bo7vDJ2miShjGIQ90hPcdmUiB2XVJcew4f04CtvMDH5o7DRt4ykWArlbPL2rhVag0jotlSidolHBwRFnbDhDY=
+ matrix:
+ - COMPONENTS=build-tools-19.0.3,android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
diff --git a/tests/.classpath b/test_client/.classpath
similarity index 100%
rename from tests/.classpath
rename to test_client/.classpath
index 51769745..7bc01d9a 100644
--- a/tests/.classpath
+++ b/test_client/.classpath
@@ -1,9 +1,9 @@
+
+
-
-
diff --git a/tests/.project b/test_client/.project
similarity index 93%
rename from tests/.project
rename to test_client/.project
index 66824491..30c2462f 100644
--- a/tests/.project
+++ b/test_client/.project
@@ -1,6 +1,6 @@
- ownCloud Android Library Test Project
+ ownCloud Android library test project
diff --git a/tests/AndroidManifest.xml b/test_client/AndroidManifest.xml
similarity index 100%
rename from tests/AndroidManifest.xml
rename to test_client/AndroidManifest.xml
diff --git a/tests/assets/fileToUpload.png b/test_client/assets/imageFile.png
similarity index 100%
rename from tests/assets/fileToUpload.png
rename to test_client/assets/imageFile.png
diff --git a/test_client/assets/textFile.txt b/test_client/assets/textFile.txt
new file mode 100644
index 00000000..f53eb8b4
--- /dev/null
+++ b/test_client/assets/textFile.txt
@@ -0,0 +1,3 @@
+This is a simple text file.
+
+To make some tests.
diff --git a/tests/assets/fileToUploadChunks.MP4 b/test_client/assets/videoFile.MP4
similarity index 100%
rename from tests/assets/fileToUploadChunks.MP4
rename to test_client/assets/videoFile.MP4
diff --git a/test_client/build.xml b/test_client/build.xml
new file mode 100644
index 00000000..1be67e32
--- /dev/null
+++ b/test_client/build.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test_client/custom_rules.xml b/test_client/custom_rules.xml
new file mode 100644
index 00000000..0d50badc
--- /dev/null
+++ b/test_client/custom_rules.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Setting username ${env.OCTEST_USERNAME}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/ic_launcher-web.png b/test_client/ic_launcher-web.png
similarity index 100%
rename from tests/ic_launcher-web.png
rename to test_client/ic_launcher-web.png
diff --git a/tests/libs/android-support-v4.jar b/test_client/libs/android-support-v4.jar
similarity index 100%
rename from tests/libs/android-support-v4.jar
rename to test_client/libs/android-support-v4.jar
diff --git a/tests/project.properties b/test_client/project.properties
similarity index 100%
rename from tests/project.properties
rename to test_client/project.properties
diff --git a/tests/res/drawable-hdpi/ic_launcher.png b/test_client/res/drawable-hdpi/ic_launcher.png
similarity index 100%
rename from tests/res/drawable-hdpi/ic_launcher.png
rename to test_client/res/drawable-hdpi/ic_launcher.png
diff --git a/tests/res/drawable-mdpi/ic_launcher.png b/test_client/res/drawable-mdpi/ic_launcher.png
similarity index 100%
rename from tests/res/drawable-mdpi/ic_launcher.png
rename to test_client/res/drawable-mdpi/ic_launcher.png
diff --git a/tests/res/drawable-xhdpi/ic_launcher.png b/test_client/res/drawable-xhdpi/ic_launcher.png
similarity index 100%
rename from tests/res/drawable-xhdpi/ic_launcher.png
rename to test_client/res/drawable-xhdpi/ic_launcher.png
diff --git a/tests/res/drawable-xxhdpi/ic_launcher.png b/test_client/res/drawable-xxhdpi/ic_launcher.png
similarity index 100%
rename from tests/res/drawable-xxhdpi/ic_launcher.png
rename to test_client/res/drawable-xxhdpi/ic_launcher.png
diff --git a/tests/res/layout/activity_test.xml b/test_client/res/layout/activity_test.xml
similarity index 100%
rename from tests/res/layout/activity_test.xml
rename to test_client/res/layout/activity_test.xml
diff --git a/tests/res/menu/test.xml b/test_client/res/menu/test.xml
similarity index 100%
rename from tests/res/menu/test.xml
rename to test_client/res/menu/test.xml
diff --git a/tests/res/values-sw600dp/dimens.xml b/test_client/res/values-sw600dp/dimens.xml
similarity index 100%
rename from tests/res/values-sw600dp/dimens.xml
rename to test_client/res/values-sw600dp/dimens.xml
diff --git a/tests/res/values-sw720dp-land/dimens.xml b/test_client/res/values-sw720dp-land/dimens.xml
similarity index 100%
rename from tests/res/values-sw720dp-land/dimens.xml
rename to test_client/res/values-sw720dp-land/dimens.xml
diff --git a/tests/res/values-v11/styles.xml b/test_client/res/values-v11/styles.xml
similarity index 100%
rename from tests/res/values-v11/styles.xml
rename to test_client/res/values-v11/styles.xml
diff --git a/tests/res/values-v14/styles.xml b/test_client/res/values-v14/styles.xml
similarity index 100%
rename from tests/res/values-v14/styles.xml
rename to test_client/res/values-v14/styles.xml
diff --git a/tests/res/values/dimens.xml b/test_client/res/values/dimens.xml
similarity index 100%
rename from tests/res/values/dimens.xml
rename to test_client/res/values/dimens.xml
diff --git a/tests/res/values/setup.xml b/test_client/res/values/setup.xml
similarity index 100%
rename from tests/res/values/setup.xml
rename to test_client/res/values/setup.xml
diff --git a/tests/res/values/strings.xml b/test_client/res/values/strings.xml
similarity index 100%
rename from tests/res/values/strings.xml
rename to test_client/res/values/strings.xml
diff --git a/tests/res/values/styles.xml b/test_client/res/values/styles.xml
similarity index 100%
rename from tests/res/values/styles.xml
rename to test_client/res/values/styles.xml
diff --git a/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java b/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java
new file mode 100644
index 00000000..3626e0b8
--- /dev/null
+++ b/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java
@@ -0,0 +1,212 @@
+/* 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.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.httpclient.ConnectTimeoutException;
+import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+
+import com.owncloud.android.lib.common.network.ServerNameIndicator;
+
+
+/**
+ * SelfSignedConfidentSslSocketFactory allows to create SSL {@link Socket}s
+ * that accepts self-signed server certificates.
+ *
+ * WARNING: this SHOULD NOT be used in productive environments.
+ *
+ * @author David A. Velasco
+ */
+
+public class SelfSignedConfidentSslSocketFactory implements SecureProtocolSocketFactory {
+
+
+ private SSLContext mSslContext = null;
+
+
+ /**
+ * Constructor for SelfSignedConfidentSslSocketFactory.
+ * @throws GeneralSecurityException
+ */
+ public SelfSignedConfidentSslSocketFactory() throws GeneralSecurityException {
+ mSslContext = createSslContext();
+ }
+
+
+ /**
+ * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
+ */
+ @Override
+ public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
+ return mSslContext.getSocketFactory().createSocket(host, port);
+ }
+
+ /**
+ * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
+ */
+ @Override
+ public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort)
+ throws IOException, UnknownHostException {
+ return mSslContext.getSocketFactory().createSocket(host, port, clientHost, clientPort);
+ }
+
+ /**
+ * Attempts to get a new socket connection to the given host within the given time limit.
+ *
+ * @param host The host name/IP
+ * @param port The port on the host
+ * @param clientHost The local host name/IP to bind the socket to
+ * @param clientPort The port on the local machine
+ * @param params {@link HttpConnectionParams} HTTP connection parameters.
+ *
+ * @return Socket A new socket
+ *
+ * @throws IOException if an I/O error occurs while creating the socket
+ * @throws UnknownHostException if the IP address of the host cannot be determined
+ */
+ @Override
+ public Socket createSocket(String host, int port, InetAddress localAddress, int localPort,
+ HttpConnectionParams params) throws IOException, UnknownHostException,
+ ConnectTimeoutException {
+
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters may not be null");
+ }
+ int timeout = params.getConnectionTimeout();
+ SocketFactory socketfactory = mSslContext.getSocketFactory();
+ Socket socket = socketfactory.createSocket();
+ SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
+ SocketAddress remoteaddr = new InetSocketAddress(host, port);
+ socket.setSoTimeout(params.getSoTimeout());
+ socket.bind(localaddr);
+ ServerNameIndicator.setServerNameIndication(host, (SSLSocket)socket);
+ socket.connect(remoteaddr, timeout);
+ return socket;
+ }
+
+ /**
+ * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
+ */
+ @Override
+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
+ throws IOException, UnknownHostException {
+ return mSslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
+ }
+
+
+
+ private static SSLContext createSslContext() throws GeneralSecurityException {
+ SSLContext context = SSLContext.getInstance("TLS");
+ context.init(
+ null,
+ new TrustManager[] {new SelfSignedConfidentX509TrustManager()},
+ null);
+ return context;
+ }
+
+ public static class SelfSignedConfidentX509TrustManager implements X509TrustManager {
+
+ private X509TrustManager mStandardTrustManager = null;
+
+ public SelfSignedConfidentX509TrustManager()
+ throws NoSuchAlgorithmException, KeyStoreException, CertStoreException {
+ super();
+ TrustManagerFactory factory = TrustManagerFactory
+ .getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ factory.init((KeyStore)null);
+ mStandardTrustManager = findX509TrustManager(factory);
+ }
+
+ /**
+ * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
+ */
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException {
+ mStandardTrustManager.checkClientTrusted(chain, authType);
+ }
+
+ /**
+ * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],
+ * String authType)
+ */
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException {
+ if (chain != null && chain.length == 1) {
+ chain[0].checkValidity();
+ } else {
+ mStandardTrustManager.checkServerTrusted(chain, authType);
+ }
+ }
+
+ /**
+ * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
+ */
+ public X509Certificate[] getAcceptedIssuers() {
+ return mStandardTrustManager.getAcceptedIssuers();
+ }
+
+ /**
+ * Locates the first X509TrustManager provided by a given TrustManagerFactory
+ * @param factory TrustManagerFactory to inspect in the search for a X509TrustManager
+ * @return The first X509TrustManager found in factory.
+ * @throws CertStoreException When no X509TrustManager instance was found in factory
+ */
+ private X509TrustManager findX509TrustManager(TrustManagerFactory factory)
+ throws CertStoreException {
+ TrustManager tms[] = factory.getTrustManagers();
+ for (int i = 0; i < tms.length; i++) {
+ if (tms[i] instanceof X509TrustManager) {
+ return (X509TrustManager) tms[i];
+ }
+ }
+ return null;
+ }
+ }
+
+
+}
diff --git a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java
similarity index 79%
rename from tests/src/com/owncloud/android/lib/test_project/TestActivity.java
rename to test_client/src/com/owncloud/android/lib/test_project/TestActivity.java
index be243a73..65771dab 100644
--- a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java
+++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java
@@ -25,10 +25,18 @@
package com.owncloud.android.lib.test_project;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
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.network.NetworkUtils;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ChunkedUploadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
@@ -47,6 +55,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
+import android.util.Log;
import android.view.Menu;
/**
@@ -57,13 +66,20 @@ import android.view.Menu;
public class TestActivity extends Activity {
+ private static final String TAG = null;
// This account must exists on the server side
private String mServerUri;
- private String mWebdavPath;
private String mUser;
private String mPass;
private boolean mChunked;
+ private static final String WEBDAV_PATH = "/remote.php/webdav";
+ private static final int BUFFER_SIZE = 1024;
+
+ public static final String ASSETS__TEXT_FILE_NAME = "textFile.txt";
+ public static final String ASSETS__IMAGE_FILE_NAME = "imageFile.png";
+ public static final String ASSETS__VIDEO_FILE_NAME = "videoFile.MP4";
+
//private Account mAccount = null;
private OwnCloudClient mClient;
@@ -73,15 +89,34 @@ public class TestActivity extends Activity {
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));
+ Protocol pr = Protocol.getProtocol("https");
+ if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
+ try {
+ ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
+ Protocol.registerProtocol(
+ "https",
+ new Protocol("https", psf, 443));
+
+ } catch (GeneralSecurityException e) {
+ Log.e(TAG, "Self-signed confident SSL context could not be loaded");
+ }
+ }
+
+ Uri uri = Uri.parse(mServerUri + WEBDAV_PATH);
+ mClient = new OwnCloudClient(NetworkUtils.getMultiThreadedConnManager());
+ mClient.setDefaultTimeouts(
+ OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,
+ OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT);
+ mClient.setWebdavUri(uri);
+ mClient.setFollowRedirects(true);
+ mClient.setBasicCredentials(mUser, mPass);
+ mClient.setBaseUri(Uri.parse(mServerUri));
+
+ Log.v(TAG, "onCreate finished, ownCloud client ready");
}
@@ -248,4 +283,33 @@ public class TestActivity extends Activity {
return result;
}
+
+
+ /**
+ * Extracts file from AssetManager to cache folder.
+ *
+ * @param fileName Name of the asset file to extract.
+ * @return File instance of the extracted file.
+ */
+ public File extractAsset(String fileName) throws IOException {
+ File extractedFile = new File(getCacheDir() + File.separator + fileName);
+ if (!extractedFile.exists()) {
+ InputStream in = null;
+ FileOutputStream out = null;
+ in = getAssets().open(fileName);
+ out = new FileOutputStream(extractedFile);
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int readCount;
+ while((readCount = in.read(buffer)) != -1){
+ out.write(buffer, 0, readCount);
+ }
+ out.flush();
+ out.close();
+ in.close();
+ }
+ return extractedFile;
+ }
+
+
+
}
diff --git a/tests/test_cases/.classpath b/test_client/tests/.classpath
similarity index 76%
rename from tests/test_cases/.classpath
rename to test_client/tests/.classpath
index 08ef9591..d1c3047c 100644
--- a/tests/test_cases/.classpath
+++ b/test_client/tests/.classpath
@@ -1,10 +1,10 @@
-
-
-
-
+
+
+
+
diff --git a/tests/test_cases/.project b/test_client/tests/.project
similarity index 94%
rename from tests/test_cases/.project
rename to test_client/tests/.project
index 54097574..f4fb0109 100644
--- a/tests/test_cases/.project
+++ b/test_client/tests/.project
@@ -1,6 +1,6 @@
- ownCloud Android Library Tests
+ ownCloud Android library test cases
diff --git a/tests/test_cases/AndroidManifest.xml b/test_client/tests/AndroidManifest.xml
similarity index 100%
rename from tests/test_cases/AndroidManifest.xml
rename to test_client/tests/AndroidManifest.xml
diff --git a/test_client/tests/ant.properties b/test_client/tests/ant.properties
new file mode 100644
index 00000000..16244024
--- /dev/null
+++ b/test_client/tests/ant.properties
@@ -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=..
diff --git a/test_client/tests/build.xml b/test_client/tests/build.xml
new file mode 100644
index 00000000..b3a5cb6a
--- /dev/null
+++ b/test_client/tests/build.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test_client/tests/custom_rules.xml b/test_client/tests/custom_rules.xml
new file mode 100644
index 00000000..c771dcd6
--- /dev/null
+++ b/test_client/tests/custom_rules.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+ Checking for failures
+
+
+
+
+
+ All tests passed.
+
+
+
\ No newline at end of file
diff --git a/tests/test_cases/project.properties b/test_client/tests/project.properties
similarity index 100%
rename from tests/test_cases/project.properties
rename to test_client/tests/project.properties
diff --git a/tests/test_cases/res/drawable-hdpi/ic_launcher.png b/test_client/tests/res/drawable-hdpi/ic_launcher.png
similarity index 100%
rename from tests/test_cases/res/drawable-hdpi/ic_launcher.png
rename to test_client/tests/res/drawable-hdpi/ic_launcher.png
diff --git a/tests/test_cases/res/drawable-ldpi/ic_launcher.png b/test_client/tests/res/drawable-ldpi/ic_launcher.png
similarity index 100%
rename from tests/test_cases/res/drawable-ldpi/ic_launcher.png
rename to test_client/tests/res/drawable-ldpi/ic_launcher.png
diff --git a/tests/test_cases/res/drawable-mdpi/ic_launcher.png b/test_client/tests/res/drawable-mdpi/ic_launcher.png
similarity index 100%
rename from tests/test_cases/res/drawable-mdpi/ic_launcher.png
rename to test_client/tests/res/drawable-mdpi/ic_launcher.png
diff --git a/tests/test_cases/res/drawable-xhdpi/ic_launcher.png b/test_client/tests/res/drawable-xhdpi/ic_launcher.png
similarity index 100%
rename from tests/test_cases/res/drawable-xhdpi/ic_launcher.png
rename to test_client/tests/res/drawable-xhdpi/ic_launcher.png
diff --git a/tests/test_cases/res/values/strings.xml b/test_client/tests/res/values/strings.xml
similarity index 100%
rename from tests/test_cases/res/values/strings.xml
rename to test_client/tests/res/values/strings.xml
diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java
similarity index 63%
rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java
rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java
index 325c8aea..3b77f220 100644
--- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java
@@ -24,7 +24,10 @@
package com.owncloud.android.lib.test_project.test;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
@@ -35,18 +38,26 @@ import android.test.ActivityInstrumentationTestCase2;
/**
* Class to test Create Folder Operation
* @author masensio
+ * @author David A. Velasco
*
*/
public class CreateFolderTest extends ActivityInstrumentationTestCase2 {
+
+ private static final String LOG_TAG = CreateFolderTest.class.getCanonicalName();
+
+ private static final String FOLDER_PATH_BASE = "/testCreateFolder";
+
private TestActivity mActivity;
private String mCurrentDate;
+ private List mCreatedFolderPaths;
public CreateFolderTest() {
super(TestActivity.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
mCurrentDate = sdf.format(new Date());
+ mCreatedFolderPaths = new ArrayList();
}
@Override
@@ -54,24 +65,22 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 : " | ? *
*/
public void testCreateFolderSpecialCharacters() {
- boolean createFullPath = true;
- String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
- RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
+ String remotePath = FOLDER_PATH_BASE + "_\\" + mCurrentDate;
+ RemoteOperationResult result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_<" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_<" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_>" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_>" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_:" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_:" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_\"" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_|" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_|" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_?" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_?" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
- remotePath = "/testSpecialCharacters_*" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ remotePath = FOLDER_PATH_BASE + "_*" + mCurrentDate;
+ result = mActivity.createFolder(remotePath, true);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
}
+ @Override
+ protected void tearDown() throws Exception {
+ Iterator it = mCreatedFolderPaths.iterator();
+ RemoteOperationResult removeResult = null;
+ while (it.hasNext()) {
+ removeResult = mActivity.removeFile(it.next());
+ if (!removeResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, removeResult);
+ }
+ }
+ super.tearDown();
+ }
+
}
diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java
similarity index 67%
rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java
rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java
index fcd9feb0..7220d888 100644
--- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java
@@ -24,6 +24,8 @@
package com.owncloud.android.lib.test_project.test;
+import java.io.File;
+
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.test_project.TestActivity;
@@ -32,9 +34,11 @@ import android.test.ActivityInstrumentationTestCase2;
public class CreateShareTest extends ActivityInstrumentationTestCase2 {
- /* File to share.*/
- private final String mFileToShare = "/fileToShare.png";
+ private static final String LOG_TAG = CreateShareTest.class.getCanonicalName();
+ /* File to share.*/
+ private static final String FILE_TO_SHARE = "/fileToShare.txt";
+
private TestActivity mActivity;
public CreateShareTest() {
@@ -43,17 +47,44 @@ public class CreateShareTest extends ActivityInstrumentationTestCase2 {
+ private static final String LOG_TAG = DeleteFileTest.class.getCanonicalName();
+
/* Folder data to delete. */
- private final String mFolderPath = "/folderToDelete";
+ private static final String FOLDER_PATH = "/folderToDelete";
/* File to delete. */
- private final String mFilePath = "fileToDelete.png";
+ private static final String FILE_PATH = "/fileToDelete.txt";
+ private static boolean mGlobalSetupDone = false;
+
private TestActivity mActivity;
public DeleteFileTest() {
super(TestActivity.class);
-
}
@Override
@@ -56,6 +61,28 @@ public class DeleteFileTest extends ActivityInstrumentationTestCase2 {
+ private static final String LOG_TAG = DownloadFileTest.class.getCanonicalName();
+
/* 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 static final String IMAGE_PATH = "/fileToDownload.png";
+ private static final String IMAGE_PATH_WITH_SPECIAL_CHARS = "/@file@download.png";
+ private static final String IMAGE_NOT_FOUND = "/fileNotFound.png";
+ private static final String [] FILE_PATHS = { IMAGE_PATH, IMAGE_PATH_WITH_SPECIAL_CHARS };
+ private static boolean mGlobalSetupDone = false;
+ private String mDownloadedFilePath;
private TestActivity mActivity;
+
public DownloadFileTest() {
super(TestActivity.class);
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
- mCurrentDate = sdf.format(new Date());
}
@Override
@@ -66,67 +66,86 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2 {
+ private static final String LOG_TAG = GetSharesTest.class.getCanonicalName();
+
+ private static final String SHARED_FILE = "/sharedFileToGet.txt";
+
private TestActivity mActivity;
public GetSharesTest() {
@@ -50,6 +57,21 @@ public class GetSharesTest extends ActivityInstrumentationTestCase2 {
- /* 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();
- }
+ private static final String LOG_TAG = ReadFileTest.class.getCanonicalName();
+
+ private TestActivity mActivity;
+
+ private String FILE_PATH = "/fileToRead.txt";
+
+ public ReadFileTest() {
+ super(TestActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
- /**
- * Test Read File
- */
- public void testReadFile() {
-
- RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
- assertTrue(result.getData().size() == 1);
- assertTrue(result.isSuccess());
- }
-
+ setActivityInitialTouchMode(false);
+ mActivity = getActivity();
+
+ File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME);
+ RemoteOperationResult uploadResult = mActivity.uploadFile(
+ textFile.getAbsolutePath(),
+ FILE_PATH,
+ "txt/plain");
+ if (!uploadResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, uploadResult);
+ }
+ }
+
+ /**
+ * Test Read File
+ */
+ public void testReadFile() {
+ RemoteOperationResult result = mActivity.readFile(FILE_PATH);
+ assertTrue(result.getData() != null && result.getData().size() == 1);
+ assertTrue(result.isSuccess());
+ // TODO check more properties of the result
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ RemoteOperationResult removeResult = mActivity.removeFile(FILE_PATH);
+ if (!removeResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, removeResult);
+ }
+
+ super.tearDown();
+ }
}
diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java
new file mode 100644
index 00000000..5697fea1
--- /dev/null
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java
@@ -0,0 +1,104 @@
+/* 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 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
+ * @author David A. Velasco
+ */
+
+public class ReadFolderTest extends ActivityInstrumentationTestCase2 {
+
+ private static final String LOG_TAG = ReadFolderTest.class.getCanonicalName();
+
+ private static final String FOLDER_PATH = "/folderToRead";
+ private static final String [] FILE_PATHS = {
+ FOLDER_PATH + "/file1.txt",
+ FOLDER_PATH + "/file2.txt",
+ FOLDER_PATH + "/file3.txt",
+ };
+
+
+ private TestActivity mActivity;
+
+ public ReadFolderTest() {
+ super(TestActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setActivityInitialTouchMode(false);
+ mActivity = getActivity();
+
+ File textFile = mActivity.extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME);
+ RemoteOperationResult result = mActivity.createFolder(FOLDER_PATH, true);
+ if (result.isSuccess()) {
+ for (int i=0; i 1);
+ assertTrue(result.getData().size() == 4);
+ // TODO assert more properties about the result
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception {
+ RemoteOperationResult removeResult = mActivity.removeFile(FOLDER_PATH);
+ if (!removeResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, removeResult);
+ }
+
+ super.tearDown();
+ }
+
+}
diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java
similarity index 63%
rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java
rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java
index 6ee21fc6..27a5fd61 100644
--- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java
@@ -24,19 +24,25 @@
package com.owncloud.android.lib.test_project.test;
+import java.io.File;
+
import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.shares.ShareType;
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 {
- private static final String TAG = RemoveShareTest.class.getSimpleName();
+ private static final String LOG_TAG = RemoveShareTest.class.getCanonicalName();
+ private static final String FILE_TO_UNSHARE = "/fileToUnshare.txt";
+
private TestActivity mActivity;
+ private long mShareId;
+
public RemoveShareTest() {
super(TestActivity.class);
@@ -47,28 +53,42 @@ public class RemoveShareTest extends ActivityInstrumentationTestCase2 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);
- }
+ RemoteOperationResult result = mActivity.removeShare((int) mShareId);
+ assertTrue(result.isSuccess());
}
+
+
+ @Override
+ protected void tearDown() throws Exception {
+ RemoteOperationResult removeResult = mActivity.removeFile(FILE_TO_UNSHARE);
+ if (!removeResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, removeResult);
+ }
+ super.tearDown();
+ }
+
}
diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java
new file mode 100644
index 00000000..23b5b276
--- /dev/null
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java
@@ -0,0 +1,241 @@
+/* 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 com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.test_project.TestActivity;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+
+/**
+ * Class to test Rename File Operation
+ * @author masensio
+ *
+ */
+
+public class RenameFileTest extends ActivityInstrumentationTestCase2 {
+
+ private static final String LOG_TAG = RenameFileTest.class.getCanonicalName();
+
+ /* Folder data to rename. This folder must exist on the account */
+ private static final String OLD_FOLDER_NAME = "folderToRename";
+ private static final String OLD_FOLDER_PATH = FileUtils.PATH_SEPARATOR + OLD_FOLDER_NAME;
+ private static final String NEW_FOLDER_NAME = "renamedFolder";
+ private static final String NEW_FOLDER_PATH = FileUtils.PATH_SEPARATOR + NEW_FOLDER_NAME;
+
+ /* File data to rename. This file must exist on the account */
+ private static final String OLD_FILE_NAME = "fileToRename.png";
+ private static final String OLD_FILE_PATH = FileUtils.PATH_SEPARATOR + OLD_FILE_NAME;
+ private static final String NEW_FILE_NAME = "renamedFile.png";
+ private static final String NEW_FILE_PATH = FileUtils.PATH_SEPARATOR + NEW_FILE_NAME;
+
+
+ private static boolean mGlobalSetupDone = false;
+
+ private String mToCleanUpInServer;
+ private TestActivity mActivity;
+
+ public RenameFileTest() {
+ super(TestActivity.class);
+
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setActivityInitialTouchMode(false);
+ mActivity = getActivity();
+
+ if (!mGlobalSetupDone) {
+
+ Log.v(LOG_TAG, "Starting global set up");
+ RemoteOperationResult result = mActivity.createFolder(OLD_FOLDER_NAME, true);
+ if (!result.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, result);
+ }
+
+ File imageFile = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME);
+ result = mActivity.uploadFile(
+ imageFile.getAbsolutePath(),
+ OLD_FILE_PATH,
+ "image/png");
+ if (!result.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, result);
+ }
+
+ Log.v(LOG_TAG, "Global set up done");
+ mGlobalSetupDone = true;
+ }
+
+ mToCleanUpInServer = null;
+ }
+
+ /**
+ * Test Rename Folder
+ */
+ public void testRenameFolder() {
+
+ mToCleanUpInServer = OLD_FOLDER_PATH;
+ RemoteOperationResult result = mActivity.renameFile(
+ OLD_FOLDER_NAME,
+ OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME,
+ true);
+ assertTrue(result.isSuccess());
+ mToCleanUpInServer = NEW_FOLDER_PATH;
+ }
+
+ /**
+ * Test Rename Folder with forbidden characters : \ < > : " | ? *
+ */
+ public void testRenameFolderForbiddenChars() {
+
+ RemoteOperationResult result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + "\\", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + "<", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + ">", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + ":", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + "\"", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + "|", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + "?", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH,
+ NEW_FOLDER_NAME + "*", true);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ }
+
+ /**
+ * Test Rename File
+ */
+ public void testRenameFile() {
+ mToCleanUpInServer = OLD_FILE_PATH;
+ RemoteOperationResult result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ NEW_FILE_NAME,
+ false);
+ assertTrue(result.isSuccess());
+ mToCleanUpInServer = NEW_FILE_PATH;
+ }
+
+
+ /**
+ * Test Rename Folder with forbidden characters: \ < > : " | ? *
+ */
+ public void testRenameFileForbiddenChars() {
+ RemoteOperationResult result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ "\\" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ "<" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ ">" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ ":" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ "\"" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ "|" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ "?" + NEW_FILE_NAME,
+ false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ result = mActivity.renameFile(
+ OLD_FILE_NAME,
+ OLD_FILE_PATH,
+ "*" + NEW_FILE_NAME, false);
+ assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (mToCleanUpInServer != null) {
+ RemoteOperationResult removeResult = mActivity.removeFile(mToCleanUpInServer);
+ if (!removeResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, removeResult);
+ }
+ }
+ super.tearDown();
+ }
+
+}
diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java
new file mode 100644
index 00000000..5a69f0d2
--- /dev/null
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java
@@ -0,0 +1,127 @@
+/* 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 android.test.ActivityInstrumentationTestCase2;
+
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.test_project.TestActivity;
+
+/**
+ * Class to test Update File Operation
+ * @author masensio
+ * @author David A. Velasco
+ *
+ */
+
+public class UploadFileTest extends ActivityInstrumentationTestCase2 {
+
+ private static final String LOG_TAG = UploadFileTest.class.getCanonicalName();
+
+ private static final String UPLOAD_PATH = "/uploadedImage.png";
+
+ private static final String CHUNKED_UPLOAD_PATH = "/uploadedVideo.MP4";
+
+ private static final String FILE_NOT_FOUND_PATH = "/notFoundShouldNotBeHere.png";
+
+
+ private TestActivity mActivity;
+ private File mFileToUpload, mFileToUploadWithChunks;
+ private String mUploadedFilePath;
+
+
+ public UploadFileTest() {
+ super(TestActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setActivityInitialTouchMode(false);
+ mActivity = getActivity();
+ mUploadedFilePath = null;
+
+ mFileToUpload = mActivity.extractAsset(TestActivity.ASSETS__IMAGE_FILE_NAME);
+ mFileToUploadWithChunks = mActivity.extractAsset(TestActivity.ASSETS__VIDEO_FILE_NAME);
+ }
+
+
+ /**
+ * Test Upload File without chunks
+ */
+ public void testUploadFile() {
+
+ RemoteOperationResult result = mActivity.uploadFile(
+ mFileToUpload.getAbsolutePath(),
+ UPLOAD_PATH,
+ "image/png"
+ );
+ mUploadedFilePath = UPLOAD_PATH;
+ assertTrue(result.isSuccess());
+ }
+
+ /**
+ * Test Upload File with chunks
+ */
+ public void testUploadFileWithChunks() {
+
+ RemoteOperationResult result = mActivity.uploadFile(
+ mFileToUploadWithChunks.getAbsolutePath(),
+ CHUNKED_UPLOAD_PATH,
+ "video/mp4"
+ );
+ mUploadedFilePath = CHUNKED_UPLOAD_PATH;
+ assertTrue(result.isSuccess());
+ }
+
+ /**
+ * Test Upload Not Found File
+ */
+ public void testUploadFileNotFound() {
+
+ RemoteOperationResult result = mActivity.uploadFile(
+ FILE_NOT_FOUND_PATH,
+ FILE_NOT_FOUND_PATH,
+ "image/png"
+ );
+ mUploadedFilePath = FILE_NOT_FOUND_PATH;
+ assertFalse(result.isSuccess());
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (mUploadedFilePath != null) {
+ RemoteOperationResult removeResult = mActivity.removeFile(mUploadedFilePath);
+ if (!removeResult.isSuccess()) {
+ Utils.logAndThrow(LOG_TAG, removeResult);
+ }
+ }
+ super.tearDown();
+ }
+
+}
diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java
similarity index 59%
rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java
rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java
index 94b2bfbc..9ce9c2c8 100644
--- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java
+++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java
@@ -24,46 +24,15 @@
package com.owncloud.android.lib.test_project.test;
+import android.util.Log;
+
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.test_project.TestActivity;
-import android.test.ActivityInstrumentationTestCase2;
+public class Utils {
-/**
- * Class to test Read Folder Operation
- * @author masensio
- *
- */
-
-public class ReadFolderTest extends ActivityInstrumentationTestCase2 {
-
-
- /* 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();
+ public static void logAndThrow(String tag, RemoteOperationResult result) throws Exception {
+ Log.e(tag, result.getLogMessage(), result.getException());
+ throw new Exception(result.getLogMessage(), result.getException());
}
- /**
- * Test Read Folder
- */
- public void testReadFolder() {
-
- RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath);
- assertTrue(result.getData().size() > 1);
- assertTrue(result.getData().size() == 4);
- assertTrue(result.isSuccess());
- }
-
}
diff --git a/tests/.settings/org.eclipse.jdt.core.prefs b/tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index b080d2dd..00000000
--- a/tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/test_cases/.settings/org.eclipse.jdt.core.prefs b/tests/test_cases/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index b080d2dd..00000000
--- a/tests/test_cases/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java
deleted file mode 100644
index 8c305371..00000000
--- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/* 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 {
-
- /* 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());
- }
-
-}
diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java
deleted file mode 100644
index 0e6c749e..00000000
--- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/* 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 {
-
- /* 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());
- }
-
-}
diff --git a/wait_for_emulator.sh b/wait_for_emulator.sh
new file mode 100644
index 00000000..7f6443c7
--- /dev/null
+++ b/wait_for_emulator.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+bootanim=""
+failcounter=0
+checkcounter=0
+until [[ "$bootanim" =~ "stopped" ]]; do
+ bootanim=`adb -e shell getprop init.svc.bootanim 2>&1`
+ echo "($checkcounter) $bootanim"
+ if [[ "$bootanim" =~ "not found" ]]; then
+ let "failcounter += 1"
+ if [[ $failcounter -gt 30 ]]; then
+ echo "Failed to start emulator"
+ exit 1
+ fi
+ fi
+ let "checkcounter += 1"
+ sleep 10
+done
+echo "Done"