Merge pull request 'chore/mock-multiplatform' (#86) from chore/mock-multiplatform into master
Reviewed-on: https://gitea.amine-louveau.fr/Louvorg/ReaderForSelfoss-multiplatform/pulls/86
This commit is contained in:
commit
6076eb1cee
@ -11,7 +11,7 @@ steps:
|
||||
- ./gradlew sonarqube -Dsonar.projectKey=RFS2 -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN -PignoreGitVersion=true -P appLoginUrl="\"URL\"" -P appLoginUsername="\"LOGIN\"" -P appLoginPassword="\"PASS\""
|
||||
- echo "---------------------------------------------------------"
|
||||
- echo "Building..."
|
||||
- ./gradlew :androidApp:build -PignoreGitVersion=true -P appLoginUrl="\"URL\"" -P appLoginUsername="\"LOGIN\"" -P appLoginPassword="\"PASS\"" -P pushCache=false
|
||||
- ./gradlew build -PignoreGitVersion=true -P appLoginUrl="\"URL\"" -P appLoginUsername="\"LOGIN\"" -P appLoginPassword="\"PASS\"" -P pushCache=false
|
||||
- echo "---------------------------------------------------------"
|
||||
- echo "Testing..."
|
||||
- echo "---------------------------------------------------------"
|
||||
|
@ -116,13 +116,6 @@ dependencies {
|
||||
|
||||
implementation("androidx.preference:preference-ktx:1.1.1")
|
||||
|
||||
// Testing
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0-alpha02")
|
||||
androidTestImplementation("androidx.test:runner:1.3.1-alpha02")
|
||||
// Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
|
||||
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.4.0-alpha02")
|
||||
// Espresso-intents for validation and stubbing of Intents
|
||||
androidTestImplementation("androidx.test.espresso:espresso-intents:3.4.0-alpha02")
|
||||
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
|
||||
|
||||
// Android Support
|
||||
@ -190,9 +183,6 @@ dependencies {
|
||||
|
||||
implementation("androidx.core:core-ktx:1.8.0")
|
||||
|
||||
// implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.5.1")
|
||||
// implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1")
|
||||
// implementation("androidx.lifecycle:lifecycle-runtime:2.5.1")
|
||||
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
|
||||
|
||||
// Network information
|
||||
@ -200,4 +190,23 @@ dependencies {
|
||||
|
||||
// SQLDELIGHT
|
||||
implementation("com.squareup.sqldelight:android-driver:1.5.3")
|
||||
|
||||
//test
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("io.mockk:mockk:1.12.0")
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
outputs.upToDateWhen { false }
|
||||
useJUnit()
|
||||
testLogging {
|
||||
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
|
||||
events = setOf(
|
||||
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
|
||||
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
|
||||
org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_ERROR
|
||||
)
|
||||
showStandardStreams = true
|
||||
}
|
||||
}
|
2
androidApp/proguard-rules.pro
vendored
2
androidApp/proguard-rules.pro
vendored
@ -90,3 +90,5 @@
|
||||
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
|
||||
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
|
||||
|
||||
-dontwarn io.mockk.**
|
||||
-keep class io.mockk.** { *; }
|
||||
|
1421
androidApp/src/test/kotlin/RepositoryTest.kt
Normal file
1421
androidApp/src/test/kotlin/RepositoryTest.kt
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,8 +9,8 @@ plugins {
|
||||
//trick: for the same plugin versions in all sub-modules
|
||||
id("com.android.application").version("7.3.1").apply(false)
|
||||
id("com.android.library").version("7.3.1").apply(false)
|
||||
kotlin("android").version("1.7.10").apply(false)
|
||||
kotlin("multiplatform").version("1.7.10").apply(false)
|
||||
kotlin("android").version("1.7.20").apply(false)
|
||||
kotlin("multiplatform").version("1.7.20").apply(false)
|
||||
id("org.sonarqube").version("3.4.0.2513").apply(false)
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ kotlin {
|
||||
listOf(
|
||||
iosX64(),
|
||||
iosArm64(),
|
||||
iosSimulatorArm64()
|
||||
// iosSimulatorArm64()
|
||||
).forEach {
|
||||
it.binaries.framework {
|
||||
baseName = "shared"
|
||||
@ -40,7 +40,7 @@ kotlin {
|
||||
implementation("org.kodein.di:kodein-di:7.12.0")
|
||||
|
||||
//Settings
|
||||
implementation("com.russhwolf:multiplatform-settings-no-arg:0.9")
|
||||
implementation("com.russhwolf:multiplatform-settings-no-arg:1.0.0-RC")
|
||||
|
||||
//Logging
|
||||
implementation("io.github.aakira:napier:2.6.1")
|
||||
@ -53,9 +53,6 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
// implementation("io.mockk:mockk:1.12.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
|
||||
|
||||
}
|
||||
}
|
||||
val androidMain by getting {
|
||||
@ -74,12 +71,12 @@ kotlin {
|
||||
}
|
||||
val iosX64Main by getting
|
||||
val iosArm64Main by getting
|
||||
val iosSimulatorArm64Main by getting
|
||||
// val iosSimulatorArm64Main by getting
|
||||
val iosMain by creating {
|
||||
dependsOn(commonMain)
|
||||
iosX64Main.dependsOn(this)
|
||||
iosArm64Main.dependsOn(this)
|
||||
iosSimulatorArm64Main.dependsOn(this)
|
||||
// iosSimulatorArm64Main.dependsOn(this)
|
||||
|
||||
dependencies {
|
||||
implementation(SqlDelight.native)
|
||||
@ -88,12 +85,12 @@ kotlin {
|
||||
}
|
||||
val iosX64Test by getting
|
||||
val iosArm64Test by getting
|
||||
val iosSimulatorArm64Test by getting
|
||||
// val iosSimulatorArm64Test by getting
|
||||
val iosTest by creating {
|
||||
dependsOn(commonTest)
|
||||
iosX64Test.dependsOn(this)
|
||||
iosArm64Test.dependsOn(this)
|
||||
iosSimulatorArm64Test.dependsOn(this)
|
||||
// iosSimulatorArm64Test.dependsOn(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package bou.amine.apps.readerforselfossv2.utils
|
||||
|
||||
import android.os.Build
|
||||
import android.text.format.DateUtils
|
||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||
import java.time.Instant
|
||||
@ -15,10 +16,18 @@ actual class DateUtils actual constructor(actual val appSettingsService: AppSett
|
||||
val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
return if (appSettingsService.getApiVersion() >= 4) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
OffsetDateTime.parse(dateString).toInstant().toEpochMilli()
|
||||
} else {
|
||||
TODO("VERSION.SDK_INT < O")
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant(
|
||||
ZoneOffset.UTC).toEpochMilli()
|
||||
} else {
|
||||
TODO("VERSION.SDK_INT < O")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,11 +35,15 @@ actual class DateUtils actual constructor(actual val appSettingsService: AppSett
|
||||
|
||||
val date = parseDate(dateString)
|
||||
|
||||
return " " + DateUtils.getRelativeTimeSpanString(
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
" " + DateUtils.getRelativeTimeSpanString(
|
||||
date,
|
||||
Instant.now().toEpochMilli(),
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE
|
||||
)
|
||||
} else {
|
||||
TODO("VERSION.SDK_INT < O")
|
||||
}
|
||||
}
|
||||
}
|
@ -54,8 +54,8 @@ class AppSettingsService {
|
||||
return _apiVersion
|
||||
}
|
||||
|
||||
fun refreshApiVersion() {
|
||||
_apiVersion = settings.getInt("apiVersionMajor", -1)
|
||||
private fun refreshApiVersion() {
|
||||
_apiVersion = settings.getInt(API_VERSION_MAJOR, -1)
|
||||
}
|
||||
|
||||
fun getBaseUrl(): String {
|
||||
@ -86,8 +86,8 @@ class AppSettingsService {
|
||||
return _itemsNumber!!
|
||||
}
|
||||
|
||||
fun refreshItemsNumber() {
|
||||
_itemsNumber = settings.getString("prefer_api_items_number", "20").toInt()
|
||||
private fun refreshItemsNumber() {
|
||||
_itemsNumber = settings.getString(API_ITEMS_NUMBER, "20").toInt()
|
||||
}
|
||||
|
||||
fun getApiTimeout(): Long {
|
||||
@ -98,24 +98,24 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshApiTimeout() {
|
||||
val settingsTimeout = settings.getLong("api_timeout", HttpTimeout.INFINITE_TIMEOUT_MS)
|
||||
val settingsTimeout = settings.getLong(API_TIMEOUT, HttpTimeout.INFINITE_TIMEOUT_MS)
|
||||
_apiTimeout = if (settingsTimeout > 0) settingsTimeout else HttpTimeout.INFINITE_TIMEOUT_MS
|
||||
}
|
||||
|
||||
private fun refreshBaseUrl() {
|
||||
_baseUrl = settings.getString("url", "")
|
||||
_baseUrl = settings.getString(BASE_URL, "")
|
||||
}
|
||||
|
||||
private fun refreshUsername() {
|
||||
_userName = settings.getString("login", "")
|
||||
_userName = settings.getString(LOGIN, "")
|
||||
}
|
||||
|
||||
private fun refreshPassword() {
|
||||
_password = settings.getString("password", "")
|
||||
_password = settings.getString(PASSWORD, "")
|
||||
}
|
||||
|
||||
private fun refreshArticleViewerEnabled() {
|
||||
_articleViewer = settings.getBoolean("prefer_article_viewer", true)
|
||||
_articleViewer = settings.getBoolean(PREFER_ARTICLE_VIEWER, true)
|
||||
}
|
||||
|
||||
fun isArticleViewerEnabled(): Boolean {
|
||||
@ -125,7 +125,7 @@ class AppSettingsService {
|
||||
return _articleViewer == true
|
||||
}
|
||||
private fun refreshShouldBeCardViewEnabled() {
|
||||
_shouldBeCardView = settings.getBoolean("card_view_active", false)
|
||||
_shouldBeCardView = settings.getBoolean(CARD_VIEW_ACTIVE, false)
|
||||
}
|
||||
|
||||
fun isCardViewEnabled(): Boolean {
|
||||
@ -135,7 +135,7 @@ class AppSettingsService {
|
||||
return _shouldBeCardView == true
|
||||
}
|
||||
private fun refreshDisplayUnreadCountEnabled() {
|
||||
_displayUnreadCount = settings.getBoolean("display_unread_count", true)
|
||||
_displayUnreadCount = settings.getBoolean(DISPLAY_UNREAD_COUNT, true)
|
||||
}
|
||||
|
||||
fun isDisplayUnreadCountEnabled(): Boolean {
|
||||
@ -145,7 +145,7 @@ class AppSettingsService {
|
||||
return _displayUnreadCount == true
|
||||
}
|
||||
private fun refreshDisplayAllCountEnabled() {
|
||||
_displayAllCount = settings.getBoolean("display_other_count", false)
|
||||
_displayAllCount = settings.getBoolean(DISPLAY_OTHER_COUNT, false)
|
||||
}
|
||||
|
||||
fun isDisplayAllCountEnabled(): Boolean {
|
||||
@ -155,7 +155,7 @@ class AppSettingsService {
|
||||
return _displayAllCount == true
|
||||
}
|
||||
private fun refreshFullHeightCardsEnabled() {
|
||||
_fullHeightCards = settings.getBoolean("full_height_cards", false)
|
||||
_fullHeightCards = settings.getBoolean(FULL_HEIGHT_CARDS, false)
|
||||
}
|
||||
|
||||
fun isFullHeightCardsEnabled(): Boolean {
|
||||
@ -165,7 +165,7 @@ class AppSettingsService {
|
||||
return _fullHeightCards == true
|
||||
}
|
||||
private fun refreshUpdateSourcesEnabled() {
|
||||
_updateSources = settings.getBoolean("update_sources", true)
|
||||
_updateSources = settings.getBoolean(UPDATE_SOURCES, true)
|
||||
}
|
||||
|
||||
fun isUpdateSourcesEnabled(): Boolean {
|
||||
@ -175,7 +175,7 @@ class AppSettingsService {
|
||||
return _updateSources == true
|
||||
}
|
||||
private fun refreshPeriodicRefreshEnabled() {
|
||||
_periodicRefresh = settings.getBoolean("periodic_refresh", false)
|
||||
_periodicRefresh = settings.getBoolean(PERIODIC_REFRESH, false)
|
||||
}
|
||||
|
||||
fun isPeriodicRefreshEnabled(): Boolean {
|
||||
@ -186,7 +186,7 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshRefreshWhenChargingOnlyEnabled() {
|
||||
_refreshWhenChargingOnly = settings.getBoolean("refresh_when_charging", false)
|
||||
_refreshWhenChargingOnly = settings.getBoolean(REFRESH_WHEN_CHARGING, false)
|
||||
}
|
||||
|
||||
fun isRefreshWhenChargingOnlyEnabled(): Boolean {
|
||||
@ -197,22 +197,22 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshRefreshMinutes() {
|
||||
_refreshMinutes = settings.getString("periodic_refresh_minutes", "360").toLong()
|
||||
_refreshMinutes = settings.getString(PERIODIC_REFRESH_MINUTES, "360").toLong()
|
||||
if (_refreshMinutes <= 15) {
|
||||
_refreshMinutes = 15
|
||||
}
|
||||
}
|
||||
|
||||
fun getRefreshMinutes(): Long {
|
||||
if (_refreshMinutes != null) {
|
||||
if (_refreshMinutes != 360L) {
|
||||
refreshRefreshMinutes()
|
||||
}
|
||||
return _refreshMinutes
|
||||
}
|
||||
|
||||
private fun refreshHiddenTags() {
|
||||
if (settings.getString("hidden_tags", "").isNotEmpty()) {
|
||||
_hiddenTags = settings.getString("hidden_tags", "").replace("\\s".toRegex(), "").split(",")
|
||||
if (settings.getString(HIDDEN_TAGS, "").isNotEmpty()) {
|
||||
_hiddenTags = settings.getString(HIDDEN_TAGS, "").replace("\\s".toRegex(), "").split(",")
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshInfiniteLoadingEnabled() {
|
||||
_infiniteLoading = settings.getBoolean("infinite_loading", false)
|
||||
_infiniteLoading = settings.getBoolean(INFINITE_LOADING, false)
|
||||
}
|
||||
|
||||
fun isInfiniteLoadingEnabled(): Boolean {
|
||||
@ -235,7 +235,7 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshItemCachingEnabled() {
|
||||
_itemsCaching = settings.getBoolean("items_caching", false)
|
||||
_itemsCaching = settings.getBoolean(ITEMS_CACHING, false)
|
||||
}
|
||||
|
||||
fun isItemCachingEnabled(): Boolean {
|
||||
@ -246,7 +246,7 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshNotifyNewItemsEnabled() {
|
||||
_notifyNewItems = settings.getBoolean("notify_new_items", false)
|
||||
_notifyNewItems = settings.getBoolean(NOTIFY_NEW_ITEMS, false)
|
||||
}
|
||||
|
||||
fun isNotifyNewItemsEnabled(): Boolean {
|
||||
@ -258,7 +258,7 @@ class AppSettingsService {
|
||||
|
||||
|
||||
private fun refreshMarkOnScrollEnabled() {
|
||||
_markOnScroll = settings.getBoolean("mark_on_scroll", false)
|
||||
_markOnScroll = settings.getBoolean(MARK_ON_SCROLL, false)
|
||||
}
|
||||
|
||||
fun isMarkOnScrollEnabled(): Boolean {
|
||||
@ -270,7 +270,7 @@ class AppSettingsService {
|
||||
|
||||
|
||||
private fun refreshActiveAllignment() {
|
||||
_activeAlignment = settings.getInt("text_align", JUSTIFY)
|
||||
_activeAlignment = settings.getInt(TEXT_ALIGN, JUSTIFY)
|
||||
}
|
||||
|
||||
fun getActiveAllignment(): Int {
|
||||
@ -281,12 +281,12 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
fun changeAllignment(allignment: Int) {
|
||||
settings.putInt("text_align", allignment)
|
||||
settings.putInt(TEXT_ALIGN, allignment)
|
||||
_activeAlignment = allignment
|
||||
}
|
||||
|
||||
private fun refreshFontSize() {
|
||||
_fontSize = settings.getString("reader_font_size", "16").toInt()
|
||||
_fontSize = settings.getString(READER_FONT_SIZE, "16").toInt()
|
||||
}
|
||||
|
||||
fun getFontSize(): Int {
|
||||
@ -297,7 +297,7 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshStaticBarEnabled() {
|
||||
_staticBar = settings.getBoolean("reader_static_bar", false)
|
||||
_staticBar = settings.getBoolean(READER_STATIC_BAR, false)
|
||||
}
|
||||
|
||||
fun isStaticBarEnabled(): Boolean {
|
||||
@ -308,11 +308,11 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
private fun refreshFont() {
|
||||
_font = settings.getString("reader_font", "")
|
||||
_font = settings.getString(READER_FONT, "")
|
||||
}
|
||||
|
||||
fun getFont(): String {
|
||||
if (_font != null) {
|
||||
if (_font.isEmpty()) {
|
||||
refreshFont()
|
||||
}
|
||||
return _font
|
||||
@ -353,21 +353,21 @@ class AppSettingsService {
|
||||
login: String,
|
||||
password: String
|
||||
) {
|
||||
settings.putString("url", url)
|
||||
settings.putString("login", login)
|
||||
settings.putString("password", password)
|
||||
settings.putString(BASE_URL, url)
|
||||
settings.putString(LOGIN, login)
|
||||
settings.putString(PASSWORD, password)
|
||||
refreshApiSettings()
|
||||
}
|
||||
|
||||
fun resetLoginInformation() {
|
||||
settings.remove("url")
|
||||
settings.remove("login")
|
||||
settings.remove("password")
|
||||
settings.remove(BASE_URL)
|
||||
settings.remove(LOGIN)
|
||||
settings.remove(PASSWORD)
|
||||
refreshApiSettings()
|
||||
}
|
||||
|
||||
fun updateApiVersion(apiMajorVersion: Int) {
|
||||
settings.putInt("apiVersionMajor", apiMajorVersion)
|
||||
settings.putInt(API_VERSION_MAJOR, apiMajorVersion)
|
||||
refreshApiVersion()
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ class AppSettingsService {
|
||||
}
|
||||
|
||||
fun disableArticleViewer() {
|
||||
settings.putBoolean("prefer_article_viewer", false)
|
||||
settings.putBoolean(PREFER_ARTICLE_VIEWER, false)
|
||||
refreshArticleViewerEnabled()
|
||||
}
|
||||
|
||||
@ -396,5 +396,53 @@ class AppSettingsService {
|
||||
const val JUSTIFY = 1
|
||||
|
||||
const val ALIGN_LEFT = 2
|
||||
|
||||
const val API_VERSION_MAJOR = "apiVersionMajor"
|
||||
|
||||
const val API_ITEMS_NUMBER = "prefer_api_items_number"
|
||||
|
||||
const val API_TIMEOUT = "api_timeout"
|
||||
|
||||
const val BASE_URL = "url"
|
||||
|
||||
const val LOGIN = "login"
|
||||
|
||||
const val PASSWORD = "password"
|
||||
|
||||
const val PREFER_ARTICLE_VIEWER = "prefer_article_viewer"
|
||||
|
||||
const val CARD_VIEW_ACTIVE = "card_view_active"
|
||||
|
||||
const val DISPLAY_UNREAD_COUNT = "display_unread_count"
|
||||
|
||||
const val DISPLAY_OTHER_COUNT = "display_other_count"
|
||||
|
||||
const val FULL_HEIGHT_CARDS = "full_height_cards"
|
||||
|
||||
const val UPDATE_SOURCES = "update_sources"
|
||||
|
||||
const val PERIODIC_REFRESH = "periodic_refresh"
|
||||
|
||||
const val REFRESH_WHEN_CHARGING = "refresh_when_charging"
|
||||
|
||||
const val READER_FONT = "reader_font"
|
||||
|
||||
const val READER_STATIC_BAR = "reader_static_bar"
|
||||
|
||||
const val READER_FONT_SIZE = "reader_font_size"
|
||||
|
||||
const val TEXT_ALIGN = "text_align"
|
||||
|
||||
const val MARK_ON_SCROLL = "mark_on_scroll"
|
||||
|
||||
const val NOTIFY_NEW_ITEMS = "notify_new_items"
|
||||
|
||||
const val PERIODIC_REFRESH_MINUTES = "periodic_refresh_minutes"
|
||||
|
||||
const val HIDDEN_TAGS = "hidden_tags"
|
||||
|
||||
const val INFINITE_LOADING = "infinite_loading"
|
||||
|
||||
const val ITEMS_CACHING = "items_caching"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
package bou.amine.apps.readerforselfossv2
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class IosGreetingTest {
|
||||
|
||||
@Test
|
||||
fun testExample() {
|
||||
assertTrue(Greeting().greeting().contains("iOS"), "Check iOS is mentioned")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user