From 98d58afce01406040b1db20777447efd60140e73 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 7 Apr 2014 14:53:21 +0200 Subject: [PATCH 01/34] Added Travis build script, fist version --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..794e2877 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: java +jdk: oraclejdk7 +before_install: + # Install base Android SDK + - sudo apt-get update -qq + - sudo apt-get install -qq libstdc++6:i386 lib32z1 + - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 + - 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 + - rm pom.xml + - ./setup_env.sh + +script: + - ant clean + - ant debug + From bda94d02aac4874c92a9fd15ff9370e68aab6188 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 8 Apr 2014 12:43:40 +0200 Subject: [PATCH 02/34] Removed unneeded script to setup environment --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 794e2877..3cc05098 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ before_install: - 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 - rm pom.xml - - ./setup_env.sh script: - ant clean From 7f8da4cce656fd6119fd6f04da97720f201d3c1e Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 8 Apr 2014 13:29:27 +0200 Subject: [PATCH 03/34] Updated layout of test projects --- {tests => test_client}/.classpath | 4 +- {tests => test_client}/.project | 2 +- {tests => test_client}/AndroidManifest.xml | 0 .../assets/fileToUpload.png | Bin .../assets/fileToUploadChunks.MP4 | Bin test_client/build.xml | 92 ++++++++++++++++++ {tests => test_client}/ic_launcher-web.png | Bin .../libs/android-support-v4.jar | Bin {tests => test_client}/project.properties | 0 .../res/drawable-hdpi/ic_launcher.png | Bin .../res/drawable-mdpi/ic_launcher.png | Bin .../res/drawable-xhdpi/ic_launcher.png | Bin .../res/drawable-xxhdpi/ic_launcher.png | Bin .../res/layout/activity_test.xml | 0 {tests => test_client}/res/menu/test.xml | 0 .../res/values-sw600dp/dimens.xml | 0 .../res/values-sw720dp-land/dimens.xml | 0 .../res/values-v11/styles.xml | 0 .../res/values-v14/styles.xml | 0 {tests => test_client}/res/values/dimens.xml | 0 {tests => test_client}/res/values/setup.xml | 0 {tests => test_client}/res/values/strings.xml | 0 {tests => test_client}/res/values/styles.xml | 0 .../lib/test_project/TestActivity.java | 0 .../tests}/.classpath | 8 +- .../test_cases => test_client/tests}/.project | 2 +- .../tests}/AndroidManifest.xml | 0 test_client/tests/ant.properties | 18 ++++ test_client/tests/build.xml | 92 ++++++++++++++++++ .../tests}/project.properties | 0 .../tests}/res/drawable-hdpi/ic_launcher.png | Bin .../tests}/res/drawable-ldpi/ic_launcher.png | Bin .../tests}/res/drawable-mdpi/ic_launcher.png | Bin .../tests}/res/drawable-xhdpi/ic_launcher.png | Bin .../tests}/res/values/strings.xml | 0 .../test_project/test/CreateFolderTest.java | 0 .../test_project/test/CreateShareTest.java | 0 .../lib/test_project/test/DeleteFileTest.java | 0 .../test_project/test/DownloadFileTest.java | 0 .../lib/test_project/test/GetSharesTest.java | 0 .../lib/test_project/test/ReadFileTest.java | 0 .../lib/test_project/test/ReadFolderTest.java | 0 .../test_project/test/RemoveShareTest.java | 0 .../lib/test_project/test/RenameFileTest.java | 0 .../lib/test_project/test/UploadFileTest.java | 0 tests/.settings/org.eclipse.jdt.core.prefs | 4 - .../.settings/org.eclipse.jdt.core.prefs | 4 - 47 files changed, 210 insertions(+), 16 deletions(-) rename {tests => test_client}/.classpath (100%) rename {tests => test_client}/.project (93%) rename {tests => test_client}/AndroidManifest.xml (100%) rename {tests => test_client}/assets/fileToUpload.png (100%) rename {tests => test_client}/assets/fileToUploadChunks.MP4 (100%) create mode 100644 test_client/build.xml rename {tests => test_client}/ic_launcher-web.png (100%) rename {tests => test_client}/libs/android-support-v4.jar (100%) rename {tests => test_client}/project.properties (100%) rename {tests => test_client}/res/drawable-hdpi/ic_launcher.png (100%) rename {tests => test_client}/res/drawable-mdpi/ic_launcher.png (100%) rename {tests => test_client}/res/drawable-xhdpi/ic_launcher.png (100%) rename {tests => test_client}/res/drawable-xxhdpi/ic_launcher.png (100%) rename {tests => test_client}/res/layout/activity_test.xml (100%) rename {tests => test_client}/res/menu/test.xml (100%) rename {tests => test_client}/res/values-sw600dp/dimens.xml (100%) rename {tests => test_client}/res/values-sw720dp-land/dimens.xml (100%) rename {tests => test_client}/res/values-v11/styles.xml (100%) rename {tests => test_client}/res/values-v14/styles.xml (100%) rename {tests => test_client}/res/values/dimens.xml (100%) rename {tests => test_client}/res/values/setup.xml (100%) rename {tests => test_client}/res/values/strings.xml (100%) rename {tests => test_client}/res/values/styles.xml (100%) rename {tests => test_client}/src/com/owncloud/android/lib/test_project/TestActivity.java (100%) rename {tests/test_cases => test_client/tests}/.classpath (76%) rename {tests/test_cases => test_client/tests}/.project (94%) rename {tests/test_cases => test_client/tests}/AndroidManifest.xml (100%) create mode 100644 test_client/tests/ant.properties create mode 100644 test_client/tests/build.xml rename {tests/test_cases => test_client/tests}/project.properties (100%) rename {tests/test_cases => test_client/tests}/res/drawable-hdpi/ic_launcher.png (100%) rename {tests/test_cases => test_client/tests}/res/drawable-ldpi/ic_launcher.png (100%) rename {tests/test_cases => test_client/tests}/res/drawable-mdpi/ic_launcher.png (100%) rename {tests/test_cases => test_client/tests}/res/drawable-xhdpi/ic_launcher.png (100%) rename {tests/test_cases => test_client/tests}/res/values/strings.xml (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/ReadFolderTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java (100%) rename {tests/test_cases => test_client/tests}/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java (100%) delete mode 100644 tests/.settings/org.eclipse.jdt.core.prefs delete mode 100644 tests/test_cases/.settings/org.eclipse.jdt.core.prefs 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/fileToUpload.png similarity index 100% rename from tests/assets/fileToUpload.png rename to test_client/assets/fileToUpload.png diff --git a/tests/assets/fileToUploadChunks.MP4 b/test_client/assets/fileToUploadChunks.MP4 similarity index 100% rename from tests/assets/fileToUploadChunks.MP4 rename to test_client/assets/fileToUploadChunks.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/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/tests/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java similarity index 100% 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 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/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 100% 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 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 100% 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 diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java similarity index 100% rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java similarity index 100% rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java similarity index 100% rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java similarity index 100% rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java 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/ReadFolderTest.java similarity index 100% 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/ReadFolderTest.java 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 100% 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 diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java similarity index 100% rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/RenameFileTest.java diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java similarity index 100% rename from tests/test_cases/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java rename to test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java 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 From 7d33ff1295596c1de2b18d9a0fae3e4090e29018 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 8 Apr 2014 13:35:55 +0200 Subject: [PATCH 04/34] Grant that local Ant properties are updated for owncloud-android-library project --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3cc05098..6c921797 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ before_install: - 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 - rm pom.xml + - android update project -p . script: - ant clean From dc93c29f3490a69a117ea244c969087696af69f4 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 09:41:32 +0200 Subject: [PATCH 05/34] Testing encrypted values in Travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6c921797..dc46e0ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: java jdk: oraclejdk7 before_install: # Install base Android SDK + - echo $ENCRYPT_TEST - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 @@ -14,3 +15,6 @@ script: - ant clean - ant debug +env: + global: + secure: RIaWeu3vSn8QPaq388W6bPkralsv5F3tixk0h56mGlEQBtiLfkLmkXGCMBUehpOPIE1nXVzKyAcpa99EMltPJoo9gzK/4t0XMqFEGBUJsttnQYM4Js4wapJ4iaoAaY1wvFHEweAz2XpwHS3Wf4W9bHYDcXBeELxFxSYXQZgPj6Y= From 5e7f2eab165f8149ca210405f377961caa371395 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 09:42:39 +0200 Subject: [PATCH 06/34] Fixed indentation --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dc46e0ec..09e88f26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: java jdk: oraclejdk7 before_install: # Install base Android SDK - - echo $ENCRYPT_TEST + - echo $ENCRYPT_TEST - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 From 02f3aa2a461ef85c3ef96006eeb72030285ad1bf Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 09:46:30 +0200 Subject: [PATCH 07/34] Trying to fix echo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 09e88f26..c78d4b5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: java jdk: oraclejdk7 before_install: # Install base Android SDK - - echo $ENCRYPT_TEST + - echo '$ENCRYPT_TEST' - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 From 91cf26209297ed3431ac95e195e74ee3459855ac Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 10:08:03 +0200 Subject: [PATCH 08/34] Still trying to fix echo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c78d4b5c..759a802f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: java jdk: oraclejdk7 before_install: # Install base Android SDK - - echo '$ENCRYPT_TEST' + - echo '\$ENCRYPT_TEST' - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 From 982748df45f460cbfae8e1b32c4f532f9d2e2389 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 12:17:15 +0200 Subject: [PATCH 09/34] Added Ant custom rules to overwrite setup.xml values from environment variables --- test_client/custom_rules.xml | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test_client/custom_rules.xml diff --git a/test_client/custom_rules.xml b/test_client/custom_rules.xml new file mode 100644 index 00000000..965385e0 --- /dev/null +++ b/test_client/custom_rules.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + Setting username ${env.OC_TEST_USERNAME} + + + + + + + + + + + + + + + \ No newline at end of file From a8655239f05543d7f630ea573e4af6288ee460aa Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 12:21:15 +0200 Subject: [PATCH 10/34] Added build of test_client project, and still testing encrypted variables --- .travis.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 759a802f..b3df1963 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,19 +2,21 @@ language: java jdk: oraclejdk7 before_install: # Install base Android SDK - - echo '\$ENCRYPT_TEST' - - sudo apt-get update -qq - - sudo apt-get install -qq libstdc++6:i386 lib32z1 - - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 - - 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 - - rm pom.xml - - android update project -p . + - sudo apt-get update -qq + - sudo apt-get install -qq libstdc++6:i386 lib32z1 + - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 + - 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 + - rm pom.xml + - android update project -p . script: - ant clean - ant debug + - cd test_client + - ant clean + - ant debug env: global: - secure: RIaWeu3vSn8QPaq388W6bPkralsv5F3tixk0h56mGlEQBtiLfkLmkXGCMBUehpOPIE1nXVzKyAcpa99EMltPJoo9gzK/4t0XMqFEGBUJsttnQYM4Js4wapJ4iaoAaY1wvFHEweAz2XpwHS3Wf4W9bHYDcXBeELxFxSYXQZgPj6Y= + secure: M3Zu6Jke2e4snRcnQdEJe7pElA29SH1sRktEFpXZ96YU8i+eeRFd3+m9UImtIrwyOK6Esj8uZlEH1TtRd6sa/W4W87vO+GtUEt4SpCbTbd/pF2HNWno0rfueP+6+CgBvyeVDLYa7JH8fQeQscnDZNSQ73PwEm8/T2v0mDYJGow4= From b84c375f3b08d9de3b878d87743fb0296bbb8bd9 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 9 Apr 2014 12:28:50 +0200 Subject: [PATCH 11/34] Fixed typo in custom rules to log and validate use of encrypted variables in Travis --- test_client/custom_rules.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_client/custom_rules.xml b/test_client/custom_rules.xml index 965385e0..0d50badc 100644 --- a/test_client/custom_rules.xml +++ b/test_client/custom_rules.xml @@ -21,7 +21,7 @@ - Setting username ${env.OC_TEST_USERNAME} + Setting username ${env.OCTEST_USERNAME} Date: Mon, 14 Apr 2014 13:10:05 +0200 Subject: [PATCH 12/34] Test project for library accepts server with a self-signed SSL certificate --- .../SelfSignedConfidentSslSocketFactory.java | 212 ++++++++++++++++++ .../lib/test_project/TestActivity.java | 33 ++- 2 files changed, 241 insertions(+), 4 deletions(-) create mode 100644 test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java 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/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java index be243a73..593f64b0 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -25,10 +25,15 @@ package com.owncloud.android.lib.test_project; import java.io.File; +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 +52,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,6 +63,7 @@ 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; @@ -78,10 +85,28 @@ public class TestActivity extends Activity { 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 + mWebdavPath); + 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)); } From e2380a6a5c08c4fea2f968d1d4c20fcba1c5848b Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 15 Apr 2014 12:32:03 +0200 Subject: [PATCH 13/34] Updated ReadFileTest to work with an empty OC server --- test_client/assets/textFile.txt | 3 + .../lib/test_project/TestActivity.java | 43 +++++++++- .../lib/test_project/test/ReadFileTest.java | 80 +++++++++++++------ 3 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 test_client/assets/textFile.txt 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/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java index 593f64b0..896ea0f5 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -25,6 +25,10 @@ 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.io.OutputStream; import java.security.GeneralSecurityException; import org.apache.commons.httpclient.protocol.Protocol; @@ -52,6 +56,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.app.Activity; +import android.content.res.AssetManager; import android.util.Log; import android.view.Menu; @@ -66,11 +71,13 @@ 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; + //private Account mAccount = null; private OwnCloudClient mClient; @@ -80,7 +87,6 @@ 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); @@ -98,7 +104,7 @@ public class TestActivity extends Activity { } } - Uri uri = Uri.parse(mServerUri + mWebdavPath); + Uri uri = Uri.parse(mServerUri + WEBDAV_PATH); mClient = new OwnCloudClient(NetworkUtils.getMultiThreadedConnManager()); mClient.setDefaultTimeouts( OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT, @@ -107,6 +113,8 @@ public class TestActivity extends Activity { mClient.setFollowRedirects(true); mClient.setBasicCredentials(mUser, mPass); mClient.setBaseUri(Uri.parse(mServerUri)); + + Log.v(TAG, "onCreate finished, ownCloud client ready"); } @@ -273,4 +281,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/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java index bac58599..686f30cc 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java @@ -23,45 +23,73 @@ */ 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.files.FileUtils; import com.owncloud.android.lib.test_project.TestActivity; import android.test.ActivityInstrumentationTestCase2; +import android.util.Log; /** * Class to test Read File Operation * @author masensio - * + * @author David A. Velasco */ public class ReadFileTest 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 static final String TEXT_FILE_NAME = "textFile.txt"; - /** - * Test Read File - */ - public void testReadFile() { + private TestActivity mActivity; + + public ReadFileTest() { + super(TestActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); - RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath); - assertTrue(result.getData().size() == 1); - assertTrue(result.isSuccess()); - } - + setActivityInitialTouchMode(false); + mActivity = getActivity(); + + File textFile = mActivity.extractAsset(TEXT_FILE_NAME); + RemoteOperationResult uploadResult = mActivity.uploadFile( + textFile.getAbsolutePath(), + FileUtils.PATH_SEPARATOR + TEXT_FILE_NAME, + "txt/plain"); + if (!uploadResult.isSuccess()) { + logAndThrow(uploadResult); + } + } + + /** + * Test Read File + */ + public void testReadFile() { + RemoteOperationResult result = mActivity.readFile(TEXT_FILE_NAME); + assertTrue(result.getData().size() == 1); + assertTrue(result.isSuccess()); + // TODO check more properties of the result + } + + @Override + protected void tearDown() throws Exception { + RemoteOperationResult removeResult = mActivity.removeFile(TEXT_FILE_NAME); + if (!removeResult.isSuccess()) { + logAndThrow(removeResult); + } + + super.tearDown(); + } + + private void logAndThrow(RemoteOperationResult result) throws Exception { + Log.e(LOG_TAG, result.getLogMessage(), result.getException()); + throw new Exception(result.getLogMessage(), result.getException()); + } } From 596c793243f21640d8e9cbe62561ace5cbb07f25 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 15 Apr 2014 13:22:45 +0200 Subject: [PATCH 14/34] Updated ReadFolderTest to work with an empty OC server --- .../lib/test_project/TestActivity.java | 4 +- .../lib/test_project/test/ReadFileTest.java | 27 ++++---- .../lib/test_project/test/ReadFolderTest.java | 64 +++++++++++++++---- .../android/lib/test_project/test/Utils.java | 38 +++++++++++ 4 files changed, 103 insertions(+), 30 deletions(-) create mode 100644 test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java diff --git a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java index 896ea0f5..44d19ef4 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -28,7 +28,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.security.GeneralSecurityException; import org.apache.commons.httpclient.protocol.Protocol; @@ -56,7 +55,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.app.Activity; -import android.content.res.AssetManager; import android.util.Log; import android.view.Menu; @@ -78,6 +76,8 @@ public class TestActivity extends Activity { 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"; + //private Account mAccount = null; private OwnCloudClient mClient; diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java index 686f30cc..c2bca6e7 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/ReadFileTest.java @@ -30,7 +30,6 @@ 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 Read File Operation @@ -42,10 +41,10 @@ public class ReadFileTest extends ActivityInstrumentationTestCase2 { + private static final String LOG_TAG = ReadFolderTest.class.getCanonicalName(); + + private static final String FOLDER_PATH = "/folderToRead"; + private static final String FILE1_NAME = "file1.txt"; + private static final String FILE2_NAME = "file2.txt"; + private static final String FILE3_NAME = "file3.txt"; - /* Folder data to read. This folder must exist on the account */ - private final String mRemoteFolderPath = "/folderToRead"; - private TestActivity mActivity; public ReadFolderTest() { - super(TestActivity.class); + super(TestActivity.class); } @Override - protected void setUp() throws Exception { - super.setUp(); - setActivityInitialTouchMode(false); - mActivity = getActivity(); + 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()) { + String [] filePaths = { + FOLDER_PATH + FileUtils.PATH_SEPARATOR + FILE1_NAME, + FOLDER_PATH + FileUtils.PATH_SEPARATOR + FILE2_NAME, + FOLDER_PATH + FileUtils.PATH_SEPARATOR + FILE3_NAME + }; + + for (int i=0; i 1); - assertTrue(result.getData().size() == 4); + RemoteOperationResult result = mActivity.readFile(FOLDER_PATH); assertTrue(result.isSuccess()); + assertTrue(result.getData() != null && result.getData().size() > 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/test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java new file mode 100644 index 00000000..9ce9c2c8 --- /dev/null +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/Utils.java @@ -0,0 +1,38 @@ +/* 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 android.util.Log; + +import com.owncloud.android.lib.common.operations.RemoteOperationResult; + +public class Utils { + + public static void logAndThrow(String tag, RemoteOperationResult result) throws Exception { + Log.e(tag, result.getLogMessage(), result.getException()); + throw new Exception(result.getLogMessage(), result.getException()); + } + +} From b3e3eb74f0248a394ad35ef5123038a45981f15c Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 15 Apr 2014 13:48:01 +0200 Subject: [PATCH 15/34] Updated CreateFolderTest to work with an empty OC server --- .../test_project/test/CreateFolderTest.java | 81 +++++++++++++------ 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java index 325c8aea..30a5aa0f 100644 --- a/test_client/tests/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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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; + mCreatedFolderPaths.add(remotePath); + 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(); + } + } From 45eecf1ff8f0f785c27ab979c217c14e6e565fbb Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 15 Apr 2014 15:19:10 +0200 Subject: [PATCH 16/34] Updated UploadFileTest to work with an empty OC server --- .../{fileToUpload.png => imageFile.png} | Bin .../{fileToUploadChunks.MP4 => videoFile.MP4} | Bin .../lib/test_project/TestActivity.java | 2 + .../lib/test_project/test/UploadFileTest.java | 136 +++++++----------- 4 files changed, 54 insertions(+), 84 deletions(-) rename test_client/assets/{fileToUpload.png => imageFile.png} (100%) rename test_client/assets/{fileToUploadChunks.MP4 => videoFile.MP4} (100%) diff --git a/test_client/assets/fileToUpload.png b/test_client/assets/imageFile.png similarity index 100% rename from test_client/assets/fileToUpload.png rename to test_client/assets/imageFile.png diff --git a/test_client/assets/fileToUploadChunks.MP4 b/test_client/assets/videoFile.MP4 similarity index 100% rename from test_client/assets/fileToUploadChunks.MP4 rename to test_client/assets/videoFile.MP4 diff --git a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java index 44d19ef4..65771dab 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -77,6 +77,8 @@ public class TestActivity extends Activity { 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; 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 index 0e6c749e..8b905d18 100644 --- 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 @@ -25,48 +25,45 @@ 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 java.util.ArrayList; +import java.util.Iterator; +import java.util.List; -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.resources.files.FileUtils; 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 { - /* Files to upload. These files must exists on the device */ - private final String mFileToUpload = "fileToUpload.png"; - private final String mMimeType = "image/png"; + private static final String LOG_TAG = UploadFileTest.class.getCanonicalName(); - private final String mFileToUploadWithChunks = "fileToUploadChunks.MP4"; - private final String mMimeTypeWithChunks = "video/mp4"; + private static final String UPLOAD_PATH = + FileUtils.PATH_SEPARATOR + TestActivity.ASSETS__IMAGE_FILE_NAME; - private final String mFileNotFound = "fileNotFound.png"; - - private final String mStoragePath = "/owncloud/tmp/uploadTest"; - private String mPath; - - private String mCurrentDate; + private static final String CHUNKED_UPLOAD_PATH = + FileUtils.PATH_SEPARATOR + TestActivity.ASSETS__VIDEO_FILE_NAME; + private static final String FILE_NOT_FOUND_PATH = + FileUtils.PATH_SEPARATOR + "fileNotFound.png"; + + private TestActivity mActivity; + private File mFileToUpload, mFileToUploadWithChunks; + private List mUploadedFilesPaths; + public UploadFileTest() { super(TestActivity.class); - + mUploadedFilesPaths = new ArrayList(); } @Override @@ -74,68 +71,24 @@ public class UploadFileTest extends ActivityInstrumentationTestCase2 it = mUploadedFilesPaths.iterator(); + RemoteOperationResult removeResult = null; + while (it.hasNext()) { + removeResult = mActivity.removeFile(it.next()); + if (!removeResult.isSuccess()) { + Utils.logAndThrow(LOG_TAG, removeResult); + } + } + super.tearDown(); + } + } From d2e69253963d078b1d03a98da769269031f845b5 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 11:48:13 +0200 Subject: [PATCH 17/34] Updated DeleteFileTest to work with an empty OC server --- .../lib/test_project/test/DeleteFileTest.java | 58 ++++++++++++++----- .../lib/test_project/test/ReadFileTest.java | 10 ++-- .../lib/test_project/test/ReadFolderTest.java | 19 +++--- .../lib/test_project/test/UploadFileTest.java | 10 +--- 4 files changed, 57 insertions(+), 40 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java index 2b0c6440..564a9da6 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DeleteFileTest.java @@ -24,11 +24,13 @@ 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.test_project.TestActivity; import android.test.ActivityInstrumentationTestCase2; +import android.util.Log; /** * Class to test Delete a File Operation @@ -38,17 +40,20 @@ import android.test.ActivityInstrumentationTestCase2; public class DeleteFileTest 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 Date: Wed, 16 Apr 2014 12:37:03 +0200 Subject: [PATCH 18/34] Updated DownloadFileTest to work with an empty OC server --- .../test_project/test/DownloadFileTest.java | 129 +++++++++++------- 1 file changed, 77 insertions(+), 52 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java index 33ed878b..a63f191e 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java @@ -24,41 +24,45 @@ package com.owncloud.android.lib.test_project.test; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import com.owncloud.android.lib.resources.files.RemoteFile; 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; +import android.util.Log; /** * Class to test Download File Operation * @author masensio - * + * @author David A. Velasco */ public class DownloadFileTest 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 List mDownloadedFilesPaths; private TestActivity mActivity; + public DownloadFileTest() { super(TestActivity.class); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); - mCurrentDate = sdf.format(new Date()); + mDownloadedFilesPaths = new ArrayList(); } @Override @@ -66,67 +70,88 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2 it = mDownloadedFilesPaths.iterator(); + RemoteOperationResult removeResult = null; + while (it.hasNext()) { + removeResult = mActivity.removeFile(it.next()); + if (!removeResult.isSuccess()) { + Utils.logAndThrow(LOG_TAG, removeResult); + } + } + File[] files = mActivity.getFilesDir().listFiles(); + for (File file : files) { + file.delete(); + } + super.tearDown(); + } + + } From 026e744ae18747987023aac170546ec5cabc21a3 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 13:40:11 +0200 Subject: [PATCH 19/34] Updated RenameFileTest to work with an empty OC server --- .../test_project/test/CreateFolderTest.java | 8 - .../test_project/test/DownloadFileTest.java | 18 +- .../lib/test_project/test/RenameFileTest.java | 174 ++++++++++++------ .../lib/test_project/test/UploadFileTest.java | 19 +- 4 files changed, 132 insertions(+), 87 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java index 30a5aa0f..3b77f220 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java @@ -91,42 +91,34 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2" + mCurrentDate; - mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); remotePath = FOLDER_PATH_BASE + "_:" + mCurrentDate; - mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); remotePath = FOLDER_PATH_BASE + "_\"" + mCurrentDate; - mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); remotePath = FOLDER_PATH_BASE + "_|" + mCurrentDate; - mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); remotePath = FOLDER_PATH_BASE + "_?" + mCurrentDate; - mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); remotePath = FOLDER_PATH_BASE + "_*" + mCurrentDate; - mCreatedFolderPaths.add(remotePath); result = mActivity.createFolder(remotePath, true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); } diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java index a63f191e..f6ae428a 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java @@ -25,9 +25,6 @@ package com.owncloud.android.lib.test_project.test; import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import com.owncloud.android.lib.resources.files.RemoteFile; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -56,13 +53,12 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2 mDownloadedFilesPaths; + private String mDownloadedFilePath; private TestActivity mActivity; public DownloadFileTest() { super(TestActivity.class); - mDownloadedFilesPaths = new ArrayList(); } @Override @@ -70,7 +66,7 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2 it = mDownloadedFilesPaths.iterator(); - RemoteOperationResult removeResult = null; - while (it.hasNext()) { - removeResult = mActivity.removeFile(it.next()); + if (mDownloadedFilePath != null) { + RemoteOperationResult removeResult = mActivity.removeFile(mDownloadedFilePath); if (!removeResult.isSuccess()) { Utils.logAndThrow(LOG_TAG, removeResult); } 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 index 8c305371..23b5b276 100644 --- 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 @@ -24,11 +24,15 @@ 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 @@ -38,20 +42,24 @@ import android.test.ActivityInstrumentationTestCase2; 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 final String mOldFolderName = "folderToRename"; - private final String mOldFolderPath = "/folderToRename"; - private final String mNewFolderName = "renamedFolder"; - private final String mNewFolderPath = "/renamedFolder"; - + 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 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 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() { @@ -64,6 +72,29 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2", true); + result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + NEW_FOLDER_NAME + ">", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFolderName, mOldFolderPath, - mNewFolderName + ":", true); + result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + NEW_FOLDER_NAME + ":", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFolderName, mOldFolderPath, - mNewFolderName + "\"", true); + result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + NEW_FOLDER_NAME + "\"", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFolderName, mOldFolderPath, - mNewFolderName + "|", true); + result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + NEW_FOLDER_NAME + "|", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFolderName, mOldFolderPath, - mNewFolderName + "?", true); + result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + NEW_FOLDER_NAME + "?", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFolderName, mOldFolderPath, - mNewFolderName + "*", true); + result = mActivity.renameFile(OLD_FOLDER_NAME, OLD_FOLDER_PATH, + NEW_FOLDER_NAME + "*", true); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); } @@ -118,9 +154,14 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2 : " | ? * */ public void testRenameFileForbiddenChars() { - RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + "\\" + mFileExtension, false); + 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(mOldFileName, mOldFilePath, - mNewFileName + "<" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + "<" + NEW_FILE_NAME, + false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + ">" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + ">" + NEW_FILE_NAME, + false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + ":" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + ":" + NEW_FILE_NAME, + false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + "\"" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + "\"" + NEW_FILE_NAME, + false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + "|" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + "|" + NEW_FILE_NAME, + false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + "?" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + "?" + NEW_FILE_NAME, + false); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileName + "*" + mFileExtension, false); + result = mActivity.renameFile( + OLD_FILE_NAME, + OLD_FILE_PATH, + "*" + NEW_FILE_NAME, 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()); + @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 index a4028a6f..5a69f0d2 100644 --- 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 @@ -25,9 +25,6 @@ package com.owncloud.android.lib.test_project.test; import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import android.test.ActivityInstrumentationTestCase2; @@ -54,12 +51,11 @@ public class UploadFileTest extends ActivityInstrumentationTestCase2 mUploadedFilesPaths; + private String mUploadedFilePath; public UploadFileTest() { super(TestActivity.class); - mUploadedFilesPaths = new ArrayList(); } @Override @@ -67,7 +63,7 @@ public class UploadFileTest extends ActivityInstrumentationTestCase2 it = mUploadedFilesPaths.iterator(); - RemoteOperationResult removeResult = null; - while (it.hasNext()) { - removeResult = mActivity.removeFile(it.next()); + if (mUploadedFilePath != null) { + RemoteOperationResult removeResult = mActivity.removeFile(mUploadedFilePath); if (!removeResult.isSuccess()) { Utils.logAndThrow(LOG_TAG, removeResult); } From 309043774e7d2a5f2b4f7968c6adbf768471978d Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 13:47:27 +0200 Subject: [PATCH 20/34] Updated CreateShareTest to work with an empty OC server --- .../test_project/test/CreateShareTest.java | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java index fcd9feb0..7220d888 100644 --- a/test_client/tests/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 Date: Wed, 16 Apr 2014 14:04:52 +0200 Subject: [PATCH 21/34] Updated RemoveShareTest to work with an empty OC server --- .../test_project/test/RemoveShareTest.java | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java index 6ee21fc6..27a5fd61 100644 --- a/test_client/tests/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(); + } + } From a94dd3439364b9e9c56b4de2e0f7c43a2ae857ce Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 14:28:58 +0200 Subject: [PATCH 22/34] Updated GetSharesTest to work with an empty OC server --- .../lib/test_project/test/GetSharesTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java index 42125df6..dbcb7777 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java @@ -24,7 +24,10 @@ 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; import android.test.ActivityInstrumentationTestCase2; @@ -38,6 +41,10 @@ import android.test.ActivityInstrumentationTestCase2; public class GetSharesTest 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 Date: Wed, 16 Apr 2014 17:51:29 +0200 Subject: [PATCH 23/34] Updated Travis setup to run automatic tests --- .travis.yml | 37 +++++++++++++++++++++---------------- wait_for_emulator.sh | 17 +++++++++++++++++ 2 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 wait_for_emulator.sh diff --git a/.travis.yml b/.travis.yml index b3df1963..8480ec2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,27 @@ language: java jdk: oraclejdk7 before_install: - # Install base Android SDK - - sudo apt-get update -qq - - sudo apt-get install -qq libstdc++6:i386 lib32z1 - - export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 - - 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 - - rm pom.xml - - android update project -p . - +- sudo apt-get update -qq +- sudo apt-get install -qq libstdc++6:i386 lib32z1 +- export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 +- 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 +- emulator -avd test -ni-skin -no-audio -no-window & +- rm pom.xml +- android update project -p . +before_script: +- ./wait_for_emulator script: - - ant clean - - ant debug - - cd test_client - - ant clean - - ant debug - +- ant clean +- ant debug +- cd test_client/tests +- ant clean debug install test env: global: - secure: M3Zu6Jke2e4snRcnQdEJe7pElA29SH1sRktEFpXZ96YU8i+eeRFd3+m9UImtIrwyOK6Esj8uZlEH1TtRd6sa/W4W87vO+GtUEt4SpCbTbd/pF2HNWno0rfueP+6+CgBvyeVDLYa7JH8fQeQscnDZNSQ73PwEm8/T2v0mDYJGow4= + - secure: f4Kms/mzkYRG4Kp8k6hsvG3Y0ztbJnA2J79OBw3VdqJOKVTzwsxMd1Yh325YDYO7I4HeHxGXy0H4p3rAPzIWr/nrOJ4wmcDwQYDQtVjF7S1ARWsX51FrCEV6A9ec2LAqNCQ8ZC0SoGb+HsmpFCE3uKAxRQt+B5MzOZvKNcvYpMA= + - secure: aF4U20Xlu/rfrbxCmoJAiGh1doYTAZ10UEDmajuinT+ZGSJLivuqD7DDY/00sI6IXWg+J1vL+7jJm4JSYusHPg38UHZ4q92k6RmZycW2ATUzZnGT54O5FRnY67MfVwgVpIMK9UOL/6NEciBHEjlIOL0wbKQiJB++1YtBZOQLGL4= + - secure: N+ECSwNg8v2GsAFJ2y/tCiffauHDpN76zuFI2pDqf0fjmCtJZHu4BH5ArXBHjyHKmgn20a/8eZXcwJaH1HsJ80bo7vDJ2miShjGIQ90hPcdmUiB2XVJcew4f04CtvMDH5o7DRt4ykWArlbPL2rhVag0jotlSidolHBwRFnbDhDY= + matrix: + - COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a diff --git a/wait_for_emulator.sh b/wait_for_emulator.sh new file mode 100644 index 00000000..31788387 --- /dev/null +++ b/wait_for_emulator.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +bootanim="" +failcounter=0 +until [[ "$bootanim" =~ "stopped" ]]; do + bootanim=`adb -e shell getprop init.svc.bootanim 2>&1` + echo "$bootanim" + if [[ "$bootanim" =~ "not found" ]]; then + let "failcounter += 1" + if [[ $failcounter -gt 3 ]]; then + echo "Failed to start emulator" + exit 1 + fi + fi + sleep 1 +done +echo "Done" From dfa5e61f5e2a2809cfb5304e215b0e0b16ebb1d4 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 18:09:12 +0200 Subject: [PATCH 24/34] Fixed type and repeated variable in Travis script --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8480ec2d..c0681607 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ jdk: oraclejdk7 before_install: - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 -- export COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 - 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 @@ -12,7 +11,7 @@ before_install: - rm pom.xml - android update project -p . before_script: -- ./wait_for_emulator +- ./wait_for_emulator.sh script: - ant clean - ant debug From 01061bf58e34fda98c3f86a5525e58529e4133fd Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 19:08:15 +0200 Subject: [PATCH 25/34] Enforce execution permissions for script waiting for Android emulator --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c0681607..f176e268 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ before_install: - rm pom.xml - android update project -p . before_script: +- chmod +x ./wait_for_emulator.sh - ./wait_for_emulator.sh script: - ant clean From 08ede2483bc78cad828d3fbeba5f2042621af3fe Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Wed, 16 Apr 2014 20:23:51 +0200 Subject: [PATCH 26/34] Fixed typo breaking start of emulator --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f176e268..eeab875e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: | bash /dev/stdin --install=$COMPONENTS - source ~/.android-sdk-installer/env - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -- emulator -avd test -ni-skin -no-audio -no-window & +- emulator -avd test -no-skin -no-audio -no-window & - rm pom.xml - android update project -p . before_script: From 800b04d5207e6d5d81c3fa9220b0c6ccd0427fcf Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 21 Apr 2014 11:14:51 +0200 Subject: [PATCH 27/34] Trying to wait more time for the emulator --- wait_for_emulator.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wait_for_emulator.sh b/wait_for_emulator.sh index 31788387..45b6e596 100644 --- a/wait_for_emulator.sh +++ b/wait_for_emulator.sh @@ -2,16 +2,18 @@ bootanim="" failcounter=0 +checkcounter=0 until [[ "$bootanim" =~ "stopped" ]]; do bootanim=`adb -e shell getprop init.svc.bootanim 2>&1` - echo "$bootanim" + echo "($checkcounter) $bootanim" if [[ "$bootanim" =~ "not found" ]]; then let "failcounter += 1" - if [[ $failcounter -gt 3 ]]; then + if [[ $failcounter -gt 300 ]]; then echo "Failed to start emulator" exit 1 fi fi + let "checkcounter += 1" sleep 1 done echo "Done" From 9fabc88ca67ff09fe5e9fc48ff276cb5026a9867 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 21 Apr 2014 12:28:08 +0200 Subject: [PATCH 28/34] Check that tests are working with the right account by commenting teardown --- .../android/lib/test_project/test/CreateFolderTest.java | 3 ++- .../android/lib/test_project/test/UploadFileTest.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java index 3b77f220..c12e6290 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java @@ -126,7 +126,7 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 it = mCreatedFolderPaths.iterator(); + /*Iterator it = mCreatedFolderPaths.iterator(); RemoteOperationResult removeResult = null; while (it.hasNext()) { removeResult = mActivity.removeFile(it.next()); @@ -134,6 +134,7 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 Date: Mon, 21 Apr 2014 13:04:28 +0200 Subject: [PATCH 29/34] Revert "Check that tests are working with the right account by commenting teardown" This reverts commit 9fabc88ca67ff09fe5e9fc48ff276cb5026a9867. --- .../android/lib/test_project/test/CreateFolderTest.java | 3 +-- .../android/lib/test_project/test/UploadFileTest.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java index c12e6290..3b77f220 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java @@ -126,7 +126,7 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 it = mCreatedFolderPaths.iterator(); + Iterator it = mCreatedFolderPaths.iterator(); RemoteOperationResult removeResult = null; while (it.hasNext()) { removeResult = mActivity.removeFile(it.next()); @@ -134,7 +134,6 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 Date: Mon, 21 Apr 2014 13:27:43 +0200 Subject: [PATCH 30/34] Updated Android build tools --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eeab875e..3f5bec25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ env: - secure: aF4U20Xlu/rfrbxCmoJAiGh1doYTAZ10UEDmajuinT+ZGSJLivuqD7DDY/00sI6IXWg+J1vL+7jJm4JSYusHPg38UHZ4q92k6RmZycW2ATUzZnGT54O5FRnY67MfVwgVpIMK9UOL/6NEciBHEjlIOL0wbKQiJB++1YtBZOQLGL4= - secure: N+ECSwNg8v2GsAFJ2y/tCiffauHDpN76zuFI2pDqf0fjmCtJZHu4BH5ArXBHjyHKmgn20a/8eZXcwJaH1HsJ80bo7vDJ2miShjGIQ90hPcdmUiB2XVJcew4f04CtvMDH5o7DRt4ykWArlbPL2rhVag0jotlSidolHBwRFnbDhDY= matrix: - - COMPONENTS=build-tools-18.1.0,android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a + - COMPONENTS=build-tools-19.0.3,android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a From 35f5ae5147f55920b027f4c47a606c5c84014b79 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 21 Apr 2014 15:05:37 +0200 Subject: [PATCH 31/34] Added drive to emulator to allow downloads in tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3f5bec25..f96eea0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ before_install: - 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 +- 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 . From b7dc13e180d07825e0d364e12400da81d443900e Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 22 Apr 2014 10:38:28 +0200 Subject: [PATCH 32/34] Updated ant rules to finish with a failure when a run test is not successful; and enforced failure of DownloadTest, to validate --- .travis.yml | 4 ++-- test_client/tests/custom_rules.xml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test_client/tests/custom_rules.xml diff --git a/.travis.yml b/.travis.yml index f96eea0b..3fc4a307 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ before_install: - 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 +- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window & - rm pom.xml - android update project -p . @@ -17,7 +17,7 @@ script: - ant clean - ant debug - cd test_client/tests -- ant clean debug install test +- ant acceptance-test env: global: - secure: f4Kms/mzkYRG4Kp8k6hsvG3Y0ztbJnA2J79OBw3VdqJOKVTzwsxMd1Yh325YDYO7I4HeHxGXy0H4p3rAPzIWr/nrOJ4wmcDwQYDQtVjF7S1ARWsX51FrCEV6A9ec2LAqNCQ8ZC0SoGb+HsmpFCE3uKAxRQt+B5MzOZvKNcvYpMA= 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 From d253daa1a80b7964004d6fbf58b9cfe958ba5cdf Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 22 Apr 2014 11:01:09 +0200 Subject: [PATCH 33/34] Fix DownloadTest after validating previous commit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3fc4a307..9f906ec0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ before_install: - 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 +- 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 . From bf41cde57c81396baab6150841a6076d11a7e21d Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 22 Apr 2014 11:13:09 +0200 Subject: [PATCH 34/34] Reduced output while waiting for emulator starts --- wait_for_emulator.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wait_for_emulator.sh b/wait_for_emulator.sh index 45b6e596..7f6443c7 100644 --- a/wait_for_emulator.sh +++ b/wait_for_emulator.sh @@ -8,12 +8,12 @@ until [[ "$bootanim" =~ "stopped" ]]; do echo "($checkcounter) $bootanim" if [[ "$bootanim" =~ "not found" ]]; then let "failcounter += 1" - if [[ $failcounter -gt 300 ]]; then + if [[ $failcounter -gt 30 ]]; then echo "Failed to start emulator" exit 1 fi fi let "checkcounter += 1" - sleep 1 + sleep 10 done echo "Done"