Compare commits
1 Commits
798c400dd2
...
9797468e31
Author | SHA1 | Date | |
---|---|---|---|
9797468e31 |
@ -46,7 +46,7 @@ jobs:
|
||||
./gradlew androidApp:connectedAndroidTest || true
|
||||
./gradlew androidApp:fetchScreenshots
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
if: always()
|
||||
with:
|
||||
name: failure-espresso
|
||||
path: build/reports/androidTests/connected/screenshots
|
||||
|
@ -95,7 +95,6 @@ android {
|
||||
|
||||
// tests
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunnerArguments["clearPackageData"] = "true"
|
||||
testInstrumentationRunnerArguments["useTestStorageService"] = "true"
|
||||
}
|
||||
packaging {
|
||||
@ -127,7 +126,6 @@ android {
|
||||
namespace = "bou.amine.apps.readerforselfossv2.android"
|
||||
testOptions {
|
||||
animationsDisabled = true
|
||||
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
||||
unitTests {
|
||||
isIncludeAndroidResources = true
|
||||
}
|
||||
@ -208,7 +206,6 @@ dependencies {
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
||||
implementation("androidx.test.espresso:espresso-idling-resource:3.6.1")
|
||||
androidTestImplementation("androidx.test.ext:junit-ktx:1.2.1")
|
||||
androidTestUtil("androidx.test:orchestrator:1.6.0-alpha02")
|
||||
androidTestUtil("androidx.test.services:test-services:1.6.0-alpha02")
|
||||
testImplementation("org.robolectric:robolectric:4.14.1")
|
||||
testImplementation("androidx.test:core-ktx:1.7.0-alpha01")
|
||||
|
@ -15,14 +15,18 @@ import androidx.test.filters.LargeTest
|
||||
import bou.amine.apps.readerforselfossv2.android.testing.CountingIdlingResourceSingleton
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@LargeTest
|
||||
class LoginActivityTest : WithANRException() {
|
||||
class `1-LoginActivityTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
|
||||
@ -48,7 +52,7 @@ class LoginActivityTest : WithANRException() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun viewIsInitialized() {
|
||||
fun `1-viewIsInitialized`() {
|
||||
onView(withId(R.id.urlView)).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.selfSigned))
|
||||
.check(matches(isDisplayed()))
|
||||
@ -65,28 +69,28 @@ class LoginActivityTest : WithANRException() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun urlError() {
|
||||
fun `2-urlError`() {
|
||||
performLogin("10.0.2.2:8888")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun connectError() {
|
||||
performLogin("http://10.0.2.2:8889")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun urlSlashError() {
|
||||
fun `3-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() {
|
||||
fun `4-connectError`() {
|
||||
performLogin("http://10.0.2.2:8889")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `5-multiError`() {
|
||||
onView(withId(R.id.signInButton)).perform(click())
|
||||
onView(withId(R.id.signInButton)).perform(click())
|
||||
onView(withId(R.id.signInButton)).perform(click())
|
||||
@ -94,8 +98,9 @@ class LoginActivityTest : WithANRException() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun connect() {
|
||||
fun `6-connect`() {
|
||||
performLogin()
|
||||
onView(withText(R.string.gdpr_dialog_title)).check(matches(isDisplayed()))
|
||||
onView(withText("OK")).perform(click())
|
||||
}
|
||||
}
|
@ -15,17 +15,20 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.junit.Before
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@LargeTest
|
||||
class HomeActivityTest : WithANRException() {
|
||||
class `2-HomeActivityTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
@ -34,11 +37,6 @@ class HomeActivityTest : WithANRException() {
|
||||
.outerRule(activityRule)
|
||||
.around(ScreenshotTakingRule())
|
||||
|
||||
@Before
|
||||
fun init() {
|
||||
loginAndInitHome()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMenu() {
|
||||
onView(withId(R.id.action_search)).check(matches(isDisplayed())).check(
|
@ -20,9 +20,10 @@ import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class SettingsActivityTest : WithANRException() {
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
class `3-SettingsActivityTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
@ -38,7 +39,6 @@ class SettingsActivityTest : WithANRException() {
|
||||
activityRule.scenario.onActivity { activity ->
|
||||
context = activity.window.context
|
||||
}
|
||||
loginAndInitHome()
|
||||
openMenu()
|
||||
onView(withText(R.string.title_activity_settings)).perform(click())
|
||||
}
|
||||
@ -77,6 +77,9 @@ class SettingsActivityTest : WithANRException() {
|
||||
changeAndSaveSetting("", "10") {
|
||||
onView(withText(R.string.pref_api_timeout)).perform(click())
|
||||
}
|
||||
changeAndSaveSetting("", "60") {
|
||||
onView(withText(R.string.pref_api_timeout)).perform(click())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
@ -22,16 +22,20 @@ import androidx.test.filters.LargeTest
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.junit.Before
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@LargeTest
|
||||
class SettingsActivityGeneralTest : WithANRException() {
|
||||
class `4-SettingsActivityGeneralTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
@ -42,7 +46,6 @@ class SettingsActivityGeneralTest : WithANRException() {
|
||||
|
||||
@Before
|
||||
fun init() {
|
||||
loginAndInitHome()
|
||||
openActionBarOverflowOrOptionsMenu(
|
||||
ApplicationProvider.getApplicationContext(),
|
||||
)
|
@ -1,30 +1,33 @@
|
||||
package bou.amine.apps.readerforselfossv2.android
|
||||
|
||||
import android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class SettingsActivityReaderTest : WithANRException() {
|
||||
class `5-SettingsActivityReaderTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
val activityRule = ActivityScenarioRule(SettingsActivity::class.java)
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
@ -40,14 +43,14 @@ class SettingsActivityReaderTest : WithANRException() {
|
||||
activityRule.scenario.onActivity { activity ->
|
||||
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())
|
||||
}
|
||||
|
||||
@After
|
||||
fun back() {
|
||||
onView(isRoot()).perform(ViewActions.pressBack())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReader() {
|
||||
onView(withSettingsCheckboxFrame(R.string.pref_switch_actions_pager_scroll)).check(
|
@ -1,32 +1,35 @@
|
||||
package bou.amine.apps.readerforselfossv2.android
|
||||
|
||||
import android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isNotEnabled
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class SettingsActivityOfflineTest : WithANRException() {
|
||||
class `6-SettingsActivityOfflineTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
val activityRule = ActivityScenarioRule(SettingsActivity::class.java)
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
@ -42,14 +45,14 @@ class SettingsActivityOfflineTest : WithANRException() {
|
||||
activityRule.scenario.onActivity { activity ->
|
||||
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())
|
||||
}
|
||||
|
||||
@After
|
||||
fun back() {
|
||||
onView(isRoot()).perform(ViewActions.pressBack())
|
||||
}
|
||||
|
||||
@Suppress("detekt:LongMethod")
|
||||
@Test
|
||||
fun testOffline() {
|
@ -22,11 +22,12 @@ import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.UUID
|
||||
|
||||
@Suppress("ktlint:standard:class-naming", "detekt:ClassNaming")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class SourcesActivityTest : WithANRException() {
|
||||
class `7-SourcesActivityTest` : WithANRException() {
|
||||
@get:Rule
|
||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||
val activityRule = ActivityScenarioRule(HomeActivity::class.java)
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
@ -41,7 +42,6 @@ class SourcesActivityTest : WithANRException() {
|
||||
fun init() {
|
||||
sourceName = UUID.randomUUID().toString().substring(0, 15)
|
||||
|
||||
loginAndInitHome()
|
||||
goToSources()
|
||||
}
|
||||
|
||||
@ -83,10 +83,4 @@ class SourcesActivityTest : WithANRException() {
|
||||
onView(withId(android.R.id.button1)).perform(click())
|
||||
onView(withText(sourceName)).check(doesNotExist())
|
||||
}
|
||||
|
||||
private fun goToSources() {
|
||||
openMenu()
|
||||
onView(withText(R.string.menu_home_sources))
|
||||
.perform(click())
|
||||
}
|
||||
}
|
@ -45,12 +45,6 @@ fun performLogin(someUrl: String? = null) {
|
||||
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(
|
||||
oldValue: String,
|
||||
newValue: String,
|
||||
@ -116,6 +110,12 @@ fun testPreferencesFromArray(
|
||||
}
|
||||
}
|
||||
|
||||
fun goToSources() {
|
||||
openMenu()
|
||||
onView(withText(R.string.menu_home_sources))
|
||||
.perform(click())
|
||||
}
|
||||
|
||||
fun testAddSourceWithUrl(
|
||||
url: String,
|
||||
sourceName: String,
|
||||
@ -139,6 +139,7 @@ fun testAddSourceWithUrl(
|
||||
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.
|
||||
|
@ -224,16 +224,25 @@ class Repository(
|
||||
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
||||
val shouldFetch = if (!appSettingsService.isUpdateSourcesEnabled()) !fetchedSources else true
|
||||
if (shouldFetch && connectivityService.isNetworkAvailable()) {
|
||||
val apiSources = api.sourcesDetailed()
|
||||
if (apiSources.success && apiSources.data != null) {
|
||||
fetchedSources = true
|
||||
sources = apiSources.data
|
||||
if (isDatabaseEnabled) {
|
||||
resetDBSourcesWithData(sources)
|
||||
}
|
||||
}
|
||||
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()
|
||||
if (apiSources.success && apiSources.data != null) {
|
||||
fetchedSources = true
|
||||
sources = apiSources.data
|
||||
if (isDatabaseEnabled) {
|
||||
resetDBSourcesWithData(sources)
|
||||
}
|
||||
}
|
||||
return sources
|
||||
}
|
||||
@ -371,6 +380,7 @@ class Repository(
|
||||
): Boolean {
|
||||
var response = false
|
||||
if (connectivityService.isNetworkAvailable()) {
|
||||
fetchedSources = false
|
||||
response = api
|
||||
.createSourceForVersion(
|
||||
title,
|
||||
@ -392,6 +402,7 @@ class Repository(
|
||||
): Boolean {
|
||||
var response = false
|
||||
if (connectivityService.isNetworkAvailable()) {
|
||||
fetchedSources = false
|
||||
response = api.updateSourceForVersion(id, title, url, spout, tags).isSuccess == true
|
||||
}
|
||||
|
||||
@ -406,6 +417,7 @@ class Repository(
|
||||
if (connectivityService.isNetworkAvailable()) {
|
||||
val response = api.deleteSource(id)
|
||||
success = response.isSuccess
|
||||
fetchedSources = false
|
||||
}
|
||||
|
||||
// We filter on success or if the network isn't available
|
||||
|
Loading…
x
Reference in New Issue
Block a user