Compare commits
No commits in common. "9797468e3173ef878030701909bafd19a46cf6be" and "359dec2ca018c6c0296b8a7132999e7fc0a95307" have entirely different histories.
9797468e31
...
359dec2ca0
@ -1,65 +0,0 @@
|
|||||||
name: Coverage
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
BuildAndTestAndCoverage:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Fetch tags
|
|
||||||
run: git fetch --tags -p
|
|
||||||
- uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '17'
|
|
||||||
cache: gradle
|
|
||||||
- uses: gradle/actions/setup-gradle@v3
|
|
||||||
- uses: android-actions/setup-android@v3
|
|
||||||
- name: Configure gradle...
|
|
||||||
run: mkdir -p ~/.gradle && echo "ignoreGitVersion=true" >> ~/.gradle/gradle.properties
|
|
||||||
- uses: KengoTODA/actions-setup-docker-compose@v1
|
|
||||||
with:
|
|
||||||
version: "2.23.3"
|
|
||||||
- name: run selfoss
|
|
||||||
run: |
|
|
||||||
docker compose -f .gitea/workflows/assets/docker-compose.yml up -d
|
|
||||||
- name: Set env url
|
|
||||||
run: |
|
|
||||||
export SELFOSS_URL=172.17.0.1:8888
|
|
||||||
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
|
|
||||||
- name: Kill crashpad_handler processes
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
pkill -SIGTERM crashpad_handler || true
|
|
||||||
sleep 5
|
|
||||||
pkill -SIGKILL crashpad_handler || true
|
|
||||||
- name: Tests
|
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
|
||||||
with:
|
|
||||||
api-level: 29
|
|
||||||
script: |
|
|
||||||
./gradlew androidApp:connectedAndroidTest
|
|
||||||
killall -INT crashpad_handler || true
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: failure()
|
|
||||||
with:
|
|
||||||
name: failure-espresso
|
|
||||||
path: build/reports/androidTests/connected/screenshots
|
|
||||||
retention-days: 2
|
|
||||||
overwrite: true
|
|
||||||
include-hidden-files: true
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: coverage-espresso
|
|
||||||
path: build/reports/coverage/androidTest/githubConfig/debug/connected
|
|
||||||
retention-days: 1
|
|
||||||
overwrite: true
|
|
||||||
include-hidden-files: true
|
|
||||||
- name: Clean
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker compose -f .gitea/workflows/assets/docker-compose.yml stop
|
|
@ -3,148 +3,89 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- chore-crowdin-ci
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
BuildAndTestAndCoverage:
|
Lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '17'
|
||||||
|
cache: gradle
|
||||||
|
- name: Install klint
|
||||||
|
run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.5.0/ktlint && chmod a+x ktlint && mv ktlint /usr/local/bin/
|
||||||
|
- name: Install detekt
|
||||||
|
run: curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.7/detekt-cli-1.23.7.zip && unzip detekt-cli-1.23.7.zip
|
||||||
|
- name: Linting...
|
||||||
|
run: ktlint 'shared/**/*.kt' 'androidApp/**/*.kt' '!shared/build'
|
||||||
|
- name: Detecting...
|
||||||
|
run: ./detekt-cli-1.23.7/bin/detekt-cli -c detekt.yml --excludes '**/shared/build/**/*.kt'
|
||||||
|
translations:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Fetch tags
|
- name: "Check translations changes"
|
||||||
run: git fetch --tags -p
|
id: check-translations-changes
|
||||||
- uses: actions/setup-java@v4
|
uses: tj-actions/changed-files@v45
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
files: |
|
||||||
java-version: '17'
|
androidApp/src/main/res/values/strings.xml
|
||||||
- uses: gradle/actions/setup-gradle@v3
|
- name: upload translation sources
|
||||||
- uses: android-actions/setup-android@v3
|
if: steps.check-api-changes.outputs.any_modified == 'true'
|
||||||
- name: Configure gradle...
|
uses: crowdin/github-action@v2
|
||||||
run: mkdir -p ~/.gradle && echo "ignoreGitVersion=true" >> ~/.gradle/gradle.properties
|
|
||||||
- uses: KengoTODA/actions-setup-docker-compose@v1
|
|
||||||
with:
|
with:
|
||||||
version: "2.23.3"
|
config: './.gitea/workflows/assets/crowdin.yml'
|
||||||
- name: run selfoss
|
upload_sources: true
|
||||||
|
upload_translations: false
|
||||||
|
download_translations: false
|
||||||
|
create_pull_request: false
|
||||||
|
push_translations: false
|
||||||
|
env:
|
||||||
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||||
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||||
|
- name: wait
|
||||||
|
if: steps.check-api-changes.outputs.any_modified == 'true'
|
||||||
|
run: sleep 10s
|
||||||
|
- name: download translations
|
||||||
|
if: steps.check-api-changes.outputs.any_modified == 'true'
|
||||||
|
uses: crowdin/github-action@v2
|
||||||
|
with:
|
||||||
|
config: './.gitea/workflows/assets/crowdin.yml'
|
||||||
|
upload_sources: false
|
||||||
|
upload_translations: false
|
||||||
|
download_translations: true
|
||||||
|
create_pull_request: false
|
||||||
|
push_translations: false
|
||||||
|
env:
|
||||||
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||||
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||||
|
- name: Check for uncommitted changes
|
||||||
|
if: steps.check-api-changes.outputs.any_modified == 'true'
|
||||||
|
id: check-changes
|
||||||
|
uses: mskri/check-uncommitted-changes-action@v1.0.1
|
||||||
|
- name: Commit Changes
|
||||||
|
if: steps.check-api-changes.outputs.any_modified == 'true' && steps.check-changes.outputs.changes != ''
|
||||||
run: |
|
run: |
|
||||||
docker compose -f .gitea/workflows/assets/docker-compose.yml up -d
|
git config --global user.email aminecmi+giteadrone@pm.me
|
||||||
- name: Set env url
|
git config --global user.name giteadrone
|
||||||
run: |
|
git add ./androidApp/src/main/res/*
|
||||||
export SELFOSS_URL=172.17.0.1:8888
|
git commit -m "translation: translation files"
|
||||||
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
|
- name: Push changes
|
||||||
- name: Kill crashpad_handler processes
|
if: steps.check-api-changes.outputs.any_modified == 'true' && steps.check-changes.outputs.changes != ''
|
||||||
if: always()
|
uses: appleboy/git-push-action@v1.0.0
|
||||||
run: |
|
|
||||||
pkill -SIGTERM crashpad_handler || true
|
|
||||||
sleep 5
|
|
||||||
pkill -SIGKILL crashpad_handler || true
|
|
||||||
- name: Tests
|
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
|
||||||
with:
|
with:
|
||||||
api-level: 29
|
author_name: giteadrone
|
||||||
script: |
|
author_email: aminecmi+giteadrone@pm.me
|
||||||
./gradlew androidApp:connectedAndroidTest || true
|
remote: ${{ secrets.REMOTE_URL }}
|
||||||
./gradlew androidApp:fetchScreenshots
|
ssh_key: ${{ secrets.PRIVATE_KEY }}
|
||||||
- uses: actions/upload-artifact@v3
|
branch: ${{ github.head_ref || github.ref_name }}
|
||||||
if: always()
|
build:
|
||||||
with:
|
needs: Lint
|
||||||
name: failure-espresso
|
uses: ./.gitea/workflows/common_build.yml
|
||||||
path: build/reports/androidTests/connected/screenshots
|
|
||||||
retention-days: 2
|
|
||||||
overwrite: true
|
|
||||||
include-hidden-files: true
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: coverage-espresso
|
|
||||||
path: build/reports/coverage/androidTest/githubConfig/debug/connected
|
|
||||||
retention-days: 1
|
|
||||||
overwrite: true
|
|
||||||
include-hidden-files: true
|
|
||||||
- name: Clean
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker compose -f .gitea/workflows/assets/docker-compose.yml stop
|
|
||||||
|
|
||||||
# Lint:
|
|
||||||
# runs-on: ubuntu-latest
|
|
||||||
# steps:
|
|
||||||
# - name: Check out repository code
|
|
||||||
# uses: actions/checkout@v4
|
|
||||||
# - uses: actions/setup-java@v4
|
|
||||||
# with:
|
|
||||||
# distribution: 'temurin'
|
|
||||||
# java-version: '17'
|
|
||||||
# cache: gradle
|
|
||||||
# - name: Install klint
|
|
||||||
# run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.5.0/ktlint && chmod a+x ktlint && mv ktlint /usr/local/bin/
|
|
||||||
# - name: Install detekt
|
|
||||||
# run: curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.7/detekt-cli-1.23.7.zip && unzip detekt-cli-1.23.7.zip
|
|
||||||
# - name: Linting...
|
|
||||||
# run: ktlint 'shared/**/*.kt' 'androidApp/**/*.kt' '!shared/build'
|
|
||||||
# - name: Detecting...
|
|
||||||
# run: ./detekt-cli-1.23.7/bin/detekt-cli -c detekt.yml --excludes '**/shared/build/**/*.kt'
|
|
||||||
# translations:
|
|
||||||
# runs-on: ubuntu-latest
|
|
||||||
# steps:
|
|
||||||
# - name: Check out repository code
|
|
||||||
# uses: actions/checkout@v4
|
|
||||||
# with:
|
|
||||||
# fetch-depth: 0
|
|
||||||
# - name: "Check translations changes"
|
|
||||||
# id: check-translations-changes
|
|
||||||
# uses: tj-actions/changed-files@v45
|
|
||||||
# with:
|
|
||||||
# files: |
|
|
||||||
# androidApp/src/main/res/values/strings.xml
|
|
||||||
# - name: upload translation sources
|
|
||||||
# if: steps.check-api-changes.outputs.any_modified == 'true'
|
|
||||||
# uses: crowdin/github-action@v2
|
|
||||||
# with:
|
|
||||||
# config: './.gitea/workflows/assets/crowdin.yml'
|
|
||||||
# upload_sources: true
|
|
||||||
# upload_translations: false
|
|
||||||
# download_translations: false
|
|
||||||
# create_pull_request: false
|
|
||||||
# push_translations: false
|
|
||||||
# env:
|
|
||||||
# CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
|
||||||
# CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
||||||
# - name: wait
|
|
||||||
# if: steps.check-api-changes.outputs.any_modified == 'true'
|
|
||||||
# run: sleep 10s
|
|
||||||
# - name: download translations
|
|
||||||
# if: steps.check-api-changes.outputs.any_modified == 'true'
|
|
||||||
# uses: crowdin/github-action@v2
|
|
||||||
# with:
|
|
||||||
# config: './.gitea/workflows/assets/crowdin.yml'
|
|
||||||
# upload_sources: false
|
|
||||||
# upload_translations: false
|
|
||||||
# download_translations: true
|
|
||||||
# create_pull_request: false
|
|
||||||
# push_translations: false
|
|
||||||
# env:
|
|
||||||
# CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
|
||||||
# CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
||||||
# - name: Check for uncommitted changes
|
|
||||||
# if: steps.check-api-changes.outputs.any_modified == 'true'
|
|
||||||
# id: check-changes
|
|
||||||
# uses: mskri/check-uncommitted-changes-action@v1.0.1
|
|
||||||
# - name: Commit Changes
|
|
||||||
# if: steps.check-api-changes.outputs.any_modified == 'true' && steps.check-changes.outputs.changes != ''
|
|
||||||
# run: |
|
|
||||||
# git config --global user.email aminecmi+giteadrone@pm.me
|
|
||||||
# git config --global user.name giteadrone
|
|
||||||
# git add ./androidApp/src/main/res/*
|
|
||||||
# git commit -m "translation: translation files"
|
|
||||||
# - name: Push changes
|
|
||||||
# if: steps.check-api-changes.outputs.any_modified == 'true' && steps.check-changes.outputs.changes != ''
|
|
||||||
# uses: appleboy/git-push-action@v1.0.0
|
|
||||||
# with:
|
|
||||||
# author_name: giteadrone
|
|
||||||
# author_email: aminecmi+giteadrone@pm.me
|
|
||||||
# remote: ${{ secrets.REMOTE_URL }}
|
|
||||||
# ssh_key: ${{ secrets.PRIVATE_KEY }}
|
|
||||||
# branch: ${{ github.head_ref || github.ref_name }}
|
|
||||||
# build:
|
|
||||||
# needs: Lint
|
|
||||||
# uses: ./.gitea/workflows/common_build.yml
|
|
||||||
|
@ -95,7 +95,7 @@ android {
|
|||||||
|
|
||||||
// tests
|
// tests
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
testInstrumentationRunnerArguments["useTestStorageService"] = "true"
|
testInstrumentationRunnerArguments["clearPackageData"] = "true"
|
||||||
}
|
}
|
||||||
packaging {
|
packaging {
|
||||||
resources {
|
resources {
|
||||||
@ -109,11 +109,6 @@ android {
|
|||||||
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
||||||
}
|
}
|
||||||
getByName("debug") {
|
getByName("debug") {
|
||||||
isTestCoverageEnabled = true
|
|
||||||
enableAndroidTestCoverage = true
|
|
||||||
installation {
|
|
||||||
installOptions("-g", "-r")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flavorDimensions.add("build")
|
flavorDimensions.add("build")
|
||||||
@ -126,6 +121,7 @@ android {
|
|||||||
namespace = "bou.amine.apps.readerforselfossv2.android"
|
namespace = "bou.amine.apps.readerforselfossv2.android"
|
||||||
testOptions {
|
testOptions {
|
||||||
animationsDisabled = true
|
animationsDisabled = true
|
||||||
|
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
||||||
unitTests {
|
unitTests {
|
||||||
isIncludeAndroidResources = true
|
isIncludeAndroidResources = true
|
||||||
}
|
}
|
||||||
@ -158,8 +154,8 @@ dependencies {
|
|||||||
implementation("androidx.multidex:multidex:2.0.1")
|
implementation("androidx.multidex:multidex:2.0.1")
|
||||||
|
|
||||||
// About
|
// About
|
||||||
implementation("com.mikepenz:aboutlibraries-core:11.6.3")
|
implementation("com.mikepenz:aboutlibraries-core:10.5.1")
|
||||||
implementation("com.mikepenz:aboutlibraries:11.6.3")
|
implementation("com.mikepenz:aboutlibraries:10.5.1")
|
||||||
|
|
||||||
// Material-ish things
|
// Material-ish things
|
||||||
implementation("com.ashokvarma.android:bottom-navigation-bar:2.2.0")
|
implementation("com.ashokvarma.android:bottom-navigation-bar:2.2.0")
|
||||||
@ -201,15 +197,14 @@ dependencies {
|
|||||||
testImplementation("io.mockk:mockk:1.13.14")
|
testImplementation("io.mockk:mockk:1.13.14")
|
||||||
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
|
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1")
|
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1")
|
||||||
androidTestImplementation("androidx.test:runner:1.7.0-alpha01")
|
androidTestImplementation("androidx.test:runner:1.6.2")
|
||||||
androidTestImplementation("androidx.test:rules:1.7.0-alpha01")
|
androidTestImplementation("androidx.test:rules:1.6.1")
|
||||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
||||||
implementation("androidx.test.espresso:espresso-idling-resource:3.6.1")
|
implementation("androidx.test.espresso:espresso-idling-resource:3.6.1")
|
||||||
androidTestImplementation("androidx.test.ext:junit-ktx:1.2.1")
|
androidTestImplementation("androidx.test.ext:junit-ktx:1.2.1")
|
||||||
androidTestUtil("androidx.test.services:test-services:1.6.0-alpha02")
|
androidTestUtil("androidx.test:orchestrator:1.5.1")
|
||||||
testImplementation("org.robolectric:robolectric:4.14.1")
|
testImplementation("org.robolectric:robolectric:4.14.1")
|
||||||
testImplementation("androidx.test:core-ktx:1.7.0-alpha01")
|
testImplementation("androidx.test:core-ktx:1.6.1")
|
||||||
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0")
|
|
||||||
|
|
||||||
implementation("ch.acra:acra-http:$acraVersion")
|
implementation("ch.acra:acra-http:$acraVersion")
|
||||||
implementation("ch.acra:acra-toast:$acraVersion")
|
implementation("ch.acra:acra-toast:$acraVersion")
|
||||||
@ -232,7 +227,6 @@ tasks.withType<Test> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
aboutLibraries {
|
aboutLibraries {
|
||||||
excludeFields = arrayOf("generated")
|
|
||||||
offlineMode = true
|
offlineMode = true
|
||||||
fetchRemoteLicense = false
|
fetchRemoteLicense = false
|
||||||
fetchRemoteFunding = false
|
fetchRemoteFunding = false
|
||||||
@ -241,33 +235,3 @@ aboutLibraries {
|
|||||||
duplicationMode = com.mikepenz.aboutlibraries.plugin.DuplicateMode.MERGE
|
duplicationMode = com.mikepenz.aboutlibraries.plugin.DuplicateMode.MERGE
|
||||||
duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.GROUP
|
duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.GROUP
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screenshot failure handling
|
|
||||||
val reportsDirectory = file("$buildDir/reports/androidTests/connected")
|
|
||||||
|
|
||||||
val clearScreenshotsTask =
|
|
||||||
tasks.register<Exec>("clearScreenshots") {
|
|
||||||
println("AMINE : clear")
|
|
||||||
commandLine = listOf("adb", "shell", "rm", "-r", "/sdcard/Pictures/selfoss_tests")
|
|
||||||
}
|
|
||||||
|
|
||||||
val createScreenshotDirectoryTask =
|
|
||||||
tasks.register<Exec>("createScreenshotDirectory") {
|
|
||||||
println("AMINE : create directory")
|
|
||||||
group = "reporting"
|
|
||||||
commandLine = listOf("adb", "shell", "mkdir", "-p", "/sdcard/Pictures/selfoss_tests")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register<Exec>("fetchScreenshots") {
|
|
||||||
println("AMINE : fetch")
|
|
||||||
group = "reporting"
|
|
||||||
executable(android.adbExecutable.toString())
|
|
||||||
commandLine = listOf("adb", "pull", "/sdcard/Pictures/selfoss_tests/.", reportsDirectory.toString())
|
|
||||||
|
|
||||||
finalizedBy(clearScreenshotsTask)
|
|
||||||
dependsOn(createScreenshotDirectoryTask)
|
|
||||||
|
|
||||||
doFirst {
|
|
||||||
reportsDirectory.mkdirs()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Environment.DIRECTORY_PICTURES
|
|
||||||
import android.os.Environment.getExternalStoragePublicDirectory
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.ArrayRes
|
import androidx.annotation.ArrayRes
|
||||||
import androidx.test.espresso.Espresso
|
|
||||||
import androidx.test.espresso.Espresso.onData
|
import androidx.test.espresso.Espresso.onData
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
@ -13,38 +9,29 @@ import androidx.test.espresso.action.ViewActions.replaceText
|
|||||||
import androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView
|
import androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.base.DefaultFailureHandler
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
|
import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
|
||||||
import androidx.test.runner.screenshot.BasicScreenCaptureProcessor
|
|
||||||
import androidx.test.runner.screenshot.Screenshot
|
|
||||||
import androidx.test.uiautomator.UiDevice
|
|
||||||
import androidx.test.uiautomator.UiSelector
|
|
||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
import org.hamcrest.Matchers.hasToString
|
import org.hamcrest.Matchers.hasToString
|
||||||
import org.junit.BeforeClass
|
|
||||||
import org.junit.rules.TestWatcher
|
|
||||||
import org.junit.runner.Description
|
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
val defaultUrl = (System.getenv("SELFOSS_URL") ?: "").ifEmpty { "http://10.0.2.2:8888" }
|
|
||||||
|
|
||||||
fun performLogin(someUrl: String? = null) {
|
fun performLogin(someUrl: String? = null) {
|
||||||
Log.i("AUTOMATION", "The url used will be ${if (!someUrl.isNullOrEmpty()) someUrl else defaultUrl}")
|
|
||||||
onView(withId(R.id.urlView)).perform(click()).perform(
|
onView(withId(R.id.urlView)).perform(click()).perform(
|
||||||
typeTextIntoFocusedView(
|
typeTextIntoFocusedView(
|
||||||
if (!someUrl.isNullOrEmpty()) someUrl else defaultUrl,
|
if (!someUrl.isNullOrEmpty()) someUrl else "http://10.0.2.2:8888",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
onView(withId(R.id.signInButton)).perform(click())
|
onView(withId(R.id.signInButton)).perform(click())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun loginAndInitHome() {
|
||||||
|
performLogin()
|
||||||
|
onView(withText(R.string.gdpr_dialog_title)).check(matches(isDisplayed()))
|
||||||
|
onView(withText("OK")).perform(click())
|
||||||
|
}
|
||||||
|
|
||||||
fun changeAndCancelSetting(
|
fun changeAndCancelSetting(
|
||||||
oldValue: String,
|
oldValue: String,
|
||||||
newValue: String,
|
newValue: String,
|
||||||
@ -110,12 +97,6 @@ fun testPreferencesFromArray(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun goToSources() {
|
|
||||||
openMenu()
|
|
||||||
onView(withText(R.string.menu_home_sources))
|
|
||||||
.perform(click())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testAddSourceWithUrl(
|
fun testAddSourceWithUrl(
|
||||||
url: String,
|
url: String,
|
||||||
sourceName: String,
|
sourceName: String,
|
||||||
@ -138,87 +119,3 @@ fun testAddSourceWithUrl(
|
|||||||
.perform(click())
|
.perform(click())
|
||||||
onView(withText(sourceName)).check(matches(isDisplayed()))
|
onView(withText(sourceName)).check(matches(isDisplayed()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("detekt:UtilityClassWithPublicConstructor")
|
|
||||||
open class WithANRException {
|
|
||||||
companion object {
|
|
||||||
// Running count of the number of Android Not Responding dialogues to prevent endless dismissal.
|
|
||||||
private var anrCount = 0
|
|
||||||
|
|
||||||
// `RootViewWithoutFocusException` class is private, need to match the message (instead of using type matching).
|
|
||||||
private val rootViewWithoutFocusExceptionMsg =
|
|
||||||
java.lang.String.format(
|
|
||||||
Locale.ROOT,
|
|
||||||
"Waited for the root of the view hierarchy to have " +
|
|
||||||
"window focus and not request layout for 10 seconds. If you specified a non " +
|
|
||||||
"default root matcher, it may be picking a root that never takes focus. " +
|
|
||||||
"Root:",
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun handleAnrDialogue() {
|
|
||||||
val device = UiDevice.getInstance(getInstrumentation())
|
|
||||||
// If running the device in English Locale
|
|
||||||
val waitButton = device.findObject(UiSelector().textContains("wait"))
|
|
||||||
if (waitButton.exists()) waitButton.click()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@BeforeClass
|
|
||||||
fun setUpHandler() {
|
|
||||||
Espresso.setFailureHandler { error, viewMatcher ->
|
|
||||||
|
|
||||||
if (error.message!!.contains(rootViewWithoutFocusExceptionMsg) && anrCount < 3) {
|
|
||||||
anrCount++
|
|
||||||
handleAnrDialogue()
|
|
||||||
} else { // chain all failures down to the default espresso handler
|
|
||||||
DefaultFailureHandler(getInstrumentation().targetContext).handle(error, viewMatcher)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyScreenCaptureProcessor(
|
|
||||||
parentFolderPath: String,
|
|
||||||
) : BasicScreenCaptureProcessor() {
|
|
||||||
init {
|
|
||||||
this.mDefaultScreenshotPath =
|
|
||||||
File(
|
|
||||||
File(
|
|
||||||
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
|
|
||||||
"selfoss_tests",
|
|
||||||
).absolutePath,
|
|
||||||
"screenshots/$parentFolderPath",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFilename(prefix: String): String = prefix
|
|
||||||
}
|
|
||||||
|
|
||||||
fun takeScreenshot(
|
|
||||||
parentFolderPath: String = "",
|
|
||||||
screenShotName: String,
|
|
||||||
) {
|
|
||||||
Log.d("Screenshots", "Taking screenshot of '$screenShotName'")
|
|
||||||
val screenCapture = Screenshot.capture()
|
|
||||||
val processors = setOf(MyScreenCaptureProcessor(parentFolderPath))
|
|
||||||
try {
|
|
||||||
screenCapture.apply {
|
|
||||||
name = screenShotName
|
|
||||||
process(processors)
|
|
||||||
}
|
|
||||||
Log.d("Screenshots", "Screenshot taken")
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
Log.e("Screenshots", "Could not take the screenshot", ex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ScreenshotTakingRule : TestWatcher() {
|
|
||||||
override fun failed(
|
|
||||||
e: Throwable?,
|
|
||||||
description: Description,
|
|
||||||
) {
|
|
||||||
val parentFolderPath = "failures/${description.className}"
|
|
||||||
takeScreenshot(parentFolderPath = parentFolderPath, screenShotName = description.methodName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -15,27 +15,21 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
|
|||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.LargeTest
|
import androidx.test.filters.LargeTest
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
|
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class `2-HomeActivityTest` : WithANRException() {
|
class HomeActivityTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
@Before
|
||||||
@Rule
|
fun init() {
|
||||||
val ruleChain: RuleChain =
|
loginAndInitHome()
|
||||||
RuleChain
|
}
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMenu() {
|
fun testMenu() {
|
@ -15,28 +15,16 @@ import androidx.test.filters.LargeTest
|
|||||||
import bou.amine.apps.readerforselfossv2.android.testing.CountingIdlingResourceSingleton
|
import bou.amine.apps.readerforselfossv2.android.testing.CountingIdlingResourceSingleton
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
|
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class `1-LoginActivityTest` : WithANRException() {
|
class LoginActivityTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val ruleChain: RuleChain =
|
|
||||||
RuleChain
|
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun registerIdlingResource() {
|
fun registerIdlingResource() {
|
||||||
IdlingRegistry
|
IdlingRegistry
|
||||||
@ -52,7 +40,7 @@ class `1-LoginActivityTest` : WithANRException() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `1-viewIsInitialized`() {
|
fun viewIsInitialized() {
|
||||||
onView(withId(R.id.urlView)).check(matches(isDisplayed()))
|
onView(withId(R.id.urlView)).check(matches(isDisplayed()))
|
||||||
onView(withId(R.id.selfSigned))
|
onView(withId(R.id.selfSigned))
|
||||||
.check(matches(isDisplayed()))
|
.check(matches(isDisplayed()))
|
||||||
@ -69,28 +57,28 @@ class `1-LoginActivityTest` : WithANRException() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `2-urlError`() {
|
fun urlError() {
|
||||||
performLogin("10.0.2.2:8888")
|
performLogin("10.0.2.2:8888")
|
||||||
onView(withId(R.id.urlView)).perform(click())
|
onView(withId(R.id.urlView)).perform(click())
|
||||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `3-urlSlashError`() {
|
fun connectError() {
|
||||||
performLogin("https://google.fr/toto")
|
|
||||||
onView(withId(R.id.urlView)).perform(click())
|
|
||||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `4-connectError`() {
|
|
||||||
performLogin("http://10.0.2.2:8889")
|
performLogin("http://10.0.2.2:8889")
|
||||||
onView(withId(R.id.urlView)).perform(click())
|
onView(withId(R.id.urlView)).perform(click())
|
||||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos)))
|
onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `5-multiError`() {
|
fun urlSlashError() {
|
||||||
|
performLogin("https://google.fr/toto")
|
||||||
|
onView(withId(R.id.urlView)).perform(click())
|
||||||
|
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun multiError() {
|
||||||
onView(withId(R.id.signInButton)).perform(click())
|
onView(withId(R.id.signInButton)).perform(click())
|
||||||
onView(withId(R.id.signInButton)).perform(click())
|
onView(withId(R.id.signInButton)).perform(click())
|
||||||
onView(withId(R.id.signInButton)).perform(click())
|
onView(withId(R.id.signInButton)).perform(click())
|
||||||
@ -98,9 +86,8 @@ class `1-LoginActivityTest` : WithANRException() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `6-connect`() {
|
fun connect() {
|
||||||
performLogin()
|
performLogin()
|
||||||
onView(withText(R.string.gdpr_dialog_title)).check(matches(isDisplayed()))
|
onView(withText(R.string.gdpr_dialog_title)).check(matches(isDisplayed()))
|
||||||
onView(withText("OK")).perform(click())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,30 +22,19 @@ import androidx.test.filters.LargeTest
|
|||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
|
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class `4-SettingsActivityGeneralTest` : WithANRException() {
|
class SettingsActivityGeneralTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val ruleChain: RuleChain =
|
|
||||||
RuleChain
|
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun init() {
|
fun init() {
|
||||||
|
loginAndInitHome()
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openActionBarOverflowOrOptionsMenu(
|
||||||
ApplicationProvider.getApplicationContext(),
|
ApplicationProvider.getApplicationContext(),
|
||||||
)
|
)
|
@ -1,42 +1,31 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions
|
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isNotEnabled
|
import androidx.test.espresso.matcher.ViewMatchers.isNotEnabled
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.LargeTest
|
import androidx.test.filters.LargeTest
|
||||||
import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity
|
|
||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.junit.After
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class `6-SettingsActivityOfflineTest` : WithANRException() {
|
class SettingsActivityOfflineTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(SettingsActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val ruleChain: RuleChain =
|
|
||||||
RuleChain
|
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
lateinit var context: Context
|
lateinit var context: Context
|
||||||
|
|
||||||
@ -45,14 +34,14 @@ class `6-SettingsActivityOfflineTest` : WithANRException() {
|
|||||||
activityRule.scenario.onActivity { activity ->
|
activityRule.scenario.onActivity { activity ->
|
||||||
context = activity.window.context
|
context = activity.window.context
|
||||||
}
|
}
|
||||||
|
loginAndInitHome()
|
||||||
|
openActionBarOverflowOrOptionsMenu(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
)
|
||||||
|
onView(withText(R.string.title_activity_settings)).perform(click())
|
||||||
onView(withText(R.string.pref_header_offline)).perform(click())
|
onView(withText(R.string.pref_header_offline)).perform(click())
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
|
||||||
fun back() {
|
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("detekt:LongMethod")
|
@Suppress("detekt:LongMethod")
|
||||||
@Test
|
@Test
|
||||||
fun testOffline() {
|
fun testOffline() {
|
@ -1,40 +1,29 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions
|
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.LargeTest
|
import androidx.test.filters.LargeTest
|
||||||
import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity
|
|
||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.junit.After
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class `5-SettingsActivityReaderTest` : WithANRException() {
|
class SettingsActivityReaderTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(SettingsActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val ruleChain: RuleChain =
|
|
||||||
RuleChain
|
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
lateinit var context: Context
|
lateinit var context: Context
|
||||||
|
|
||||||
@ -43,14 +32,14 @@ class `5-SettingsActivityReaderTest` : WithANRException() {
|
|||||||
activityRule.scenario.onActivity { activity ->
|
activityRule.scenario.onActivity { activity ->
|
||||||
context = activity.window.context
|
context = activity.window.context
|
||||||
}
|
}
|
||||||
|
loginAndInitHome()
|
||||||
|
openActionBarOverflowOrOptionsMenu(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
)
|
||||||
|
onView(withText(R.string.title_activity_settings)).perform(click())
|
||||||
onView(withText(R.string.pref_header_viewer)).perform(click())
|
onView(withText(R.string.pref_header_viewer)).perform(click())
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
|
||||||
fun back() {
|
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testReader() {
|
fun testReader() {
|
||||||
onView(withSettingsCheckboxFrame(R.string.pref_switch_actions_pager_scroll)).check(
|
onView(withSettingsCheckboxFrame(R.string.pref_switch_actions_pager_scroll)).check(
|
@ -15,23 +15,13 @@ import org.hamcrest.CoreMatchers.not
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
class SettingsActivityTest {
|
||||||
class `3-SettingsActivityTest` : WithANRException() {
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val ruleChain: RuleChain =
|
|
||||||
RuleChain
|
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
lateinit var context: Context
|
lateinit var context: Context
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -39,6 +29,7 @@ class `3-SettingsActivityTest` : WithANRException() {
|
|||||||
activityRule.scenario.onActivity { activity ->
|
activityRule.scenario.onActivity { activity ->
|
||||||
context = activity.window.context
|
context = activity.window.context
|
||||||
}
|
}
|
||||||
|
loginAndInitHome()
|
||||||
openMenu()
|
openMenu()
|
||||||
onView(withText(R.string.title_activity_settings)).perform(click())
|
onView(withText(R.string.title_activity_settings)).perform(click())
|
||||||
}
|
}
|
||||||
@ -77,9 +68,6 @@ class `3-SettingsActivityTest` : WithANRException() {
|
|||||||
changeAndSaveSetting("", "10") {
|
changeAndSaveSetting("", "10") {
|
||||||
onView(withText(R.string.pref_api_timeout)).perform(click())
|
onView(withText(R.string.pref_api_timeout)).perform(click())
|
||||||
}
|
}
|
||||||
changeAndSaveSetting("", "60") {
|
|
||||||
onView(withText(R.string.pref_api_timeout)).perform(click())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -18,23 +18,14 @@ import org.junit.After
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.RuleChain
|
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class `7-SourcesActivityTest` : WithANRException() {
|
class SourcesActivityTest {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val ruleChain: RuleChain =
|
|
||||||
RuleChain
|
|
||||||
.outerRule(activityRule)
|
|
||||||
.around(ScreenshotTakingRule())
|
|
||||||
|
|
||||||
lateinit var sourceName: String
|
lateinit var sourceName: String
|
||||||
|
|
||||||
@ -42,6 +33,7 @@ class `7-SourcesActivityTest` : WithANRException() {
|
|||||||
fun init() {
|
fun init() {
|
||||||
sourceName = UUID.randomUUID().toString().substring(0, 15)
|
sourceName = UUID.randomUUID().toString().substring(0, 15)
|
||||||
|
|
||||||
|
loginAndInitHome()
|
||||||
goToSources()
|
goToSources()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +71,12 @@ class `7-SourcesActivityTest` : WithANRException() {
|
|||||||
fun deleteTheCreatedSource() {
|
fun deleteTheCreatedSource() {
|
||||||
onView(withText(sourceName)).check(matches(isDisplayed()))
|
onView(withText(sourceName)).check(matches(isDisplayed()))
|
||||||
onView(withId(R.id.deleteBtn)).perform(click())
|
onView(withId(R.id.deleteBtn)).perform(click())
|
||||||
onView(withText(R.string.confirm_delete_title)).check(matches(isDisplayed()))
|
|
||||||
onView(withId(android.R.id.button1)).perform(click())
|
|
||||||
onView(withText(sourceName)).check(doesNotExist())
|
onView(withText(sourceName)).check(doesNotExist())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun goToSources() {
|
||||||
|
openMenu()
|
||||||
|
onView(withText(R.string.menu_home_sources))
|
||||||
|
.perform(click())
|
||||||
|
}
|
||||||
}
|
}
|
@ -37,6 +37,22 @@ class ReaderActivity :
|
|||||||
private val repository: Repository by instance()
|
private val repository: Repository by instance()
|
||||||
private val appSettingsService: AppSettingsService by instance()
|
private val appSettingsService: AppSettingsService by instance()
|
||||||
|
|
||||||
|
private fun showMenuItem(willAddToFavorite: Boolean) {
|
||||||
|
if (willAddToFavorite) {
|
||||||
|
toolbarMenu.findItem(R.id.star).icon?.setTint(Color.WHITE)
|
||||||
|
} else {
|
||||||
|
toolbarMenu.findItem(R.id.star).icon?.setTint(Color.RED)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun canFavorite() {
|
||||||
|
showMenuItem(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun canRemoveFromFavorite() {
|
||||||
|
showMenuItem(false)
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("detekt:SwallowedException")
|
@Suppress("detekt:SwallowedException")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -57,21 +73,14 @@ class ReaderActivity :
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
readItem()
|
try {
|
||||||
|
readItem(allItems[currentItem])
|
||||||
|
} catch (e: IndexOutOfBoundsException) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
binding.pager.adapter = ScreenSlidePagerAdapter(this)
|
binding.pager.adapter = ScreenSlidePagerAdapter(this)
|
||||||
binding.pager.setCurrentItem(currentItem, false)
|
binding.pager.setCurrentItem(currentItem, false)
|
||||||
|
|
||||||
binding.pager.registerOnPageChangeCallback(
|
|
||||||
object : ViewPager2.OnPageChangeCallback() {
|
|
||||||
override fun onPageSelected(position: Int) {
|
|
||||||
super.onPageSelected(position)
|
|
||||||
currentItem = position
|
|
||||||
updateStarIcon()
|
|
||||||
readItem()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@ -80,20 +89,14 @@ class ReaderActivity :
|
|||||||
binding.indicator.setViewPager(binding.pager)
|
binding.indicator.setViewPager(binding.pager)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun readItem() {
|
private fun readItem(item: SelfossModel.Item) {
|
||||||
val item = allItems.getOrNull(currentItem)
|
if (appSettingsService.isMarkOnScrollEnabled() && !appSettingsService.getPublicAccess()) {
|
||||||
if (appSettingsService.isMarkOnScrollEnabled() && !appSettingsService.getPublicAccess() && item != null) {
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
repository.markAsRead(item)
|
repository.markAsRead(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateStarIcon() {
|
|
||||||
val isStarred = allItems.getOrNull(currentItem)?.starred ?: false
|
|
||||||
toolbarMenu.findItem(R.id.star)?.icon?.setTint(if (isStarred) Color.RED else Color.WHITE)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(oldInstanceState: Bundle) {
|
override fun onSaveInstanceState(oldInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(oldInstanceState)
|
super.onSaveInstanceState(oldInstanceState)
|
||||||
oldInstanceState.clear()
|
oldInstanceState.clear()
|
||||||
@ -138,7 +141,8 @@ class ReaderActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.reader_menu, menu)
|
val inflater = menuInflater
|
||||||
|
inflater.inflate(R.menu.reader_menu, menu)
|
||||||
toolbarMenu = menu
|
toolbarMenu = menu
|
||||||
|
|
||||||
alignmentMenu()
|
alignmentMenu()
|
||||||
@ -146,50 +150,87 @@ class ReaderActivity :
|
|||||||
if (appSettingsService.getPublicAccess()) {
|
if (appSettingsService.getPublicAccess()) {
|
||||||
menu.removeItem(R.id.star)
|
menu.removeItem(R.id.star)
|
||||||
} else {
|
} else {
|
||||||
updateStarIcon()
|
if (allItems.isNotEmpty() && allItems[currentItem].starred) {
|
||||||
|
canRemoveFromFavorite()
|
||||||
|
} else {
|
||||||
|
canFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.pager.registerOnPageChangeCallback(
|
||||||
|
object : ViewPager2.OnPageChangeCallback() {
|
||||||
|
override fun onPageSelected(position: Int) {
|
||||||
|
super.onPageSelected(position)
|
||||||
|
|
||||||
|
if (!allItems.isNullOrEmpty() && allItems.size >= position) {
|
||||||
|
if (allItems[position].starred) {
|
||||||
|
canRemoveFromFavorite()
|
||||||
|
} else {
|
||||||
|
canFavorite()
|
||||||
|
}
|
||||||
|
readItem(allItems[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
fun afterSave() {
|
||||||
|
allItems[binding.pager.currentItem] =
|
||||||
|
allItems[binding.pager.currentItem].toggleStar()
|
||||||
|
canRemoveFromFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun afterUnsave() {
|
||||||
|
allItems[binding.pager.currentItem] = allItems[binding.pager.currentItem].toggleStar()
|
||||||
|
canFavorite()
|
||||||
|
}
|
||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> onBackPressedDispatcher.onBackPressed()
|
android.R.id.home -> {
|
||||||
R.id.star -> toggleFavorite()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
R.id.align_left -> switchAlignmentSetting(AppSettingsService.ALIGN_LEFT)
|
return true
|
||||||
R.id.align_justify -> switchAlignmentSetting(AppSettingsService.JUSTIFY)
|
}
|
||||||
|
|
||||||
|
R.id.star -> {
|
||||||
|
if (allItems[binding.pager.currentItem].starred) {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
repository.unstarr(allItems[binding.pager.currentItem])
|
||||||
|
}
|
||||||
|
afterUnsave()
|
||||||
|
} else {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
repository.starr(allItems[binding.pager.currentItem])
|
||||||
|
}
|
||||||
|
afterSave()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.align_left -> {
|
||||||
|
switchAlignmentSetting(AppSettingsService.ALIGN_LEFT)
|
||||||
|
refreshFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.align_justify -> {
|
||||||
|
switchAlignmentSetting(AppSettingsService.JUSTIFY)
|
||||||
|
refreshFragment()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFavorite() {
|
private fun switchAlignmentSetting(allignment: Int) {
|
||||||
val item = allItems.getOrNull(currentItem) ?: return
|
appSettingsService.changeAllignment(allignment)
|
||||||
|
|
||||||
val starred = item.starred
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
if (starred) {
|
|
||||||
repository.unstarr(item)
|
|
||||||
} else {
|
|
||||||
repository.starr(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item.toggleStar()
|
|
||||||
updateStarIcon()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun switchAlignmentSetting(alignment: Int) {
|
|
||||||
appSettingsService.changeAllignment(alignment)
|
|
||||||
alignmentMenu()
|
alignmentMenu()
|
||||||
|
|
||||||
val fragmentManager = supportFragmentManager
|
|
||||||
val fragments = fragmentManager.fragments
|
|
||||||
|
|
||||||
for (fragment in fragments) {
|
|
||||||
if (fragment is ArticleFragment) {
|
|
||||||
fragment.refreshAlignment()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun refreshFragment() {
|
||||||
|
finish()
|
||||||
|
overridePendingTransition(0, 0)
|
||||||
|
startActivity(intent)
|
||||||
|
overridePendingTransition(0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,15 +263,13 @@ class ArticleFragment :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshAlignment() {
|
private fun refreshAlignment() {
|
||||||
textAlignment =
|
textAlignment =
|
||||||
when (appSettingsService.getActiveAllignment()) {
|
when (appSettingsService.getActiveAllignment()) {
|
||||||
1 -> "justify"
|
1 -> "justify"
|
||||||
2 -> "left"
|
2 -> "left"
|
||||||
else -> "justify"
|
else -> "justify"
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlToWebview()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("detekt:SwallowedException")
|
@Suppress("detekt:SwallowedException")
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
@file:Suppress("ktlint")
|
|
||||||
/*
|
|
||||||
package bou.amine.apps.readerforselfossv2.android.tests.robolectric
|
package bou.amine.apps.readerforselfossv2.android.tests.robolectric
|
||||||
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
@ -27,4 +25,3 @@ fun Menu.assertVisible(
|
|||||||
val item = this.findItem(id)
|
val item = this.findItem(id)
|
||||||
assertTrue(item.isVisible)
|
assertTrue(item.isVisible)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
@file:Suppress("ktlint")
|
|
||||||
/*
|
|
||||||
package bou.amine.apps.readerforselfossv2.android.tests.robolectric
|
package bou.amine.apps.readerforselfossv2.android.tests.robolectric
|
||||||
|
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
@ -59,8 +57,7 @@ class LoginActivityTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
/* @Test
|
||||||
/* @Test
|
|
||||||
fun connect() {
|
fun connect() {
|
||||||
Robolectric.buildActivity(LoginActivity::class.java).use { controller ->
|
Robolectric.buildActivity(LoginActivity::class.java).use { controller ->
|
||||||
controller.setup() // Moves the Activity to the RESUMED state
|
controller.setup() // Moves the Activity to the RESUMED state
|
||||||
@ -75,7 +72,4 @@ class LoginActivityTest {
|
|||||||
assertEquals(expectedIntent.component, actual.component)
|
assertEquals(expectedIntent.component, actual.component)
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
/*
|
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
@file:Suppress("ktlint")
|
|
||||||
/*
|
|
||||||
package bou.amine.apps.readerforselfossv2.android.tests.robolectric
|
package bou.amine.apps.readerforselfossv2.android.tests.robolectric
|
||||||
|
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
@ -10,4 +8,3 @@ class RobotElectriqueRunner(
|
|||||||
) : RobolectricTestRunner(testClass) {
|
) : RobolectricTestRunner(testClass) {
|
||||||
override fun buildGlobalConfig(): Config = Config.Builder().setSdk(25, 30, 33).build()
|
override fun buildGlobalConfig(): Config = Config.Builder().setSdk(25, 30, 33).build()
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -27,4 +27,3 @@ org.gradle.caching=true
|
|||||||
ignoreGitVersion=false
|
ignoreGitVersion=false
|
||||||
kotlin.native.cacheKind.iosX64=none
|
kotlin.native.cacheKind.iosX64=none
|
||||||
org.gradle.configureondemand=true
|
org.gradle.configureondemand=true
|
||||||
kotlin.jvm.target.validation.mode=IGNORE
|
|
||||||
|
@ -224,18 +224,6 @@ class Repository(
|
|||||||
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
||||||
val shouldFetch = if (!appSettingsService.isUpdateSourcesEnabled()) !fetchedSources else true
|
val shouldFetch = if (!appSettingsService.isUpdateSourcesEnabled()) !fetchedSources else true
|
||||||
if (shouldFetch && connectivityService.isNetworkAvailable()) {
|
if (shouldFetch && connectivityService.isNetworkAvailable()) {
|
||||||
sources = sourceDetails(isDatabaseEnabled)
|
|
||||||
} else if (isDatabaseEnabled) {
|
|
||||||
sources = getDBSources().map { it.toView() } as ArrayList<SelfossModel.SourceDetail>
|
|
||||||
if (sources.isEmpty() && !connectivityService.isNetworkAvailable() && !fetchedSources) {
|
|
||||||
sources = sourceDetails(isDatabaseEnabled)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sources
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun sourceDetails(isDatabaseEnabled: Boolean): ArrayList<SelfossModel.SourceDetail> {
|
|
||||||
var sources = ArrayList<SelfossModel.SourceDetail>()
|
|
||||||
val apiSources = api.sourcesDetailed()
|
val apiSources = api.sourcesDetailed()
|
||||||
if (apiSources.success && apiSources.data != null) {
|
if (apiSources.success && apiSources.data != null) {
|
||||||
fetchedSources = true
|
fetchedSources = true
|
||||||
@ -244,6 +232,9 @@ class Repository(
|
|||||||
resetDBSourcesWithData(sources)
|
resetDBSourcesWithData(sources)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (isDatabaseEnabled) {
|
||||||
|
sources = getDBSources().map { it.toView() } as ArrayList<SelfossModel.SourceDetail>
|
||||||
|
}
|
||||||
return sources
|
return sources
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +371,6 @@ class Repository(
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
var response = false
|
var response = false
|
||||||
if (connectivityService.isNetworkAvailable()) {
|
if (connectivityService.isNetworkAvailable()) {
|
||||||
fetchedSources = false
|
|
||||||
response = api
|
response = api
|
||||||
.createSourceForVersion(
|
.createSourceForVersion(
|
||||||
title,
|
title,
|
||||||
@ -402,7 +392,6 @@ class Repository(
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
var response = false
|
var response = false
|
||||||
if (connectivityService.isNetworkAvailable()) {
|
if (connectivityService.isNetworkAvailable()) {
|
||||||
fetchedSources = false
|
|
||||||
response = api.updateSourceForVersion(id, title, url, spout, tags).isSuccess == true
|
response = api.updateSourceForVersion(id, title, url, spout, tags).isSuccess == true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +406,6 @@ class Repository(
|
|||||||
if (connectivityService.isNetworkAvailable()) {
|
if (connectivityService.isNetworkAvailable()) {
|
||||||
val response = api.deleteSource(id)
|
val response = api.deleteSource(id)
|
||||||
success = response.isSuccess
|
success = response.isSuccess
|
||||||
fetchedSources = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We filter on success or if the network isn't available
|
// We filter on success or if the network isn't available
|
||||||
|
Loading…
x
Reference in New Issue
Block a user