Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79151cad6f |
No files matched your search
@@ -22,14 +22,13 @@ steps:
|
||||
- emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
- sed -i s"#server#server#" gradle.properties
|
||||
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport && scripts/deleteOutdatedComments.sh "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
@@ -56,8 +55,6 @@ steps:
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
commands:
|
||||
- BRANCH='stable18' /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
@@ -104,14 +101,13 @@ steps:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport && scripts/deleteOutdatedComments.sh "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
- curl -o codecov.sh https://codecov.io/bash
|
||||
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5
|
||||
@@ -140,8 +136,6 @@ steps:
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
commands:
|
||||
- /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
@@ -192,7 +186,8 @@ steps:
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/runAllScreenshotCombinations "stable" false
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
@@ -214,6 +209,26 @@ steps:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
commands:
|
||||
- BRANCH='stable18' /usr/local/bin/initnc.sh
|
||||
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
|
||||
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
|
||||
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
|
||||
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
|
||||
- su www-data -c "php /var/www/html/occ group:add users"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user1"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user2"
|
||||
- su www-data -c "git clone -b stable18 https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable activity"
|
||||
- su www-data -c "git clone -b stable18 https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable text"
|
||||
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -246,8 +261,8 @@ steps:
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- sed -i s"#5#1#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- scripts/runAllScreenshotCombinations "master" false
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
@@ -269,6 +284,27 @@ steps:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
commands:
|
||||
- /usr/local/bin/initnc.sh
|
||||
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
|
||||
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
|
||||
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
|
||||
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
|
||||
- su www-data -c "php /var/www/html/occ group:add users"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user1"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user2"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable activity"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable text"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -352,7 +388,7 @@ steps:
|
||||
- sed -i "/qa/,/\}/ s/versionCode .*/versionCode $DRONE_BUILD_NUMBER/" build.gradle
|
||||
- sed -i "/qa/,/\}/ s/versionName .*/versionName \"$DRONE_BUILD_NUMBER\"/" build.gradle
|
||||
- ./gradlew assembleQaDebug
|
||||
- $(find /opt/android-sdk-linux/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
- /opt/android-sdk-linux/build-tools/*/apksigner sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
- scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
|
||||
trigger:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# You can add one username per supported platform and one custom link
|
||||
custom: https://nextcloud.com/include/
|
||||
custom: https://www.bountysource.com/teams/nextcloud/issues?tracker_ids=38838206
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install NDK
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install NDK
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Build generic
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -47,5 +47,3 @@ fastlane/Fastfile
|
||||
|
||||
# scan temporary files
|
||||
**/fastlane/test_output
|
||||
/fastlane/vendor/
|
||||
/.bundle/
|
||||
@@ -1,21 +1,3 @@
|
||||
## 3.13.0 (August, 18, 2020)
|
||||
|
||||
- new UI overhaul @Shagequi @JorisBodin
|
||||
- E2EE beta support
|
||||
- dark mode enhancement @AndyScherzinger
|
||||
- warn on outdated NC16 server
|
||||
- requires Android 4.3 or newer
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/48
|
||||
|
||||
## 3.12.1 (July, 07, 2020)
|
||||
|
||||
- UI does not hang when changing auto upload
|
||||
- fix crash on contacts backup settings
|
||||
- bugfixes
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/49
|
||||
|
||||
## 3.12.0 (June, 10, 2020)
|
||||
|
||||
- add circle support for searching/displaying
|
||||
|
||||
@@ -379,7 +379,6 @@ Generally, whenever you need:
|
||||
* media playback
|
||||
* networking
|
||||
* logging
|
||||
* notifications management
|
||||
|
||||
we have something more suitable.
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Autogenerated by fastlane
|
||||
#
|
||||
# Ensure this file is checked in to source control!
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem 'fastlane'
|
||||
|
||||
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
|
||||
eval_gemfile(plugins_path) if File.exist?(plugins_path)
|
||||
@@ -1,180 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.2)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.1.0)
|
||||
aws-partitions (1.343.0)
|
||||
aws-sdk-core (3.104.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.239.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.36.0)
|
||||
aws-sdk-core (~> 3, >= 3.99.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.75.0)
|
||||
aws-sdk-core (~> 3, >= 3.104.1)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sigv4 (1.2.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.3)
|
||||
claide (1.0.3)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander-fastlane (4.4.6)
|
||||
highline (~> 1.7.2)
|
||||
declarative (0.0.20)
|
||||
declarative-option (0.1.0)
|
||||
digest-crc (0.6.1)
|
||||
rake (~> 13.0)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.7.6)
|
||||
emoji_regex (3.0.0)
|
||||
excon (0.75.0)
|
||||
faraday (0.17.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-cookie_jar (0.0.6)
|
||||
faraday (>= 0.7.4)
|
||||
http-cookie (~> 1.0.0)
|
||||
faraday_middleware (0.14.0)
|
||||
faraday (>= 0.7.4, < 1.0)
|
||||
fastimage (2.1.7)
|
||||
fastlane (2.152.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.3, < 3.0.0)
|
||||
aws-sdk-s3 (~> 1.0)
|
||||
babosa (>= 1.0.3, < 2.0.0)
|
||||
bundler (>= 1.12.0, < 3.0.0)
|
||||
colored
|
||||
commander-fastlane (>= 4.4.6, < 5.0.0)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 1.0.0)
|
||||
faraday (>= 0.17, < 1.0)
|
||||
faraday-cookie_jar (~> 0.0.6)
|
||||
faraday_middleware (>= 0.13.1, < 2.0)
|
||||
fastimage (>= 2.1.0, < 3.0.0)
|
||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||
google-api-client (>= 0.37.0, < 0.39.0)
|
||||
google-cloud-storage (>= 1.15.0, < 2.0.0)
|
||||
highline (>= 1.7.2, < 2.0.0)
|
||||
json (< 3.0.0)
|
||||
jwt (>= 2.1.0, < 3)
|
||||
mini_magick (>= 4.9.4, < 5.0.0)
|
||||
multipart-post (~> 2.0.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
rubyzip (>= 2.0.0, < 3.0.0)
|
||||
security (= 0.1.3)
|
||||
simctl (~> 1.6.3)
|
||||
slack-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-table (>= 1.4.5, < 2.0.0)
|
||||
tty-screen (>= 0.6.3, < 1.0.0)
|
||||
tty-spinner (>= 0.8.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.3.0)
|
||||
xcpretty-travis-formatter (>= 0.0.3)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.9)
|
||||
gh_inspector (1.1.3)
|
||||
google-api-client (0.38.0)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
googleauth (~> 0.9)
|
||||
httpclient (>= 2.8.1, < 3.0)
|
||||
mini_mime (~> 1.0)
|
||||
representable (~> 3.0)
|
||||
retriable (>= 2.0, < 4.0)
|
||||
signet (~> 0.12)
|
||||
google-cloud-core (1.5.0)
|
||||
google-cloud-env (~> 1.0)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (1.3.3)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
google-cloud-errors (1.0.1)
|
||||
google-cloud-storage (1.26.2)
|
||||
addressable (~> 2.5)
|
||||
digest-crc (~> 0.4)
|
||||
google-api-client (~> 0.33)
|
||||
google-cloud-core (~> 1.2)
|
||||
googleauth (~> 0.9)
|
||||
mini_mime (~> 1.0)
|
||||
googleauth (0.13.0)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
jwt (>= 1.4, < 3.0)
|
||||
memoist (~> 0.16)
|
||||
multi_json (~> 1.11)
|
||||
os (>= 0.9, < 2.0)
|
||||
signet (~> 0.14)
|
||||
highline (1.7.10)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.4.0)
|
||||
json (2.3.1)
|
||||
jwt (2.2.1)
|
||||
memoist (0.16.2)
|
||||
mini_magick (4.10.1)
|
||||
mini_mime (1.0.2)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.0.0)
|
||||
nanaimo (0.3.0)
|
||||
naturally (2.2.0)
|
||||
os (1.1.0)
|
||||
plist (3.5.0)
|
||||
public_suffix (4.0.5)
|
||||
rake (13.0.1)
|
||||
representable (3.0.4)
|
||||
declarative (< 0.1.0)
|
||||
declarative-option (< 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.1.2)
|
||||
rouge (2.0.7)
|
||||
rubyzip (2.3.0)
|
||||
security (0.1.3)
|
||||
signet (0.14.0)
|
||||
addressable (~> 2.3)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.8)
|
||||
CFPropertyList
|
||||
naturally
|
||||
slack-notifier (2.3.2)
|
||||
terminal-notifier (2.0.0)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
tty-cursor (0.7.1)
|
||||
tty-screen (0.8.1)
|
||||
tty-spinner (0.9.3)
|
||||
tty-cursor (~> 0.7)
|
||||
uber (0.1.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.7)
|
||||
unicode-display_width (1.7.0)
|
||||
word_wrap (1.0.0)
|
||||
xcodeproj (1.17.1)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.3.0)
|
||||
xcpretty (0.3.0)
|
||||
rouge (~> 2.0.7)
|
||||
xcpretty-travis-formatter (1.0.0)
|
||||
xcpretty (~> 0.2, >= 0.0.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
fastlane
|
||||
fastlane-plugin-huawei_appgallery_connect
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
||||
@@ -1,14 +1,13 @@
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
|
||||
// Gradle build file
|
||||
//
|
||||
// This project was started in Eclipse and later moved to Android Studio. In the transition, both IDEs were supported.
|
||||
// Due to this, the files layout is not the usual in new projects created with Android Studio / gradle. This file
|
||||
// merges declarations usually split in two separates build.gradle file, one for global settings of the project in
|
||||
// its root folder, another one for the app module in subfolder of root.
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.4.0'
|
||||
ext.kotlin_version = '1.3.72'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
@@ -21,11 +20,13 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath('com.hiya:jacoco-android:0.2')
|
||||
classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.0'
|
||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.4') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.11.2"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.9.1"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:4.3.0'
|
||||
}
|
||||
@@ -38,7 +39,7 @@ apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'pmd'
|
||||
apply plugin: 'com.hiya.jacoco-android'
|
||||
apply plugin: 'jacoco-android'
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
apply plugin: 'shot'
|
||||
@@ -50,7 +51,7 @@ configurations {
|
||||
exclude group: 'com.google.firebase', module: 'firebase-core'
|
||||
exclude group: 'com.google.firebase', module: 'firebase-analytics'
|
||||
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitely
|
||||
|
||||
// check for updates every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
@@ -59,16 +60,15 @@ configurations {
|
||||
|
||||
ext {
|
||||
jacocoVersion = "0.8.2"
|
||||
daggerVersion = "2.28.3"
|
||||
markwonVersion = "4.5.1"
|
||||
daggerVersion = "2.27"
|
||||
markwonVersion = "4.4.0"
|
||||
prismVersion = "2.0.0"
|
||||
butterknifeVersion = "10.2.3"
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
// allows for -D pre-dex=false to be set
|
||||
preDexEnabled = "true" == System.getProperty("pre-dex", "true")
|
||||
// allows for -Dpre-dex=false to be set
|
||||
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -84,7 +84,7 @@ repositories {
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 14
|
||||
def versionMinor = 13
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
@@ -99,7 +99,9 @@ for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '3.1.12'
|
||||
}
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
@@ -124,7 +126,7 @@ android {
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 18
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 29
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
@@ -194,7 +196,7 @@ android {
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
dexOptions {
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -D pre-dex=false.
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
|
||||
preDexLibraries = preDexEnabled && !travisBuild
|
||||
}
|
||||
|
||||
@@ -236,33 +238,41 @@ android {
|
||||
android.applicationVariants.all { variant ->
|
||||
String variantName = variant.name
|
||||
String capVariantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1)
|
||||
tasks.register("spotbugs${capVariantName}Report", SpotBugsTask) {
|
||||
tasks.register("spotbugs${capVariantName}", SpotBugsTask) {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = "max"
|
||||
reportLevel = "medium"
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
|
||||
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
|
||||
pluginClasspath = project.configurations.spotbugsPlugins
|
||||
source = fileTree('src/main/java')
|
||||
classpath = files()
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = true
|
||||
html {
|
||||
enabled = true
|
||||
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
viewBinding true
|
||||
dataBinding {
|
||||
enabled true
|
||||
}
|
||||
|
||||
viewBinding {
|
||||
enabled true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,24 +296,23 @@ dependencies {
|
||||
compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2
|
||||
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.1' // remove after entire switch to lib v2
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0-rc01'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.2.0'
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
|
||||
implementation "androidx.work:work-runtime:2.4.0"
|
||||
implementation "androidx.work:work-runtime-ktx:2.4.0"
|
||||
implementation "androidx.fragment:fragment:1.2.5"
|
||||
implementation "androidx.work:work-runtime:2.3.4"
|
||||
implementation "androidx.work:work-runtime-ktx:2.3.4"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.7'
|
||||
implementation "com.jakewharton:butterknife:$butterknifeVersion"
|
||||
kapt "com.jakewharton:butterknife-compiler:$butterknifeVersion"
|
||||
implementation 'com.jakewharton:butterknife:10.2.1'
|
||||
kapt 'com.jakewharton:butterknife-compiler:10.2.1'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.0'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.6'
|
||||
implementation 'org.lukhnos:nnio:0.2'
|
||||
implementation 'org.bouncycastle:bcpkix-jdk15on:1.65'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
@@ -321,8 +330,7 @@ dependencies {
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:4.1.0'
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido2:4.1.0'
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:2.5.1'
|
||||
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
|
||||
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
|
||||
@@ -333,8 +341,8 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.38.1"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.5.0'
|
||||
ktlint "com.pinterest:ktlint:0.36.0"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.4.0'
|
||||
|
||||
// Shimmer animation
|
||||
implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0'
|
||||
@@ -352,16 +360,16 @@ dependencies {
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.13'
|
||||
testImplementation 'org.mockito:mockito-core:3.4.6'
|
||||
testImplementation 'org.mockito:mockito-core:3.3.3'
|
||||
testImplementation 'androidx.test:core:1.2.0'
|
||||
testImplementation 'org.powermock:powermock-core:2.0.7'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
|
||||
testImplementation 'org.powermock:powermock-api-mockito2:2.0.7'
|
||||
testImplementation 'org.json:json:20200518'
|
||||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
testImplementation 'androidx.arch.core:core-testing:2.1.0'
|
||||
testImplementation 'io.mockk:mockk:1.10.0'
|
||||
testImplementation 'io.mockk:mockk-android:1.10.0'
|
||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||
kaptAndroidTest "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kaptTest "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
@@ -374,20 +382,7 @@ dependencies {
|
||||
// Espresso core
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
|
||||
|
||||
// Mocking support
|
||||
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
||||
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
androidTestImplementation 'org.mockito:mockito-core:3.4.4'
|
||||
androidTestImplementation("org.mockito:mockito-android:3.4.6") {
|
||||
exclude group: "net.bytebuddy", module: "byte-buddy-android"
|
||||
}
|
||||
androidTestImplementation 'net.bytebuddy:byte-buddy:1.10.14'
|
||||
androidTestImplementation "net.bytebuddy:byte-buddy-android:1.10.14"
|
||||
androidTestImplementation "io.mockk:mockk-android:1.10.0"
|
||||
androidTestImplementation 'androidx.arch.core:core-testing:2.0.1'
|
||||
|
||||
androidTestImplementation 'org.mockito:mockito-core:3.3.1'
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
// androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
@@ -405,10 +400,9 @@ dependencies {
|
||||
// androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '3.1.12'
|
||||
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
androidTestImplementation "org.mockito:mockito-android:3.3.3"
|
||||
androidTestImplementation 'net.bytebuddy:byte-buddy:1.10.11'
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
@@ -431,15 +425,17 @@ android.applicationVariants.all { variant ->
|
||||
tasks.register("combinedTestReport", JacocoReport) {
|
||||
|
||||
reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
csv.enabled false
|
||||
xml.enabled = true
|
||||
html.enabled = true
|
||||
}
|
||||
|
||||
additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
classDirectories.setFrom files(subprojects.sourceSets.main.output)
|
||||
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
|
||||
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
|
||||
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
|
||||
def mainSrc = "$project.projectDir/src/main/java"
|
||||
|
||||
sourceDirectories = files([mainSrc])
|
||||
classDirectories = files([debugTree])
|
||||
executionData = fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ complexity:
|
||||
ignoreStringsRegex: '$^'
|
||||
TooManyFunctions:
|
||||
active: true
|
||||
thresholdInFiles: 15
|
||||
thresholdInClasses: 15
|
||||
thresholdInInterfaces: 15
|
||||
thresholdInObjects: 15
|
||||
thresholdInFiles: 11
|
||||
thresholdInClasses: 11
|
||||
thresholdInInterfaces: 11
|
||||
thresholdInObjects: 11
|
||||
thresholdInEnums: 11
|
||||
ignoreDeprecated: true
|
||||
ignoreDeprecated: false
|
||||
ignorePrivate: false
|
||||
ignoreOverridden: true
|
||||
ignoreOverridden: false
|
||||
|
||||
empty-blocks:
|
||||
active: true
|
||||
|
||||
@@ -8,9 +8,6 @@ fastlane_version "2.58.0"
|
||||
# export FASTLANE_NEXTCLOUD_KEY_ALIAS=""
|
||||
# export FASTLANE_NEXTCLOUD_KEY_PASSWORD=""
|
||||
# export FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN=""
|
||||
# export FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_ID=""
|
||||
# export FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_SECRET=""
|
||||
# export FASTLANE_NEXTCLOUD_HUAWEI_APP_ID=""
|
||||
|
||||
skip_docs
|
||||
|
||||
@@ -39,14 +36,19 @@ lane :screenshotsTablet do
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for RC, then test it"
|
||||
lane :RC_releasePhase1 do
|
||||
lane :releasePhase1_RC do
|
||||
disableLogger()
|
||||
makeReleases()
|
||||
enableLogger()
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for FINAL, then test it"
|
||||
lane :releasePhase1_Final do
|
||||
makeReleases()
|
||||
end
|
||||
|
||||
desc "Release phase 2 for RC: checks, tag, upload gplay to playstore with values from build.gradle"
|
||||
lane :RC_releasePhase2 do |options|
|
||||
lane :releasePhase2_RC do |options|
|
||||
info = androidVersion
|
||||
checkChangelog(info)
|
||||
checkLibrary_RC()
|
||||
@@ -59,13 +61,8 @@ lane :RC_releasePhase2 do |options|
|
||||
createChangelogPullRequest_RC(info)
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for FINAL, then test it"
|
||||
lane :Final_releasePhase1 do
|
||||
makeReleases()
|
||||
end
|
||||
|
||||
desc "Release phase 2 for FINAL: checks, tag, upload gplay to playstore with values from build.gradle"
|
||||
lane :Final_releasePhase2 do |options|
|
||||
lane :releasePhase2_Final do |options|
|
||||
info = androidVersion
|
||||
checkChangelog(info)
|
||||
checkLibrary_Final()
|
||||
@@ -73,7 +70,6 @@ lane :Final_releasePhase2 do |options|
|
||||
checkIfAPKexists()
|
||||
tag(info)
|
||||
uploadToPlaystore_Final(info)
|
||||
uploadToHuawei_Final(info)
|
||||
createGithubRelease_Final(info)
|
||||
fdroidMergeRequest_Final(info)
|
||||
createChangelogPullRequest_Final(info)
|
||||
@@ -120,19 +116,6 @@ lane :beautifyPhone do
|
||||
sh("adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false -e level 100")
|
||||
end
|
||||
|
||||
# to install
|
||||
# bundle exec fastlane add_plugin huawei_appgallery_connect
|
||||
# bundle install --path build/vendor/bundle
|
||||
private_lane :uploadToHuawei_Final do |options|
|
||||
huawei_appgallery_connect(
|
||||
client_id: ENV["FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_ID"],
|
||||
client_secret: ENV["FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_SECRET"],
|
||||
app_id: ENV["FASTLANE_NEXTCLOUD_HUAWEI_APP_ID"],
|
||||
apk_path: "release/nextcloud-" + options["versionCode"] + ".apk",
|
||||
submit_for_review: true,
|
||||
)
|
||||
end
|
||||
|
||||
## private lanes
|
||||
|
||||
desc "Build debug and test APK for screenshots"
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# Autogenerated by fastlane
|
||||
#
|
||||
# Ensure this file is checked in to source control!
|
||||
|
||||
gem 'fastlane-plugin-huawei_appgallery_connect'
|
||||
gem 'fastlane-plugin-huawei_appgallery_connect'
|
||||
@@ -1,6 +1,6 @@
|
||||
#Fri May 29 07:39:21 CEST 2020
|
||||
#Wed Aug 21 07:03:37 CEST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
@@ -55,12 +55,4 @@
|
||||
<issue id="NewApi" severity="error">
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<issue id="ObsoleteLintCustomCheck" severity="warning">
|
||||
<ignore path="**/fragment-1.2.5/**/lint.jar" />
|
||||
<ignore path="**/work-runtime-2.**/**/lint.jar" />
|
||||
<ignore path="**/jetified-butterknife-runtime-10.**/**/lint.jar" />
|
||||
<ignore path="**/jetified-dagger-lint-aar-2.28.**/**/lint.jar" />
|
||||
<ignore path="**/jetified-annotation-experimental-1.**/**/lint.jar" />
|
||||
</issue>
|
||||
</lint>
|
||||
|
After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1 +1 @@
|
||||
329
|
||||
373
|
||||
@@ -47,7 +47,7 @@ require 'xmlsimple'
|
||||
|
||||
# run FindBugs
|
||||
puts "running FindBugs..."
|
||||
system './gradlew assembleGplayDebug 1>/dev/null'
|
||||
system './gradlew assembleGplayDebug'
|
||||
|
||||
# confirm that assemble ran w/out error
|
||||
result = $?.to_i
|
||||
@@ -56,7 +56,7 @@ if result != 0
|
||||
exit 1
|
||||
end
|
||||
|
||||
system './gradlew spotbugsGplayDebugReport 1>/dev/null 2>&1'
|
||||
system './gradlew spotbugsGplayDebug'
|
||||
|
||||
# find FindBugs report file
|
||||
findbugs_reports = Dir.glob(FINDBUGS_REPORT_FILE)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 81 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 95 warnings</span>
|
||||
@@ -56,7 +56,7 @@ end
|
||||
|
||||
# run Lint
|
||||
puts "running Lint..."
|
||||
system './gradlew clean lint 1>/dev/null'
|
||||
system './gradlew clean lint'
|
||||
|
||||
# confirm that Lint ran w/out error
|
||||
result = $?.to_i
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "1: record: true/false
|
||||
2: class name
|
||||
3: method name
|
||||
4: darkMode / \"all\" to run all screenshot combinations
|
||||
5: color"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
|
||||
emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 &
|
||||
|
||||
cd src/androidTest/java
|
||||
|
||||
class=$(find | grep $2 | grep -E "java$|kt$" | head -n1|sed s'/\//\./'g | sed s'#^\.\.##' | sed s'#\.java##'| sed s'#\.kt##')
|
||||
|
||||
if [[ -z $class ]]; then
|
||||
echo "Class not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ../../../
|
||||
|
||||
if [ $1 == "true" ] ; then
|
||||
record="-Precord"
|
||||
else
|
||||
record=""
|
||||
fi
|
||||
|
||||
if [ -e $3 ] ; then
|
||||
method=""
|
||||
else
|
||||
method="#$3"
|
||||
|
||||
# check if method exists
|
||||
if [[ $(grep -c $3 $(find | grep $2 | grep -E "java$|kt$" | head -n1)) -eq 0 ]]; then
|
||||
echo "Method not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e $4 ] ; then
|
||||
darkMode=""
|
||||
else
|
||||
darkMode="-Pandroid.testInstrumentationRunnerArguments.DARKMODE=$4"
|
||||
fi
|
||||
|
||||
if [ -e $5 ] ; then
|
||||
color=""
|
||||
else
|
||||
color="-Pandroid.testInstrumentationRunnerArguments.COLOR=$5"
|
||||
fi
|
||||
|
||||
if [[ $4 = "all" ]]; then
|
||||
scripts/runAllScreenshotCombinations "noCI" "$1" "-Pandroid.testInstrumentationRunnerArguments.class=$class$method"
|
||||
else
|
||||
./gradlew gplayDebugExecuteScreenshotTests $record \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=$class$method \
|
||||
$darkMode \
|
||||
$color
|
||||
fi
|
||||
|
||||
|
||||
sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g src/main/res/values/setup.xml
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BRANCH=$1
|
||||
TYPE=$2
|
||||
PR=$3
|
||||
GITHUB_USER=$4
|
||||
GITHUB_PASSWORD=$5
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
|
||||
# delete all old comments, matching this type
|
||||
oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## $1 noCI/stable/master: wether to run deleteOutdatedComments.sh or uploadReport.sh
|
||||
## $2 true/false: record or verify screenshots
|
||||
## $3 classMethod: piped from androidScreenshotTest
|
||||
|
||||
if [[ $2 = "true" ]]; then
|
||||
record="-Precord"
|
||||
else
|
||||
record=""
|
||||
fi
|
||||
|
||||
classMethod=$3
|
||||
|
||||
while read line
|
||||
do
|
||||
darkMode=$(echo "$line" | cut -d" " -f1)
|
||||
color=$(echo "$line" | cut -d" " -f2)
|
||||
|
||||
echo "Run $color on $darkMode mode"
|
||||
|
||||
if [[ $1 = "noCI" ]]; then
|
||||
./gradlew --console plain gplayDebugExecuteScreenshotTests \
|
||||
$record \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
||||
-Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \
|
||||
-Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" \
|
||||
$classMethod </dev/null > /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
./gradlew gplayDebugExecuteScreenshotTests \
|
||||
$record \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
||||
-Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \
|
||||
-Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" \
|
||||
&& scripts/deleteOutdatedComments.sh "$1-$darkMode-$color" "Screenshot" "$DRONE_PULL_REQUEST" \
|
||||
"$GIT_USERNAME" "$GIT_TOKEN" \
|
||||
|| scripts/uploadReport.sh "$LOG_USERNAME" "$LOG_PASSWORD" "$DRONE_BUILD_NUMBER" \
|
||||
"$1-$darkMode-$color" "Screenshot" "$DRONE_PULL_REQUEST" "$GIT_USERNAME" "$GIT_TOKEN"
|
||||
fi
|
||||
done < scripts/screenshotCombinations
|
||||
@@ -1 +0,0 @@
|
||||
light blue
|
||||
@@ -74,7 +74,7 @@ sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g
|
||||
|
||||
## update/create all screenshots
|
||||
#./gradlew gplayDebugExecuteScreenshotTests -Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest
|
||||
#-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotOnServerTest
|
||||
|
||||
## update screenshots in a class
|
||||
#./gradlew gplayDebugExecuteScreenshotTests \
|
||||
@@ -94,7 +94,7 @@ until [ $resultCode -eq 0 ] || [ $retryCount -gt 2 ]
|
||||
do
|
||||
# test all screenshots
|
||||
./gradlew gplayDebugExecuteScreenshotTests \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotOnServerTest
|
||||
|
||||
resultCode=$?
|
||||
((retryCount++))
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## emulator
|
||||
if [[ ! $(emulator -list-avds | grep uiComparison -c) -eq 0 ]]; then
|
||||
avdmanager delete avd -n uiComparison
|
||||
(sleep 5; echo "no") | avdmanager create avd -n uiComparison -c 100M -k "system-images;android-27;google_apis;x86" --abi "google_apis/x86"
|
||||
fi
|
||||
|
||||
if [ "$1" == "debug" ]; then
|
||||
emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 1>/dev/null &
|
||||
else
|
||||
emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 1>/dev/null &
|
||||
fi
|
||||
PID=$!
|
||||
|
||||
scripts/wait_for_emulator.sh
|
||||
|
||||
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
|
||||
## update/create all screenshots
|
||||
#./gradlew gplayDebugExecuteScreenshotTests -Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotWithoutServerTest
|
||||
|
||||
## update screenshots in a class
|
||||
#./gradlew gplayDebugExecuteScreenshotTests \
|
||||
#-Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.class=\
|
||||
#com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest
|
||||
|
||||
## update single screenshot within a class
|
||||
#./gradlew gplayDebugExecuteScreenshotTests \
|
||||
#-Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.class=\
|
||||
#com.nextcloud.client.FileDisplayActivityIT#showShares
|
||||
|
||||
resultCode=-1
|
||||
retryCount=0
|
||||
until [ $resultCode -eq 0 ] || [ $retryCount -gt 2 ]
|
||||
do
|
||||
# test all screenshots
|
||||
./gradlew gplayDebugRemoveScreenshots
|
||||
./gradlew gplayDebugExecuteScreenshotTests \
|
||||
-Precord \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotWithoutServerTest
|
||||
|
||||
resultCode=$?
|
||||
((retryCount++))
|
||||
done
|
||||
|
||||
sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g src/main/res/values/setup.xml
|
||||
|
||||
if [ "$1" == "debug" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# tidy up
|
||||
kill "$PID"
|
||||
@@ -1,21 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
deleteOldComments() {
|
||||
# delete all old comments, matching this type
|
||||
echo "Deleting old comments for $BRANCH_TYPE"
|
||||
oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
count=$(echo $oldComments | grep true | wc -l)
|
||||
echo "Found $count old comments"
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
echo "Deleting comment: $comment"
|
||||
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
}
|
||||
|
||||
upload() {
|
||||
deleteOldComments
|
||||
|
||||
cd $1
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
|
||||
@@ -24,7 +9,7 @@ upload() {
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
|
||||
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
||||
-d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
||||
|
||||
exit 1
|
||||
}
|
||||
@@ -32,11 +17,10 @@ upload() {
|
||||
#1: LOG_USERNAME
|
||||
#2: LOG_PASSWORD
|
||||
#3: DRONE_BUILD_NUMBER
|
||||
#4: BRANCH (stable or master)
|
||||
#5: TYPE (IT or Unit)
|
||||
#6: DRONE_PULL_REQUEST
|
||||
#7: GIT_USERNAME
|
||||
#8: GIT_TOKEN
|
||||
#4: TYPE (IT or Unit)
|
||||
#5: DRONE_PULL_REQUEST
|
||||
#6: GIT_USERNAME
|
||||
#7: GIT_TOKEN
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
||||
ID=$3
|
||||
@@ -47,8 +31,7 @@ TYPE=$5
|
||||
PR=$6
|
||||
GITHUB_USER=$7
|
||||
GITHUB_PASSWORD=$8
|
||||
REMOTE_FOLDER=$ID-$TYPE-$BRANCH
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
REMOTE_FOLDER=$ID-$TYPE
|
||||
|
||||
set -e
|
||||
|
||||
@@ -63,28 +46,24 @@ fi
|
||||
if [ -e $FOLDER ]; then
|
||||
upload $FOLDER
|
||||
else
|
||||
deleteOldComments
|
||||
echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
echo "$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD \
|
||||
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
-d "{ \"body\" : \"$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
|
||||
if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
|
||||
TYPE="IT"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/androidTests/connected/flavors/GPLAY"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
|
||||
TYPE="Unit"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/tests/testGplayDebugUnitTest"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/shot/verification ] ; then
|
||||
TYPE="Screenshot"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/shot/verification"
|
||||
fi
|
||||
fi
|
||||
@@ -32,7 +32,6 @@
|
||||
<Or>
|
||||
<Class name="~.*BindingImpl"/>
|
||||
<Class name="~.*\.DataBinderMapperImpl" />
|
||||
<Class name="~.*Binding" />
|
||||
</Or>
|
||||
</Match>
|
||||
|
||||
|
||||
@@ -31,4 +31,6 @@
|
||||
android:sharedUserId="${applicationId}.uid">
|
||||
|
||||
<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator, tools.fastlane.screengrab" />
|
||||
|
||||
<application android:name="com.owncloud.android.TestApp"></application>
|
||||
</manifest>
|
||||
@@ -1,17 +0,0 @@
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
N:Mustermann;Erika;;Dr.;
|
||||
FN:Dr. Erika Mustermann
|
||||
ORG:Wikimedia
|
||||
ROLE:Kommunikation
|
||||
TITLE:Redaktion & Gestaltung
|
||||
PHOTO;VALUE=URL;TYPE=JPEG:http://commons.wikimedia.org/wiki/File:Erika_Mustermann_2010.jpg
|
||||
TEL;TYPE=WORK,VOICE:+49 221 9999123
|
||||
TEL;TYPE=HOME,VOICE:+49 221 1234567
|
||||
ADR;TYPE=HOME:;;Heidestraße 17;Köln;;51147;Germany
|
||||
EMAIL;TYPE=PREF,INTERNET:[email protected]
|
||||
URL:http://de.wikipedia.org/
|
||||
REV:2014-03-01T22:11:10Z
|
||||
END:VCARD
|
||||
|
||||
## from https://de.wikipedia.org/wiki/VCard#vCard_3.0 on 27.07.2020
|
||||
@@ -23,12 +23,13 @@
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activities.ActivitiesActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithoutServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -51,6 +52,18 @@ public class ActivitiesActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithoutServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
ActivitiesActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithoutServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
ActivitiesActivity sut = activityRule.launchActivity(null);
|
||||
@@ -59,13 +72,8 @@ public class ActivitiesActivityIT extends AbstractIT {
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
sut.runOnUiThread(() -> {
|
||||
sut.emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
sut.recyclerView.setVisibility(View.INVISIBLE);
|
||||
});
|
||||
shortSleep();
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut);
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
}
|
||||
@@ -24,24 +24,18 @@ package com.nextcloud.client;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.GetPrivateKeyOperation;
|
||||
import com.owncloud.android.lib.resources.users.GetPublicKeyOperation;
|
||||
import com.owncloud.android.lib.resources.users.SendCSROperation;
|
||||
import com.owncloud.android.lib.resources.users.StorePrivateKeyOperation;
|
||||
import com.owncloud.android.operations.DownloadFileOperation;
|
||||
import com.owncloud.android.operations.GetCapabilitiesOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.utils.CsrHelper;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
@@ -58,24 +52,19 @@ import java.io.IOException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PrivateKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.owncloud.android.lib.resources.status.OwnCloudVersion.nextcloud_19;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
public class EndToEndRandomIT extends AbstractIT {
|
||||
public enum Action {
|
||||
CREATE_FOLDER,
|
||||
GO_INTO_FOLDER,
|
||||
GO_UP,
|
||||
UPLOAD_FILE,
|
||||
DOWNLOAD_FILE,
|
||||
DELETE_FILE,
|
||||
UPLOAD_FILE
|
||||
}
|
||||
|
||||
private static ArbitraryDataProvider arbitraryDataProvider;
|
||||
@@ -90,13 +79,7 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
OCCapability capability = getStorageManager().getCapability(account.name);
|
||||
|
||||
if (capability.getVersion().equals(new OwnCloudVersion("0.0.0"))) {
|
||||
// fetch new one
|
||||
assertTrue(new GetCapabilitiesOperation().execute(client, getStorageManager()).isSuccess());
|
||||
}
|
||||
public void before() {
|
||||
// tests only for NC19+
|
||||
assumeTrue(getStorageManager()
|
||||
.getCapability(account.name)
|
||||
@@ -104,8 +87,6 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
.isNewerOrEqual(nextcloud_19)
|
||||
);
|
||||
|
||||
// make sure that every file is available, even after tests that remove source file
|
||||
createDummyFiles();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,14 +113,6 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
uploadFile(i);
|
||||
break;
|
||||
|
||||
case DOWNLOAD_FILE:
|
||||
downloadFile(i);
|
||||
break;
|
||||
|
||||
case DELETE_FILE:
|
||||
deleteFile(i);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "]" + " Unknown action: " + nextAction);
|
||||
break;
|
||||
@@ -225,14 +198,6 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
deleteFile(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downloadFile() throws Exception {
|
||||
init();
|
||||
|
||||
uploadFile(1);
|
||||
downloadFile(1);
|
||||
}
|
||||
|
||||
private void init() throws Exception {
|
||||
// create folder
|
||||
createFolder(rootEncFolder);
|
||||
@@ -295,149 +260,17 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
|
||||
private void uploadFile(int i) throws IOException {
|
||||
String fileName = RandomString.make(5) + ".txt";
|
||||
|
||||
File file;
|
||||
if (new Random().nextBoolean()) {
|
||||
file = createFile(fileName, new Random().nextInt(50000));
|
||||
} else {
|
||||
file = createFile(fileName, 500000 + new Random().nextInt(50000));
|
||||
}
|
||||
|
||||
String remotePath = currentFolder.getRemotePath() + fileName;
|
||||
createFile(fileName, new Random().nextInt(50000));
|
||||
String path = currentFolder.getRemotePath() + fileName;
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " +
|
||||
"Upload file to: " + currentFolder.getDecryptedRemotePath() + fileName);
|
||||
|
||||
OCUpload ocUpload = new OCUpload(file.getAbsolutePath(),
|
||||
remotePath,
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + File.separator + fileName,
|
||||
path,
|
||||
account.name);
|
||||
uploadOCUpload(ocUpload);
|
||||
shortSleep();
|
||||
|
||||
OCFile parentFolder = getStorageManager()
|
||||
.getFileByEncryptedRemotePath(new File(ocUpload.getRemotePath()).getParent() + "/");
|
||||
String uploadedFileName = new File(ocUpload.getRemotePath()).getName();
|
||||
|
||||
String decryptedPath = parentFolder.getDecryptedRemotePath() + uploadedFileName;
|
||||
|
||||
OCFile uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
|
||||
verifyStoragePath(uploadedFile);
|
||||
|
||||
// verify storage path
|
||||
refreshFolder(currentFolder.getRemotePath());
|
||||
uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
|
||||
verifyStoragePath(uploadedFile);
|
||||
|
||||
// verify that encrypted file is on server
|
||||
assertTrue(new ReadFileRemoteOperation(currentFolder.getRemotePath() + uploadedFile.getEncryptedFileName())
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
// verify that unencrypted file is not on server
|
||||
assertFalse(new ReadFileRemoteOperation(currentFolder.getDecryptedRemotePath() + fileName)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
private void downloadFile(int i) {
|
||||
ArrayList<OCFile> files = new ArrayList<>();
|
||||
for (OCFile file : getStorageManager().getFolderContent(currentFolder, false)) {
|
||||
if (!file.isFolder()) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
|
||||
return;
|
||||
}
|
||||
|
||||
OCFile fileToDownload = files.get(new Random().nextInt(files.size()));
|
||||
assertNotNull(fileToDownload.getRemoteId());
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " + "Download file: " +
|
||||
currentFolder.getDecryptedRemotePath() + fileToDownload.getDecryptedFileName());
|
||||
|
||||
assertTrue(new DownloadFileOperation(account, fileToDownload, targetContext)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
assertTrue(new File(fileToDownload.getStoragePath()).exists());
|
||||
verifyStoragePath(fileToDownload);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithCopy() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithMove() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_MOVE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithForget() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_FORGET);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithDelete() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_DELETE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
private void deleteFile(int i) {
|
||||
@@ -448,13 +281,7 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
}
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
|
||||
return;
|
||||
}
|
||||
|
||||
OCFile fileToDelete = files.get(new Random().nextInt(files.size()));
|
||||
assertNotNull(fileToDelete.getRemoteId());
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " +
|
||||
@@ -568,65 +395,4 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
private String generateMnemonicString() {
|
||||
return "1 2 3 4 5 6";
|
||||
}
|
||||
|
||||
public void after() {
|
||||
// remove all encrypted files
|
||||
OCFile root = fileDataStorageManager.getFileByDecryptedRemotePath("/");
|
||||
removeFolder(root);
|
||||
|
||||
// List<OCFile> files = fileDataStorageManager.getFolderContent(root, false);
|
||||
//
|
||||
// for (OCFile child : files) {
|
||||
// removeFolder(child);
|
||||
// }
|
||||
|
||||
assertEquals(0, fileDataStorageManager.getFolderContent(root, false).size());
|
||||
|
||||
super.after();
|
||||
}
|
||||
|
||||
private void removeFolder(OCFile folder) {
|
||||
Log_OC.d(this, "Start removing content of folder: " + folder.getDecryptedRemotePath());
|
||||
|
||||
List<OCFile> children = fileDataStorageManager.getFolderContent(folder, false);
|
||||
|
||||
// remove children
|
||||
for (OCFile child : children) {
|
||||
if (child.isFolder()) {
|
||||
removeFolder(child);
|
||||
|
||||
// remove folder
|
||||
Log_OC.d(this, "Remove folder: " + child.getDecryptedRemotePath());
|
||||
if (!folder.isEncrypted() && child.isEncrypted()) {
|
||||
assertTrue(new ToggleEncryptionRemoteOperation(child.getLocalId(),
|
||||
child.getRemotePath(),
|
||||
false)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
OCFile f = getStorageManager().getFileByEncryptedRemotePath(child.getRemotePath());
|
||||
f.setEncrypted(false);
|
||||
getStorageManager().saveFile(f);
|
||||
|
||||
child.setEncrypted(false);
|
||||
}
|
||||
} else {
|
||||
Log_OC.d(this, "Remove file: " + child.getDecryptedRemotePath());
|
||||
}
|
||||
|
||||
assertTrue(new RemoveFileOperation(child, false, account, false, targetContext)
|
||||
.execute(client, getStorageManager())
|
||||
.isSuccess()
|
||||
);
|
||||
}
|
||||
|
||||
Log_OC.d(this, "Finished removing content of folder: " + folder.getDecryptedRemotePath());
|
||||
}
|
||||
|
||||
private void verifyStoragePath(OCFile file) {
|
||||
assertEquals(FileStorageUtils.getSavePath(account.name) +
|
||||
currentFolder.getDecryptedRemotePath() +
|
||||
file.getDecryptedFileName(),
|
||||
file.getStoragePath());
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
|
||||
@@ -37,6 +38,8 @@ import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.events.SearchEvent;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
@@ -54,7 +57,7 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
public class FileDisplayActivityIT extends AbstractOnServerIT {
|
||||
public class FileDisplayActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
@@ -64,7 +67,34 @@ public class FileDisplayActivityIT extends AbstractOnServerIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
// @ScreenshotTest // todo run without real server
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void drawer() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
sut.getListOfFilesFragment().setFabEnabled(false);
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void showShares() {
|
||||
assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
@@ -125,7 +155,7 @@ public class FileDisplayActivityIT extends AbstractOnServerIT {
|
||||
shortSleep();
|
||||
shortSleep();
|
||||
|
||||
screenshot(sut);
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +163,7 @@ public class FileDisplayActivityIT extends AbstractOnServerIT {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
// given test folder
|
||||
assertTrue(new CreateFolderOperation("/test/", user, targetContext)
|
||||
assertTrue(new CreateFolderOperation("/test/", account, targetContext)
|
||||
.execute(client, getStorageManager())
|
||||
.isSuccess());
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2019 Tobias Kaminsky
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class FileDisplayActivityScreenshotIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
sut.getListOfFilesFragment().setFabEnabled(false);
|
||||
sut.getListOfFilesFragment().setEmptyListLoadingMessage(false);
|
||||
sut.getListOfFilesFragment().setLoading(false);
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void drawer() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
sut.getListOfFilesFragment().setFabEnabled(false);
|
||||
sut.getListOfFilesFragment().setEmptyListLoadingMessage(false);
|
||||
sut.getListOfFilesFragment().setLoading(false);
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,11 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -46,11 +48,12 @@ public class FirstRunActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
screenshot(sut);
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.NotificationsActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
|
||||
public class NotificationsActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<NotificationsActivity> activityRule = new IntentsTestRule<>(NotificationsActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import org.junit.runners.model.Statement
|
||||
/**
|
||||
* C&p from https://stackoverflow.com/questions/45635833/how-can-i-use-flakytest-annotation-now on 18.03.2020
|
||||
*/
|
||||
class RetryTestRule(val retryCount: Int = 1) : TestRule {
|
||||
class RetryTestRule(val retryCount: Int = 5) : TestRule {
|
||||
|
||||
companion object {
|
||||
private val TAG = RetryTestRule::class.java.simpleName
|
||||
|
||||
@@ -24,11 +24,10 @@ package com.nextcloud.client;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.facebook.testing.screenshot.ScreenshotRunner;
|
||||
import com.github.tmurakami.dexopener.DexOpener;
|
||||
import com.owncloud.android.TestApp;
|
||||
|
||||
import androidx.test.runner.AndroidJUnitRunner;
|
||||
|
||||
@@ -36,17 +35,10 @@ public class ScreenshotTestRunner extends AndroidJUnitRunner {
|
||||
|
||||
@Override
|
||||
public Application newApplication(ClassLoader cl, String className, Context context)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
|
||||
/*
|
||||
* Initialize DexOpener only on API below 28 to enable mocking of Kotlin classes.
|
||||
* On API 28+ the platform supports mocking natively.
|
||||
*/
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
DexOpener.install(this);
|
||||
}
|
||||
|
||||
return super.newApplication(cl, className, context);
|
||||
throws ClassNotFoundException,
|
||||
IllegalAccessException,
|
||||
InstantiationException {
|
||||
return super.newApplication(cl, TestApp.class.getName(), context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,15 +24,12 @@ package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.ui.activity.RequestCredentialsActivity;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithoutServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -40,8 +37,6 @@ import org.junit.Test;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class SettingsActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<SettingsActivity> activityRule = new IntentsTestRule<>(SettingsActivity.class,
|
||||
@@ -53,39 +48,11 @@ public class SettingsActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithoutServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
Activity test = activityRule.launchActivity(null);
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void showMnemonic_Error() {
|
||||
SettingsActivity sut = activityRule.launchActivity(null);
|
||||
sut.handleMnemonicRequest(null);
|
||||
shortSleep();
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showMnemonic() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(RequestCredentialsActivity.KEY_CHECK_RESULT, RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE);
|
||||
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(targetContext.getContentResolver());
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), EncryptionUtils.MNEMONIC, "Secret mnemonic");
|
||||
|
||||
SettingsActivity sut = activityRule.launchActivity(null);
|
||||
sut.handleMnemonicRequest(intent);
|
||||
|
||||
assertTrue(true); // if we reach this, everything is ok
|
||||
Screenshot.snapActivity(test).record();
|
||||
}
|
||||
}
|
||||
@@ -23,25 +23,17 @@
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.MediaFolderType;
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
|
||||
public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
|
||||
@@ -53,39 +45,9 @@ public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testSyncedFolderDialog() {
|
||||
SyncedFolderDisplayItem item = new SyncedFolderDisplayItem(1,
|
||||
"/sdcard/DCIM/",
|
||||
"/InstantUpload/",
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
"test@https://server.com",
|
||||
0,
|
||||
0,
|
||||
true,
|
||||
1000,
|
||||
"Name",
|
||||
MediaFolderType.IMAGE,
|
||||
false);
|
||||
SyncedFolderPreferencesDialogFragment sut = SyncedFolderPreferencesDialogFragment.newInstance(item, 0);
|
||||
|
||||
Intent intent = new Intent(targetContext, SyncedFoldersActivity.class);
|
||||
SyncedFoldersActivity activity = activityRule.launchActivity(intent);
|
||||
|
||||
sut.show(activity.getSupportFragmentManager(), "");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
screenshot(Objects.requireNonNull(sut.requireDialog().getWindow()).getDecorView());
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import android.Manifest;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.UploadListActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -45,6 +46,7 @@ public class UploadListActivityActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 Chris Narkiewicz
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.os.Parcel
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotSame
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class MockUserTest {
|
||||
|
||||
private companion object {
|
||||
const val ACCOUNT_NAME = "test_account_name"
|
||||
const val ACCOUNT_TYPE = "test_account_type"
|
||||
}
|
||||
|
||||
@Test
|
||||
fun mock_user_is_parcelable() {
|
||||
// GIVEN
|
||||
// mock user instance
|
||||
val original = MockUser(ACCOUNT_NAME, ACCOUNT_TYPE)
|
||||
|
||||
// WHEN
|
||||
// instance is serialized into Parcel
|
||||
// instance is retrieved from Parcel
|
||||
val parcel = Parcel.obtain()
|
||||
parcel.setDataPosition(0)
|
||||
parcel.writeParcelable(original, 0)
|
||||
parcel.setDataPosition(0)
|
||||
val retrieved = parcel.readParcelable<User>(User::class.java.classLoader)
|
||||
|
||||
// THEN
|
||||
// retrieved instance in distinct
|
||||
// instances are equal
|
||||
assertNotSame(original, retrieved)
|
||||
assertTrue(retrieved is MockUser)
|
||||
assertEquals(original, retrieved)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun mock_user_has_platform_account() {
|
||||
// GIVEN
|
||||
// mock user instance
|
||||
val mock = MockUser(ACCOUNT_NAME, ACCOUNT_TYPE)
|
||||
|
||||
// THEN
|
||||
// can convert to platform account
|
||||
val account = mock.toPlatformAccount()
|
||||
assertEquals(ACCOUNT_NAME, account.name)
|
||||
assertEquals(ACCOUNT_TYPE, account.type)
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import android.accounts.OperationCanceledException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManager;
|
||||
@@ -48,7 +48,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class OwnCloudClientManagerTest extends AbstractOnServerIT {
|
||||
public class OwnCloudClientManagerTest extends AbstractIT {
|
||||
|
||||
/**
|
||||
* Like on files app we create & store an account in Android's account manager.
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -17,7 +17,7 @@ import static junit.framework.TestCase.assertNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class UserAccountManagerImplTest extends AbstractOnServerIT {
|
||||
public class UserAccountManagerImplTest extends AbstractIT {
|
||||
|
||||
private AccountManager accountManager;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.facebook.testing.screenshot.Screenshot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest
|
||||
import org.junit.Assume
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -41,14 +42,13 @@ class EtmActivityTest : AbstractIT() {
|
||||
@Before
|
||||
fun before() {
|
||||
// tests only on NC 18
|
||||
Assume.assumeTrue(
|
||||
storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0
|
||||
)
|
||||
Assume.assumeTrue(storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun overview() {
|
||||
val sut: Activity = activityRule.launchActivity(null)
|
||||
@@ -59,6 +59,7 @@ class EtmActivityTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun preferences() {
|
||||
val sut: EtmActivity = activityRule.launchActivity(null)
|
||||
@@ -69,6 +70,7 @@ class EtmActivityTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun accounts() {
|
||||
val sut: EtmActivity = activityRule.launchActivity(null)
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files
|
||||
|
||||
import android.net.Uri
|
||||
import com.nextcloud.client.account.Server
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nhaarman.mockitokotlin2.mock
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.junit.runners.Suite
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.net.URI
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
DeepLinkHandlerTest.DeepLinkPattern::class,
|
||||
DeepLinkHandlerTest.FileDeepLink::class
|
||||
)
|
||||
class DeepLinkHandlerTest {
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
class DeepLinkPattern {
|
||||
|
||||
companion object {
|
||||
val FILE_ID = 1234
|
||||
val SERVER_BASE_URLS = listOf(
|
||||
"http://hostname.net",
|
||||
"https://hostname.net",
|
||||
"http://hostname.net/subdir1",
|
||||
"https://hostname.net/subdir1",
|
||||
"http://hostname.net/subdir1/subdir2",
|
||||
"https://hostname.net/subdir1/subdir2",
|
||||
"http://hostname.net/subdir1/subdir2/subdir3",
|
||||
"https://hostname.net/subdir1/subdir2/subdir3"
|
||||
)
|
||||
val INDEX_PHP_PATH = listOf(
|
||||
"",
|
||||
"/index.php"
|
||||
)
|
||||
|
||||
@Parameterized.Parameters
|
||||
@JvmStatic
|
||||
fun urls(): Array<Array<Any>> {
|
||||
val testInput = mutableListOf<Array<Any>>()
|
||||
SERVER_BASE_URLS.forEach { baseUrl ->
|
||||
INDEX_PHP_PATH.forEach { indexPath ->
|
||||
val url = "$baseUrl$indexPath/f/$FILE_ID"
|
||||
testInput.add(arrayOf(baseUrl, indexPath, "$FILE_ID", url))
|
||||
}
|
||||
}
|
||||
return testInput.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
lateinit var baseUrl: String
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
lateinit var indexPath: String
|
||||
|
||||
@Parameterized.Parameter(2)
|
||||
lateinit var fileId: String
|
||||
|
||||
@Parameterized.Parameter(3)
|
||||
lateinit var url: String
|
||||
|
||||
@Test
|
||||
fun matches_deep_link_patterns() {
|
||||
val match = DeepLinkHandler.DEEP_LINK_PATTERN.matchEntire(url)
|
||||
assertNotNull("Url [$url] does not match pattern", match)
|
||||
assertEquals(baseUrl, match?.groupValues?.get(DeepLinkHandler.BASE_URL_GROUP_INDEX))
|
||||
assertEquals(indexPath, match?.groupValues?.get(DeepLinkHandler.INDEX_PATH_GROUP_INDEX))
|
||||
assertEquals(fileId, match?.groupValues?.get(DeepLinkHandler.FILE_ID_GROUP_INDEX))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_trailing_path_allowed_after_file_id() {
|
||||
val invalidUrl = "$url/"
|
||||
val match = DeepLinkHandler.DEEP_LINK_PATTERN.matchEntire(invalidUrl)
|
||||
assertNull(match)
|
||||
}
|
||||
}
|
||||
|
||||
class FileDeepLink {
|
||||
|
||||
companion object {
|
||||
const val OTHER_SERVER_BASE_URL = "https://someotherserver.net"
|
||||
const val SERVER_BASE_URL = "https://server.net"
|
||||
const val FILE_ID = "1234567890"
|
||||
val DEEP_LINK = Uri.parse("$SERVER_BASE_URL/index.php/f/$FILE_ID")
|
||||
|
||||
fun createMockUser(serverBaseUrl: String): User {
|
||||
val user = mock<User>()
|
||||
val uri = URI.create(serverBaseUrl)
|
||||
val server = Server(uri = uri, version = OwnCloudVersion.nextcloud_19)
|
||||
whenever(user.server).thenReturn(server)
|
||||
return user
|
||||
}
|
||||
}
|
||||
|
||||
@Mock
|
||||
lateinit var userAccountManager: UserAccountManager
|
||||
lateinit var allUsers: List<User>
|
||||
lateinit var handler: DeepLinkHandler
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
whenever(userAccountManager.allUsers).thenAnswer { allUsers }
|
||||
allUsers = emptyList()
|
||||
handler = DeepLinkHandler(userAccountManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_user_can_open_file() {
|
||||
// GIVEN
|
||||
// no user capable of opening the file
|
||||
allUsers = listOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link is valid
|
||||
// no user can open the file
|
||||
assertNotNull(match)
|
||||
assertEquals(0, match?.users?.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun single_user_can_open_file() {
|
||||
// GIVEN
|
||||
// multiple users registered
|
||||
// one user capable of opening the link
|
||||
val matchingUser = createMockUser(SERVER_BASE_URL)
|
||||
allUsers = listOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
matchingUser,
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link can be opened by single user
|
||||
assertNotNull(match)
|
||||
assertSame(matchingUser, match?.users?.get(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiple_users_can_open_file() {
|
||||
// GIVEN
|
||||
// mutltiple users registered
|
||||
// multiple users capable of opening the link
|
||||
val matchingUsers = setOf(
|
||||
createMockUser(SERVER_BASE_URL),
|
||||
createMockUser(SERVER_BASE_URL)
|
||||
)
|
||||
val otherUsers = setOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
allUsers = listOf(matchingUsers, otherUsers).flatten()
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link can be opened by multiple matching users
|
||||
assertNotNull(match)
|
||||
assertEquals(matchingUsers, match?.users?.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun match_contains_extracted_file_id() {
|
||||
// WHEN
|
||||
// valid deep file link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// file id is returned
|
||||
assertEquals(FILE_ID, match?.fileId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_match_for_invalid_link() {
|
||||
// GIVEN
|
||||
// invalid deep link
|
||||
val invalidLink = Uri.parse("http://www.dodgylink.com/index.php")
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(invalidLink)
|
||||
|
||||
// THEN
|
||||
// no match
|
||||
assertNull(match)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider.getApplicationContext
|
||||
import androidx.test.rule.ServiceTestRule
|
||||
import com.nextcloud.client.account.MockUser
|
||||
import io.mockk.MockKAnnotations
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
class DownloaderServiceTest {
|
||||
|
||||
@get:Rule
|
||||
val service = ServiceTestRule.withTimeout(3, TimeUnit.SECONDS)
|
||||
|
||||
val user = MockUser()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
}
|
||||
|
||||
@Test(expected = TimeoutException::class)
|
||||
fun cannot_bind_to_service_without_user() {
|
||||
val intent = DownloaderService.createBindIntent(getApplicationContext(), user)
|
||||
intent.removeExtra(DownloaderService.EXTRA_USER)
|
||||
service.bindService(intent)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bind_with_user() {
|
||||
val intent = DownloaderService.createBindIntent(getApplicationContext(), user)
|
||||
val binder = service.bindService(intent)
|
||||
assertTrue(binder is DownloaderService.Binder)
|
||||
}
|
||||
}
|
||||
@@ -1,519 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import io.mockk.CapturingSlot
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.clearAllMocks
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Suite
|
||||
import java.util.UUID
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
RegistryTest.Pending::class,
|
||||
RegistryTest.Start::class,
|
||||
RegistryTest.Progress::class,
|
||||
RegistryTest.Complete::class,
|
||||
RegistryTest.GetTransfers::class,
|
||||
RegistryTest.IsRunning::class
|
||||
)
|
||||
class RegistryTest {
|
||||
|
||||
abstract class Base {
|
||||
companion object {
|
||||
const val MAX_TRANSFER_THREADS = 4
|
||||
const val PROGRESS_FULL = 100
|
||||
const val PROGRESS_HALF = 50
|
||||
}
|
||||
|
||||
@MockK
|
||||
lateinit var user: User
|
||||
|
||||
lateinit var file: OCFile
|
||||
|
||||
@MockK
|
||||
lateinit var onTransferStart: (UUID, Request) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var onTransferChanged: (Transfer) -> Unit
|
||||
|
||||
internal lateinit var registry: Registry
|
||||
|
||||
@Before
|
||||
fun setUpBase() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
file = OCFile("/test/path")
|
||||
registry = Registry(onTransferStart, onTransferChanged, MAX_TRANSFER_THREADS)
|
||||
resetMocks()
|
||||
}
|
||||
|
||||
fun resetMocks() {
|
||||
clearAllMocks()
|
||||
every { onTransferStart(any(), any()) } answers {}
|
||||
every { onTransferChanged(any()) } answers {}
|
||||
}
|
||||
}
|
||||
|
||||
class Pending : Base() {
|
||||
|
||||
@Test
|
||||
fun inserting_pending_transfer() {
|
||||
// GIVEN
|
||||
// registry has no pending transfers
|
||||
assertEquals(0, registry.pending.size)
|
||||
|
||||
// WHEN
|
||||
// new transfer requests added
|
||||
val addedTransfersCount = 10
|
||||
for (i in 0 until addedTransfersCount) {
|
||||
val request = Request(user, file)
|
||||
registry.add(request)
|
||||
}
|
||||
|
||||
// THEN
|
||||
// transfer is added to the pending queue
|
||||
assertEquals(addedTransfersCount, registry.pending.size)
|
||||
}
|
||||
}
|
||||
|
||||
class Start : Base() {
|
||||
|
||||
companion object {
|
||||
const val ENQUEUED_REQUESTS_COUNT = 10
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
for (i in 0 until ENQUEUED_REQUESTS_COUNT) {
|
||||
registry.add(Request(user, file))
|
||||
}
|
||||
assertEquals(ENQUEUED_REQUESTS_COUNT, registry.pending.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun starting_transfer() {
|
||||
// WHEN
|
||||
// started
|
||||
registry.startNext()
|
||||
|
||||
// THEN
|
||||
// up to max threads requests are started
|
||||
// start callback is triggered
|
||||
// update callback is triggered on transfer transition
|
||||
// started transfers are in running state
|
||||
assertEquals(
|
||||
"Transfers not moved to running queue",
|
||||
MAX_TRANSFER_THREADS,
|
||||
registry.running.size
|
||||
)
|
||||
assertEquals(
|
||||
"Transfers not moved from pending queue",
|
||||
ENQUEUED_REQUESTS_COUNT - MAX_TRANSFER_THREADS,
|
||||
registry.pending.size
|
||||
)
|
||||
verify(exactly = MAX_TRANSFER_THREADS) { onTransferStart(any(), any()) }
|
||||
val startedTransfers = mutableListOf<Transfer>()
|
||||
verify(exactly = MAX_TRANSFER_THREADS) { onTransferChanged(capture(startedTransfers)) }
|
||||
assertEquals(
|
||||
"Callbacks not invoked for running transfers",
|
||||
MAX_TRANSFER_THREADS,
|
||||
startedTransfers.size
|
||||
)
|
||||
startedTransfers.forEach {
|
||||
assertEquals("Transfer not placed into running state", TransferState.RUNNING, it.state)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun start_is_ignored_if_no_more_free_threads() {
|
||||
// WHEN
|
||||
// max number of running transfers
|
||||
registry.startNext()
|
||||
assertEquals(MAX_TRANSFER_THREADS, registry.running.size)
|
||||
clearAllMocks()
|
||||
|
||||
// WHEN
|
||||
// starting more transfers
|
||||
registry.startNext()
|
||||
|
||||
// THEN
|
||||
// no more transfers can be started
|
||||
assertEquals(MAX_TRANSFER_THREADS, registry.running.size)
|
||||
verify(exactly = 0) { onTransferStart(any(), any()) }
|
||||
}
|
||||
}
|
||||
|
||||
class Progress : Base() {
|
||||
|
||||
var uuid: UUID = UUID.randomUUID()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val request = Request(user, file)
|
||||
uuid = registry.add(request)
|
||||
registry.startNext()
|
||||
assertEquals(uuid, request.uuid)
|
||||
assertEquals(1, registry.running.size)
|
||||
resetMocks()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun transfer_progress_is_updated() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer progress is updated
|
||||
val progressHalf = 50
|
||||
registry.progress(uuid, progressHalf)
|
||||
|
||||
// THEN
|
||||
// progress is updated
|
||||
// update callback is invoked
|
||||
val transfer = mutableListOf<Transfer>()
|
||||
verify { onTransferChanged(capture(transfer)) }
|
||||
assertEquals(1, transfer.size)
|
||||
assertEquals(progressHalf, transfer.first().progress)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updates_for_non_running_transfers_are_ignored() {
|
||||
// GIVEN
|
||||
// transfer is not running
|
||||
registry.complete(uuid, true)
|
||||
assertEquals(0, registry.running.size)
|
||||
resetMocks()
|
||||
|
||||
// WHEN
|
||||
// progress for a non-running transfer is updated
|
||||
registry.progress(uuid, PROGRESS_HALF)
|
||||
|
||||
// THEN
|
||||
// progress update is ignored
|
||||
verify(exactly = 0) { onTransferChanged(any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updates_for_non_existing_transfers_are_ignored() {
|
||||
// GIVEN
|
||||
// some transfer is running
|
||||
|
||||
// WHEN
|
||||
// progress is updated for non-existing transfer
|
||||
val nonExistingTransferId = UUID.randomUUID()
|
||||
registry.progress(nonExistingTransferId, PROGRESS_HALF)
|
||||
|
||||
// THEN
|
||||
// progress uppdate is ignored
|
||||
verify(exactly = 0) { onTransferChanged(any()) }
|
||||
}
|
||||
}
|
||||
|
||||
class Complete : Base() {
|
||||
|
||||
lateinit var uuid: UUID
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
uuid = registry.add(Request(user, file))
|
||||
registry.startNext()
|
||||
registry.progress(uuid, PROGRESS_FULL)
|
||||
resetMocks()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun complete_successful_transfer_with_updated_file() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer is completed
|
||||
// file has been updated
|
||||
val updatedFile = OCFile("/updated/file")
|
||||
registry.complete(uuid, true, updatedFile)
|
||||
|
||||
// THEN
|
||||
// transfer is completed successfully
|
||||
// status carries updated file
|
||||
val slot = CapturingSlot<Transfer>()
|
||||
verify { onTransferChanged(capture(slot)) }
|
||||
assertEquals(TransferState.COMPLETED, slot.captured.state)
|
||||
assertSame(slot.captured.file, updatedFile)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun complete_successful_transfer() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer is completed
|
||||
// file is not updated
|
||||
registry.complete(uuid = uuid, success = true, file = null)
|
||||
|
||||
// THEN
|
||||
// transfer is completed successfully
|
||||
// status carries previous file
|
||||
val slot = CapturingSlot<Transfer>()
|
||||
verify { onTransferChanged(capture(slot)) }
|
||||
assertEquals(TransferState.COMPLETED, slot.captured.state)
|
||||
assertSame(slot.captured.file, file)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun complete_failed_transfer() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer is failed
|
||||
registry.complete(uuid, false)
|
||||
|
||||
// THEN
|
||||
// transfer is completed successfully
|
||||
val slot = CapturingSlot<Transfer>()
|
||||
verify { onTransferChanged(capture(slot)) }
|
||||
assertEquals(TransferState.FAILED, slot.captured.state)
|
||||
}
|
||||
}
|
||||
|
||||
class GetTransfers : Base() {
|
||||
|
||||
val pendingTransferFile = OCFile("/pending")
|
||||
val runningTransferFile = OCFile("/running")
|
||||
val completedTransferFile = OCFile("/completed")
|
||||
|
||||
lateinit var pendingTransferId: UUID
|
||||
lateinit var runningTransferId: UUID
|
||||
lateinit var completedTransferId: UUID
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
completedTransferId = registry.add(Request(user, completedTransferFile))
|
||||
registry.startNext()
|
||||
registry.complete(completedTransferId, true)
|
||||
|
||||
runningTransferId = registry.add(Request(user, runningTransferFile))
|
||||
registry.startNext()
|
||||
|
||||
pendingTransferId = registry.add(Request(user, pendingTransferFile))
|
||||
resetMocks()
|
||||
|
||||
assertEquals(1, registry.pending.size)
|
||||
assertEquals(1, registry.running.size)
|
||||
assertEquals(1, registry.completed.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_path_searches_pending_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(pendingTransferFile)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(pendingTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_id_searches_pending_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(pendingTransferId)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(pendingTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_path_searches_running_queue() {
|
||||
// GIVEN
|
||||
// file transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(runningTransferFile)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(runningTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_id_searches_running_queue() {
|
||||
// GIVEN
|
||||
// file transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(runningTransferId)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(runningTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_path_searches_completed_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(completedTransferFile)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(completedTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_id_searches_completed_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(completedTransferId)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(completedTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_found_by_path() {
|
||||
// GIVEN
|
||||
// no transfer for a file
|
||||
val nonExistingTransferFile = OCFile("/non-nexisting/transfer")
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved for a file
|
||||
val transfer = registry.getTransfer(nonExistingTransferFile)
|
||||
|
||||
// THEN
|
||||
// no transfer is found
|
||||
assertNull(transfer)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_found_by_id() {
|
||||
// GIVEN
|
||||
// no transfer for an id
|
||||
val nonExistingId = UUID.randomUUID()
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved for a file
|
||||
val transfer = registry.getTransfer(nonExistingId)
|
||||
|
||||
// THEN
|
||||
// no transfer is found
|
||||
assertNull(transfer)
|
||||
}
|
||||
}
|
||||
|
||||
class IsRunning : Base() {
|
||||
|
||||
@Test
|
||||
fun no_requests() {
|
||||
// WHEN
|
||||
// all queues empty
|
||||
assertEquals(0, registry.pending.size)
|
||||
assertEquals(0, registry.running.size)
|
||||
assertEquals(0, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// not running
|
||||
assertFalse(registry.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun request_pending() {
|
||||
// WHEN
|
||||
// request is enqueued
|
||||
registry.add(Request(user, OCFile("/path/alpha/1")))
|
||||
assertEquals(1, registry.pending.size)
|
||||
assertEquals(0, registry.running.size)
|
||||
assertEquals(0, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// is running
|
||||
assertTrue(registry.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun request_running() {
|
||||
// WHEN
|
||||
// request is running
|
||||
registry.add(Request(user, OCFile("/path/alpha/1")))
|
||||
registry.startNext()
|
||||
assertEquals(0, registry.pending.size)
|
||||
assertEquals(1, registry.running.size)
|
||||
assertEquals(0, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// is running
|
||||
assertTrue(registry.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun request_completed() {
|
||||
// WHEN
|
||||
// request is running
|
||||
val id = registry.add(Request(user, OCFile("/path/alpha/1")))
|
||||
registry.startNext()
|
||||
registry.complete(id, true)
|
||||
assertEquals(0, registry.pending.size)
|
||||
assertEquals(0, registry.running.size)
|
||||
assertEquals(1, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// is not running
|
||||
assertFalse(registry.isRunning)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import com.nextcloud.client.account.MockUser
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class TransferManagerConnectionTest {
|
||||
|
||||
lateinit var connection: TransferManagerConnection
|
||||
|
||||
@MockK
|
||||
lateinit var context: Context
|
||||
|
||||
@MockK
|
||||
lateinit var firstDownloadListener: (Transfer) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var secondDownloadListener: (Transfer) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var firstStatusListener: (TransferManager.Status) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var secondStatusListener: (TransferManager.Status) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var binder: DownloaderService.Binder
|
||||
|
||||
val file get() = OCFile("/path")
|
||||
val componentName = ComponentName("", DownloaderService::class.java.simpleName)
|
||||
val user = MockUser()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
connection = TransferManagerConnection(context, user)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listeners_are_set_after_connection() {
|
||||
// GIVEN
|
||||
// not connected
|
||||
// listener is added
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
connection.registerTransferListener(secondDownloadListener)
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// all listeners are passed to the service
|
||||
val listeners = mutableListOf<(Transfer) -> Unit>()
|
||||
verify { binder.registerTransferListener(capture(listeners)) }
|
||||
assertEquals(listOf(firstDownloadListener, secondDownloadListener), listeners)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listeners_are_set_immediately_when_connected() {
|
||||
// GIVEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// WHEN
|
||||
// listeners are added
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
|
||||
// THEN
|
||||
// listener is forwarded to service
|
||||
verify { binder.registerTransferListener(firstDownloadListener) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listeners_are_removed_when_unbinding() {
|
||||
// GIVEN
|
||||
// service is bound
|
||||
// service has some listeners
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
connection.registerTransferListener(secondDownloadListener)
|
||||
|
||||
// WHEN
|
||||
// service unbound
|
||||
connection.unbind()
|
||||
|
||||
// THEN
|
||||
// listeners removed from service
|
||||
verify { binder.removeTransferListener(firstDownloadListener) }
|
||||
verify { binder.removeTransferListener(secondDownloadListener) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun missed_updates_are_delivered_on_connection() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// has listeners
|
||||
// download is scheduled and is progressing
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
connection.registerTransferListener(secondDownloadListener)
|
||||
|
||||
val request1 = Request(user, file)
|
||||
connection.enqueue(request1)
|
||||
val download1 = Transfer(request1.uuid, TransferState.RUNNING, 50, request1.file, request1)
|
||||
|
||||
val request2 = Request(user, file)
|
||||
connection.enqueue(request2)
|
||||
val download2 = Transfer(request2.uuid, TransferState.RUNNING, 50, request2.file, request1)
|
||||
|
||||
every { binder.getTransfer(request1.uuid) } returns download1
|
||||
every { binder.getTransfer(request2.uuid) } returns download2
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// listeners receive current download state for pending downloads
|
||||
val firstListenerNotifications = mutableListOf<Transfer>()
|
||||
verify { firstDownloadListener(capture(firstListenerNotifications)) }
|
||||
assertEquals(listOf(download1, download2), firstListenerNotifications)
|
||||
|
||||
val secondListenerNotifications = mutableListOf<Transfer>()
|
||||
verify { secondDownloadListener(capture(secondListenerNotifications)) }
|
||||
assertEquals(listOf(download1, download2), secondListenerNotifications)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun downloader_status_updates_are_delivered_on_connection() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// has status listeners
|
||||
val mockStatus: TransferManager.Status = mockk()
|
||||
every { binder.status } returns mockStatus
|
||||
connection.registerStatusListener(firstStatusListener)
|
||||
connection.registerStatusListener(secondStatusListener)
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// downloader status is delivered
|
||||
verify { firstStatusListener(mockStatus) }
|
||||
verify { secondStatusListener(mockStatus) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun downloader_status_not_requested_if_no_listeners() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// no status listeners
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// downloader status is not requested
|
||||
verify(exactly = 0) { binder.status }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_running_if_not_connected() {
|
||||
// GIVEN
|
||||
// downloader is running
|
||||
// connection not bound
|
||||
every { binder.isRunning } returns true
|
||||
|
||||
// THEN
|
||||
// not running
|
||||
assertFalse(connection.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun is_running_from_binder_if_connected() {
|
||||
// GIVEN
|
||||
// service bound
|
||||
every { binder.isRunning } returns true
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// WHEN
|
||||
// is runnign flag accessed
|
||||
val isRunning = connection.isRunning
|
||||
|
||||
// THEN
|
||||
// call delegated to binder
|
||||
assertTrue(isRunning)
|
||||
verify(exactly = 1) { binder.isRunning }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun missed_updates_not_tracked_before_listeners_registered() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// some downloads requested without listener
|
||||
val request = Request(user, file)
|
||||
connection.enqueue(request)
|
||||
val download = Transfer(request.uuid, TransferState.RUNNING, 50, request.file, request)
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
every { binder.getTransfer(request.uuid) } returns download
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// missed updates not redelivered
|
||||
verify(exactly = 0) { firstDownloadListener(any()) }
|
||||
}
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.core.ManualAsyncRunner
|
||||
import com.nextcloud.client.core.OnProgressCallback
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.mockk
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Suite
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
TransferManagerTest.Enqueue::class,
|
||||
TransferManagerTest.TransferStatusUpdates::class
|
||||
)
|
||||
class TransferManagerTest {
|
||||
|
||||
abstract class Base {
|
||||
|
||||
companion object {
|
||||
const val MAX_TRANSFER_THREADS = 4
|
||||
}
|
||||
|
||||
@MockK
|
||||
lateinit var user: User
|
||||
|
||||
@MockK
|
||||
lateinit var client: OwnCloudClient
|
||||
|
||||
@MockK
|
||||
lateinit var mockTaskFactory: DownloadTask.Factory
|
||||
|
||||
/**
|
||||
* All task mock functions created during test run are
|
||||
* stored here.
|
||||
*/
|
||||
lateinit var downloadTaskMocks: MutableList<DownloadTask>
|
||||
lateinit var runner: ManualAsyncRunner
|
||||
lateinit var transferManager: TransferManagerImpl
|
||||
|
||||
/**
|
||||
* Response value for all download tasks
|
||||
*/
|
||||
var downloadTaskResult: Boolean = true
|
||||
|
||||
/**
|
||||
* Progress values posted by all download task mocks before
|
||||
* returning result value
|
||||
*/
|
||||
var taskProgress = listOf<Int>()
|
||||
|
||||
@Before
|
||||
fun setUpBase() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
MockitoAnnotations.initMocks(this)
|
||||
downloadTaskMocks = mutableListOf()
|
||||
runner = ManualAsyncRunner()
|
||||
transferManager = TransferManagerImpl(
|
||||
runner = runner,
|
||||
taskFactory = mockTaskFactory,
|
||||
threads = MAX_TRANSFER_THREADS
|
||||
)
|
||||
downloadTaskResult = true
|
||||
every { mockTaskFactory.create() } answers { createMockTask() }
|
||||
}
|
||||
|
||||
private fun createMockTask(): DownloadTask {
|
||||
val task = mockk<DownloadTask>()
|
||||
every { task.download(any(), any(), any()) } answers {
|
||||
taskProgress.forEach {
|
||||
arg<OnProgressCallback<Int>>(1).invoke(it)
|
||||
}
|
||||
val request = arg<Request>(0)
|
||||
DownloadTask.Result(request.file, downloadTaskResult)
|
||||
}
|
||||
downloadTaskMocks.add(task)
|
||||
return task
|
||||
}
|
||||
}
|
||||
|
||||
class Enqueue : Base() {
|
||||
|
||||
@Test
|
||||
fun enqueued_download_is_started_immediately() {
|
||||
// GIVEN
|
||||
// downloader has no running downloads
|
||||
|
||||
// WHEN
|
||||
// download is enqueued
|
||||
val file = OCFile("/path")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
|
||||
// THEN
|
||||
// download is started immediately
|
||||
val download = transferManager.getTransfer(request.uuid)
|
||||
assertEquals(TransferState.RUNNING, download?.state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun enqueued_downloads_are_pending_if_running_queue_is_full() {
|
||||
// GIVEN
|
||||
// downloader is downloading max simultaneous files
|
||||
for (i in 0 until MAX_TRANSFER_THREADS) {
|
||||
val file = OCFile("/running/download/path/$i")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
val runningDownload = transferManager.getTransfer(request.uuid)
|
||||
assertEquals(runningDownload?.state, TransferState.RUNNING)
|
||||
}
|
||||
|
||||
// WHEN
|
||||
// another download is enqueued
|
||||
val file = OCFile("/path")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
|
||||
// THEN
|
||||
// download is pending
|
||||
val download = transferManager.getTransfer(request.uuid)
|
||||
assertEquals(TransferState.PENDING, download?.state)
|
||||
}
|
||||
}
|
||||
|
||||
class TransferStatusUpdates : Base() {
|
||||
|
||||
@get:Rule
|
||||
val rule = InstantTaskExecutorRule()
|
||||
|
||||
val file = OCFile("/path")
|
||||
|
||||
@Test
|
||||
fun download_task_completes() {
|
||||
// GIVEN
|
||||
// download is running
|
||||
// download is being observed
|
||||
val downloadUpdates = mutableListOf<Transfer>()
|
||||
transferManager.registerTransferListener { downloadUpdates.add(it) }
|
||||
transferManager.enqueue(Request(user, file))
|
||||
|
||||
// WHEN
|
||||
// download task finishes successfully
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// listener is notified about status change
|
||||
assertEquals(TransferState.RUNNING, downloadUpdates[0].state)
|
||||
assertEquals(TransferState.COMPLETED, downloadUpdates[1].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun download_task_fails() {
|
||||
// GIVEN
|
||||
// download is running
|
||||
// download is being observed
|
||||
val downloadUpdates = mutableListOf<Transfer>()
|
||||
transferManager.registerTransferListener { downloadUpdates.add(it) }
|
||||
transferManager.enqueue(Request(user, file))
|
||||
|
||||
// WHEN
|
||||
// download task fails
|
||||
downloadTaskResult = false
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// listener is notified about status change
|
||||
assertEquals(TransferState.RUNNING, downloadUpdates[0].state)
|
||||
assertEquals(TransferState.FAILED, downloadUpdates[1].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun download_progress_is_updated() {
|
||||
// GIVEN
|
||||
// download is running
|
||||
val downloadUpdates = mutableListOf<Transfer>()
|
||||
transferManager.registerTransferListener { downloadUpdates.add(it) }
|
||||
transferManager.enqueue(Request(user, file))
|
||||
|
||||
// WHEN
|
||||
// download progress updated 4 times before completion
|
||||
taskProgress = listOf(25, 50, 75, 100)
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// listener receives 6 status updates
|
||||
// transition to running
|
||||
// 4 progress updates
|
||||
// completion
|
||||
assertEquals(6, downloadUpdates.size)
|
||||
if (downloadUpdates.size >= 6) {
|
||||
assertEquals(TransferState.RUNNING, downloadUpdates[0].state)
|
||||
assertEquals(25, downloadUpdates[1].progress)
|
||||
assertEquals(50, downloadUpdates[2].progress)
|
||||
assertEquals(75, downloadUpdates[3].progress)
|
||||
assertEquals(100, downloadUpdates[4].progress)
|
||||
assertEquals(TransferState.COMPLETED, downloadUpdates[5].state)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun download_task_is_created_only_for_running_downloads() {
|
||||
// WHEN
|
||||
// multiple downloads are enqueued
|
||||
for (i in 0 until MAX_TRANSFER_THREADS * 2) {
|
||||
transferManager.enqueue(Request(user, file))
|
||||
}
|
||||
|
||||
// THEN
|
||||
// download task is created only for running downloads
|
||||
assertEquals(MAX_TRANSFER_THREADS, downloadTaskMocks.size)
|
||||
}
|
||||
}
|
||||
|
||||
class RunningStatusUpdates : Base() {
|
||||
|
||||
@get:Rule
|
||||
val rule = InstantTaskExecutorRule()
|
||||
|
||||
@Test
|
||||
fun is_running_flag_on_enqueue() {
|
||||
// WHEN
|
||||
// download is enqueued
|
||||
val file = OCFile("/path/to/file")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
|
||||
// THEN
|
||||
// is running changes
|
||||
assertTrue(transferManager.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun is_running_flag_on_completion() {
|
||||
// GIVEN
|
||||
// a download is in progress
|
||||
val file = OCFile("/path/to/file")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
assertTrue(transferManager.isRunning)
|
||||
|
||||
// WHEN
|
||||
// download is processed
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// downloader is not running
|
||||
assertFalse(transferManager.isRunning)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.integrations.deck
|
||||
package com.nextcloud.client.integration.deck
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.Manifest
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import androidx.work.WorkManager
|
||||
import com.nextcloud.client.core.ClockImpl
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import ezvcard.Ezvcard
|
||||
import ezvcard.VCard
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class ContactsBackupIT : AbstractOnServerIT() {
|
||||
val workmanager = WorkManager.getInstance(targetContext)
|
||||
private val backgroundJobManager = BackgroundJobManagerImpl(workmanager, ClockImpl())
|
||||
|
||||
@get:Rule
|
||||
val writeContactsRule = GrantPermissionRule.grant(Manifest.permission.WRITE_CONTACTS)
|
||||
|
||||
@get:Rule
|
||||
val readContactsRule = GrantPermissionRule.grant(Manifest.permission.READ_CONTACTS)
|
||||
|
||||
private val vcard: String = "vcard.vcf"
|
||||
|
||||
@Test
|
||||
fun importExport() {
|
||||
val intArray = IntArray(1)
|
||||
intArray[0] = 0
|
||||
|
||||
// import file to local contacts
|
||||
backgroundJobManager.startImmediateContactsImport(null, null, getFile(vcard).absolutePath, intArray)
|
||||
|
||||
shortSleep()
|
||||
|
||||
// export contact
|
||||
backgroundJobManager.startImmediateContactsBackup(user)
|
||||
|
||||
longSleep()
|
||||
|
||||
val backupFolder: String = targetContext.resources.getString(R.string.contacts_backup_folder) +
|
||||
OCFile.PATH_SEPARATOR
|
||||
|
||||
refreshFolder("/")
|
||||
longSleep()
|
||||
|
||||
refreshFolder(backupFolder)
|
||||
longSleep()
|
||||
|
||||
val backupOCFile = storageManager.getFolderContent(
|
||||
storageManager.getFileByDecryptedRemotePath(backupFolder),
|
||||
false
|
||||
)[0]
|
||||
|
||||
assertTrue(DownloadFileOperation(account, backupOCFile, AbstractIT.targetContext).execute(client).isSuccess)
|
||||
|
||||
val backupFile = File(backupOCFile.storagePath)
|
||||
|
||||
// verify same
|
||||
val originalCards: ArrayList<VCard> = ArrayList()
|
||||
originalCards.addAll(Ezvcard.parse(getFile(vcard)).all())
|
||||
|
||||
val backupCards: ArrayList<VCard> = ArrayList()
|
||||
backupCards.addAll(Ezvcard.parse(backupFile).all())
|
||||
|
||||
assertEquals(originalCards.size, backupCards.size)
|
||||
assertEquals(originalCards[0].formattedName.toString(), backupCards[0].formattedName.toString())
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,10 @@ class MigrationsManagerTest {
|
||||
// pending migrations
|
||||
// mandatory migrations are passing
|
||||
// one migration is optional and fails
|
||||
assertEquals("Fixture should provide 1 optional, failing migration", 1, migrations.count { !it.mandatory })
|
||||
assertEquals("Fixture should provide 1 optional, failing migration",
|
||||
1,
|
||||
migrations.count { !it.mandatory }
|
||||
)
|
||||
val optionalFailingMigration = migrations.first { !it.mandatory }
|
||||
whenever(optionalFailingMigration.run()).thenThrow(RuntimeException())
|
||||
|
||||
|
||||