Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a00dcd675e |
No files matched your search
@@ -1,10 +1,10 @@
|
||||
FROM ubuntu:noble@sha256:cd1dba651b3080c3686ecf4e3c4220f026b521fb76978881737d24f200828b2b
|
||||
FROM ubuntu:noble@sha256:728785b59223d755e3e5c5af178fab1be7031f3522c5ccd7a0b32b80d8248123
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
|
||||
RUN apt-get update -y
|
||||
RUN apt-get install -y unzip wget openjdk-21-jdk vim
|
||||
RUN apt-get install -y unzip wget openjdk-17-jdk vim
|
||||
|
||||
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -O /tmp/commandlinetools.zip
|
||||
RUN cd /tmp && unzip commandlinetools.zip
|
||||
|
||||
+5
-7
@@ -9,7 +9,7 @@ name: tests-stable
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: ghcr.io/nextcloud/continuous-integration-android16:latest
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:4
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
@@ -40,7 +40,6 @@ services:
|
||||
commands:
|
||||
- BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
- rm /etc/apt/sources.list.d/php.list
|
||||
- apt-get update && apt-get install -y composer
|
||||
- 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"
|
||||
@@ -75,7 +74,7 @@ name: tests-master
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: ghcr.io/nextcloud/continuous-integration-android16:latest
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:4
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
@@ -100,7 +99,6 @@ services:
|
||||
commands:
|
||||
- /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
- rm /etc/apt/sources.list.d/php.list
|
||||
- apt-get update && apt-get install -y composer
|
||||
- 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"
|
||||
@@ -136,7 +134,7 @@ name: allScreenshots
|
||||
|
||||
steps:
|
||||
- name: runAllScreenshots
|
||||
image: ghcr.io/nextcloud/continuous-integration-android16:latest
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:4
|
||||
privileged: true
|
||||
environment:
|
||||
GIT_USERNAME:
|
||||
@@ -150,7 +148,7 @@ steps:
|
||||
commands:
|
||||
- emulator -avd android -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 app/src/main/res/values/setup.xml
|
||||
- sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle.kts
|
||||
- sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle
|
||||
- scripts/wait_for_emulator.sh
|
||||
- scripts/runAllScreenshotCombinations noCI false
|
||||
- scripts/screenshotSummary.sh
|
||||
@@ -187,6 +185,6 @@ name: GIT_TOKEN
|
||||
data: XIoa9IYq+xQ+N5iln8dlpWv0jV6ROr7HuE24ioUr4uQ8m8SjyH0yognWYLYLqnbTKrFWlFZiEMQTH/sZiWjRFvV1iL0=
|
||||
---
|
||||
kind: signature
|
||||
hmac: de23b70b660e9f78e936d89699fd24777a83c8caaad97d086bbc0c8a0373aa91
|
||||
hmac: ea9432c9317fa6ca12a282bb117c9f3268ddb29b208dbd772795ba19cf395082
|
||||
|
||||
...
|
||||
@@ -8,12 +8,4 @@ Unit tests: https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#uni
|
||||
Instrumented tests: https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#instrumented-tests
|
||||
UI tests: https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#ui-tests
|
||||
-->
|
||||
### 🖼️ Screenshots
|
||||
|
||||
🏚️ Before | 🏡 After
|
||||
---|---
|
||||
B | A
|
||||
|
||||
### 🏁 Checklist
|
||||
|
||||
- [ ] Tests written, or not not needed
|
||||
@@ -1,2 +1,2 @@
|
||||
SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -51,16 +51,16 @@ jobs:
|
||||
echo "repo=${{ github.event.pull_request.head.repo.full_name }}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install python3-defusedxml
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
|
||||
echo "org.gradle.jvmargs=-Xmx5g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.configureondemand=true"
|
||||
echo "kapt.incremental.apt=true"
|
||||
} > "$HOME/.gradle/gradle.properties"
|
||||
|
||||
@@ -22,13 +22,13 @@ jobs:
|
||||
matrix:
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- uses: gradle/actions/wrapper-validation@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1
|
||||
java-version: 17
|
||||
- uses: gradle/actions/wrapper-validation@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
|
||||
|
||||
@@ -20,13 +20,13 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
task: [ detekt, spotlessKotlinCheck, lint ]
|
||||
task: [ detekt, spotlessKotlinCheck ]
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Check ${{ matrix.task }}
|
||||
run: ./gradlew ${{ matrix.task }}
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set Swap Space
|
||||
@@ -43,18 +43,18 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
|
||||
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Assemble
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew --no-daemon assembleDebug
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
|
||||
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
|
||||
@@ -20,11 +20,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Detect SNAPSHOT
|
||||
run: scripts/analysis/detectWrongSettings.sh
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
#
|
||||
|
||||
## This file is intended to be sourced by other scripts
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
SPDX-FileCopyrightText: 2019-2025 Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
|
||||
echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: nextcloud/pr-feedback-action@5227c55be184087d0aef6338bee210d8620b6297 # main
|
||||
- uses: nextcloud/pr-feedback-action@e397f3c7e655092b746e3610d121545530c6a90e # main
|
||||
with:
|
||||
feedback-message: |
|
||||
Hello there,
|
||||
|
||||
@@ -24,17 +24,17 @@ jobs:
|
||||
id: check-secrets
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
|
||||
- name: Build QA
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
@@ -46,12 +46,10 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > "$HOME/.gradle/gradle.properties"
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > "$HOME/.gradle/gradle.properties"
|
||||
echo "org.gradle.caching=true; org.gradle.parallel=true; org.gradle.configureondemand=true; kapt.incremental.apt=true" >> "$HOME/.gradle/gradle.properties"
|
||||
[ -e app/build.gradle ] && sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" "app/build.gradle"
|
||||
[ -e app/build.gradle ] && sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" "app/build.gradle"
|
||||
[ -e app/build.gradle.kts ] && sed -i "/qa/,/\}/ s/versionCode .*/versionCode = ${{github.event.number}} /" "app/build.gradle.kts"
|
||||
[ -e app/build.gradle.kts ] && sed -i "/qa/,/\}/ s/versionName .*/versionName = \"${{github.event.number}}\"/" "app/build.gradle.kts"
|
||||
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" "app/build.gradle"
|
||||
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" "app/build.gradle"
|
||||
./gradlew assembleQaDebug
|
||||
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:"$KS_PASS" --key-pass pass:"$KEY_PASS" --ks-key-alias key0 --ks ".github/workflows/QA_keystore.jks" app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
.github/workflows/uploadArtifact.sh "$LOG_USERNAME" "$LOG_PASSWORD" "${{github.event.number}}" "${{github.event.number}}" "$GITHUB_TOKEN"
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: REUSE Compliance Check
|
||||
uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 # v6.0.0
|
||||
uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5.0.0
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -42,6 +42,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
|
||||
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -23,19 +23,19 @@ jobs:
|
||||
matrix:
|
||||
scheme: [ Light ]
|
||||
color: [ blue ]
|
||||
api-level: [ 28 ]
|
||||
api-level: [ 27 ]
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
@@ -43,10 +43,10 @@ jobs:
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
|
||||
- name: Enable KVM group perms
|
||||
run: |
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
|
||||
- name: create AVD and generate snapshot for caching
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
|
||||
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
echo "org.gradle.configureondemand=true" >> $HOME/.gradle/gradle.properties
|
||||
echo "kapt.incremental.apt=true" >> $HOME/.gradle/gradle.properties
|
||||
|
||||
- name: Build generic flavor
|
||||
- name: Build gplay
|
||||
run: ./gradlew assembleGenericDebug
|
||||
|
||||
- name: Delete old comments
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
- name: Run screenshot tests
|
||||
env:
|
||||
SHOT_TEST: "true"
|
||||
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
|
||||
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
@@ -102,7 +102,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
|
||||
- name: Archive Espresso results
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0
|
||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
|
||||
with:
|
||||
days-before-stale: 28
|
||||
days-before-close: 14
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022-2025 Nextcloud GmbH and contributors
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
|
||||
name: Unit tests
|
||||
@@ -20,45 +20,36 @@ concurrency:
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
|
||||
- name: Delete old comments
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1
|
||||
|
||||
- name: Run unit tests with coverage
|
||||
run: ./gradlew jacocoTestGplayDebugUnitTest
|
||||
|
||||
- name: Upload failing results
|
||||
if: ${{ failure() }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
|
||||
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
fail_ci_if_error: true
|
||||
files: app/build/reports/jacoco/jacocoTestGplayDebugUnitTestReport/jacoco.xml
|
||||
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/jacoco/jacocoTestGplayDebugUnitTestReport/html/
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
- name: Delete old comments
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4
|
||||
- name: Run unit tests with coverage
|
||||
run: ./gradlew jacocoTestGplayDebugUnitTest
|
||||
- name: Upload failing results
|
||||
if: ${{ failure() }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
fail_ci_if_error: true
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/tests/testGplayDebugUnitTest/
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2019-2022 Tobias Kaminsky <[email protected]>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
#
|
||||
|
||||
#1: LOG_USERNAME
|
||||
|
||||
Generated
-7
@@ -6,19 +6,15 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
@@ -33,7 +29,6 @@
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="KotlinUnusedImport" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="LongLine" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
@@ -44,7 +39,6 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
@@ -72,7 +66,6 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
|
||||
+10
-39
@@ -14,7 +14,7 @@
|
||||
1. [Contributing to Source Code](#contributing-to-source-code)
|
||||
1. [Developing process](#developing-process)
|
||||
1. [Branching model](#branching-model)
|
||||
1. [Formatter setup](#formatter-setup)
|
||||
1. [Android Studio formatter setup](#android-studio-formatter-setup)
|
||||
1. [Build variants](#build-variants)
|
||||
1. [Git hooks](#git-hooks)
|
||||
1. [Contribution process](#contribution-process)
|
||||
@@ -107,22 +107,12 @@ We are all about quality while not sacrificing speed so we use a very pragmatic
|
||||
* Hot fixes not relevant for an upcoming feature release but the latest release can target the bug fix branch directly
|
||||
|
||||
|
||||
### Formatter setup
|
||||
### Android Studio formatter setup
|
||||
Our formatter setup is rather simple:
|
||||
* Standard Android Studio
|
||||
* Line length 120 characters (Settings->Editor->Code Style->Right margin(columns): 120; also set by EditorConfig
|
||||
* Line length 120 characters (Settings->Editor->Code Style->Right margin(columns): 120)
|
||||
* Auto optimize imports (Settings->Editor->Auto Import->Optimize imports on the fly)
|
||||
|
||||
You can fix Check / check (spotlessKotlinCheck) via following commands:
|
||||
|
||||
```bash
|
||||
./gradlew spotlessApply
|
||||
./gradlew detekt
|
||||
./gradlew spotlessCheck
|
||||
./gradlew spotlessKotlinCheck
|
||||
```
|
||||
|
||||
See section [Git hooks](#git-hooks) to have these run automatically with your commits.
|
||||
|
||||
### Build variants
|
||||
There are three build variants
|
||||
@@ -132,7 +122,7 @@ There are three build variants
|
||||
|
||||
### Git hooks
|
||||
We provide git hooks to make development process easier for both the developer and the reviewers.
|
||||
They are stored in [/scripts/hooks](/scripts/hooks) and can be installed with:
|
||||
To install them, just run:
|
||||
|
||||
```bash
|
||||
./gradlew installGitHooks
|
||||
@@ -224,44 +214,25 @@ Source code of app:
|
||||
- small, isolated tests, with no need of Android SDK
|
||||
- code coverage can be directly shown via right click on test and select "Run Test with Coverage"
|
||||
|
||||
```
|
||||
./gradlew jacocoTestGplayDebugUnitTest
|
||||
```bash
|
||||
|
||||
#### Instrumented tests
|
||||
- tests to see larger code working in correct way
|
||||
- tests that require parts of Android SDK
|
||||
- best to avoid server communication, see https://github.com/nextcloud/android/pull/3624
|
||||
|
||||
- run all tests ```./gradlew createGplayDebugCoverageReport -Pcoverage=true```
|
||||
- run selective test class: ```./gradlew createGplayDebugCoverageReport -Pcoverage=true
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerContentProviderClientIT```
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest```
|
||||
- run multiple test classes:
|
||||
- separate by ","
|
||||
- ```./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerContentProviderClientIT,com.nextcloud.client.FileDisplayActivityIT```
|
||||
- ```./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest,com.nextcloud.client.FileDisplayActivityIT```
|
||||
- run one test in class: ```./gradlew createGplayDebugCoverageReport -Pcoverage=true
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerContentProviderClientIT#saveFile```
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest#saveNewFile```
|
||||
- JaCoCo results are shown as html: firefox ./build/reports/coverage/gplay/debug/index.html
|
||||
|
||||
#### Instrumented tests with server communication
|
||||
It is best to avoid server communication, see https://github.com/nextcloud/android/pull/3624.
|
||||
But if a test requires a server, this is how it is done:
|
||||
- Have a Nextcloud service reachable by your test device. This can be an existing server in the internet or a locally deployed one
|
||||
as per the [server developer documentation](https://docs.nextcloud.com/server/latest/developer_manual/getting_started/devenv.html)
|
||||
- Create a separate(!) test user on that server, otherwise the tests will infer with productive data.
|
||||
- In `gradle.properties`, enter the URL, user name and password via the `NC_TEST_SERVER_...` attributes.
|
||||
If you want to prevent an accidental commit of those, you can also store them in `~/.gradle/gradle.properties`.
|
||||
- Your test class should inherit from `AbstractOnServerIT`, e.g.: `public class DownloadIT extends AbstractOnServerIT { ...`
|
||||
Note that this will automatically delete all files after each test run, so you absolutely NEED a separate test user as mentioned above.
|
||||
- All preconditions of your test regarding server data, e.g. existing files, need to be established by your test itself.
|
||||
As a reference, see how `DownloadIT` first uploads the files it later tests the download with.
|
||||
- Clean up these preconditions again, also in the failure case, using one or multiple `@After` methods in your test class.
|
||||
|
||||
#### UI tests
|
||||
We use [shot](https://github.com/Karumi/Shot) for taking screenshots and compare them.
|
||||
To exclude the shot dependency from normal builds, the dependency needs to be activated via an environment variable `SHOT_TEST`.
|
||||
For convenience, this and other prerequisites are encapsulated in utility scripts, so it is advised to use them
|
||||
- check screenshots: ```scripts/androidScreenshotTest ```
|
||||
- check the script for a detailed documentation of the parameters
|
||||
We use [shot](https://github.com/Karumi/Shot) for taking screenshots and compare them
|
||||
- check screenshots: ```./gradlew gplayDebugExecuteScreenshotTests ```
|
||||
- update/generate new screenshots: ```scripts/updateScreenshots.sh ```
|
||||
- in this script are samples how to only execute a given class/test
|
||||
- this will fire up docker & emulator to ensure that screenshots look the same
|
||||
|
||||
+32
-31
@@ -1,41 +1,40 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.8)
|
||||
abbrev (0.1.2)
|
||||
addressable (2.8.8)
|
||||
public_suffix (>= 2.0.2, < 8.0)
|
||||
CFPropertyList (3.0.7)
|
||||
base64
|
||||
nkf
|
||||
rexml
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1213.0)
|
||||
aws-sdk-core (3.242.0)
|
||||
aws-partitions (1.1121.0)
|
||||
aws-sdk-core (3.226.1)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
bigdecimal
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
aws-sdk-kms (1.121.0)
|
||||
aws-sdk-core (~> 3, >= 3.241.4)
|
||||
aws-sdk-kms (1.106.0)
|
||||
aws-sdk-core (~> 3, >= 3.225.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.213.0)
|
||||
aws-sdk-core (~> 3, >= 3.241.4)
|
||||
aws-sdk-s3 (1.191.0)
|
||||
aws-sdk-core (~> 3, >= 3.225.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.12.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.3.0)
|
||||
bigdecimal (3.3.1)
|
||||
cgi (0.4.2)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
csv (3.3.5)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
@@ -43,34 +42,37 @@ GEM
|
||||
dotenv (2.8.1)
|
||||
emoji_regex (3.2.3)
|
||||
excon (0.112.0)
|
||||
faraday (1.8.0)
|
||||
faraday (1.10.4)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-retry (~> 1.0)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.8)
|
||||
faraday-cookie_jar (0.0.7)
|
||||
faraday (>= 0.8.0)
|
||||
http-cookie (>= 1.0.0)
|
||||
http-cookie (~> 1.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.1)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.1.1)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.0)
|
||||
fastlane (2.229.0)
|
||||
fastlane (2.228.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
abbrev (~> 0.1.2)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
aws-sdk-s3 (~> 1.0)
|
||||
@@ -78,7 +80,6 @@ GEM
|
||||
bundler (>= 1.12.0, < 3.0.0)
|
||||
colored (~> 1.2)
|
||||
commander (~> 4.6)
|
||||
csv (~> 3.3)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 1.0.0)
|
||||
@@ -98,7 +99,6 @@ GEM
|
||||
jwt (>= 2.1.0, < 3)
|
||||
mini_magick (>= 4.9.4, < 5.0.0)
|
||||
multipart-post (>= 2.0.0, < 3.0.0)
|
||||
mutex_m (~> 0.3.0)
|
||||
naturally (~> 2.2)
|
||||
optparse (>= 0.1.1, < 1.0.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
@@ -160,36 +160,37 @@ GEM
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.18.1)
|
||||
jwt (2.10.2)
|
||||
json (2.12.2)
|
||||
jwt (2.10.1)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.19.1)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.3.0)
|
||||
optparse (0.8.1)
|
||||
nkf (0.2.0)
|
||||
optparse (0.6.0)
|
||||
os (1.1.4)
|
||||
plist (3.7.2)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.3.1)
|
||||
rake (13.3.0)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.1.2)
|
||||
rexml (3.4.4)
|
||||
rexml (3.4.1)
|
||||
rouge (3.28.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
signet (0.21.0)
|
||||
signet (0.20.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
jwt (>= 1.5, < 4.0)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.10)
|
||||
CFPropertyList
|
||||
|
||||
@@ -16,7 +16,7 @@ height="80">](https://f-droid.org/packages/com.nextcloud.client/)
|
||||
alt="Get it with Obtainium"
|
||||
height="80">](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22com.nextcloud.client%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fnextcloud%2Fandroid%22%2C%22author%22%3A%22nextcloud%22%2C%22name%22%3A%22Nextcloud%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22includePrereleases%5C%22%3Afalse%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22filterReleaseNotesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22sortMethodChoice%5C%22%3A%5C%22date%5C%22%2C%5C%22useLatestAssetDateAsReleaseDate%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%2C%5C%22trackOnly%5C%22%3Afalse%2C%5C%22versionExtractionRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22matchGroupToUse%5C%22%3A%5C%22%5C%22%2C%5C%22versionDetection%5C%22%3Atrue%2C%5C%22releaseDateAsVersion%5C%22%3Afalse%2C%5C%22useVersionCodeAsOSVersion%5C%22%3Afalse%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Enextcloud.*%5C%22%2C%5C%22invertAPKFilter%5C%22%3Afalse%2C%5C%22autoApkFilterByArch%5C%22%3Atrue%2C%5C%22appName%5C%22%3A%5C%22%5C%22%2C%5C%22appAuthor%5C%22%3A%5C%22%5C%22%2C%5C%22shizukuPretendToBeGooglePlay%5C%22%3Afalse%2C%5C%22allowInsecure%5C%22%3Afalse%2C%5C%22exemptFromBackgroundUpdates%5C%22%3Afalse%2C%5C%22skipUpdateNotifications%5C%22%3Afalse%2C%5C%22about%5C%22%3A%5C%22Nextcloud%20ist%20eine%20Cloudanwendung%2C%20die%20selbst%20gehostet%20werden%20kann.%5C%22%2C%5C%22refreshBeforeDownload%5C%22%3Atrue%7D%22%2C%22overrideSource%22%3Anull%7D)
|
||||
|
||||
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK using the official Android documentation.
|
||||
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK:
|
||||
- APK with "gplay" name, found [here](https://github.com/nextcloud/android/releases) or distributed via Google Play Store
|
||||
- APK with "nextcloud", found [here](https://github.com/nextcloud/android/releases)
|
||||
- not suitable for Fdroid downloads, as Fdroid is signing it on their own
|
||||
@@ -48,7 +48,6 @@ If you want to [contribute](https://nextcloud.com/contribute/) to the Nextcloud
|
||||
* reporting problems / suggesting enhancements by [opening new issues](https://github.com/nextcloud/android/issues/new/choose)
|
||||
* implementing proposed bug fixes and enhancement ideas by submitting PRs (associated with a corresponding issue preferably)
|
||||
* reviewing [pull requests](https://github.com/nextcloud/android/pulls) and providing feedback on code, implementation, and functionality
|
||||
* Add [automated tests](CONTRIBUTING.md#testing) for existing functionality
|
||||
* installing and testing [pull request builds](https://github.com/nextcloud/android/pulls), [daily/dev builds](https://github.com/nextcloud/android#development-version-hammer), or [RCs/release candidate builds](https://github.com/nextcloud/android/releases)
|
||||
* enhancing Admin, User, or Developer [documentation](https://github.com/nextcloud/documentation/)
|
||||
* hitting hard on the latest stable release by testing fundamental features and evaluating the user experience
|
||||
|
||||
+4
-4
@@ -30,13 +30,13 @@ SPDX-FileCopyrightText = "2015-2016 ownCloud Inc."
|
||||
SPDX-License-Identifier = "GPL-2.0-only"
|
||||
|
||||
[[annotations]]
|
||||
path = ["app/src/**/res/mipmap-**dpi/ic_launcher.png", "app/src/**/ic_launcher-web.png", "src/**/fastlane/metadata/en-US/images/*.png", "src/generic/fastlane/metadata/android/en-US/images/icon.png", "src/versionDev/fastlane/metadata/android/en-US/images/icon.png", "app/src/main/ic_launcher-web-round.png"]
|
||||
path = ["app/src/**/res/mipmap-**dpi/ic_launcher.png", "app/src/**/ic_launcher-web.png", "src/generic/fastlane/metadata/android/en-US/images/icon.png", "src/versionDev/fastlane/metadata/android/en-US/images/icon.png", "app/src/main/ic_launcher-web-round.png"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2017-2025 Nextcloud GmbH <https://nextcloud.com/trademarks/>"
|
||||
SPDX-FileCopyrightText = "2017-2024 Nextcloud GmbH <https://nextcloud.com/trademarks/>"
|
||||
SPDX-License-Identifier = "LicenseRef-NextcloudTrademarks"
|
||||
|
||||
[[annotations]]
|
||||
path = [".idea/**", "app/schemas/com.nextcloud.client.database.NextcloudDatabase/**.json", "app/screenshots/generic/debug/**.png", "app/src/main/res/values-**/strings.xml", "src/**/fastlane/metadata/**/*.txt", "src/versionDev/fastlane/metadata/android/**/changelogs/**.txt", "app/src/androidTest/assets/**", "app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "app/src/**/google-services.json", "app/src/main/res/drawable-**dpi/checker_16_16.png", "app/src/main/res/raw/encryption_key_words.txt", "app/src/main/resources/ical4j.properties", "app/src/main/res/drawable-**dpi/apk.png", "app/src/main/res/drawable-**dpi/fdroid.png", "app/src/main/res/drawable-**dpi/playstore.png", "app/src/main/res/drawable-**dpi/background.png", "app/src/main/res/drawable-**dpi/background_nc18.png"]
|
||||
path = [".idea/**", "app/schemas/com.nextcloud.client.database.NextcloudDatabase/**.json", "app/screenshots/generic/debug/**.png", "app/src/main/res/values-**/strings.xml", "src/**/fastlane/metadata/android/**/**.txt", "src/versionDev/fastlane/metadata/android/**/changelogs/**.txt", "app/src/androidTest/assets/**", "app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "app/src/**/google-services.json", "app/src/main/res/drawable-**dpi/checker_16_16.png", "app/src/main/res/raw/encryption_key_words.txt", "app/src/main/resources/ical4j.properties", "app/src/main/res/drawable-**dpi/apk.png", "app/src/main/res/drawable-**dpi/fdroid.png", "app/src/main/res/drawable-**dpi/playstore.png", "app/src/main/res/drawable-**dpi/background.png", "app/src/main/res/drawable-**dpi/background_nc18.png"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2016-2025 Nextcloud GmbH and Nextcloud contributors"
|
||||
SPDX-FileCopyrightText = "2016-2024 Nextcloud GmbH and Nextcloud contributors"
|
||||
SPDX-License-Identifier = "AGPL-3.0-or-later"
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
<!--
|
||||
~ SPDX-FileCopyrightText: 2025 Saeed <[email protected]>
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
-->
|
||||
# تطبيق [Nextcloud](https://nextcloud.com)لأجهزة أندرويد 📱
|
||||
|
||||
[](https://api.reuse.software/info/github.com/nextcloud/android)
|
||||
[](https://drone.nextcloud.com/nextcloud/android)
|
||||
[](https://app.codacy.com/gh/nextcloud/android/dashboard)
|
||||
[](https://github.com/nextcloud/android/releases/latest)
|
||||
|
||||
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" alt="تحميل من Google Play" height="80">](https://play.google.com/store/apps/details?id=com.nextcloud.client)
|
||||
[<img src="https://f-droid.org/badge/get-it-on.png" alt="احصل عليه من F-Droid" height="80">](https://f-droid.org/packages/com.nextcloud.client/)
|
||||
|
||||
## التحقق من توقيع التطبيق 🔐
|
||||
|
||||
للتأكد من صحة ملف APK:
|
||||
|
||||
- ملف APK باسم "gplay" متوفر [هنا](https://github.com/nextcloud/android/releases) أو عبر متجر Google Play
|
||||
- ملف APK باسم "nextcloud" متوفر [هنا](https://github.com/nextcloud/android/releases)
|
||||
- غير مناسب لتحميلات F-Droid، لأن F-Droid يقوم بتوقيعه بنفسه
|
||||
|
||||
```plaintext
|
||||
SHA-256: fb009522f65e25802261b67b10a45fd70e610031976f40b28a649e152ded0373
|
||||
SHA-1: 74aa1702e714941be481e1f7ce4a8f779c19dcea
|
||||
```
|
||||
|
||||
**تطبيق Nextcloud لأندرويد يتيح لك إدارة بياناتك بسهولة على خادم Nextcloud الخاص بك.**
|
||||
|
||||
## الحصول على الدعم 🆘
|
||||
|
||||
إذا واجهت مشكلة أو لديك سؤال، يمكنك زيارة [منتدى الدعم](https://help.nextcloud.com/c/clients/android).
|
||||
إذا اكتشفت خطأ أو لديك اقتراح لتحسين التطبيق، يمكنك [فتح قضية جديدة على GitHub](https://github.com/nextcloud/android/issues).
|
||||
|
||||
إذا لم تكن متأكدًا ما إذا كانت المشكلة ناتجة عن التطبيق أو الإعدادات أو الخادم، فابدأ بالسؤال في المنتدى، ثم عد إلى GitHub إذا لزم الأمر.
|
||||
|
||||
> ملاحظة: هذا المستودع خاص بتطبيق أندرويد فقط. إذا كانت المشكلة في الخادم، يرجى التواصل مع [فريق خادم Nextcloud](https://github.com/nextcloud/server).
|
||||
|
||||
## كيف تساهم في المشروع 🚀
|
||||
|
||||
هناك العديد من الطرق للمساهمة، سواء كنت مبرمجًا أو لا:
|
||||
|
||||
- مساعدة المستخدمين في المنتدى: https://help.nextcloud.com
|
||||
- ترجمة التطبيق عبر [Transifex](https://app.transifex.com/nextcloud/nextcloud/android/)
|
||||
- الإبلاغ عن المشاكل أو تقديم اقتراحات عبر [GitHub Issues](https://github.com/nextcloud/android/issues/new/choose)
|
||||
- تنفيذ إصلاحات أو تحسينات عبر Pull Requests
|
||||
- مراجعة [طلبات الدمج](https://github.com/nextcloud/android/pulls)
|
||||
- اختبار النسخ التجريبية أو اليومية أو المرشحة للإصدار
|
||||
- تحسين [التوثيق](https://github.com/nextcloud/documentation/)
|
||||
- اختبار الميزات الأساسية في آخر إصدار مستقر
|
||||
- تعلم كيفية جمع سجلات الأخطاء (logcat) لتقديم تقارير دقيقة
|
||||
|
||||
## إرشادات المساهمة والترخيص 📜
|
||||
|
||||
- الترخيص: [GPLv2](https://github.com/nextcloud/android/blob/master/LICENSE.txt)
|
||||
- جميع المساهمات بعد 16 يونيو 2016 تعتبر مرخصة تحت AGPLv3 أو أي إصدار لاحق
|
||||
- لا حاجة لتوقيع اتفاقية مساهم (CLA)
|
||||
- يُفضل إضافة السطر التالي في رأس الملف عند إجراء تغييرات كبيرة:
|
||||
|
||||
```plaintext
|
||||
SPDX-FileCopyrightText: <السنة> <اسمك> <بريدك الإلكتروني>
|
||||
```
|
||||
|
||||
يرجى قراءة [مدونة السلوك](https://nextcloud.com/community/code-of-conduct/) لضمان بيئة تعاون إيجابية.
|
||||
راجع أيضًا [إرشادات المساهمة](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## ابدأ بالمساهمة 🔧
|
||||
|
||||
- اقرأ [SETUP.md](https://github.com/nextcloud/android/blob/master/SETUP.md) و[CONTRIBUTING.md](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md)
|
||||
- قم بعمل fork للمستودع وابدأ بإرسال Pull Requests إلى فرع master
|
||||
- يمكنك البدء بمراجعة [طلبات الدمج](https://github.com/nextcloud/android/pulls) أو العمل على [القضايا المبتدئة](https://github.com/nextcloud/android/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
|
||||
|
||||
## جمع سجلات الأخطاء (logcat) 🔍
|
||||
|
||||
### على لينكس:
|
||||
|
||||
- فعّل USB-Debugging على هاتفك
|
||||
- افتح الطرفية وأدخل:
|
||||
|
||||
```bash
|
||||
adb logcat --pid=$(adb shell pidof -s 'com.nextcloud.client') > logcatOutput.txt
|
||||
```
|
||||
|
||||
> تأكد من تثبيت [adb](https://developer.android.com/studio/releases/platform-tools.html)
|
||||
|
||||
### على ويندوز:
|
||||
|
||||
- حمّل [Minimal ADB and Fastboot](https://forum.xda-developers.com/t/tool-minimal-adb-and-fastboot-2-9-18.2317790/#post-42407269)
|
||||
- فعّل USB-Debugging
|
||||
- افتح البرنامج وأدخل:
|
||||
|
||||
```bash
|
||||
adb shell pidof -s 'com.nextcloud.client'
|
||||
```
|
||||
|
||||
- استخدم الناتج كـ `<processID>` في الأمر التالي:
|
||||
|
||||
```bash
|
||||
adb logcat --pid=<processID> > "%USERPROFILE%\Downloads\logcatOutput.txt"
|
||||
```
|
||||
|
||||
### على الجهاز (مع صلاحيات root):
|
||||
|
||||
```bash
|
||||
su
|
||||
logcat -d --pid $(pidof -s com.nextcloud.client) -f /sdcard/logcatOutput.txt
|
||||
```
|
||||
|
||||
أو استخدم تطبيقات مثل [CatLog](https://play.google.com/store/apps/details?id=com.nolanlawson.logcat) أو [aLogcat](https://play.google.com/store/apps/details?id=org.jtb.alogcat)
|
||||
|
||||
## النسخة التطويرية 🛠️
|
||||
|
||||
- [تحميل مباشر للـ APK](https://download.nextcloud.com/android/dev/latest.apk)
|
||||
- [F-Droid النسخة التجريبية](https://f-droid.org/en/packages/com.nextcloud.android.beta/)
|
||||
|
||||
## المشاكل المعروفة والأسئلة الشائعة
|
||||
|
||||
### الإشعارات الفورية لا تعمل في نسخ F-Droid
|
||||
|
||||
بسبب اعتمادها على خدمات Google Play، لا تعمل الإشعارات الفورية في نسخ F-Droid حاليًا.
|
||||
@@ -0,0 +1,591 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2024 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2024 Andy Scherzinger <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
import com.github.spotbugs.snom.Confidence
|
||||
import com.github.spotbugs.snom.Effort
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:$androidPluginVersion"
|
||||
classpath libs.spotbugs.gradle.plugin
|
||||
classpath libs.kotlin.gradle.plugin
|
||||
classpath libs.detekt.gradle.plugin
|
||||
classpath libs.commons.httpclient.commons.httpclient // remove after entire switch to lib v2
|
||||
classpath libs.shot
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.spotless)
|
||||
alias(libs.plugins.kapt)
|
||||
alias(libs.plugins.ksp) apply false
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
}
|
||||
|
||||
apply plugin: "com.android.application"
|
||||
|
||||
apply plugin: "kotlin-android"
|
||||
apply plugin: "kotlin-parcelize"
|
||||
apply plugin: "checkstyle"
|
||||
apply plugin: "pmd"
|
||||
apply from: "$rootProject.projectDir/jacoco.gradle"
|
||||
apply plugin: "com.github.spotbugs"
|
||||
apply plugin: "io.gitlab.arturbosch.detekt"
|
||||
|
||||
// needed to make renovate run without shot, as shot requires Android SDK
|
||||
// https://github.com/pedrovgs/Shot/issues/300
|
||||
if (shotTest) {
|
||||
apply plugin: "shot"
|
||||
}
|
||||
apply plugin: "com.google.devtools.ksp"
|
||||
|
||||
|
||||
println "Gradle uses Java ${Jvm.current()}"
|
||||
|
||||
configurations {
|
||||
configureEach {
|
||||
exclude group: "org.jetbrains", module: "annotations-java5" // via prism4j, already using annotations explicitly
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy.eachDependency {
|
||||
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
|
||||
useVersion(checkerVersion)
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
}
|
||||
|
||||
if (requested.group == "commons-logging" && requested.name == "commons-logging") {
|
||||
useTarget("org.slf4j:jcl-over-slf4j:1.7.36")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 35
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
|
||||
def ndkEnv = new HashMap<String, String>()
|
||||
file("$project.rootDir/ndk.env").readLines().each() {
|
||||
def (key, value) = it.tokenize("=")
|
||||
ndkEnv.put(key, value)
|
||||
}
|
||||
|
||||
def perfAnalysis = project.hasProperty("perfAnalysis")
|
||||
|
||||
def getConfigProperties() {
|
||||
def props = new Properties()
|
||||
def file = rootProject.file(".gradle/config.properties")
|
||||
if (file.exists()) {
|
||||
props.load(new FileInputStream(file))
|
||||
}
|
||||
return props
|
||||
}
|
||||
|
||||
def configProps = getConfigProperties()
|
||||
|
||||
android {
|
||||
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
|
||||
ndkVersion = "${ndkEnv.get("NDK_VERSION")}"
|
||||
|
||||
|
||||
namespace = "com.owncloud.android"
|
||||
testNamespace = "${namespace}.test"
|
||||
|
||||
androidResources {
|
||||
generateLocaleConfig = true
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.nextcloud.client"
|
||||
minSdk = 27
|
||||
targetSdk = 35
|
||||
compileSdk = 35
|
||||
|
||||
buildConfigField "boolean", "CI", ciBuild.toString()
|
||||
buildConfigField "boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString()
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
if (shotTest) {
|
||||
testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
|
||||
} else {
|
||||
testInstrumentationRunner "com.nextcloud.client.TestRunner"
|
||||
}
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
|
||||
testInstrumentationRunnerArguments disableAnalytics: "true"
|
||||
|
||||
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
|
||||
if (versionBuild > 89) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
} else if (versionBuild > 50) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
|
||||
} else {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
flavorDimensions += "default"
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
buildConfigField "String", "NC_TEST_SERVER_DATA_STRING", "\"\""
|
||||
}
|
||||
|
||||
debug {
|
||||
testCoverageEnabled = project.hasProperty("coverage")
|
||||
resConfigs "xxxhdpi"
|
||||
|
||||
buildConfigField "String", "NC_TEST_SERVER_DATA_STRING", "\"nc://login/user:${configProps['NC_TEST_SERVER_USERNAME']}&password:${configProps['NC_TEST_SERVER_PASSWORD']}&server:${configProps['NC_TEST_SERVER_BASEURL']}\""
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
generic {
|
||||
applicationId "com.nextcloud.client"
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
gplay {
|
||||
applicationId "com.nextcloud.client"
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
huawei {
|
||||
applicationId "com.nextcloud.client"
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20220322
|
||||
versionName "20220322"
|
||||
}
|
||||
|
||||
qa {
|
||||
applicationId "com.nextcloud.android.qa"
|
||||
dimension "default"
|
||||
versionCode 1
|
||||
versionName "1"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
animationsDisabled = true
|
||||
}
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += "META-INF/LICENSE*"
|
||||
excludes += "META-INF/versions/9/OSGI-INF/MANIFEST*"
|
||||
pickFirst "MANIFEST.MF" // workaround for duplicated manifest on some dependencies
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkstyle", Checkstyle) {
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
|
||||
source "src"
|
||||
include "**/*.java"
|
||||
exclude "**/gen/**"
|
||||
classpath = files()
|
||||
}
|
||||
|
||||
tasks.register("pmd", Pmd) {
|
||||
ruleSetFiles = files("${project.rootDir}/ruleset.xml")
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = []
|
||||
|
||||
source "src"
|
||||
include "**/*.java"
|
||||
exclude "**/gen/**"
|
||||
|
||||
reports {
|
||||
xml {
|
||||
destination = layout.buildDirectory.file("reports/pmd/pmd.xml").get().asFile
|
||||
}
|
||||
html {
|
||||
destination = layout.buildDirectory.file("reports/pmd/pmd.html").get().asFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn "checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt"
|
||||
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
aidl = true
|
||||
compose = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError = false
|
||||
checkGeneratedSources = true
|
||||
disable "MissingTranslation", "GradleDependency", "VectorPath", "IconMissingDensityFolder", "IconDensities", "GoogleAppIndexingWarning", "MissingDefaultResource", "InvalidPeriodicWorkRequestInterval", "StringFormatInvalid", "MissingQuantity"
|
||||
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
|
||||
htmlReport = true
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
// Adds exported schema location as test app assets.
|
||||
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
||||
}
|
||||
|
||||
kapt {
|
||||
useBuildCache = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// region Nextcloud library
|
||||
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: "org.ogce", module: "xpp3" // unused in Android and brings wrong Junit version
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Splash Screen
|
||||
implementation libs.splashscreen
|
||||
// endregion
|
||||
|
||||
// region Jetpack Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.graphics)
|
||||
implementation(libs.compose.material3)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
// endregion
|
||||
|
||||
// region Media3
|
||||
implementation libs.media3.ui
|
||||
implementation libs.media3.session
|
||||
implementation libs.media3.exoplayer
|
||||
implementation libs.media3.datasource
|
||||
// endregion
|
||||
|
||||
// region Room
|
||||
implementation libs.room.runtime
|
||||
ksp "androidx.room:room-compiler:$roomVersion"
|
||||
androidTestImplementation libs.room.testing
|
||||
// endregion
|
||||
|
||||
// region Espresso
|
||||
androidTestImplementation libs.espresso.core
|
||||
androidTestImplementation libs.espresso.contrib
|
||||
androidTestImplementation libs.espresso.web
|
||||
androidTestImplementation libs.espresso.accessibility
|
||||
androidTestImplementation libs.espresso.intents
|
||||
androidTestImplementation libs.espresso.idling.resource
|
||||
// endregion
|
||||
|
||||
// region Glide
|
||||
implementation libs.glide
|
||||
ksp libs.ksp
|
||||
// endregion
|
||||
|
||||
// region UI
|
||||
implementation libs.appcompat
|
||||
implementation libs.webkit
|
||||
implementation libs.cardview
|
||||
implementation libs.exifinterface
|
||||
implementation libs.fragment.ktx
|
||||
// endregion
|
||||
|
||||
// region Worker
|
||||
implementation libs.work.runtime
|
||||
implementation libs.work.runtime.ktx
|
||||
// endregion
|
||||
|
||||
// region Lifecycle
|
||||
implementation libs.lifecycle.viewmodel.ktx
|
||||
implementation libs.lifecycle.service
|
||||
implementation(libs.lifecycle.runtime.ktx)
|
||||
// endregion
|
||||
|
||||
// region JUnit
|
||||
androidTestImplementation libs.junit
|
||||
androidTestImplementation libs.rules
|
||||
androidTestImplementation libs.runner
|
||||
androidTestUtil libs.orchestrator
|
||||
androidTestImplementation libs.core.ktx
|
||||
androidTestImplementation libs.core.testing
|
||||
// endregion
|
||||
|
||||
// region other libraries
|
||||
compileOnly libs.org.jbundle.util.osgi.wrapped.org.apache.http.client
|
||||
implementation libs.commons.httpclient.commons.httpclient // remove after entire switch to lib v2
|
||||
implementation libs.jackrabbit.webdav // remove after entire switch to lib v2
|
||||
implementation libs.constraintlayout
|
||||
implementation libs.legacy.support.v4
|
||||
implementation libs.material
|
||||
implementation libs.disklrucache
|
||||
implementation libs.juniversalchardet // need this version for Android <7
|
||||
compileOnly libs.annotations
|
||||
implementation libs.commons.io
|
||||
implementation libs.eventbus
|
||||
implementation libs.ez.vcard
|
||||
implementation libs.nnio
|
||||
implementation libs.bcpkix.jdk18on
|
||||
implementation libs.gson
|
||||
implementation libs.sectioned.recyclerview
|
||||
implementation libs.photoview
|
||||
implementation libs.android.gif.drawable
|
||||
implementation libs.qrcodescanner // "com.github.blikoon:QRCodeScanner:0.1.2"
|
||||
implementation libs.flexbox
|
||||
implementation libs.androidsvg
|
||||
implementation libs.annotation
|
||||
implementation libs.emoji.google
|
||||
// endregion
|
||||
|
||||
// region AppScan, document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
gplayImplementation project(":appscan")
|
||||
huaweiImplementation project(":appscan")
|
||||
qaImplementation project(":appscan")
|
||||
// endregion
|
||||
|
||||
// region SpotBugs
|
||||
spotbugsPlugins libs.findsecbugs.plugin
|
||||
spotbugsPlugins libs.fb.contrib
|
||||
// endregion
|
||||
|
||||
// region Dagger
|
||||
implementation libs.dagger
|
||||
implementation libs.dagger.android
|
||||
implementation libs.dagger.android.support
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
// endregion
|
||||
|
||||
// region Crypto
|
||||
implementation libs.conscrypt.android
|
||||
// endregion
|
||||
|
||||
// region Library
|
||||
implementation libs.library
|
||||
// endregion
|
||||
|
||||
// region Shimmer
|
||||
implementation libs.loaderviewlibrary
|
||||
// endregion
|
||||
|
||||
// region Markdown rendering
|
||||
implementation libs.core
|
||||
implementation libs.ext.strikethrough
|
||||
implementation libs.ext.tables
|
||||
implementation libs.ext.tasklist
|
||||
implementation libs.html
|
||||
implementation libs.syntax.highlight
|
||||
implementation libs.prism4j
|
||||
kapt "io.noties:prism4j-bundler:$prismVersion"
|
||||
// endregion
|
||||
|
||||
// region Image cropping / rotation
|
||||
implementation libs.android.image.cropper
|
||||
// endregion
|
||||
|
||||
// region Maps
|
||||
implementation libs.osmdroid.android
|
||||
// endregion
|
||||
|
||||
// region iCal4j
|
||||
implementation(libs.ical4j) {
|
||||
["org.apache.commons", "commons-logging"].each {
|
||||
exclude group: "$it"
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region LeakCanary
|
||||
if (perfAnalysis) {
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:2.14"
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Local Unit Test
|
||||
testImplementation libs.junit.junit
|
||||
testImplementation libs.mockito.core
|
||||
testImplementation libs.test.core
|
||||
testImplementation libs.json
|
||||
testImplementation libs.mockito.kotlin
|
||||
testImplementation libs.core.testing
|
||||
testImplementation "io.mockk:mockk:$mockkVersion"
|
||||
testImplementation libs.mockk.android
|
||||
// endregion
|
||||
|
||||
// region Mocking support
|
||||
androidTestImplementation libs.dexopener // required to allow mocking on API 27 and older
|
||||
androidTestImplementation libs.mockito.kotlin
|
||||
androidTestImplementation libs.mockito.core
|
||||
androidTestImplementation(libs.mockito.android)
|
||||
androidTestImplementation libs.mockk.android
|
||||
androidTestImplementation libs.screenshot.core
|
||||
// endregion
|
||||
|
||||
// region UIAutomator
|
||||
// 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
|
||||
// androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation libs.screengrab
|
||||
// endregion
|
||||
|
||||
// region Kotlin
|
||||
implementation libs.kotlin.stdlib
|
||||
// endregion
|
||||
|
||||
// region Stateless
|
||||
implementation libs.stateless4j
|
||||
// endregion
|
||||
|
||||
// region Google Play dependencies, upon each update first test: new registration, receive push
|
||||
gplayImplementation libs.firebase.messaging
|
||||
gplayImplementation libs.play.services.base
|
||||
gplayImplementation libs.review.ktx
|
||||
// endregion
|
||||
|
||||
// region UI
|
||||
implementation libs.ui
|
||||
// endregion
|
||||
|
||||
// region Image loading
|
||||
implementation libs.coil
|
||||
// endregion
|
||||
|
||||
// kotlinx.serialization
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy {
|
||||
force "org.objenesis:objenesis:3.4"
|
||||
eachDependency { details ->
|
||||
if ("org.jacoco" == details.requested.group) {
|
||||
details.useVersion "$jacoco_version"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run the compiler as a separate process
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.fork = true
|
||||
|
||||
// Enable Incremental Compilation
|
||||
options.incremental = true
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
// Run tests in parallel
|
||||
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
|
||||
|
||||
// increased logging for tests
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.configureEach { variant ->
|
||||
variant.outputs.configureEach { output -> outputFileName = "${output.baseName}-${variant.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
spotless {
|
||||
kotlin {
|
||||
target "**/*.kt"
|
||||
ktlint()
|
||||
}
|
||||
}
|
||||
|
||||
detekt {
|
||||
config.setFrom("detekt.yml")
|
||||
}
|
||||
|
||||
if (shotTest) {
|
||||
shot {
|
||||
showOnlyFailingTestsInReports = ciBuild
|
||||
// CI environment renders some shadows slightly different from local VMs
|
||||
// Add a 0.5% tolerance to account for that
|
||||
tolerance = ciBuild ? 0.1 : 0
|
||||
}
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "$jacoco_version"
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = Effort.MAX
|
||||
reportLevel = Confidence.valueOf("MEDIUM")
|
||||
}
|
||||
|
||||
tasks.withType(SpotBugsTask){task ->
|
||||
String variantNameCap = task.name.replace("spotbugs", "")
|
||||
String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
|
||||
dependsOn "compile${variantNameCap}Sources"
|
||||
|
||||
classes = fileTree(layout.buildDirectory.get().asFile.toString()+"/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/")
|
||||
excludeFilter = file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml")
|
||||
reports {
|
||||
xml {
|
||||
required = true
|
||||
}
|
||||
html {
|
||||
required = true
|
||||
outputLocation = layout.buildDirectory.file("reports/spotbugs/spotbugs.html").get().asFile
|
||||
stylesheet = "fancy.xsl"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksp {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
}
|
||||
@@ -1,514 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Jimly Asshiddiqy <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
@file:Suppress("UnstableApiUsage", "DEPRECATION")
|
||||
|
||||
import com.android.build.gradle.internal.api.ApkVariantOutputImpl
|
||||
import com.github.spotbugs.snom.Confidence
|
||||
import com.github.spotbugs.snom.Effort
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
import com.karumi.shot.ShotExtension
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import java.io.FileInputStream
|
||||
import java.util.Properties
|
||||
|
||||
val shotTest = System.getenv("SHOT_TEST") == "true"
|
||||
val ciBuild = System.getenv("CI") == "true"
|
||||
val perfAnalysis = project.hasProperty("perfAnalysis")
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.spotless)
|
||||
alias(libs.plugins.kapt)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.kotlin.parcelize)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
alias(libs.plugins.spotbugs)
|
||||
alias(libs.plugins.detekt)
|
||||
// needed to make renovate run without shot, as shot requires Android SDK
|
||||
// https://github.com/pedrovgs/Shot/issues/300
|
||||
if (System.getenv("SHOT_TEST") == "true") alias(libs.plugins.shot)
|
||||
id("checkstyle")
|
||||
id("pmd")
|
||||
}
|
||||
apply(from = "${rootProject.projectDir}/jacoco.gradle.kts")
|
||||
|
||||
println("Gradle uses Java ${Jvm.current()}")
|
||||
|
||||
configurations.configureEach {
|
||||
// via prism4j, already using annotations explicitly
|
||||
exclude(group = "org.jetbrains", module = "annotations-java5")
|
||||
|
||||
resolutionStrategy {
|
||||
force(libs.objenesis)
|
||||
|
||||
eachDependency {
|
||||
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
|
||||
useVersion(libs.versions.checker.get())
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
} else if (requested.group == "org.jacoco") {
|
||||
useVersion(libs.versions.jacoco.get())
|
||||
} else if (requested.group == "commons-logging" && requested.name == "commons-logging") {
|
||||
useTarget(libs.slfj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
val versionMajor = 33
|
||||
val versionMinor = 1
|
||||
val versionPatch = 0
|
||||
val versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
val ndkEnv = buildMap {
|
||||
file("${project.rootDir}/ndk.env").readLines().forEach {
|
||||
val (key, value) = it.split("=")
|
||||
put(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
val configProps = Properties().apply {
|
||||
val file = rootProject.file("gradle.properties")
|
||||
if (file.exists()) load(FileInputStream(file))
|
||||
}
|
||||
|
||||
val ncTestServerUsername = configProps["NC_TEST_SERVER_USERNAME"]
|
||||
val ncTestServerPassword = configProps["NC_TEST_SERVER_PASSWORD"]
|
||||
val ncTestServerBaseUrl = configProps["NC_TEST_SERVER_BASEURL"]
|
||||
|
||||
android {
|
||||
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
|
||||
ndkVersion = "${ndkEnv["NDK_VERSION"]}"
|
||||
|
||||
namespace = "com.owncloud.android"
|
||||
testNamespace = "${namespace}.test"
|
||||
|
||||
androidResources.generateLocaleConfig = true
|
||||
|
||||
defaultConfig {
|
||||
testInstrumentationRunnerArguments += mapOf(
|
||||
"TEST_SERVER_URL" to ncTestServerBaseUrl.toString(),
|
||||
"TEST_SERVER_USERNAME" to ncTestServerUsername.toString(),
|
||||
"TEST_SERVER_PASSWORD" to ncTestServerPassword.toString(),
|
||||
"disableAnalytics" to "true"
|
||||
)
|
||||
applicationId = "com.nextcloud.client"
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
compileSdk = 36
|
||||
|
||||
buildConfigField("boolean", "CI", ciBuild.toString())
|
||||
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunner = if (shotTest) "com.karumi.shot.ShotTestRunner"
|
||||
else "com.nextcloud.client.TestRunner"
|
||||
|
||||
versionCode = versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
versionName = when {
|
||||
versionBuild > 89 -> "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
versionBuild > 50 -> "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
|
||||
else -> "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
flavorDimensions += "default"
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"")
|
||||
}
|
||||
|
||||
debug {
|
||||
enableUnitTestCoverage = project.hasProperty("coverage")
|
||||
resConfigs("xxxhdpi")
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
register("generic") {
|
||||
applicationId = "com.nextcloud.client"
|
||||
dimension = "default"
|
||||
}
|
||||
|
||||
register("gplay") {
|
||||
applicationId = "com.nextcloud.client"
|
||||
dimension = "default"
|
||||
}
|
||||
|
||||
register("huawei") {
|
||||
applicationId = "com.nextcloud.client"
|
||||
dimension = "default"
|
||||
}
|
||||
|
||||
register("versionDev") {
|
||||
applicationId = "com.nextcloud.android.beta"
|
||||
dimension = "default"
|
||||
versionCode = 20220322
|
||||
versionName = "20220322"
|
||||
}
|
||||
|
||||
register("qa") {
|
||||
applicationId = "com.nextcloud.android.qa"
|
||||
dimension = "default"
|
||||
versionCode = 1
|
||||
versionName = "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applicationVariants.configureEach {
|
||||
outputs.configureEach {
|
||||
if (this is ApkVariantOutputImpl) this.outputFileName = "${this.baseName}-${this.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.isReturnDefaultValues = true
|
||||
animationsDisabled = true
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
packaging.resources {
|
||||
excludes.addAll(listOf("META-INF/LICENSE*", "META-INF/versions/9/OSGI-INF/MANIFEST*"))
|
||||
pickFirsts.add("MANIFEST.MF") // workaround for duplicated manifest on some dependencies
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
aidl = true
|
||||
compose = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError = true
|
||||
warningsAsErrors = true
|
||||
checkGeneratedSources = true
|
||||
disable.addAll(
|
||||
listOf(
|
||||
"MissingTranslation",
|
||||
"GradleDependency",
|
||||
"VectorPath",
|
||||
"IconMissingDensityFolder",
|
||||
"IconDensities",
|
||||
"GoogleAppIndexingWarning",
|
||||
"MissingDefaultResource",
|
||||
"InvalidPeriodicWorkRequestInterval",
|
||||
"StringFormatInvalid",
|
||||
"MissingQuantity",
|
||||
"IconXmlAndPng",
|
||||
"SelectedPhotoAccess",
|
||||
"UnsafeIntentLaunch"
|
||||
)
|
||||
)
|
||||
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
|
||||
htmlReport = true
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
// Adds exported schema location as test app assets.
|
||||
getByName("androidTest") {
|
||||
assets.srcDirs(files("$projectDir/schemas"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
kapt.useBuildCache = true
|
||||
|
||||
ksp.arg("room.schemaLocation", "$projectDir/schemas")
|
||||
|
||||
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
|
||||
|
||||
spotless.kotlin {
|
||||
target("**/*.kt")
|
||||
ktlint()
|
||||
}
|
||||
|
||||
detekt.config.setFrom("detekt.yml")
|
||||
|
||||
if (shotTest) configure<ShotExtension> {
|
||||
showOnlyFailingTestsInReports = ciBuild
|
||||
// CI environment renders some shadows slightly different from local VMs
|
||||
// Add a 0.5% tolerance to account for that
|
||||
tolerance = if (ciBuild) 0.1 else 0.0
|
||||
}
|
||||
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = Effort.MAX
|
||||
reportLevel = Confidence.valueOf("MEDIUM")
|
||||
}
|
||||
|
||||
tasks.register<Checkstyle>("checkstyle") {
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
setConfigProperties(
|
||||
"checkstyleSuppressionsPath" to file("${rootProject.rootDir}/suppressions.xml").absolutePath
|
||||
)
|
||||
source("src")
|
||||
include("**/*.java")
|
||||
exclude("**/gen/**")
|
||||
classpath = files()
|
||||
}
|
||||
|
||||
tasks.register<Pmd>("pmd") {
|
||||
ruleSetFiles = files("${rootProject.rootDir}/ruleset.xml")
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = emptyList()
|
||||
|
||||
source("src")
|
||||
include("**/*.java")
|
||||
exclude("**/gen/**")
|
||||
|
||||
reports {
|
||||
xml.outputLocation.set(layout.buildDirectory.file("reports/pmd/pmd.xml").get().asFile)
|
||||
html.outputLocation.set(layout.buildDirectory.file("reports/pmd/pmd.html").get().asFile)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<SpotBugsTask>().configureEach {
|
||||
val variantNameCap = name.replace("spotbugs", "")
|
||||
val variantName = variantNameCap.substring(0, 1).lowercase() + variantNameCap.substring(1)
|
||||
dependsOn("compile${variantNameCap}Sources")
|
||||
|
||||
classes = fileTree(
|
||||
layout.buildDirectory.get().asFile.toString() +
|
||||
"/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/"
|
||||
)
|
||||
excludeFilter.set(file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml"))
|
||||
|
||||
reports.create("xml") {
|
||||
required.set(true)
|
||||
}
|
||||
reports.create("html") {
|
||||
required.set(true)
|
||||
outputLocation.set(layout.buildDirectory.file("reports/spotbugs/spotbugs.html"))
|
||||
setStylesheet("fancy.xsl")
|
||||
}
|
||||
}
|
||||
|
||||
// Run the compiler as a separate process
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.isFork = true
|
||||
|
||||
// Enable Incremental Compilation
|
||||
options.isIncremental = true
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
// Run tests in parallel
|
||||
maxParallelForks = maxOf(1, Runtime.getRuntime().availableProcessors().div(2))
|
||||
|
||||
// increased logging for tests
|
||||
testLogging.events("passed", "skipped", "failed")
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn("checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// region Nextcloud library
|
||||
implementation(libs.android.library) {
|
||||
exclude(group = "org.ogce", module = "xpp3") // unused in Android and brings wrong Junit version
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Splash Screen
|
||||
implementation(libs.splashscreen)
|
||||
// endregion
|
||||
|
||||
// region Jetpack Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.material.icons.core)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.graphics)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.activity)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.foundation)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
// endregion
|
||||
|
||||
// region Media3
|
||||
implementation(libs.bundles.media3)
|
||||
// endregion
|
||||
|
||||
// region Room
|
||||
implementation(libs.room.runtime)
|
||||
ksp(libs.room.compiler)
|
||||
androidTestImplementation(libs.room.testing)
|
||||
// endregion
|
||||
|
||||
// region Espresso
|
||||
androidTestImplementation(libs.bundles.espresso)
|
||||
// endregion
|
||||
|
||||
// region Glide
|
||||
implementation(libs.glide)
|
||||
ksp(libs.ksp)
|
||||
// endregion
|
||||
|
||||
// region UI
|
||||
implementation(libs.bundles.ui)
|
||||
// endregion
|
||||
|
||||
// region Worker
|
||||
implementation(libs.work.runtime)
|
||||
implementation(libs.work.runtime.ktx)
|
||||
// endregion
|
||||
|
||||
// region Lifecycle
|
||||
implementation(libs.lifecycle.viewmodel.ktx)
|
||||
implementation(libs.lifecycle.service)
|
||||
implementation(libs.lifecycle.runtime.ktx)
|
||||
// endregion
|
||||
|
||||
// region JUnit
|
||||
androidTestImplementation(libs.junit)
|
||||
androidTestImplementation(libs.rules)
|
||||
androidTestImplementation(libs.runner)
|
||||
androidTestUtil(libs.orchestrator)
|
||||
androidTestImplementation(libs.core.ktx)
|
||||
androidTestImplementation(libs.core.testing)
|
||||
// endregion
|
||||
|
||||
// region other libraries
|
||||
compileOnly(libs.org.jbundle.util.osgi.wrapped.org.apache.http.client)
|
||||
implementation(libs.commons.httpclient.commons.httpclient) // remove after entire switch to lib v2
|
||||
implementation(libs.jackrabbit.webdav) // remove after entire switch to lib v2
|
||||
implementation(libs.constraintlayout)
|
||||
implementation(libs.legacy.support.v4)
|
||||
implementation(libs.material)
|
||||
implementation(libs.disklrucache)
|
||||
implementation(libs.juniversalchardet) // need this version for Android <7
|
||||
compileOnly(libs.annotations)
|
||||
implementation(libs.commons.io)
|
||||
implementation(libs.eventbus)
|
||||
implementation(libs.ez.vcard)
|
||||
implementation(libs.nnio)
|
||||
implementation(libs.bcpkix.jdk18on)
|
||||
implementation(libs.gson)
|
||||
implementation(libs.sectioned.recyclerview)
|
||||
implementation(libs.photoview)
|
||||
implementation(libs.android.gif.drawable)
|
||||
implementation(libs.qrcodescanner) // "com.github.blikoon:QRCodeScanner:0.1.2"
|
||||
implementation(libs.flexbox)
|
||||
implementation(libs.androidsvg)
|
||||
implementation(libs.annotation)
|
||||
implementation(libs.emoji.google)
|
||||
// endregion
|
||||
|
||||
// region AppScan, document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
"gplayImplementation"(project(":appscan"))
|
||||
"huaweiImplementation"(project(":appscan"))
|
||||
"qaImplementation"(project(":appscan"))
|
||||
// endregion
|
||||
|
||||
// region SpotBugs
|
||||
spotbugsPlugins(libs.findsecbugs.plugin)
|
||||
spotbugsPlugins(libs.fb.contrib)
|
||||
// endregion
|
||||
|
||||
// region Dagger
|
||||
implementation(libs.dagger)
|
||||
implementation(libs.dagger.android)
|
||||
implementation(libs.dagger.android.support)
|
||||
ksp(libs.dagger.compiler)
|
||||
ksp(libs.dagger.processor)
|
||||
// endregion
|
||||
|
||||
// region Crypto
|
||||
implementation(libs.conscrypt.android)
|
||||
// endregion
|
||||
|
||||
// region Library
|
||||
implementation(libs.library)
|
||||
// endregion
|
||||
|
||||
// region Shimmer
|
||||
implementation(libs.loaderviewlibrary)
|
||||
// endregion
|
||||
|
||||
// region Markdown rendering
|
||||
implementation(libs.bundles.markdown.rendering)
|
||||
kapt(libs.prism4j.bundler)
|
||||
// endregion
|
||||
|
||||
// region Image cropping / rotation
|
||||
implementation(libs.android.image.cropper)
|
||||
// endregion
|
||||
|
||||
// region Maps
|
||||
implementation(libs.osmdroid.android)
|
||||
// endregion
|
||||
|
||||
// region iCal4j
|
||||
implementation(libs.ical4j) {
|
||||
listOf("org.apache.commons", "commons-logging").forEach { groupName -> exclude(group = groupName) }
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region LeakCanary
|
||||
if (perfAnalysis) debugImplementation(libs.leakcanary)
|
||||
// endregion
|
||||
|
||||
// region Local Unit Test
|
||||
testImplementation(libs.bundles.unit.test)
|
||||
// endregion
|
||||
|
||||
// region Mocking support
|
||||
androidTestImplementation(libs.bundles.mocking)
|
||||
// endregion
|
||||
|
||||
// region UIAutomator
|
||||
// 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
|
||||
// androidTestImplementation("com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation(libs.screengrab)
|
||||
// endregion
|
||||
|
||||
// region Kotlin
|
||||
implementation(libs.kotlin.stdlib)
|
||||
// endregion
|
||||
|
||||
// region Stateless
|
||||
implementation(libs.stateless4j)
|
||||
// endregion
|
||||
|
||||
// region Google Play dependencies, upon each update first test: new registration, receive push
|
||||
"gplayImplementation"(libs.bundles.gplay)
|
||||
// endregion
|
||||
|
||||
// region common
|
||||
implementation(libs.ui)
|
||||
implementation(libs.common.core)
|
||||
// endregion
|
||||
|
||||
// region Image loading
|
||||
implementation(libs.coil)
|
||||
// endregion
|
||||
|
||||
// kotlinx.serialization
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
@@ -39,10 +39,6 @@
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="PluralsCandidate">
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="ExtraTranslation">
|
||||
<ignore path="**/strings.xml"/>
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -116,14 +116,12 @@ BEGIN:VEVENT
|
||||
DTSTAMP:20210820T083606Z
|
||||
UID:[email protected]
|
||||
SUMMARY:Test event
|
||||
DESCRIPTION:Test event
|
||||
|
||||
DESCRIPTION:
|
||||
ORGANIZER:mailto:[email protected]
|
||||
LOCATION:
|
||||
STATUS:CONFIRMED
|
||||
DTSTART;TZID=Europe/Berlin:20210806T090000
|
||||
DTEND;TZID=Europe/Berlin:20210806T100000
|
||||
|
||||
DTEND:20210806T080000Z
|
||||
BEGIN:VALARM
|
||||
TRIGGER:-PT30M
|
||||
ACTION:DISPLAY
|
||||
|
||||
@@ -2,6 +2,22 @@ Java:
|
||||
|
||||
```java
|
||||
private String getAppProcessName() {
|
||||
return Application.getProcessName();
|
||||
}
|
||||
String processName = "";
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
final int ownPid = android.os.Process.myPid();
|
||||
final List<ActivityManager.RunningAppProcessInfo> processes = manager.getRunningAppProcesses();
|
||||
if (processes != null) {
|
||||
for (ActivityManager.RunningAppProcessInfo info : processes) {
|
||||
if (info.pid == ownPid) {
|
||||
processName = info.processName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
processName = Application.getProcessName();
|
||||
}
|
||||
return processName;
|
||||
}
|
||||
```
|
||||
@@ -8,8 +8,10 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
@@ -23,72 +25,88 @@ import com.owncloud.android.lib.resources.activities.model.RichObject
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.ui.activities.ActivitiesActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class ActivitiesActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.ActivitiesActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openDrawer() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.dismissSnackbar()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "openDrawer", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val screenShotName = createName("${testClassName}_openDrawer", "")
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
|
||||
onView(withId(R.id.drawer_layout)).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.dismissSnackbar()
|
||||
sut.binding.emptyList.root.visibility = View.GONE
|
||||
sut.binding.swipeContainingList.visibility = View.GONE
|
||||
sut.binding.loadingContent.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.dismissSnackbar()
|
||||
sut.binding.emptyList.root.visibility = View.GONE
|
||||
sut.binding.swipeContainingList.visibility = View.GONE
|
||||
sut.binding.loadingContent.visibility = View.VISIBLE
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.showActivities(mutableListOf(), nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showActivities(mutableListOf(), nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@SuppressWarnings("MagicNumber")
|
||||
fun showActivities() {
|
||||
@@ -168,35 +186,36 @@ class ActivitiesActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.showActivities(activities as List<Any>?, nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showActivities(activities as List<Any>?, nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "showActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.showEmptyContent("Error", "Error! Please try again later!")
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showEmptyContent("Error", "Error! Please try again later!")
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,20 @@
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.ui.activity.CommunityActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestRule
|
||||
@@ -24,18 +29,30 @@ import org.junit.rules.TestRule
|
||||
class CommunityActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.CommunityActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<CommunityActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Philipp Hasper <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -15,14 +14,12 @@ import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
|
||||
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.contrib.NavigationViewActions
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
@@ -39,7 +36,6 @@ import com.owncloud.android.operations.CreateFolderOperation
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.adapter.OCFileListItemViewHolder
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
@@ -48,7 +44,6 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class FileDisplayActivityIT : AbstractOnServerIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
@@ -241,53 +236,4 @@ class FileDisplayActivityIT : AbstractOnServerIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShowAndDismissLoadingDialog() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
val loadingText = "Some text displayed while loading"
|
||||
|
||||
// Test that display works
|
||||
scenario.onActivity { sut ->
|
||||
sut.showLoadingDialog(loadingText)
|
||||
}
|
||||
onView(withText(loadingText))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
// Test that hiding works
|
||||
scenario.onActivity { sut ->
|
||||
sut.dismissLoadingDialog()
|
||||
}
|
||||
onView(allOf(withText(loadingText), isDisplayed()))
|
||||
.check(doesNotExist())
|
||||
|
||||
// Test that there is no timing issue when hiding the dialog directly after.
|
||||
// This timing issue was reproducible when testing RemoveFilesDialogFragment#removeFiles
|
||||
// as well as sporadically "in the wild".
|
||||
scenario.onActivity { sut ->
|
||||
sut.showLoadingDialog(loadingText)
|
||||
sut.dismissLoadingDialog()
|
||||
}
|
||||
onView(allOf(withText(loadingText), isDisplayed()))
|
||||
.check(doesNotExist())
|
||||
// Wait for a potential timing issue - dialog appearing belatedly
|
||||
Thread.sleep(1000)
|
||||
onView(allOf(withText(loadingText), isDisplayed()))
|
||||
.check(doesNotExist())
|
||||
|
||||
// Test that multiple display calls after another don't cause a timing issue
|
||||
scenario.onActivity { sut ->
|
||||
sut.showLoadingDialog(loadingText)
|
||||
sut.showLoadingDialog(loadingText)
|
||||
sut.showLoadingDialog(loadingText)
|
||||
sut.dismissLoadingDialog()
|
||||
}
|
||||
onView(allOf(withText(loadingText), isDisplayed()))
|
||||
.check(doesNotExist())
|
||||
// Wait for a potential timing issue - dialog appearing belatedly
|
||||
Thread.sleep(1000)
|
||||
onView(allOf(withText(loadingText), isDisplayed()))
|
||||
.check(doesNotExist())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,10 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.contrib.NavigationViewActions
|
||||
@@ -23,18 +25,30 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.fragment.EmptyListState
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.FileDisplayActivityScreenshotIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -42,27 +56,31 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
try {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.run {
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
resetScrolling(true)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.run {
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
resetScrolling(true)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log_OC.e(TAG, "Error caught at open $e")
|
||||
@@ -70,35 +88,41 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showMediaThenAllFiles() {
|
||||
try {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var activity: FileDisplayActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = sut.listOfFilesFragment
|
||||
Assert.assertNotNull(fragment)
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = sut.listOfFilesFragment
|
||||
Assert.assertNotNull(fragment)
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_gallery))
|
||||
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_all_files))
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
fragment.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMediaThenAllFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_gallery))
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_all_files))
|
||||
|
||||
val fragment = activity!!.listOfFilesFragment
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMediaThenAllFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log_OC.e(TAG, "Error caught at open $e")
|
||||
@@ -106,31 +130,35 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun drawer() {
|
||||
try {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.run {
|
||||
hideInfoBox()
|
||||
resetScrolling(true)
|
||||
onIdleSync {
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.run {
|
||||
hideInfoBox()
|
||||
resetScrolling(true)
|
||||
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "drawer", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "drawer", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log_OC.e(TAG, "Error caught at open $e")
|
||||
|
||||
@@ -8,28 +8,45 @@
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class FirstRunActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.FirstRunActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<FirstRunActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ package com.nextcloud.client
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -21,8 +23,11 @@ import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
|
||||
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.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestRule
|
||||
@@ -31,38 +36,53 @@ import org.junit.rules.TestRule
|
||||
class SettingsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.SettingsActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showMnemonic_Error() {
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic_Error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.handleMnemonicRequest(null)
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
sut.handleMnemonicRequest(null)
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic_Error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
@UiThread
|
||||
fun showMnemonic() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
@@ -76,14 +96,14 @@ class SettingsActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.handleMnemonicRequest(intent)
|
||||
onIdleSync {
|
||||
sut.handleMnemonicRequest(intent)
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Looper.myLooper()?.quitSafely()
|
||||
Assert.assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
Looper.myLooper()?.quitSafely()
|
||||
Assert.assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,10 @@ package com.nextcloud.client
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -23,27 +24,46 @@ import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SyncedFoldersActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.SyncedFoldersActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<SyncedFoldersActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.adapter.clear()
|
||||
screenshotViaName(sut.binding.emptyList.emptyListView, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.adapter.clear()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.binding.emptyList.emptyListView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testSyncedFolderDialog() {
|
||||
val item = SyncedFolderDisplayItem(
|
||||
@@ -66,21 +86,26 @@ class SyncedFoldersActivityIT : AbstractIT() {
|
||||
false,
|
||||
SyncedFolder.NOT_SCANNED_YET
|
||||
)
|
||||
val fragment = newInstance(item, 0)
|
||||
|
||||
val intent = Intent(targetContext, SyncedFoldersActivity::class.java)
|
||||
launchActivity<SyncedFoldersActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "testSyncedFolderDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val fragment = newInstance(item, 0)
|
||||
fragment!!.show(sut.supportFragmentManager, "")
|
||||
screenshot(fragment.requireDialog().window?.decorView, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
fragment?.show(sut.supportFragmentManager, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testSyncedFolderDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(fragment?.requireDialog()?.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showPowerCheckDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -90,15 +115,18 @@ class SyncedFoldersActivityIT : AbstractIT() {
|
||||
val intent = Intent(targetContext, SyncedFoldersActivity::class.java)
|
||||
|
||||
launchActivity<SyncedFoldersActivity>(intent).use { scenario ->
|
||||
var dialog: AlertDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
dialog = sut.buildPowerCheckDialog()
|
||||
sut.showPowerCheckDialog()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val dialog = sut.buildPowerCheckDialog()
|
||||
dialog.show()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPowerCheckDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialog!!.window?.decorView, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showPowerCheckDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialog.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2023 Álvaro Brey <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
|
||||
@@ -10,12 +9,23 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.app.Application
|
||||
import android.app.Instrumentation
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.test.runner.AndroidJUnitRunner
|
||||
import com.github.tmurakami.dexopener.DexOpener
|
||||
import com.nextcloud.test.TestMainApp
|
||||
|
||||
class TestRunner : AndroidJUnitRunner() {
|
||||
@Throws(ClassNotFoundException::class, IllegalAccessException::class, InstantiationException::class)
|
||||
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application =
|
||||
newApplication(TestMainApp::class.java, context)
|
||||
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
|
||||
/*
|
||||
* 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 Instrumentation.newApplication(TestMainApp::class.java, context)
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,10 @@
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
@@ -18,23 +20,38 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.ui.activity.UploadListActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class UploadListActivityActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.UploadListActivityActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openDrawer() {
|
||||
launchActivity<UploadListActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "openDrawer", "")
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "openDrawer", "")
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-25
@@ -7,11 +7,10 @@
|
||||
*/
|
||||
package com.nextcloud.client.assistant
|
||||
|
||||
import com.nextcloud.client.assistant.repository.remote.AssistantRemoteRepositoryImpl
|
||||
import com.nextcloud.client.assistant.repository.AssistantRepository
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -19,11 +18,11 @@ import org.junit.Test
|
||||
@Suppress("MagicNumber")
|
||||
class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
|
||||
private var sut: AssistantRemoteRepositoryImpl? = null
|
||||
private var sut: AssistantRepository? = null
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
sut = AssistantRemoteRepositoryImpl(nextcloudClient, capability)
|
||||
sut = AssistantRepository(nextcloudClient, capability)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -34,10 +33,8 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
return
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
val result = sut?.getTaskTypes()
|
||||
assertTrue(result?.isNotEmpty() == true)
|
||||
}
|
||||
val result = sut?.getTaskTypes()
|
||||
assertTrue(result?.isNotEmpty() == true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,10 +45,8 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
return
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
val result = sut?.getTaskList("assistant")
|
||||
assertTrue(result?.isEmpty() == true || (result?.size ?: 0) > 0)
|
||||
}
|
||||
val result = sut?.getTaskList("assistant")
|
||||
assertTrue(result?.isEmpty() == true || (result?.size ?: 0) > 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,11 +65,8 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
emptyMap(),
|
||||
emptyMap()
|
||||
)
|
||||
|
||||
runBlocking {
|
||||
val result = sut?.createTask(input, taskType)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
val result = sut?.createTask(input, taskType)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,16 +81,14 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
|
||||
sleep(120)
|
||||
|
||||
runBlocking {
|
||||
val taskList = sut?.getTaskList("assistant")
|
||||
assertTrue(taskList != null)
|
||||
val taskList = sut?.getTaskList("assistant")
|
||||
assertTrue(taskList != null)
|
||||
|
||||
sleep(120)
|
||||
sleep(120)
|
||||
|
||||
assert((taskList?.size ?: 0) > 0)
|
||||
assert((taskList?.size ?: 0) > 0)
|
||||
|
||||
val result = sut?.deleteTask(taskList!!.first().id)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
val result = sut?.deleteTask(taskList!!.first().id)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
}
|
||||
@@ -7,41 +7,63 @@
|
||||
*/
|
||||
package com.nextcloud.client.etm
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class EtmActivityTest : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.etm.EtmActivityTest"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun overview() {
|
||||
launchActivity<EtmActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "overview", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "overview", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun accounts() {
|
||||
launchActivity<EtmActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "accounts", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.vm.onPageSelected(1)
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.vm.onPageSelected(1)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "accounts", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ class TransferManagerConnectionTest {
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// WHEN
|
||||
// is running flag accessed
|
||||
// is runnign flag accessed
|
||||
val isRunning = connection.isRunning
|
||||
|
||||
// THEN
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.extensions
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.nextcloud.utils.decodeSampledBitmapFromFile
|
||||
import com.nextcloud.utils.extensions.toFile
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.OutputStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.ExperimentalPathApi
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.io.path.deleteRecursively
|
||||
import kotlin.io.path.exists
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
class BitmapDecodeTests {
|
||||
|
||||
private lateinit var tempDir: Path
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
tempDir = Files.createTempDirectory("auto_upload_test_")
|
||||
assertTrue("Temp directory should exist", tempDir.exists())
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
@After
|
||||
fun cleanup() {
|
||||
if (tempDir.exists()) {
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTempImageFile(width: Int = 100, height: Int = 100): Path {
|
||||
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||
val imagePath = tempDir.resolve("test_${System.currentTimeMillis()}.jpg")
|
||||
|
||||
Files.newOutputStream(imagePath).use { out: OutputStream ->
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)
|
||||
}
|
||||
|
||||
assertTrue(imagePath.exists())
|
||||
return imagePath
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToFileWhenPathIsValidShouldReturnExistingFile() {
|
||||
val path = createTempImageFile()
|
||||
val result = path.absolutePathString().toFile()
|
||||
assertNotNull(result)
|
||||
assertTrue(result!!.exists())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToFileWhenPathIsEmptyShouldReturnNull() {
|
||||
val result = "".toFile()
|
||||
assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToFileWhenFileDoesNotExistShouldReturnNull() {
|
||||
val nonExistentPath = tempDir.resolve("does_not_exist.jpg")
|
||||
val result = nonExistentPath.absolutePathString().toFile()
|
||||
assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecodeSampledBitmapFromFileWhenValidPathShouldReturnBitmap() {
|
||||
val path = createTempImageFile(400, 400)
|
||||
val bitmap = decodeSampledBitmapFromFile(path.absolutePathString(), 100, 100)
|
||||
assertNotNull(bitmap)
|
||||
assertTrue(bitmap!!.width <= 400)
|
||||
assertTrue(bitmap.height <= 400)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecodeSampledBitmapFromFileWhenInvalidPathShouldReturnNull() {
|
||||
val invalidPath = tempDir.resolve("invalid_path.jpg").absolutePathString()
|
||||
val bitmap = decodeSampledBitmapFromFile(invalidPath, 100, 100)
|
||||
assertNull(bitmap)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecodeSampledBitmapFromFileWhenImageIsLargeShouldDownsampleBitmap() {
|
||||
val path = createTempImageFile(2000, 2000)
|
||||
val bitmap = decodeSampledBitmapFromFile(path.absolutePathString(), 100, 100)
|
||||
assertNotNull(bitmap)
|
||||
assertTrue("Bitmap should be smaller than original", bitmap!!.width < 2000 && bitmap.height < 2000)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDecodeSampledBitmapFromFileWhenImageIsSmallerThanRequestedShouldKeepOriginalSize() {
|
||||
val path = createTempImageFile(100, 100)
|
||||
val bitmap = decodeSampledBitmapFromFile(path.absolutePathString(), 200, 200)
|
||||
assertNotNull(bitmap)
|
||||
assertEquals(100, bitmap!!.width)
|
||||
assertEquals(100, bitmap.height)
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
package com.nextcloud.extensions
|
||||
import com.nextcloud.utils.extensions.eTagChanged
|
||||
import com.nextcloud.utils.extensions.isNotBlankAndEquals
|
||||
import junit.framework.TestCase.assertFalse
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Test
|
||||
@@ -17,160 +17,160 @@ class StringExtensionTests {
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreNull() {
|
||||
val str1: String? = null
|
||||
val str2: String? = null
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsNull() {
|
||||
val str1: String? = null
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsNull() {
|
||||
val str1 = "hello"
|
||||
val str2: String? = null
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreEmpty() {
|
||||
val str1 = ""
|
||||
val str2 = ""
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsEmpty() {
|
||||
val str1 = ""
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsEmpty() {
|
||||
val str1 = "hello"
|
||||
val str2 = ""
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreWhitespaceOnly() {
|
||||
val str1 = " "
|
||||
val str2 = " \t "
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsWhitespaceOnly() {
|
||||
val str1 = " "
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsWhitespaceOnly() {
|
||||
val str1 = "hello"
|
||||
val str2 = " "
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenStringsAreDifferentButBothValid() {
|
||||
val str1 = "hello"
|
||||
val str2 = "world"
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenStringsHaveDifferentCase() {
|
||||
val str1 = "Hello"
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenMixedCaseStrings() {
|
||||
val str1 = "HeLLo WoRLd"
|
||||
val str2 = "hello world"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenUppercaseStrings() {
|
||||
val str1 = "HELLO"
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalAndValid() {
|
||||
val str1 = "hello"
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalWithSpaces() {
|
||||
val str1 = "hello world"
|
||||
val str2 = "hello world"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalSingleCharacter() {
|
||||
val str1 = "a"
|
||||
val str2 = "A"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalWithSpecialCharacters() {
|
||||
val str1 = "hello@world!123"
|
||||
val str2 = "HELLO@WORLD!123"
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneHasLeadingWhitespaceAndOtherDoesNot() {
|
||||
val str1 = " hello"
|
||||
val str2 = "HELLO"
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneHasTrailingWhitespaceAndOtherDoesNot() {
|
||||
val str1 = "hello"
|
||||
val str2 = "HELLO "
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothHaveIdenticalWhitespacePaddingDifferentCase() {
|
||||
val str1 = " hello "
|
||||
val str2 = " HELLO "
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenMixedWhitespaceCharacters() {
|
||||
val str1 = "\t"
|
||||
val str2 = "\n"
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneIsNullAndOtherIsEmpty() {
|
||||
val str1: String? = null
|
||||
val str2 = ""
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneIsNullAndOtherIsWhitespace() {
|
||||
val str1: String? = null
|
||||
val str2 = " "
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.strings
|
||||
|
||||
import android.content.Context
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper.Companion.MAX_FILE_COUNT
|
||||
import com.owncloud.android.R
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class StringsTests {
|
||||
|
||||
private lateinit var context: Context
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxFileCountText() {
|
||||
val message = context.resources.getQuantityString(
|
||||
R.plurals.file_upload_limit_message,
|
||||
MAX_FILE_COUNT,
|
||||
MAX_FILE_COUNT
|
||||
)
|
||||
|
||||
assertEquals(message, "You can upload up to 500 files at once.")
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,6 @@ import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
|
||||
/**
|
||||
* Rule to automatically enable the test to write to the external storage.
|
||||
* Depending on the SDK version, different approaches might be necessary to achieve the full access.
|
||||
*/
|
||||
class GrantStoragePermissionRule private constructor() {
|
||||
|
||||
companion object {
|
||||
@@ -27,7 +23,6 @@ class GrantStoragePermissionRule private constructor() {
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.R -> GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
else -> GrantManageExternalStoragePermissionRule()
|
||||
}
|
||||
}
|
||||
@@ -35,7 +30,6 @@ class GrantStoragePermissionRule private constructor() {
|
||||
private class GrantManageExternalStoragePermissionRule : TestRule {
|
||||
override fun apply(base: Statement, description: Description): Statement = object : Statement() {
|
||||
override fun evaluate() {
|
||||
// Refer to https://developer.android.com/training/data-storage/manage-all-files#enable-manage-external-storage-for-testing
|
||||
InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand(
|
||||
"appops set --uid ${InstrumentationRegistry.getInstrumentation().targetContext.packageName} " +
|
||||
"MANAGE_EXTERNAL_STORAGE allow"
|
||||
|
||||
@@ -11,8 +11,10 @@ package com.nextcloud.ui
|
||||
import android.graphics.BitmapFactory
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -20,43 +22,58 @@ import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class BitmapIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.ui.BitmapIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun roundBitmap() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
val file = getFile("christine.jpg")
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val file = getFile("christine.jpg")
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
|
||||
val imageView = ImageView(activity).apply {
|
||||
setImageBitmap(bitmap)
|
||||
val imageView = ImageView(activity).apply {
|
||||
setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
val bitmap2 = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val imageView2 = ImageView(activity).apply {
|
||||
setImageBitmap(BitmapUtils.roundBitmap(bitmap2))
|
||||
}
|
||||
|
||||
val linearLayout = LinearLayout(activity).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
}
|
||||
linearLayout.addView(imageView, 200, 200)
|
||||
linearLayout.addView(imageView2, 200, 200)
|
||||
activity.addView(linearLayout)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "roundBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
|
||||
val bitmap2 = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val imageView2 = ImageView(activity).apply {
|
||||
setImageBitmap(BitmapUtils.roundBitmap(bitmap2))
|
||||
}
|
||||
|
||||
val linearLayout = LinearLayout(activity).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
}
|
||||
linearLayout.addView(imageView, 200, 200)
|
||||
linearLayout.addView(imageView2, 200, 200)
|
||||
activity.addView(linearLayout)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "roundBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,43 +8,48 @@
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import org.junit.Rule
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SetOnlineStatusBottomSheetIT : AbstractIT() {
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
onView(withId(R.id.clearStatusAfterSpinner))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,49 +8,60 @@
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.users.ClearAt
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import org.junit.Rule
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SetStatusMessageBottomSheetIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
val sut = SetStatusMessageBottomSheet(
|
||||
user,
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("be-right-back", "⏳", "Be right back", ClearAt("period", "900")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
sut.setPredefinedStatus(predefinedStatus)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetStatusMessageBottomSheet(
|
||||
user,
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("be-right-back", "⏳", "Be right back", ClearAt("period", "900")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
sut.setPredefinedStatus(predefinedStatus)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ package com.nextcloud.utils
|
||||
import com.nextcloud.utils.autoRename.AutoRename
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.datamodel.e2e.v2.decrypted.DecryptedFile
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import org.junit.Before
|
||||
@@ -28,7 +27,6 @@ class AutoRenameTests : AbstractOnServerIT() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
capability = capability.apply {
|
||||
isWCFEnabled = CapabilityBooleanType.TRUE
|
||||
forbiddenFilenameExtensionJson = listOf(
|
||||
"""[" ",".",".part",".part"]""",
|
||||
"""[".",".part",".part"," "]""",
|
||||
@@ -240,14 +238,4 @@ class AutoRenameTests : AbstractOnServerIT() {
|
||||
val expectedFilename = "Foo.Bar.Baz"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun skipAutoRenameWhenWCFDisabled() {
|
||||
capability = capability.apply {
|
||||
isWCFEnabled = CapabilityBooleanType.FALSE
|
||||
}
|
||||
val filename = " readme.txt "
|
||||
val result = AutoRename.rename(filename, capability, isFolderPath = true)
|
||||
assert(result == filename) { "Expected $filename but got $result" }
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.utils
|
||||
|
||||
import com.nextcloud.utils.extensions.checkWCFRestrictions
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
class CheckWCFRestrictionsTests {
|
||||
|
||||
private fun createCapability(
|
||||
version: NextcloudVersion,
|
||||
isWCFEnabled: CapabilityBooleanType = CapabilityBooleanType.UNKNOWN
|
||||
): OCCapability = OCCapability().apply {
|
||||
this.versionMayor = version.majorVersionNumber
|
||||
this.isWCFEnabled = isWCFEnabled
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReturnsFalseForVersionsOlderThan30() {
|
||||
val capability = createCapability(NextcloudVersion.nextcloud_29)
|
||||
assertFalse(capability.checkWCFRestrictions())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReturnsTrueForVersion30WhenWCFAlwaysEnabled() {
|
||||
val capability = createCapability(NextcloudVersion.nextcloud_30)
|
||||
assertTrue(capability.checkWCFRestrictions())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReturnsTrueForVersion31WhenWCFAlwaysEnabled() {
|
||||
val capability = createCapability(NextcloudVersion.nextcloud_31)
|
||||
assertTrue(capability.checkWCFRestrictions())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReturnsTrueForVersion32WhenWCFEnabled() {
|
||||
val capability = createCapability(NextcloudVersion.nextcloud_32, CapabilityBooleanType.TRUE)
|
||||
assertTrue(capability.checkWCFRestrictions())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReturnsFalseForVersion32WhenWCFDisabled() {
|
||||
val capability = createCapability(NextcloudVersion.nextcloud_32, CapabilityBooleanType.FALSE)
|
||||
assertFalse(capability.checkWCFRestrictions())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReturnsFalseForVersion32WhenWCFIsUnknown() {
|
||||
val capability = createCapability(NextcloudVersion.nextcloud_32)
|
||||
assertFalse(capability.checkWCFRestrictions())
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ package com.nextcloud.utils
|
||||
import com.nextcloud.utils.fileNameValidator.FileNameValidator
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -28,7 +27,6 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
@Before
|
||||
fun setup() {
|
||||
capability = capability.apply {
|
||||
isWCFEnabled = CapabilityBooleanType.TRUE
|
||||
forbiddenFilenamesJson = """[".htaccess",".htaccess"]"""
|
||||
forbiddenFilenameBaseNamesJson = """
|
||||
["con", "prn", "aux", "nul", "com0", "com1", "com2", "com3", "com4",
|
||||
@@ -230,14 +228,4 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
val result = FileNameValidator.checkFolderAndFilePaths(folderPath, listOf(), capability, targetContext)
|
||||
assertFalse(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun skipValidationWhenWCFDisabled() {
|
||||
capability = capability.apply {
|
||||
isWCFEnabled = CapabilityBooleanType.FALSE
|
||||
}
|
||||
val filename = "abc.txt"
|
||||
val result = FileNameValidator.checkFileName(filename, capability, targetContext)
|
||||
assertNull(result)
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateUtils
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.database.entity.UploadEntity
|
||||
import com.nextcloud.client.database.entity.toOCUpload
|
||||
import com.nextcloud.client.database.entity.toUploadEntity
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.mockkStatic
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class UploadDateTests {
|
||||
|
||||
companion object {
|
||||
private const val JANUARY_27_2026 = 1769505718000
|
||||
private const val ONE_YEAR = 365L * 24 * 60 * 60 * 1000
|
||||
private const val ONE_MONTH = 30L * 24 * 60 * 60 * 1000
|
||||
private const val ONE_WEEK = 7 * 24 * 60 * 60 * 1000
|
||||
private const val TWO_HOURS = 2 * 60 * 60 * 1000
|
||||
private const val ONE_MINUTE = 60_000
|
||||
private const val THIRTY_SECONDS = 30_000
|
||||
|
||||
private const val DATE_FORMATTER_PATTERN = "MMM dd, yyyy, hh:mm:ss a"
|
||||
}
|
||||
|
||||
private lateinit var context: Context
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
context = InstrumentationRegistry.getInstrumentation().context
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
mockkStatic(System::class)
|
||||
every { System.currentTimeMillis() } returns JANUARY_27_2026
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uploadEntityConvertsToOCUploadAndBackCorrectly() {
|
||||
val entity = UploadEntity(
|
||||
id = 123,
|
||||
localPath = "/local/file.txt",
|
||||
remotePath = "/remote/file.txt",
|
||||
accountName = "[email protected]",
|
||||
fileSize = 1024L,
|
||||
status = 2,
|
||||
localBehaviour = 1,
|
||||
uploadTime = null,
|
||||
nameCollisionPolicy = 0,
|
||||
isCreateRemoteFolder = 1,
|
||||
uploadEndTimestamp = 0,
|
||||
uploadEndTimestampLong = 1_650_000_000_000,
|
||||
lastResult = 0,
|
||||
isWhileChargingOnly = 1,
|
||||
isWifiOnly = 1,
|
||||
createdBy = 5,
|
||||
folderUnlockToken = "token123"
|
||||
)
|
||||
|
||||
val upload = entity.toOCUpload()
|
||||
assertNotNull(upload)
|
||||
assertEquals(entity.localPath, upload?.localPath)
|
||||
assertEquals(entity.remotePath, upload?.remotePath)
|
||||
assertEquals(entity.uploadEndTimestampLong, upload?.uploadEndTimestamp)
|
||||
|
||||
val convertedEntity = upload!!.toUploadEntity()
|
||||
assertEquals(entity.localPath, convertedEntity.localPath)
|
||||
assertEquals(entity.remotePath, convertedEntity.remotePath)
|
||||
assertEquals(entity.uploadEndTimestampLong, convertedEntity.uploadEndTimestampLong)
|
||||
assertEquals(entity.isCreateRemoteFolder, convertedEntity.isCreateRemoteFolder)
|
||||
assertEquals(entity.isWifiOnly, convertedEntity.isWifiOnly)
|
||||
assertEquals(entity.isWhileChargingOnly, convertedEntity.isWhileChargingOnly)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsSecondsAgoForRecentPast() {
|
||||
val result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
JANUARY_27_2026 - THIRTY_SECONDS,
|
||||
DateUtils.SECOND_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
)
|
||||
assertTrue(result.toString() == context.getString(R.string.file_list_seconds_ago))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsFutureAsHumanReadableWhenShowFutureIsFalse() {
|
||||
val formatter = SimpleDateFormat(DATE_FORMATTER_PATTERN, Locale.US)
|
||||
val time = JANUARY_27_2026 + ONE_MINUTE
|
||||
val expected = formatter.format(Date(time))
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.SECOND_IN_MILLIS)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsProperRelativeStringForHoursAgo() {
|
||||
val expected = "2 hours ago"
|
||||
val time = JANUARY_27_2026 - TWO_HOURS
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.MINUTE_IN_MILLIS)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsRelativeStringForOneWeekAgo() {
|
||||
val expected = "Jan 20"
|
||||
val time = JANUARY_27_2026 - ONE_WEEK
|
||||
|
||||
assertRelativeDateTimeString(time, expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsRelativeStringForOneMonthAgo() {
|
||||
val expected = "12/28/2025"
|
||||
val time = JANUARY_27_2026 - ONE_MONTH
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.DAY_IN_MILLIS)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsRelativeStringForOneYearAgo() {
|
||||
val expected = "1/27/2025"
|
||||
val time = JANUARY_27_2026 - ONE_YEAR
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.DAY_IN_MILLIS)
|
||||
}
|
||||
|
||||
private fun assertRelativeDateTimeString(
|
||||
time: Long,
|
||||
expected: String,
|
||||
minResolution: Long = DateUtils.MINUTE_IN_MILLIS,
|
||||
transitionResolution: Long = DateUtils.WEEK_IN_MILLIS
|
||||
) {
|
||||
val result = DisplayUtils.getRelativeDateTimeString(context, time, minResolution, transitionResolution, 0)
|
||||
assertEquals(expected.normalizeResult(), result.toString().normalizeResult())
|
||||
}
|
||||
|
||||
private fun String.normalizeResult(): String = replace('\u202F', ' ').replace('\u00A0', ' ')
|
||||
}
|
||||
@@ -6,8 +6,10 @@
|
||||
*/
|
||||
package com.nmc.android.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||
@@ -16,37 +18,60 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LauncherActivityIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
|
||||
launchActivity<LauncherActivity>().use { scenario ->
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
onView(
|
||||
withId(R.id.splashScreenBold)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
onView(
|
||||
withId(R.id.splashScreenNormal)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
scenario.onActivity { _ ->
|
||||
onIdleSync {
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
onView(
|
||||
withId(R.id.splashScreenBold)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
onView(
|
||||
withId(R.id.splashScreenNormal)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun testSplashScreenWithTitlesShouldShowTitles() {
|
||||
launchActivity<LauncherActivity>().use { scenario ->
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
|
||||
scenario.onActivity {
|
||||
it.setSplashTitles("Example", "Cloud")
|
||||
}
|
||||
onIdleSync {
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
|
||||
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
|
||||
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
|
||||
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
|
||||
EspressoIdlingResource.increment()
|
||||
it.setSplashTitles("Example", "Cloud")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
|
||||
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
|
||||
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@
|
||||
*/
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
@@ -55,6 +55,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.theme.MaterialSchemesProvider;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.After;
|
||||
@@ -77,7 +78,6 @@ import androidx.fragment.app.DialogFragment;
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
|
||||
import androidx.test.runner.lifecycle.Stage;
|
||||
|
||||
@@ -93,10 +93,7 @@ import static org.junit.Assume.assumeTrue;
|
||||
*/
|
||||
public abstract class AbstractIT {
|
||||
@Rule
|
||||
public final TestRule storagePermissionRule = GrantStoragePermissionRule.grant();
|
||||
|
||||
@Rule
|
||||
public GrantPermissionRule notificationsPermissionRule = GrantPermissionRule.grant(Manifest.permission.POST_NOTIFICATIONS);
|
||||
public final TestRule permissionRule = GrantStoragePermissionRule.grant();
|
||||
|
||||
protected static OwnCloudClient client;
|
||||
protected static NextcloudClient nextcloudClient;
|
||||
@@ -121,7 +118,7 @@ public abstract class AbstractIT {
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
|
||||
for (Account account : platformAccountManager.getAccounts()) {
|
||||
if (account.type.equalsIgnoreCase(MainApp.getAccountType(targetContext))) {
|
||||
if (account.type.equalsIgnoreCase("nextcloud")) {
|
||||
platformAccountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
}
|
||||
@@ -211,7 +208,11 @@ public abstract class AbstractIT {
|
||||
protected OCCapability getCapability() throws AccountUtils.AccountNotFoundException {
|
||||
NextcloudClient client = OwnCloudClientFactory.createNextcloudClient(user, targetContext);
|
||||
|
||||
return new GetCapabilitiesRemoteOperation().execute(client).getResultData();
|
||||
OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
|
||||
.execute(client)
|
||||
.getSingleData();
|
||||
|
||||
return ocCapability;
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -425,7 +426,7 @@ public abstract class AbstractIT {
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
var result = newUpload.execute(client);
|
||||
RemoteOperationResult result = newUpload.execute(client);
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
}
|
||||
|
||||
@@ -530,8 +531,8 @@ public abstract class AbstractIT {
|
||||
platformAccountManager.setUserData(temp, KEY_USER_ID, name.substring(0, atPos));
|
||||
|
||||
Account account = UserAccountManagerImpl.fromContext(targetContext).getAccountByName(name);
|
||||
if (Objects.equals(account.type, targetContext.getString(R.string.anonymous_account_type))) {
|
||||
throw new RuntimeException("Could not get account with name " + name);
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
return account;
|
||||
}
|
||||
@@ -540,7 +541,37 @@ public abstract class AbstractIT {
|
||||
return AccountManager.get(targetContext).removeAccountExplicitly(account);
|
||||
}
|
||||
|
||||
protected MaterialSchemes getMaterialSchemesForCurrentUser() {
|
||||
return new MaterialSchemesImpl(R.color.primary, false);
|
||||
protected MaterialSchemesProvider getMaterialSchemesProvider() {
|
||||
return new MaterialSchemesProvider() {
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForUser(@NonNull User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCapability(@NonNull OCCapability capability) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCurrentUser() {
|
||||
return new MaterialSchemesImpl(R.color.primary, false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getDefaultMaterialSchemes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForPrimaryBackground() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@ import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
@@ -28,13 +28,13 @@ import com.owncloud.android.files.services.NameCollisionPolicy;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
@@ -44,7 +44,6 @@ import org.junit.BeforeClass;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -53,15 +52,9 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/// Common base for all integration tests requiring a server connection.
|
||||
/// ATTENTION: Deletes ALL files of the test user on the server after each test run.
|
||||
/// So you MUST use a dedicated test user.
|
||||
/// Uses server, user and password given as `testInstrumentationRunnerArgument`
|
||||
/// - TEST_SERVER_URL
|
||||
/// - TEST_SERVER_USERNAME
|
||||
/// - TEST_SERVER_PASSWORD
|
||||
/// These are supplied via build.gradle, which takes them from gradle.properties.
|
||||
/// So look in the latter file to set to your own server & test user.
|
||||
/**
|
||||
* Common base for all integration tests.
|
||||
*/
|
||||
public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
@@ -96,8 +89,8 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
account = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
|
||||
if (Objects.equals(account.type, targetContext.getString(R.string.anonymous_account_type))) {
|
||||
throw new RuntimeException("Could not get account with name " + loginName + "@" + baseUrl);
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
Optional<User> optionalUser = userAccountManager.getUser(account.name);
|
||||
@@ -127,19 +120,14 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
super.after();
|
||||
}
|
||||
|
||||
private static boolean isFolder(RemoteFile file) {
|
||||
// TODO: should probably move to RemoteFile class
|
||||
return MimeType.DIRECTORY.equals(file.getMimeType()) || MimeType.WEBDAV_FOLDER.equals(file.getMimeType());
|
||||
}
|
||||
|
||||
public static void deleteAllFilesOnServer() {
|
||||
var result = new ReadFolderRemoteOperation("/").execute(client);
|
||||
assertTrue(result.getLogMessage(targetContext), result.isSuccess());
|
||||
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
|
||||
for (Object object : result.getData()) {
|
||||
RemoteFile remoteFile = (RemoteFile) object;
|
||||
|
||||
if (!Objects.equals(remoteFile.getRemotePath(), "/")) {
|
||||
if (!remoteFile.getRemotePath().equals("/")) {
|
||||
if (remoteFile.isEncrypted()) {
|
||||
ToggleEncryptionRemoteOperation operation = new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
|
||||
remoteFile.getRemotePath(),
|
||||
@@ -149,13 +137,6 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
.execute(client)
|
||||
.isSuccess();
|
||||
|
||||
if (!operationResult && isFolder(remoteFile)) {
|
||||
// Deleting encrypted folder is not possible due to bug
|
||||
// https://github.com/nextcloud/end_to_end_encryption/issues/421
|
||||
// Toggling encryption also fails, when the folder is not empty. So we ignore this folder
|
||||
continue;
|
||||
}
|
||||
|
||||
assertTrue(operationResult);
|
||||
}
|
||||
|
||||
@@ -261,7 +242,7 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
var result = newUpload.execute(client);
|
||||
RemoteOperationResult result = newUpload.execute(client);
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
|
||||
OCFile parentFolder = getStorageManager()
|
||||
@@ -270,7 +251,6 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
OCFile uploadedFile = getStorageManager().
|
||||
getFileByDecryptedRemotePath(parentFolder.getDecryptedRemotePath() + uploadedFileName);
|
||||
|
||||
assertNotNull(uploadedFile);
|
||||
assertNotNull(uploadedFile.getRemoteId());
|
||||
assertNotNull(uploadedFile.getPermissions());
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests related to file downloads.
|
||||
* Tests related to file uploads.
|
||||
*/
|
||||
public class DownloadIT extends AbstractOnServerIT {
|
||||
private static final String FOLDER = "/testUpload/";
|
||||
@@ -98,10 +98,10 @@ public class DownloadIT extends AbstractOnServerIT {
|
||||
assertTrue(new File(file2.getStoragePath()).exists());
|
||||
|
||||
// test against hardcoded path to make sure that it is correct
|
||||
assertEquals("/storage/emulated/0/Android/media/"+targetContext.getPackageName()+"/nextcloud/" +
|
||||
assertEquals("/storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty.txt",
|
||||
file1.getStoragePath());
|
||||
assertEquals("/storage/emulated/0/Android/media/"+targetContext.getPackageName()+"/nextcloud/" +
|
||||
assertEquals("/storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty2.txt",
|
||||
file2.getStoragePath());
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
*/
|
||||
package com.owncloud.android
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.action.ViewActions.scrollTo
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
@@ -18,16 +19,17 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import tools.fastlane.screengrab.Screengrab
|
||||
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy
|
||||
@@ -35,91 +37,135 @@ import tools.fastlane.screengrab.locale.LocaleTestRule
|
||||
|
||||
class ScreenshotsIT : AbstractIT() {
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun gridViewScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("01_gridView")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("01_gridView")
|
||||
|
||||
// Switch back
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
// Switch back
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
|
||||
assertTrue(true)
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun listViewScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
val path = "/Camera/"
|
||||
OCFile(path).apply {
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
onView(withId(R.id.list_root)).perform(click())
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val path = "/Camera/"
|
||||
OCFile(path).apply {
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
onView(withId(R.id.list_root)).perform(click())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("02_listView")
|
||||
assertTrue(true)
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("02_listView")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun drawerScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("03_drawer")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("03_drawer")
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close())
|
||||
assertTrue(true)
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close())
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun multipleAccountsScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
onView(withId(R.id.switch_account_button)).perform(click())
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.switch_account_button)).perform(click())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("04_accounts")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("04_accounts")
|
||||
|
||||
Espresso.pressBack()
|
||||
assertTrue(true)
|
||||
Espresso.pressBack()
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun autoUploadScreenshot() {
|
||||
launchActivity<SyncedFoldersActivity>().use {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("05_autoUpload")
|
||||
assertTrue(true)
|
||||
launchActivity<SyncedFoldersActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("05_autoUpload")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun davdroidScreenshot() {
|
||||
launchActivity<SettingsActivity>().use {
|
||||
onView(withText(R.string.prefs_category_more)).perform(scrollTo())
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withText(R.string.prefs_category_more)).perform(scrollTo())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("06_davdroid")
|
||||
assertTrue(true)
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("06_davdroid")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ package com.owncloud.android.datamodel
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SdkSuppress
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -58,4 +60,20 @@ class ContentResolverHelperIT {
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SdkSuppress(maxSdkVersion = Build.VERSION_CODES.N_MR1)
|
||||
fun contentResolver_onAndroidBelow26_usesOldAPI() {
|
||||
ContentResolverHelper
|
||||
.queryResolver(resolver, URI, PROJECTION, SELECTION, null, SORT_COLUMN, SORT_DIRECTION, LIMIT)
|
||||
|
||||
verify(resolver).query(
|
||||
eq(URI),
|
||||
eq(PROJECTION),
|
||||
eq(SELECTION),
|
||||
eq(null),
|
||||
eq("$SORT_COLUMN $SORT_DIRECTION LIMIT $LIMIT"),
|
||||
eq(null)
|
||||
)
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -53,7 +53,9 @@ abstract public class FileDataStorageManagerIT extends AbstractOnServerIT {
|
||||
|
||||
assertEquals(0, sut.getAllFiles().size());
|
||||
|
||||
capability = new GetCapabilitiesRemoteOperation(null).execute(client).getResultData();
|
||||
capability = (OCCapability) new GetCapabilitiesRemoteOperation(null)
|
||||
.execute(client)
|
||||
.getSingleData();
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+7
-5
@@ -18,7 +18,6 @@ import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.database.entity.UploadEntityKt;
|
||||
import com.nextcloud.test.RandomStringGenerator;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -109,7 +108,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
OCUpload upload = createUpload(account);
|
||||
|
||||
uploads.add(upload);
|
||||
uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(upload));
|
||||
uploadsStorageManager.storeUpload(upload);
|
||||
}
|
||||
|
||||
OCUpload[] storedUploads = uploadsStorageManager.getAllStoredUploads();
|
||||
@@ -152,14 +151,17 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
account.name);
|
||||
|
||||
corruptUpload.setLocalPath(null);
|
||||
uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(corruptUpload));
|
||||
|
||||
uploadsStorageManager.storeUpload(corruptUpload);
|
||||
|
||||
uploadsStorageManager.getAllStoredUploads();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getById() {
|
||||
OCUpload upload = createUpload(account);
|
||||
long id = uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(upload));
|
||||
long id = uploadsStorageManager.storeUpload(upload);
|
||||
|
||||
OCUpload newUpload = uploadsStorageManager.getUploadById(id);
|
||||
|
||||
assertNotNull(newUpload);
|
||||
@@ -176,7 +178,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
|
||||
private void insertUploads(Account account, int rowsToInsert) {
|
||||
for (int i = 0; i < rowsToInsert; i++) {
|
||||
uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(createUpload(account)));
|
||||
uploadsStorageManager.storeUpload(createUpload(account));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
|
||||
inline fun <reified T : Activity> AbstractIT.launchAndCapture(
|
||||
testClassName: String,
|
||||
actionName: String,
|
||||
intent: Intent? = null,
|
||||
crossinline before: (T) -> Unit
|
||||
) {
|
||||
launchActivity<T>(intent).use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
before(activity)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenshotName = createName(testClassName + "_" + actionName, "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenshotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,9 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
uploadsStorageManager = UploadsStorageManager(accountManager, contentResolver)
|
||||
}
|
||||
|
||||
// /**
|
||||
// * uploads a file, overwrites it with an empty one, check if overwritten
|
||||
// */
|
||||
/**
|
||||
* uploads a file, overwrites it with an empty one, check if overwritten
|
||||
*/
|
||||
// disabled, flaky test
|
||||
// @Test
|
||||
// fun testKeepLocalAndOverwriteRemote() {
|
||||
@@ -324,7 +324,7 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
user,
|
||||
null,
|
||||
ocUpload2,
|
||||
NameCollisionPolicy.SKIP,
|
||||
NameCollisionPolicy.CANCEL,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
@@ -373,7 +373,7 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
user,
|
||||
arrayOf(ocFile2),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
NameCollisionPolicy.SKIP
|
||||
NameCollisionPolicy.CANCEL
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
@@ -400,7 +400,7 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
NameCollisionPolicy.SKIP,
|
||||
NameCollisionPolicy.CANCEL,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
@@ -426,7 +426,7 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
user,
|
||||
null,
|
||||
ocUpload2,
|
||||
NameCollisionPolicy.SKIP,
|
||||
NameCollisionPolicy.CANCEL,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
@@ -477,7 +477,7 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
user,
|
||||
arrayOf(ocFile2),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
NameCollisionPolicy.SKIP
|
||||
NameCollisionPolicy.CANCEL
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.providers
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.ContentUris
|
||||
import android.net.Uri
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.owncloud.android.db.ProviderMeta
|
||||
import io.mockk.Runs
|
||||
import io.mockk.every
|
||||
import io.mockk.just
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
class FileContentProviderTests {
|
||||
|
||||
private lateinit var provider: FileContentProvider
|
||||
private lateinit var db: SupportSQLiteDatabase
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
provider = FileContentProvider()
|
||||
db = mockk()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertNewFileShouldReturnNewId() {
|
||||
val values = ContentValues().apply {
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_PATH, "/path/to/file.txt")
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER, "[email protected]")
|
||||
}
|
||||
|
||||
// Mock insert to return new ID
|
||||
every { db.insert(any(), any(), any()) } returns 42L
|
||||
|
||||
val result: Uri = provider.upsertSingleFile(
|
||||
db,
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE,
|
||||
values
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 42),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateExistingFileShouldReturnSameId() {
|
||||
val values = ContentValues().apply {
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_PATH, "/path/to/file.txt")
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER, "[email protected]")
|
||||
}
|
||||
|
||||
// Simulate insert conflict
|
||||
every { db.insert(ProviderMeta.ProviderTableMeta.FILE_TABLE_NAME, any(), values) } returns -1L
|
||||
|
||||
// Simulate update returning 1 row affected
|
||||
every {
|
||||
db.update(
|
||||
ProviderMeta.ProviderTableMeta.FILE_TABLE_NAME,
|
||||
any(),
|
||||
values,
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
} returns 1
|
||||
|
||||
// Mock cursor to return ID 99
|
||||
val cursor = mockk<android.database.Cursor>()
|
||||
every { cursor.moveToFirst() } returns true
|
||||
every { cursor.getLong(0) } returns 99L
|
||||
every { cursor.close() } just Runs
|
||||
|
||||
every { db.query(any<SimpleSQLiteQuery>()) } returns cursor
|
||||
|
||||
val result: Uri = provider.upsertSingleFile(
|
||||
db,
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE,
|
||||
values
|
||||
)
|
||||
|
||||
assertEquals(ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 99), result)
|
||||
|
||||
cursor.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConcurrentUpserts() = runBlocking {
|
||||
val values = ContentValues().apply {
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_PATH, "/path/to/file.txt")
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER, "[email protected]")
|
||||
}
|
||||
|
||||
// shared state to simulate race
|
||||
val inserted = mutableListOf<Long>()
|
||||
|
||||
// mock insert: fail first call, succeed second
|
||||
every { db.insert(any(), any(), any()) } answers {
|
||||
synchronized(inserted) {
|
||||
if (inserted.isEmpty()) {
|
||||
// first thread "fails" insert which means already existing file id will be returned
|
||||
inserted.add(-1L)
|
||||
-1L
|
||||
} else {
|
||||
// second thread "succeeds" it will update existing one
|
||||
inserted.add(42L)
|
||||
42L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mock update only one row should be affected
|
||||
every { db.update(any(), any(), any(), any(), any()) } returns 1
|
||||
|
||||
// mock query existing file id will return 99
|
||||
val cursor = mockk<android.database.Cursor>()
|
||||
every { cursor.moveToFirst() } returns true
|
||||
every { cursor.getLong(0) } returns 99L
|
||||
every { cursor.close() } just Runs
|
||||
every { db.query(any<SimpleSQLiteQuery>()) } returns cursor
|
||||
|
||||
// launch two coroutines simulating concurrent threads
|
||||
val results = mutableListOf<Uri>()
|
||||
coroutineScope {
|
||||
val job1 =
|
||||
async {
|
||||
results.add(provider.upsertSingleFile(db, ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, values))
|
||||
}
|
||||
val job2 =
|
||||
async {
|
||||
results.add(provider.upsertSingleFile(db, ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, values))
|
||||
}
|
||||
awaitAll(job1, job2)
|
||||
}
|
||||
|
||||
// both URIs should be correct (one updated, one inserted)
|
||||
assertTrue(results.contains(ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 99)))
|
||||
assertTrue(results.contains(ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 42)))
|
||||
|
||||
cursor.close()
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -7,19 +7,26 @@
|
||||
*/
|
||||
package com.owncloud.android.providers
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import org.junit.Test
|
||||
|
||||
class UsersAndGroupsSearchProviderIT {
|
||||
class UsersAndGroupsSearchProviderIT : AbstractOnServerIT() {
|
||||
@Test
|
||||
@UiThread
|
||||
fun searchUser() {
|
||||
launchActivity<TestActivity>().use {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
-71
@@ -9,6 +9,7 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
@@ -17,7 +18,6 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.utils.extensions.getDecryptedPath
|
||||
import com.owncloud.android.AbstractIT
|
||||
@@ -25,7 +25,6 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener
|
||||
@@ -43,6 +42,7 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
private var returnCode = false
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun screenshotTextFiles() {
|
||||
val newFile = OCFile("/newFile.txt").apply {
|
||||
@@ -67,33 +67,33 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var dialog: ConflictsResolveDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
dialog = newInstance(
|
||||
storageManager.getDecryptedPath(existingFile),
|
||||
targetContext,
|
||||
newFile,
|
||||
existingFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser()
|
||||
)
|
||||
dialog.showDialog(sut)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
onView(withId(R.id.headline))
|
||||
.check(matches(isDisplayed()))
|
||||
val dialog = newInstance(
|
||||
storageManager.getDecryptedPath(existingFile),
|
||||
targetContext,
|
||||
newFile,
|
||||
existingFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser()
|
||||
)
|
||||
dialog.showDialog(sut)
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "screenshotTextFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(dialog!!.requireDialog().window?.decorView, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "screenshotTextFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(dialog.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun cancel() {
|
||||
val newUpload = OCUpload(
|
||||
FileStorageUtils.getSavePath(user.accountName) + "/nonEmpty.txt",
|
||||
@@ -126,19 +126,24 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
returnCode = false
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.CANCEL)
|
||||
returnCode = true
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
returnCode = false
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.CANCEL)
|
||||
returnCode = true
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withText("Cancel")).perform(ViewActions.click())
|
||||
TestCase.assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
onView(ViewMatchers.withText("Cancel")).perform(ViewActions.click())
|
||||
TestCase.assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun keepExisting() {
|
||||
returnCode = false
|
||||
@@ -175,29 +180,30 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var activity: ConflictsResolveActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_SERVER)
|
||||
returnCode = true
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_SERVER)
|
||||
returnCode = true
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
val dialog = sut.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepExisting", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
|
||||
val dialog = activity!!.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepExisting", "")
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun keepNew() {
|
||||
returnCode = false
|
||||
@@ -229,26 +235,31 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
intent.putExtra(ConflictsResolveActivity.EXTRA_CONFLICT_UPLOAD_ID, newUpload.uploadId)
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var activity: ConflictsResolveActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_LOCAL)
|
||||
returnCode = true
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_LOCAL)
|
||||
returnCode = true
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
val dialog = sut.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepNew", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
val dialog = activity!!.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepNew", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun keepBoth() {
|
||||
returnCode = false
|
||||
@@ -282,24 +293,29 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var activity: ConflictsResolveActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_BOTH)
|
||||
returnCode = true
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_BOTH)
|
||||
returnCode = true
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
val dialog = sut.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepBoth", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
onView(withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
|
||||
val dialog = activity!!.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepBoth", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-8
@@ -8,21 +8,37 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ContactsPreferenceActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.ContactsPreferenceActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openVCF() {
|
||||
val file = getFile("vcard.vcf")
|
||||
@@ -37,24 +53,27 @@ class ContactsPreferenceActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ContactsPreferenceActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "openVCF", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "openVCF", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openContactsPreference() {
|
||||
launchActivity<ContactsPreferenceActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "openContactsPreference", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "openContactsPreference", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.Manifest
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.net.Uri
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
@@ -26,6 +26,7 @@ import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.hamcrest.Matchers
|
||||
import org.junit.Assert
|
||||
import org.junit.BeforeClass
|
||||
@@ -38,36 +39,32 @@ class DrawerActivityIT : AbstractIT() {
|
||||
@JvmField
|
||||
val retryTestRule = RetryTestRule()
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun switchAccountViaAccountList() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.setUser(user1)
|
||||
|
||||
Assert.assertEquals(account1, sut.user.get().toPlatformAccount())
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf<View?>(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(account1, sut!!.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ public class FileDisplayActivityTest extends AbstractIT {
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
Activity activity =
|
||||
ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED).iterator().next();
|
||||
if (activity instanceof WhatsNewActivity whatsNewActivity) {
|
||||
whatsNewActivity.getOnBackPressedDispatcher().onBackPressed();
|
||||
if (activity instanceof WhatsNewActivity) {
|
||||
activity.onBackPressed();
|
||||
}
|
||||
});
|
||||
scenario.recreate();
|
||||
|
||||
+110
-70
@@ -10,8 +10,10 @@ package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -19,8 +21,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -28,133 +33,167 @@ import org.junit.runner.RunWith
|
||||
class FolderPickerActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.FolderPickerActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getActivityFile() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/remotePath/test"
|
||||
}
|
||||
|
||||
var target: OCFile? = null
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
target = sut.file
|
||||
}
|
||||
onIdleSync {
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/remotePath/test"
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
// Act
|
||||
sut.file = origin
|
||||
val target = sut.file
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getParentFolder_isNotRootFolder() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
val origin = OCFile("/test/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/test/"
|
||||
setStoragePath("/test/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
var target: OCFile? = null
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
target = sut.currentFolder
|
||||
}
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val origin = OCFile("/test/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/test/"
|
||||
setStoragePath("/test/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
// Act
|
||||
sut.file = origin
|
||||
val target = sut.currentFolder
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getParentFolder_isRootFolder() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
val origin = OCFile("/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/"
|
||||
setStoragePath("/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
var target: OCFile? = null
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
target = sut.currentFolder
|
||||
}
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val origin = OCFile("/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/"
|
||||
setStoragePath("/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
// Act
|
||||
sut.file = origin
|
||||
val target = sut.currentFolder
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
@UiThread
|
||||
fun nullFile() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
var rootFolder: OCFile? = null
|
||||
var target: OCFile? = null
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
rootFolder = sut.storageManager.getFileByPath(OCFile.ROOT_PATH)
|
||||
sut.file = null
|
||||
target = sut.currentFolder
|
||||
}
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val rootFolder = sut.storageManager.getFileByPath(OCFile.ROOT_PATH)
|
||||
|
||||
assertEquals(rootFolder, target)
|
||||
// Act
|
||||
sut.file = null
|
||||
val target = sut.currentFolder
|
||||
|
||||
// Assert
|
||||
assertEquals(rootFolder, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getParentFolder() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/test/file.test"
|
||||
}
|
||||
|
||||
val target = OCFile("/test/")
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
}
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/test/file.test"
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
val target = OCFile("/test/")
|
||||
|
||||
// Act
|
||||
sut.file = origin
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val origin = OCFile("/test/file.txt")
|
||||
sut.file = origin
|
||||
sut.findViewById<View>(R.id.folder_picker_btn_copy).requestFocus()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val origin = OCFile("/test/file.txt")
|
||||
sut.file = origin
|
||||
sut.findViewById<View>(R.id.folder_picker_btn_copy).requestFocus()
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testMoveOrCopy() {
|
||||
val intent = Intent(targetContext, FolderPickerActivity::class.java)
|
||||
launchActivity<FolderPickerActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "testMoveOrCopy", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "testMoveOrCopy", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testChooseLocationAction() {
|
||||
val intent = Intent(targetContext, FolderPickerActivity::class.java).apply {
|
||||
@@ -162,11 +201,12 @@ class FolderPickerActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<FolderPickerActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "testChooseLocationAction", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "testChooseLocationAction", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+45
-23
@@ -8,59 +8,81 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.common.Quota
|
||||
import com.owncloud.android.lib.common.UserInfo
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ManageAccountsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.ManageAccountsActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<ManageAccountsActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun userInfoDetail() {
|
||||
launchActivity<ManageAccountsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val user = sut.accountManager.user
|
||||
val userInfo = UserInfo(
|
||||
"test",
|
||||
true,
|
||||
"Test User",
|
||||
"[email protected]",
|
||||
"+49 123 456",
|
||||
"Address 123, Berlin",
|
||||
"https://www.nextcloud.com",
|
||||
"https://twitter.com/Nextclouders",
|
||||
Quota(),
|
||||
ArrayList()
|
||||
)
|
||||
sut.showUser(user, userInfo)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
val user = sut.accountManager.user
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(getCurrentActivity(), screenShotName)
|
||||
val userInfo = UserInfo(
|
||||
"test",
|
||||
true,
|
||||
"Test User",
|
||||
"[email protected]",
|
||||
"+49 123 456",
|
||||
"Address 123, Berlin",
|
||||
"https://www.nextcloud.com",
|
||||
"https://twitter.com/Nextclouders",
|
||||
Quota(),
|
||||
ArrayList()
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
sut.showUser(user, userInfo)
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(getCurrentActivity(), screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+42
-24
@@ -7,40 +7,57 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.notifications.models.Action
|
||||
import com.owncloud.android.lib.resources.notifications.models.Notification
|
||||
import com.owncloud.android.lib.resources.notifications.models.RichObject
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class NotificationsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.NotificationsActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.populateList(ArrayList())
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.populateList(ArrayList())
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@SuppressWarnings("MagicNumber")
|
||||
fun showNotifications() {
|
||||
@@ -124,31 +141,32 @@ class NotificationsActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.populateList(notifications)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotifications", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.populateList(notifications)
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "showNotifications", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.setEmptyContent("Error", "Error! Please try again later!")
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.setEmptyContent("Error", "Error! Please try again later!")
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,20 +9,36 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PassCodeActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.PassCodeActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun check() {
|
||||
val intent = Intent(targetContext, PassCodeActivity::class.java).apply {
|
||||
@@ -31,21 +47,22 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<PassCodeActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.binding.txt0.clearFocus()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.binding.txt0.clearFocus()
|
||||
Espresso.closeSoftKeyboard()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Espresso.closeSoftKeyboard()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "check", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "check", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun request() {
|
||||
val intent = Intent(targetContext, PassCodeActivity::class.java).apply {
|
||||
@@ -54,21 +71,22 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<PassCodeActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.binding.txt0.clearFocus()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.binding.txt0.clearFocus()
|
||||
Espresso.closeSoftKeyboard()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Espresso.closeSoftKeyboard()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "request", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "request", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun delete() {
|
||||
val intent = Intent(targetContext, PassCodeActivity::class.java).apply {
|
||||
@@ -77,16 +95,16 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<PassCodeActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.binding.txt0.clearFocus()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.binding.txt0.clearFocus()
|
||||
Espresso.closeSoftKeyboard()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Espresso.closeSoftKeyboard()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "delete", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "delete", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-4
@@ -8,27 +8,44 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ReceiveExternalFilesActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.ReceiveExternalFilesActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<ReceiveExternalFilesActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+83
-53
@@ -9,13 +9,16 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
@@ -44,31 +47,46 @@ class UploadFilesActivityIT : AbstractIT() {
|
||||
directories.forEach { it.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun noneSelected() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "noneSelected", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "noneSelected", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun localFolderPickerMode() {
|
||||
val intent = Intent(targetContext, UploadFilesActivity::class.java).apply {
|
||||
@@ -84,65 +102,77 @@ class UploadFilesActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<UploadFilesActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.fileListFragment.setFiles(
|
||||
directories
|
||||
)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "localFolderPickerMode", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
sut.fileListFragment.setFiles(
|
||||
directories
|
||||
)
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "localFolderPickerMode", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun search() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.fileListFragment.performSearch("1.txt", arrayListOf(), false)
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.fileListFragment.performSearch("1.txt", arrayListOf(), false)
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "search", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun selectAll() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.fileListFragment.setFiles(
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "search", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun selectAll() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.fileListFragment.setFiles(
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
sut.fileListFragment.selectAllFiles(true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "selectAll", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
sut.fileListFragment.selectAllFiles(true)
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "selectAll", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,36 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.common.UserInfo
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class UserInfoActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.UserInfoActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun fullUserInfoDetail() {
|
||||
val intent = Intent(targetContext, UserInfoActivity::class.java).apply {
|
||||
@@ -43,11 +59,12 @@ class UserInfoActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<UserInfoActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "fullUserInfoDetail", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "fullUserInfoDetail", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import android.Manifest
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.app.Dialog
|
||||
@@ -20,14 +19,15 @@ import android.view.ViewGroup
|
||||
import android.webkit.SslErrorHandler
|
||||
import android.widget.TextView
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
@@ -38,7 +38,6 @@ import com.nextcloud.client.account.RegisteredUser
|
||||
import com.nextcloud.client.account.Server
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.client.documentscan.AppScanOptionalFeature
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment.Companion.newInstance
|
||||
import com.nextcloud.ui.SetOnlineStatusBottomSheet
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet.Companion.newInstance
|
||||
@@ -67,16 +66,18 @@ import com.owncloud.android.ui.dialog.LoadingDialog.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.Companion.newInstanceForEmptySslError
|
||||
import com.owncloud.android.ui.dialog.StoragePermissionDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import io.mockk.mockk
|
||||
import org.junit.After
|
||||
import org.junit.Rule
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.net.URI
|
||||
import java.util.function.Supplier
|
||||
@@ -86,11 +87,15 @@ class DialogFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.DialogFragmentIT"
|
||||
private val serverUrl = "https://nextcloud.localhost"
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun quitLooperIfNeeded() {
|
||||
@@ -98,6 +103,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRenameFileDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -113,6 +119,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testLoadingDialog() {
|
||||
newInstance("Wait…").run {
|
||||
@@ -121,13 +128,14 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithOneAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_ok,
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
@@ -137,13 +145,14 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithTwoAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_ok,
|
||||
R.string.common_cancel,
|
||||
-1,
|
||||
-1
|
||||
@@ -153,13 +162,14 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithThreeAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_ok,
|
||||
R.string.common_cancel,
|
||||
R.string.common_confirm,
|
||||
-1
|
||||
@@ -169,6 +179,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithThreeActionRTL() {
|
||||
enableRTL()
|
||||
@@ -176,7 +187,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
-1,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_ok,
|
||||
R.string.common_cancel,
|
||||
R.string.common_confirm,
|
||||
-1
|
||||
@@ -187,6 +198,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFileDialog() {
|
||||
RemoveFilesDialogFragment.newInstance(OCFile("/Test.md")).run {
|
||||
@@ -195,6 +207,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFilesDialog() {
|
||||
val toDelete = ArrayList<OCFile>().apply {
|
||||
@@ -207,6 +220,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFolderDialog() {
|
||||
val dialog = RemoveFilesDialogFragment.newInstance(OCFile("/Folder/"))
|
||||
@@ -214,6 +228,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFoldersDialog() {
|
||||
val toDelete = ArrayList<OCFile>()
|
||||
@@ -225,6 +240,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testNewFolderDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -235,6 +251,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testEnforcedPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -245,6 +262,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testOptionalPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -255,13 +273,13 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testAccountChooserDialog() {
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
ActivityScenario.launch<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: ChooseAccountDialogFragment? = null
|
||||
|
||||
scenario.onActivity { activity: FileDisplayActivity ->
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val userAccountManager = activity.userAccountManager
|
||||
val accountManager = AccountManager.get(targetContext)
|
||||
@@ -304,74 +322,73 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
|
||||
sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(URI.create(serverUrl), OwnCloudVersion.nextcloud_20)
|
||||
)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
sut.show(activity.supportFragmentManager, null)
|
||||
}
|
||||
try {
|
||||
onIdleSync {
|
||||
val sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(URI.create(serverUrl), OwnCloudVersion.nextcloud_20)
|
||||
)
|
||||
)
|
||||
showDialog(activity, sut)
|
||||
|
||||
val dialogInstance = waitForDialog(sut!!) ?: throw IllegalStateException("Dialog was not created")
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.DND,
|
||||
"Busy fixing 🐛…",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "dnd")
|
||||
|
||||
scenario.onActivity {
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content)
|
||||
if (viewGroup != null) {
|
||||
hideCursors(viewGroup)
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "online")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"Let's have some fun",
|
||||
"🎉",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "fun")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.OFFLINE, "", "", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "offline")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.AWAY, "Vacation", "🌴", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "away")
|
||||
}
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
throw java.lang.RuntimeException(e)
|
||||
}
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.DND,
|
||||
"Busy fixing 🐛…",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "dnd")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "online")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"Let's have some fun",
|
||||
"🎉",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "fun")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.OFFLINE, "", "", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "offline")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.AWAY, "Vacation", "🌴", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "away")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Throws(AccountUtils.AccountNotFoundException::class)
|
||||
fun testAccountChooserDialogWithStatusDisabled() {
|
||||
@@ -387,42 +404,44 @@ class DialogFragmentIT : AbstractIT() {
|
||||
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password")
|
||||
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: ChooseAccountDialogFragment? = null
|
||||
scenario.onActivity { fda ->
|
||||
val userAccountManager = fda.userAccountManager
|
||||
val newUser = userAccountManager.getUser(newAccount.name).get()
|
||||
val fileDataStorageManager = FileDataStorageManager(
|
||||
newUser,
|
||||
targetContext.contentResolver
|
||||
)
|
||||
|
||||
val capability = OCCapability().apply {
|
||||
userStatus = CapabilityBooleanType.FALSE
|
||||
}
|
||||
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
|
||||
sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(
|
||||
URI.create(serverUrl),
|
||||
OwnCloudVersion.nextcloud_20
|
||||
)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val userAccountManager = fda.userAccountManager
|
||||
val newUser = userAccountManager.getUser(newAccount.name).get()
|
||||
val fileDataStorageManager = FileDataStorageManager(
|
||||
newUser,
|
||||
targetContext.contentResolver
|
||||
)
|
||||
)
|
||||
|
||||
sut.show(fda.supportFragmentManager, null)
|
||||
val capability = OCCapability().apply {
|
||||
userStatus = CapabilityBooleanType.FALSE
|
||||
}
|
||||
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val sut =
|
||||
newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(
|
||||
URI.create(serverUrl),
|
||||
OwnCloudVersion.nextcloud_20
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
showDialog(fda, sut)
|
||||
}
|
||||
}
|
||||
|
||||
waitForDialog(sut!!) ?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -450,127 +469,142 @@ class DialogFragmentIT : AbstractIT() {
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: OCFileListBottomSheetDialog? = null
|
||||
scenario.onActivity { fda ->
|
||||
var directEditing = DirectEditing()
|
||||
val creators = directEditing.creators.toMutableMap()
|
||||
val editors = directEditing.editors.toMutableMap()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
creators["1"] = Creator(
|
||||
"1",
|
||||
"text",
|
||||
"text file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
// add direct editing info
|
||||
var directEditing = DirectEditing()
|
||||
val creators = directEditing.creators.toMutableMap()
|
||||
val editors = directEditing.editors.toMutableMap()
|
||||
|
||||
creators["2"] = Creator(
|
||||
"2",
|
||||
"md",
|
||||
"markdown file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
creators.put(
|
||||
"1",
|
||||
Creator(
|
||||
"1",
|
||||
"text",
|
||||
"text file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
)
|
||||
creators.put(
|
||||
"2",
|
||||
Creator(
|
||||
"2",
|
||||
"md",
|
||||
"markdown file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
)
|
||||
editors.put(
|
||||
"text",
|
||||
Editor(
|
||||
"1",
|
||||
"Text",
|
||||
ArrayList(mutableListOf(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)),
|
||||
ArrayList(),
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
editors["text"] = Editor(
|
||||
"1",
|
||||
"Text",
|
||||
ArrayList(mutableListOf(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)),
|
||||
ArrayList(),
|
||||
false
|
||||
)
|
||||
directEditing = DirectEditing(editors, creators)
|
||||
val json = Gson().toJson(directEditing)
|
||||
|
||||
directEditing = DirectEditing(editors, creators)
|
||||
val json = Gson().toJson(directEditing)
|
||||
ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue(
|
||||
user.accountName,
|
||||
ArbitraryDataProvider.DIRECT_EDITING,
|
||||
json
|
||||
)
|
||||
|
||||
ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue(
|
||||
user.accountName,
|
||||
ArbitraryDataProvider.DIRECT_EDITING,
|
||||
json
|
||||
)
|
||||
// activate templates
|
||||
val capability = fda.capabilities.apply {
|
||||
richDocuments = CapabilityBooleanType.TRUE
|
||||
richDocumentsDirectEditing = CapabilityBooleanType.TRUE
|
||||
richDocumentsTemplatesAvailable = CapabilityBooleanType.TRUE
|
||||
accountName = user.accountName
|
||||
}
|
||||
CapabilityUtils.updateCapability(capability)
|
||||
|
||||
val capability = fda.capabilities.apply {
|
||||
richDocuments = CapabilityBooleanType.TRUE
|
||||
richDocumentsDirectEditing = CapabilityBooleanType.TRUE
|
||||
richDocumentsTemplatesAvailable = CapabilityBooleanType.TRUE
|
||||
accountName = user.accountName
|
||||
val appScanOptionalFeature: AppScanOptionalFeature = object : AppScanOptionalFeature() {
|
||||
override fun getScanContract(): ActivityResultContract<Unit, String?> =
|
||||
throw UnsupportedOperationException("Document scan is not available")
|
||||
}
|
||||
|
||||
val materialSchemesProvider = getMaterialSchemesProvider()
|
||||
val viewThemeUtils = ViewThemeUtils(
|
||||
materialSchemesProvider.getMaterialSchemesForCurrentUser(),
|
||||
ColorUtil(targetContext)
|
||||
)
|
||||
|
||||
val editorUtils = EditorUtils(ArbitraryDataProviderImpl(targetContext))
|
||||
|
||||
val sut = OCFileListBottomSheetDialog(
|
||||
fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
sut.show()
|
||||
sut.behavior.setState(BottomSheetBehavior.STATE_EXPANDED)
|
||||
val viewGroup = sut.window?.findViewById<ViewGroup>(android.R.id.content) ?: return@onIdleSync
|
||||
hideCursors(viewGroup)
|
||||
val screenShotName = createName(testClassName + "_" + "testBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
CapabilityUtils.updateCapability(capability)
|
||||
|
||||
val appScanOptionalFeature: AppScanOptionalFeature = object : AppScanOptionalFeature() {
|
||||
override fun getScanContract(): ActivityResultContract<Unit, String?> =
|
||||
throw UnsupportedOperationException("Document scan is not available")
|
||||
}
|
||||
|
||||
val viewThemeUtils = ViewThemeUtils(
|
||||
materialSchemesForCurrentUser,
|
||||
ColorUtil(targetContext)
|
||||
)
|
||||
|
||||
val editorUtils = EditorUtils(ArbitraryDataProviderImpl(targetContext))
|
||||
|
||||
sut = OCFileListBottomSheetDialog(
|
||||
fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature
|
||||
)
|
||||
|
||||
sut.show()
|
||||
}
|
||||
|
||||
sut!!.behavior.setState(BottomSheetBehavior.STATE_EXPANDED)
|
||||
val viewGroup = sut.window?.findViewById<ViewGroup>(android.R.id.content) ?: return
|
||||
hideCursors(viewGroup)
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testOnlineStatusBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
// show dialog
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: SetOnlineStatusBottomSheet? = null
|
||||
scenario.onActivity { fda ->
|
||||
sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Focus time", "\uD83E\uDD13", -1)
|
||||
)
|
||||
sut.show(fda.supportFragmentManager, "set_online_status")
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Focus time", "\uD83E\uDD13", -1)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.show(fda.supportFragmentManager, "set_online_status")
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testOnlineStatusBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.view, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "testOnlineStatusBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.view, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testProfileBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
// Fixed values for HoverCard
|
||||
val actions: MutableList<Action> = ArrayList()
|
||||
actions.add(
|
||||
Action(
|
||||
@@ -599,30 +633,33 @@ class DialogFragmentIT : AbstractIT() {
|
||||
)
|
||||
|
||||
val hoverCard = HoverCard("christine", "Christine Scott", actions)
|
||||
|
||||
// show dialog
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: ProfileBottomSheetDialog? = null
|
||||
scenario.onActivity { fda ->
|
||||
sut = ProfileBottomSheetDialog(
|
||||
fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils
|
||||
)
|
||||
sut.show()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = ProfileBottomSheetDialog(
|
||||
fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.show()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testProfileBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.window?.decorView, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "testProfileBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testSslUntrustedCertDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -640,17 +677,20 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testStoragePermissionDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val dialog = StoragePermissionDialogFragment()
|
||||
showDialog(dialog)
|
||||
newInstance(false).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testFileActionsBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -669,30 +709,34 @@ class DialogFragmentIT : AbstractIT() {
|
||||
private fun showDialog(dialog: DialogFragment) {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
dialog.show(sut.supportFragmentManager, null)
|
||||
}
|
||||
|
||||
val dialogInstance = waitForDialog(dialog) ?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
scenario.onActivity {
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content)
|
||||
if (viewGroup != null) {
|
||||
hideCursors(viewGroup)
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
showDialog(sut, dialog)
|
||||
}
|
||||
screenshot(dialogInstance.window?.decorView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialog(sut: FileDisplayActivity, dialog: DialogFragment) {
|
||||
dialog.show(sut.supportFragmentManager, null)
|
||||
onIdleSync {
|
||||
val dialogInstance = waitForDialog(dialog)
|
||||
?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content) ?: return@onIdleSync
|
||||
hideCursors(viewGroup)
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialogInstance.window?.decorView)
|
||||
}
|
||||
}
|
||||
|
||||
private fun waitForDialog(dialogFragment: DialogFragment, timeoutMs: Long = 5000): Dialog? {
|
||||
val start = System.currentTimeMillis()
|
||||
while (System.currentTimeMillis() - start < timeoutMs) {
|
||||
if (dialogFragment.isAdded && dialogFragment.dialog != null) {
|
||||
return dialogFragment.dialog
|
||||
}
|
||||
Thread.sleep(50)
|
||||
val dialog = dialogFragment.dialog
|
||||
if (dialog != null) return dialog
|
||||
Thread.sleep(100)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -19,8 +21,11 @@ import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SendFilesDialogTest : AbstractIT() {
|
||||
@@ -48,25 +53,38 @@ class SendFilesDialogTest : AbstractIT() {
|
||||
)
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
private fun showDialog(files: Set<OCFile>, onComplete: (SendFilesDialog) -> Unit) {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
var dialog: SendFilesDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
val fm: FragmentManager = sut.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
dialog = SendFilesDialog.newInstance(files)
|
||||
dialog.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
fm.executePendingTransactions()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
onComplete(dialog!!)
|
||||
val fm: FragmentManager = sut.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
|
||||
val dialog = SendFilesDialog.newInstance(files)
|
||||
dialog.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
onComplete(dialog)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog() {
|
||||
showDialog(FILES_SAME_TYPE) { sut ->
|
||||
@@ -77,15 +95,18 @@ class SendFilesDialogTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog_Screenshot() {
|
||||
showDialog(FILES_SAME_TYPE) { sut ->
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog_Screenshot", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialogDifferentTypes() {
|
||||
showDialog(FILES_MIXED_TYPE) { sut ->
|
||||
@@ -96,6 +117,7 @@ class SendFilesDialogTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialogDifferentTypes_Screenshot() {
|
||||
showDialog(FILES_MIXED_TYPE) { sut ->
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
@@ -18,6 +19,7 @@ import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Test
|
||||
|
||||
@@ -25,26 +27,29 @@ class SendShareDialogTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SendShareDialogTest"
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SendShareDialog? = null
|
||||
scenario.onActivity { activity ->
|
||||
val fm: FragmentManager = activity.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
fm.executePendingTransactions()
|
||||
val file = OCFile("/1.jpg").apply {
|
||||
mimeType = "image/jpg"
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fm: FragmentManager = activity.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
|
||||
val file = OCFile("/1.jpg").apply {
|
||||
mimeType = "image/jpg"
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val sut = SendShareDialog.newInstance(file, false, OCCapability())
|
||||
sut.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
|
||||
sut = SendShareDialog.newInstance(file, false, OCCapability())
|
||||
sut.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut!!.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-34
@@ -8,72 +8,93 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SetupEncryptionDialogFragmentIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showMnemonic() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SetupEncryptionDialogFragment? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
val keyWords = arrayListOf(
|
||||
"ability",
|
||||
"able",
|
||||
"about",
|
||||
"above",
|
||||
"absent",
|
||||
"absorb",
|
||||
"abstract",
|
||||
"absurd",
|
||||
"abuse",
|
||||
"access",
|
||||
"accident",
|
||||
"account",
|
||||
"accuse"
|
||||
)
|
||||
sut.setMnemonic(keyWords)
|
||||
sut.showMnemonicInfo()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.requireDialog().window?.decorView, screenShotName)
|
||||
val keyWords = arrayListOf(
|
||||
"ability",
|
||||
"able",
|
||||
"about",
|
||||
"above",
|
||||
"absent",
|
||||
"absorb",
|
||||
"abstract",
|
||||
"absurd",
|
||||
"abuse",
|
||||
"access",
|
||||
"accident",
|
||||
"account",
|
||||
"accuse"
|
||||
)
|
||||
sut.setMnemonic(keyWords)
|
||||
sut.showMnemonicInfo()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SetupEncryptionDialogFragment? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
sut.errorSavingKeys()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
val sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
sut.errorSavingKeys()
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.requireDialog().window?.decorView, screenShotName)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+39
-28
@@ -6,73 +6,84 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SyncFileNotEnoughSpaceDialogFragmentTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest"
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
fun showNotEnoughSpaceDialogForFolder() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
scenario.onActivity { sut ->
|
||||
val ocFile = OCFile("/Document/").apply {
|
||||
fileLength = 5000000
|
||||
setFolder()
|
||||
}
|
||||
|
||||
newInstance(ocFile, 1000).apply {
|
||||
show(activity.supportFragmentManager, "1")
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
newInstance(ocFile, 1000).apply {
|
||||
show(sut.supportFragmentManager, "1")
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
|
||||
sut = activity
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
fun showNotEnoughSpaceDialogForFile() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
scenario.onActivity { sut ->
|
||||
val ocFile = OCFile("/Video.mp4").apply {
|
||||
fileLength = 1000000
|
||||
}
|
||||
|
||||
newInstance(ocFile, 2000).apply {
|
||||
show(activity.supportFragmentManager, "2")
|
||||
}
|
||||
sut = activity
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
newInstance(ocFile, 2000).apply {
|
||||
show(sut.supportFragmentManager, "2")
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,13 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
@@ -22,164 +23,171 @@ import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.TextDrawable
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class AvatarIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.AvatarIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showAvatars() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val fragment = AvatarTestFragment()
|
||||
sut.addFragment(fragment)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
onView(withId(R.id.avatar_list1))
|
||||
.check(matches(isDisplayed()))
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = AvatarTestFragment()
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = sut.supportFragmentManager.fragments.last() as AvatarTestFragment
|
||||
sut.addFragment(fragment)
|
||||
fragment.run {
|
||||
addAvatar("Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Test Server Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Cormier Paulette", avatarRadius, width, targetContext)
|
||||
addAvatar("winston brent", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("[email protected]", avatarRadius, width, targetContext)
|
||||
}
|
||||
|
||||
fragment.run {
|
||||
addAvatar("Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Test Server Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Cormier Paulette", avatarRadius, width, targetContext)
|
||||
addAvatar("winston brent", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("[email protected]", avatarRadius, width, targetContext)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatars", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatars", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showAvatarsWithStatus() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val fragment = AvatarTestFragment()
|
||||
sut.addFragment(fragment)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
onView(withId(R.id.avatar_list1))
|
||||
.check(matches(isDisplayed()))
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = AvatarTestFragment()
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val paulette = BitmapFactory.decodeFile(getFile("paulette.jpg").absolutePath)
|
||||
val christine = BitmapFactory.decodeFile(getFile("christine.jpg").absolutePath)
|
||||
val textBitmap = BitmapUtils.drawableToBitmap(TextDrawable.createNamedAvatar("Admin", avatarRadius))
|
||||
|
||||
val paulette = BitmapFactory.decodeFile(getFile("paulette.jpg").absolutePath)
|
||||
val christine = BitmapFactory.decodeFile(getFile("christine.jpg").absolutePath)
|
||||
val textBitmap = BitmapUtils.drawableToBitmap(TextDrawable.createNamedAvatar("Admin", avatarRadius))
|
||||
val fragment = sut.supportFragmentManager.fragments.last() as AvatarTestFragment
|
||||
sut.addFragment(fragment)
|
||||
|
||||
fragment.run {
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.ONLINE, "😘", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "☁️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.DND, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.AWAY, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.OFFLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "😘", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "☁️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.DND, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.AWAY, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.OFFLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
fragment.run {
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.ONLINE, "😘", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "☁️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.DND, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.AWAY, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.OFFLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "😘", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "☁️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.DND, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.AWAY, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.OFFLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatarsWithStatus", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatarsWithStatus", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+98
-69
@@ -9,8 +9,10 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -23,7 +25,10 @@ import com.owncloud.android.lib.resources.activities.model.Activity
|
||||
import com.owncloud.android.lib.resources.activities.model.RichElement
|
||||
import com.owncloud.android.lib.resources.activities.model.RichObject
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.util.GregorianCalendar
|
||||
@@ -31,6 +36,16 @@ import java.util.GregorianCalendar
|
||||
class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
private var file: File = getFile("gps.jpg")
|
||||
private val oCFile: OCFile = OCFile("/").apply {
|
||||
storagePath = file.absolutePath
|
||||
@@ -39,60 +54,67 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFileDetailActivitiesFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user))
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user))
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailActivitiesFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailActivitiesFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFileDetailSharingFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user))
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user))
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailSharingFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailSharingFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFileDetailDetailsFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = ImageDetailFragment.newInstance(oCFile, user).apply {
|
||||
hideMap()
|
||||
}
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = ImageDetailFragment.newInstance(oCFile, user).apply {
|
||||
hideMap()
|
||||
}
|
||||
sut.addFragment(fragment)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailDetailsFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailDetailsFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
fun showDetailsActivities() {
|
||||
@@ -149,77 +171,84 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
)
|
||||
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
fragment.fileDetailActivitiesFragment.populateList(activities as List<Any>?, true)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
fragment.fileDetailActivitiesFragment.populateList(activities as List<Any>?, true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDetailsActivitiesNone() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
fragment.fileDetailActivitiesFragment.populateList(emptyList(), true)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
fragment.fileDetailActivitiesFragment.populateList(emptyList(), true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesNone", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesNone", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDetailsActivitiesError() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
fragment.fileDetailActivitiesFragment.disableLoadingActivities()
|
||||
fragment.fileDetailActivitiesFragment.setErrorContent(
|
||||
targetContext.resources.getString(R.string.file_detail_activity_error)
|
||||
)
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
fragment.fileDetailActivitiesFragment.disableLoadingActivities()
|
||||
fragment.fileDetailActivitiesFragment.setErrorContent(
|
||||
targetContext.resources.getString(R.string.file_detail_activity_error)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesError", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesError", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDetailsSharing() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 1)
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 1)
|
||||
sut.addFragment(fragment)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsSharing", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsSharing", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+570
-523
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Philipp Hasper <vcs@hasper.info>
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-FileCopyrightText: 2022 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
@@ -13,37 +12,27 @@ import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.UiController
|
||||
import androidx.test.espresso.ViewAction
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension
|
||||
import com.owncloud.android.ui.adapter.GalleryRowHolder
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.Random
|
||||
import org.hamcrest.Matchers.`is` as isSameView
|
||||
|
||||
class GalleryFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.GalleryFragmentIT"
|
||||
@@ -51,6 +40,8 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
|
||||
// initialise thumbnails cache on background thread
|
||||
@Suppress("DEPRECATION")
|
||||
ThumbnailsCacheManager.initDiskCacheAsync()
|
||||
@@ -58,140 +49,62 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
ThumbnailsCacheManager.clearCache()
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showEmpty() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
}
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showEmpty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showGallery() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
createImage(10000001, 700, 300)
|
||||
createImage(10000002, 500, 300)
|
||||
createImage(10000007, 300, 400)
|
||||
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGallery", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiSelect() {
|
||||
val imageCount = 100
|
||||
for (num in 1..imageCount) {
|
||||
// Spread the files over multiple days to also get multiple sections
|
||||
val secondsPerDay = 1L * 24 * 60 * 60
|
||||
createImage(10000000 + num * 7 * secondsPerDay, 700, 300)
|
||||
}
|
||||
|
||||
// Test that scrolling through the whole list is possible without a crash
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
lateinit var galleryFragment: GalleryFragment
|
||||
scenario.onActivity { testActivity ->
|
||||
galleryFragment = GalleryFragment()
|
||||
testActivity.addFragment(galleryFragment)
|
||||
}
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
onView(withId(R.id.list_root))
|
||||
.perform(RecyclerViewActions.scrollToLastPosition<GalleryRowHolder>())
|
||||
.perform(RecyclerViewActions.scrollToPosition<GalleryRowHolder>(0))
|
||||
}
|
||||
|
||||
// Test selection of all entries
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
lateinit var galleryFragment: GalleryFragment
|
||||
scenario.onActivity { testActivity ->
|
||||
galleryFragment = GalleryFragment()
|
||||
testActivity.addFragment(galleryFragment)
|
||||
}
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
// get the RecyclerView and itemCount on the UI thread
|
||||
val recyclerView = findRecyclerViewRecursively(galleryFragment.view)
|
||||
?: throw AssertionError("RecyclerView not found")
|
||||
val adapterCount = recyclerView.adapter?.itemCount ?: 0
|
||||
|
||||
// Perform the view action on each adapter position (row)
|
||||
for (pos in 0 until adapterCount) {
|
||||
onView(isSameView(recyclerView))
|
||||
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(pos, longClickAllThumbnailsInRow()))
|
||||
}
|
||||
|
||||
val checked = galleryFragment.commonAdapter.getCheckedItems()
|
||||
assertEquals(imageCount, checked.size)
|
||||
}
|
||||
}
|
||||
|
||||
/** Recursively walk view tree to find the first RecyclerView. Runs on the same thread that calls it. */
|
||||
@Suppress("ReturnCount")
|
||||
private fun findRecyclerViewRecursively(root: View?): RecyclerView? {
|
||||
if (root == null) return null
|
||||
if (root is RecyclerView) return root
|
||||
if (root !is ViewGroup) return null
|
||||
for (i in 0 until root.childCount) {
|
||||
val child = root.getChildAt(i)
|
||||
val found = findRecyclerViewRecursively(child)
|
||||
if (found != null) return found
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** For the given row view, long-click each thumbnail inside its FrameLayouts */
|
||||
@Suppress("NestedBlockDepth")
|
||||
fun longClickAllThumbnailsInRow() = object : ViewAction {
|
||||
override fun getConstraints() = isDisplayed()
|
||||
|
||||
override fun getDescription() = "Long-click all thumbnail ImageViews inside a GalleryRowHolder"
|
||||
|
||||
override fun perform(uiController: UiController, view: View) {
|
||||
if (view is ViewGroup) {
|
||||
// each child of the row is a FrameLayout representing one gallery cell
|
||||
for (i in 0 until view.childCount) {
|
||||
val cell = view.getChildAt(i)
|
||||
if (cell is FrameLayout) {
|
||||
// GalleryRowHolder builds FrameLayout with children:
|
||||
// 0 = shimmer, 1 = thumbnail ImageView, 2 = checkbox
|
||||
val thumbnail = if (cell.childCount > 1) cell.getChildAt(1) else cell
|
||||
thumbnail.performLongClick()
|
||||
}
|
||||
val screenShotName = createName(testClassName + "_" + "showEmpty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createImage(id: Long, width: Int? = null, height: Int? = null) {
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showGallery() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
createImage(10000001, 700, 300)
|
||||
createImage(10000002, 500, 300)
|
||||
createImage(10000007, 300, 400)
|
||||
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGallery", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createImage(id: Int, width: Int? = null, height: Int? = null) {
|
||||
val defaultSize = ThumbnailsCacheManager.getThumbnailDimension().toFloat()
|
||||
val file = OCFile("/$id.png").apply {
|
||||
fileId = id
|
||||
fileId = id.toLong()
|
||||
remoteId = "$id"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = true
|
||||
modificationTimestamp = (1658475504 + id) * 1000
|
||||
modificationTimestamp = (1658475504 + id.toLong()) * 1000
|
||||
imageDimension = ImageDimension(width?.toFloat() ?: defaultSize, height?.toFloat() ?: defaultSize)
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
+56
-32
@@ -8,67 +8,91 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.android.lib.resources.groupfolders.Groupfolder
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class GroupfolderListFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.GroupfolderListFragmentIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showGroupfolder() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showGroupfolders() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("1", Groupfolder(1, "/test/")),
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
)
|
||||
}
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolders", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("1", Groupfolder(1, "/test/")),
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolders", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+328
-353
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Philipp Hasper <vcs@hasper.info>
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
||||
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com>
|
||||
@@ -10,32 +9,24 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.espresso.intent.Intents.intended
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
import com.owncloud.android.lib.resources.tags.Tag
|
||||
import com.owncloud.android.ui.activity.FolderPickerActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.hamcrest.Matchers.not
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -45,74 +36,84 @@ import org.junit.rules.TestRule
|
||||
class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.OCFileListFragmentStaticServerIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Before
|
||||
fun initIntentRecording() {
|
||||
Intents.init()
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
fun showFiles() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
OCFile("/1.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
OCFile("/image.png").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Top secret", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/1.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/live photo.png").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
setLivePhoto("/video.mov")
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/image.png").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Top secret", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/video.mp4").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = "video/mp4"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 12092000
|
||||
modificationTimestamp = 746143952000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Confidential", null), Tag("", "+5", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/live photo.png").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
setLivePhoto("/video.mov")
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(OCFileListFragment())
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val fragment = (sut.fragment as OCFileListFragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false)
|
||||
OCFile("/video.mp4").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = "video/mp4"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 12092000
|
||||
modificationTimestamp = 746143952000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Confidential", null), Tag("", "+5", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(OCFileListFragment())
|
||||
|
||||
val fragment = (sut.fragment as OCFileListFragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,131 +121,135 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
|
||||
*/
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showSharedFiles() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
val fragment = OCFileListFragment()
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
OCFile("/sharedToUser.jpg").apply {
|
||||
remoteId = "00000001"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Admin", "Server Admin", ShareType.USER))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
OCFile("/sharedToGroup.jpg").apply {
|
||||
remoteId = "00000002"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("group", "Group", ShareType.GROUP))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/sharedToUser.jpg").apply {
|
||||
remoteId = "00000001"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Admin", "Server Admin", ShareType.USER))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToEmail.jpg").apply {
|
||||
remoteId = "00000003"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees =
|
||||
listOf(
|
||||
ShareeUser("[email protected]", "[email protected]", ShareType.EMAIL)
|
||||
OCFile("/sharedToGroup.jpg").apply {
|
||||
remoteId = "00000002"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("group", "Group", ShareType.GROUP))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToEmail.jpg").apply {
|
||||
remoteId = "00000003"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees =
|
||||
listOf(
|
||||
ShareeUser("[email protected]", "[email protected]", ShareType.EMAIL)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/publicLink.jpg").apply {
|
||||
remoteId = "00000004"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToFederatedUser.jpg").apply {
|
||||
remoteId = "00000005"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser(
|
||||
"[email protected]",
|
||||
"[email protected] (remote)",
|
||||
ShareType.FEDERATED
|
||||
)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/publicLink.jpg").apply {
|
||||
remoteId = "00000004"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/sharedToPersonalCircle.jpg").apply {
|
||||
remoteId = "00000006"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("circle", "Circle (Personal circle)", ShareType.CIRCLE))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToFederatedUser.jpg").apply {
|
||||
remoteId = "00000005"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser(
|
||||
"[email protected]",
|
||||
"[email protected] (remote)",
|
||||
ShareType.FEDERATED
|
||||
OCFile("/sharedToUserRoom.jpg").apply {
|
||||
remoteId = "00000007"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Admin", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToGroupRoom.jpg").apply {
|
||||
remoteId = "00000008"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Meeting", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToUsers.jpg").apply {
|
||||
remoteId = "00000009"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser("Admin", "Server Admin", ShareType.USER),
|
||||
ShareeUser("User", "User", ShareType.USER),
|
||||
ShareeUser("Christine", "Christine Scott", ShareType.USER)
|
||||
)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToPersonalCircle.jpg").apply {
|
||||
remoteId = "00000006"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("circle", "Circle (Personal circle)", ShareType.CIRCLE))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/notShared.jpg").apply {
|
||||
remoteId = "000000010"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToUserRoom.jpg").apply {
|
||||
remoteId = "00000007"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Admin", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
OCFile("/Foo%e2%80%aedm.exe").apply {
|
||||
remoteId = "000000011"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToGroupRoom.jpg").apply {
|
||||
remoteId = "00000008"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Meeting", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
sut.addFragment(fragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
|
||||
OCFile("/sharedToUsers.jpg").apply {
|
||||
remoteId = "00000009"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser("Admin", "Server Admin", ShareType.USER),
|
||||
ShareeUser("User", "User", ShareType.USER),
|
||||
ShareeUser("Christine", "Christine Scott", ShareType.USER)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
OCFile("/notShared.jpg").apply {
|
||||
remoteId = "000000010"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
val screenShotName = createName(testClassName + "_" + "showSharedFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
|
||||
OCFile("/Foo%e2%80%aedm.exe").apply {
|
||||
remoteId = "000000011"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showSharedFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,211 +257,181 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
|
||||
*/
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFolderTypes() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
val fragment = OCFileListFragment()
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
OCFile("/normal/").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1624003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
OCFile("/normal/").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1624003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedViaLink/").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1619003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/share/").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedWithSharee = true
|
||||
modificationTimestamp = 1619303571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/groupFolder/").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1615003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
permissions += "M"
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/encrypted/").apply {
|
||||
remoteId = "00000005"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isEncrypted = true
|
||||
decryptedRemotePath = "/encrypted/"
|
||||
modificationTimestamp = 1614003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/locked/").apply {
|
||||
remoteId = "00000006"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isLocked = true
|
||||
decryptedRemotePath = "/locked/"
|
||||
modificationTimestamp = 1613003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/offlineOperation/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
decryptedRemotePath = "/offlineOperation/"
|
||||
modificationTimestamp = System.currentTimeMillis()
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFolderTypes", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
|
||||
OCFile("/sharedViaLink/").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1619003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/share/").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedWithSharee = true
|
||||
modificationTimestamp = 1619303571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/groupFolder/").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1615003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
permissions += "M"
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/encrypted/").apply {
|
||||
remoteId = "00000005"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isEncrypted = true
|
||||
decryptedRemotePath = "/encrypted/"
|
||||
modificationTimestamp = 1614003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/locked/").apply {
|
||||
remoteId = "00000006"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isLocked = true
|
||||
decryptedRemotePath = "/locked/"
|
||||
modificationTimestamp = 1613003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/offlineOperation/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
decryptedRemotePath = "/offlineOperation/"
|
||||
modificationTimestamp = System.currentTimeMillis()
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFolderTypes", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
fun showRichWorkspace() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
val fragment = OCFileListFragment()
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val folder = OCFile("/test/")
|
||||
folder.setFolder()
|
||||
sut.storageManager.saveFile(folder)
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
val imageFile = OCFile("/test/image.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/test/").fileId
|
||||
storagePath = getFile("java.md").absolutePath
|
||||
val folder = OCFile("/test/")
|
||||
folder.setFolder()
|
||||
sut.storageManager.saveFile(folder)
|
||||
|
||||
val imageFile = OCFile("/test/image.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/test/").fileId
|
||||
storagePath = getFile("java.md").absolutePath
|
||||
}
|
||||
|
||||
sut.storageManager.saveFile(imageFile)
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val testFolder: OCFile = sut.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
testFolder.richWorkspace = getFile("java.md").readText()
|
||||
fragment.listDirectory(testFolder, false, false)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showRichWorkspace", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
|
||||
sut.storageManager.saveFile(imageFile)
|
||||
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val testFolder: OCFile = sut.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
testFolder.richWorkspace = getFile("java.md").readText()
|
||||
fragment.listDirectory(testFolder, false)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showRichWorkspace", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun shouldShowHeader() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
val sut = OCFileListFragment()
|
||||
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val folder = OCFile("/test/").apply {
|
||||
remoteId = "000001"
|
||||
setFolder()
|
||||
}
|
||||
activity.storageManager.saveFile(folder)
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
|
||||
val testFolder: OCFile = activity!!.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
|
||||
// richWorkspace is not set
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = " "
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = null
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = "1"
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.setCurrentDirectory(testFolder)
|
||||
|
||||
Assert.assertTrue(sut.adapter.shouldShowHeader())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldStartMoveInParentFolder() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
val fragment = OCFileListFragment()
|
||||
var testFolder: OCFile? = null
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
testFolder = OCFile("/folder/").apply {
|
||||
setFolder()
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = OCFileListFragment()
|
||||
val folder = OCFile("/test/").apply {
|
||||
remoteId = "000001"
|
||||
setFolder()
|
||||
}
|
||||
activity.storageManager.saveFile(folder)
|
||||
activity.addFragment(sut)
|
||||
val testFolder: OCFile = activity.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
// richWorkspace is not set
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = " "
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = null
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = "1"
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.setCurrentDirectory(testFolder)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Assert.assertTrue(sut.adapter.shouldShowHeader())
|
||||
}
|
||||
activity.storageManager.saveNewFile(testFolder)
|
||||
|
||||
val testFile = OCFile("${testFolder.remotePath}myImage.png").apply {
|
||||
parentId = testFolder.fileId
|
||||
activity.storageManager.saveNewFile(this)
|
||||
}
|
||||
|
||||
activity.addFragment(fragment)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
|
||||
fragment.listDirectory(testFolder, false)
|
||||
fragment.onFileActionChosen(R.id.action_move_or_copy, setOf(testFile))
|
||||
}
|
||||
// Check that the FolderPickerActivity was opened
|
||||
intended(hasComponent(FolderPickerActivity::class.java.canonicalName))
|
||||
|
||||
// Check that the Action Bar shows the current folder name as title
|
||||
onView(
|
||||
allOf(
|
||||
isDescendantOfA(withId(R.id.toolbar)),
|
||||
withText(testFolder!!.fileName)
|
||||
)
|
||||
).check(matches(isDisplayed()))
|
||||
|
||||
// Test the button's enabled status. "Move" should not be enabled, but the rest should.
|
||||
onView(allOf(withId(R.id.folder_picker_btn_cancel), isDisplayed()))
|
||||
.check(matches(isEnabled()))
|
||||
onView(allOf(withId(R.id.folder_picker_btn_copy), isDisplayed()))
|
||||
.check(matches(isEnabled()))
|
||||
onView(allOf(withId(R.id.folder_picker_btn_move), isDisplayed()))
|
||||
.check(matches(not(isEnabled())))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
@@ -20,10 +21,8 @@ import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.OCShare
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.ui.adapter.OCShareToOCFileConverter
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -47,6 +46,7 @@ internal class SharedListFragmentIT : AbstractIT() {
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showSharedFiles() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
@@ -165,15 +165,14 @@ internal class SharedListFragmentIT : AbstractIT() {
|
||||
|
||||
fragment.isLoading = false
|
||||
fragment.mEmptyListContainer?.visibility = View.GONE
|
||||
fragment.adapter.setData(
|
||||
shares,
|
||||
SearchType.SHARED_FILTER,
|
||||
storageManager,
|
||||
null,
|
||||
true
|
||||
)
|
||||
|
||||
val newList = runBlocking {
|
||||
OCShareToOCFileConverter
|
||||
.parseAndSaveShares(listOf(), shares, storageManager, user.accountName)
|
||||
}
|
||||
fragment.adapter.run {
|
||||
prepareForSearchData(storageManager, SearchType.SHARED_FILTER)
|
||||
updateAdapter(newList, null)
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showSharedFiles", "")
|
||||
|
||||
+64
-40
@@ -8,8 +8,10 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -19,67 +21,89 @@ import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.SearchResultEntry
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchSection
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchViewModel
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class UnifiedSearchFragmentIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun showSearchResult() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.onSearchResultChanged(
|
||||
listOf(
|
||||
UnifiedSearchSection(
|
||||
providerID = "files",
|
||||
name = "Files",
|
||||
entries = listOf(
|
||||
SearchResultEntry(
|
||||
"thumbnailUrl",
|
||||
"Test",
|
||||
"in Files",
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
),
|
||||
hasMoreResults = false
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.onSearchResultChanged(
|
||||
listOf(
|
||||
UnifiedSearchSection(
|
||||
providerID = "files",
|
||||
name = "Files",
|
||||
entries = listOf(
|
||||
SearchResultEntry(
|
||||
"thumbnailUrl",
|
||||
"Test",
|
||||
"in Files",
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
),
|
||||
hasMoreResults = false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun search() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
val ocFile = OCFile("/folder/test1.txt").apply {
|
||||
storagePath = "/sdcard/1.txt"
|
||||
storageManager.saveFile(this)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
val ocFile = OCFile("/folder/test1.txt").apply {
|
||||
storagePath = "/sdcard/1.txt"
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
File(ocFile.storagePath).createNewFile()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setViewModel(testViewModel)
|
||||
sut.vm.setQuery("test")
|
||||
sut.vm.initialQuery()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
File(ocFile.storagePath).createNewFile()
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.setViewModel(testViewModel)
|
||||
sut.vm.setQuery("test")
|
||||
sut.vm.initialQuery()
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-3
@@ -9,13 +9,18 @@
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
@@ -25,7 +30,18 @@ class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
private const val PNG_FILE_ASSET = "imageFile.png"
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showBitmap() {
|
||||
val pngFile = getFile(PNG_FILE_ASSET)
|
||||
@@ -35,10 +51,12 @@ class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
)
|
||||
|
||||
launchActivity<PreviewBitmapActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "showBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "showBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
-24
@@ -6,70 +6,84 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
|
||||
class PreviewTextFileFragmentTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.preview.PreviewTextFileFragmentTest"
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
@Throws(IOException::class)
|
||||
fun displaySimpleTextFile() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
scenario.onActivity { sut ->
|
||||
val test = OCFile("/text.md").apply {
|
||||
mimeType = MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN
|
||||
storagePath = getDummyFile("nonEmpty.txt").absolutePath
|
||||
}
|
||||
sut.startTextPreview(test, true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displaySimpleTextFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.startTextPreview(test, true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displaySimpleTextFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
@Throws(IOException::class)
|
||||
fun displayJavaSnippetFile() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
scenario.onActivity { sut ->
|
||||
val test = OCFile("/java.md").apply {
|
||||
mimeType = MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN
|
||||
storagePath = getFile("java.md").absolutePath
|
||||
}
|
||||
sut.startTextPreview(test, true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displayJavaSnippetFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.startTextPreview(test, true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displayJavaSnippetFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
-15
@@ -8,15 +8,20 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.preview.pdf
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewPdfFragmentScreenshotIT : AbstractIT() {
|
||||
@@ -26,27 +31,40 @@ class PreviewPdfFragmentScreenshotIT : AbstractIT() {
|
||||
private const val PDF_FILE_ASSET = "test.pdf"
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showPdf() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
}
|
||||
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
sut.dismissSnack()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPdf", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.dismissSnack()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPdf", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,15 +10,21 @@ package com.owncloud.android.ui.trashbin
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.extensions.launchAndCapture
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class TrashbinActivityIT : AbstractIT() {
|
||||
@@ -30,106 +36,90 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
FILES
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
scenario.onActivity { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun files() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "files", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "files", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "empty", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showInitialLoading()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "loading", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showInitialLoading()
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun normalUser() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "normalUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "normalUser", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun differentUser() {
|
||||
val temp = Account("differentUser@https://nextcloud.localhost", MainApp.getAccountType(targetContext))
|
||||
@@ -144,18 +134,10 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
putExtra(Intent.EXTRA_USER, "differentUser@https://nextcloud.localhost")
|
||||
}
|
||||
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "differentUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "differentUser", intent = intent, before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase)
|
||||
override fun getFolder(remotePath: String?, callback: LoadFolderCallback?) {
|
||||
when (testCase) {
|
||||
TrashbinActivityIT.TestCase.ERROR -> callback?.onError(R.string.trashbin_loading_failed)
|
||||
|
||||
TrashbinActivityIT.TestCase.FILES -> {
|
||||
val files = ArrayList<TrashbinFile>()
|
||||
files.add(
|
||||
@@ -70,7 +69,6 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase)
|
||||
|
||||
callback?.onSuccess(files)
|
||||
}
|
||||
|
||||
TrashbinActivityIT.TestCase.EMPTY -> callback?.onSuccess(ArrayList<TrashbinFile>())
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 900 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user