diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index e1eea1d..69e8615 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 6325944..fe412d7 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,8 @@
kotlin.code.style=official
android.useAndroidX=true
+
+kotlin.native.cacheKind=none
+
+org.jetbrains.compose.experimental.macos.enabled=true
+org.jetbrains.compose.experimental.uikit.enabled=true
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 74f76f3..ca6a429 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,15 +1,16 @@
[versions]
-compose = "1.2.1"
-kotlin = "1.7.20"
+compose = "1.4.0"
+kotlin = "1.8.20"
[libraries]
-android-gradle = { group = "com.android.tools.build", name = "gradle", version = "7.2.2" }
+android-gradle = { group = "com.android.tools.build", name = "gradle", version = "7.4.0" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
-kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.6.4" }
+kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.7.1" }
mockk = { group = "io.mockk", name = "mockk", version = "1.13.2" }
rxjava2-rxkotlin = { group = "io.reactivex.rxjava2", name = "rxkotlin", version = "2.4.0" }
rxjava3-rxkotlin = { group = "io.reactivex.rxjava3", name = "rxkotlin", version = "3.0.1" }
testng = { group = "org.testng", name = "testng", version = "7.6.1" }
+assertk = { group = "com.willowtreeapps.assertk", name = "assertk", version = "0.26.1" }
[plugins]
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 41d9927..c1962a7 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 8fad3f5..e8be595 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
+networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 1b6c787..aeb74cb 100755
--- a/gradlew
+++ b/gradlew
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,10 @@ do
esac
done
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
+# This is normally unused
+# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
@@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
diff --git a/gradlew.bat b/gradlew.bat
index 107acd3..93e3f59 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
-@if "%DEBUG%" == "" @echo off
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
+if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/remotedata-androidlayout/build.gradle.kts b/remotedata-androidlayout/build.gradle.kts
index 208c49d..979590a 100644
--- a/remotedata-androidlayout/build.gradle.kts
+++ b/remotedata-androidlayout/build.gradle.kts
@@ -6,31 +6,24 @@ plugins {
}
group = "com.carelesscoyotes.remotedata"
-version = "0.1"
+version = "0.2"
android {
- compileSdk = 32
+ compileSdk = 33
+
+ namespace = "remotedata.androidlayout"
defaultConfig {
- @Suppress("UnstableApiUsage")
minSdk = 21
- @Suppress("UnstableApiUsage")
- targetSdk = 32
- @Suppress("UnstableApiUsage")
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
+ @Suppress("UnstableApiUsage")
consumerProguardFiles("consumer-rules.pro")
}
compileOptions {
- @Suppress("UnstableApiUsage")
- sourceCompatibility = JavaVersion.VERSION_1_8
- @Suppress("UnstableApiUsage")
- targetCompatibility = JavaVersion.VERSION_1_8
- }
-
- kotlinOptions {
- jvmTarget = "1.8"
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
}
publishing {
@@ -40,6 +33,10 @@ android {
}
}
+kotlin {
+ jvmToolchain(11)
+}
+
repositories {
mavenCentral()
google()
diff --git a/remotedata-bom/build.gradle.kts b/remotedata-bom/build.gradle.kts
index bd1c36e..0e17cfa 100644
--- a/remotedata-bom/build.gradle.kts
+++ b/remotedata-bom/build.gradle.kts
@@ -5,7 +5,7 @@ plugins {
}
group = "com.carelesscoyotes.remotedata"
-version = "0.3"
+version = "0.4"
repositories {
mavenCentral()
diff --git a/remotedata-compose/build.gradle.kts b/remotedata-compose/build.gradle.kts
index 45b6864..28416b9 100644
--- a/remotedata-compose/build.gradle.kts
+++ b/remotedata-compose/build.gradle.kts
@@ -8,7 +8,7 @@ plugins {
}
group = "com.carelesscoyotes.remotedata"
-version = "0.1"
+version = "0.2"
repositories {
google()
@@ -17,20 +17,24 @@ repositories {
kotlin {
jvm()
+ macosX64()
+ macosArm64()
+ ios()
+ iosSimulatorArm64()
sourceSets {
- named("commonMain") {
+ commonMain {
dependencies {
implementation(kotlin("stdlib-common"))
implementation(compose.runtime)
+ implementation(compose.foundation)
api(project(":remotedata"))
}
}
- named("commonTest") {
+ commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
- implementation(libs.mockk)
}
}
@@ -42,6 +46,8 @@ kotlin {
}
}
}
+
+ jvmToolchain(11)
}
signing {
diff --git a/remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewDesktopTest.kt b/remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewDesktopTest.kt
index fa88bb5..04e9845 100644
--- a/remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewDesktopTest.kt
+++ b/remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewDesktopTest.kt
@@ -1,8 +1,10 @@
package remotedata.compose
import androidx.compose.runtime.Composable
+import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.compose.ui.test.onAllNodesWithTag
import org.junit.Rule
import org.junit.Test
@@ -11,6 +13,11 @@ internal fun ComposeContentTestRule.testContext() =
override fun setContent(composable: @Composable () -> Unit) {
this@testContext.setContent(composable = composable)
}
+
+ override fun assertExistsSingle(testTag: String) {
+ onAllNodesWithTag(testTag, useUnmergedTree = true)
+ .assertCountEquals(1)
+ }
}
class RemoteDataViewDesktopTest {
diff --git a/remotedata-compose/src/commonTest/kotlin/remotedata/compose/RemoteDataViewTest.kt b/remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewTest.kt
similarity index 66%
rename from remotedata-compose/src/commonTest/kotlin/remotedata/compose/RemoteDataViewTest.kt
rename to remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewTest.kt
index 0eec916..ad1487b 100644
--- a/remotedata-compose/src/commonTest/kotlin/remotedata/compose/RemoteDataViewTest.kt
+++ b/remotedata-compose/src/jvmTest/kotlin/remotedata/compose/RemoteDataViewTest.kt
@@ -1,8 +1,9 @@
package remotedata.compose
+import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
-import io.mockk.mockk
-import io.mockk.verify
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.testTag
import remotedata.RemoteData
import remotedata.RemoteData.Companion.failure
import remotedata.RemoteData.Companion.success
@@ -10,68 +11,63 @@ import kotlin.test.fail
interface ComposeTestContext {
fun setContent(composable: @Composable () -> Unit)
+ fun assertExistsSingle(testTag: String)
}
fun ComposeTestContext.testNotAsked() {
val rd = RemoteData.NotAsked
- val notAsked: () -> Unit = mockk(relaxed = true)
+ val tag = "not asked"
setContent {
RemoteDataView(
remoteData = rd,
- notAsked = { notAsked() },
+ notAsked = { Box(modifier = Modifier.testTag(tag)) },
loading = { fail() },
failure = { fail() },
success = { fail() },
)
}
- verify(exactly = 1) {
- notAsked()
- }
+ assertExistsSingle(testTag = tag)
}
fun ComposeTestContext.testLoading() {
val rd = RemoteData.Loading
- val loading: () -> Unit = mockk(relaxed = true)
+ val tag = "loading"
setContent {
RemoteDataView(
remoteData = rd,
notAsked = { fail() },
- loading = { loading() },
+ loading = { Box(modifier = Modifier.testTag(tag)) },
failure = { fail() },
success = { fail() },
)
}
- verify(exactly = 1) {
- loading()
- }
+ assertExistsSingle(testTag = tag)
}
fun ComposeTestContext.testFailure() {
val rd = "test error".failure()
- val failure: () -> Unit = mockk(relaxed = true)
+ val tag = "failure"
setContent {
RemoteDataView(
remoteData = rd,
notAsked = { fail() },
loading = { fail() },
- failure = { failure() },
+ failure = { Box(modifier = Modifier.testTag(tag = tag)) },
success = { fail() },
)
}
- verify(exactly = 1) {
- failure()
- }
+ assertExistsSingle(testTag = tag)
}
fun ComposeTestContext.testSuccess() {
val rd = "test data".success()
- val success: () -> Unit = mockk(relaxed = true)
+ val tag = "success"
setContent {
RemoteDataView(
@@ -79,11 +75,9 @@ fun ComposeTestContext.testSuccess() {
notAsked = { fail() },
loading = { fail() },
failure = { fail() },
- success = { success() },
+ success = { Box(modifier = Modifier.testTag(tag = tag)) },
)
}
- verify(exactly = 1) {
- success()
- }
+ assertExistsSingle(testTag = tag)
}
diff --git a/remotedata-flow/build.gradle.kts b/remotedata-flow/build.gradle.kts
index cd5208b..543cfda 100644
--- a/remotedata-flow/build.gradle.kts
+++ b/remotedata-flow/build.gradle.kts
@@ -1,38 +1,48 @@
plugins {
- kotlin("jvm")
+ kotlin("multiplatform")
`maven-publish`
signing
}
group = "com.carelesscoyotes.remotedata"
-version = "0.2"
+version = "0.3"
repositories {
mavenCentral()
}
-dependencies {
- implementation(kotlin("stdlib"))
- implementation(libs.kotlinx.coroutines.core)
- api(project(":remotedata"))
+kotlin {
+ jvm()
+ linuxX64()
+ linuxArm64()
+ macosX64()
+ macosArm64()
+ ios()
+ iosSimulatorArm64()
- testImplementation(libs.testng)
- testImplementation("com.google.truth:truth:1.1.3")
+ sourceSets {
+ commonMain {
+ dependencies {
+ implementation(kotlin("stdlib-common"))
+ implementation(libs.kotlinx.coroutines.core)
+ api(project(":remotedata"))
+ }
+ }
+ commonTest {
+ dependencies {
+ implementation(kotlin("test-testng"))
+ implementation(libs.assertk)
+ }
+ }
+ }
+
+ jvmToolchain(11)
}
tasks.withType {
useTestNG()
}
-publishing {
- publications {
- create("lib") {
- from(components["kotlin"])
- artifact(tasks.kotlinSourcesJar)
- }
- }
-}
-
signing {
useGpgCmd()
sign(publishing.publications)
diff --git a/remotedata-flow/src/main/kotlin/remotedata/flow/FlowExtension.kt b/remotedata-flow/src/commonMain/kotlin/remotedata/flow/FlowExtension.kt
similarity index 100%
rename from remotedata-flow/src/main/kotlin/remotedata/flow/FlowExtension.kt
rename to remotedata-flow/src/commonMain/kotlin/remotedata/flow/FlowExtension.kt
diff --git a/remotedata-flow/src/test/kotlin/remotedata/flow/FlowExtensionTest.kt b/remotedata-flow/src/commonTest/kotlin/remotedata/flow/FlowExtensionTest.kt
similarity index 91%
rename from remotedata-flow/src/test/kotlin/remotedata/flow/FlowExtensionTest.kt
rename to remotedata-flow/src/commonTest/kotlin/remotedata/flow/FlowExtensionTest.kt
index 35cdfa6..836504e 100644
--- a/remotedata-flow/src/test/kotlin/remotedata/flow/FlowExtensionTest.kt
+++ b/remotedata-flow/src/commonTest/kotlin/remotedata/flow/FlowExtensionTest.kt
@@ -1,14 +1,15 @@
package remotedata.flow
-import com.google.common.truth.Truth.assertThat
+import assertk.assertThat
+import assertk.assertions.containsExactly
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
-import org.testng.annotations.Test
import remotedata.RemoteData
import remotedata.RemoteData.Companion.failure
import remotedata.RemoteData.Companion.success
+import kotlin.test.Test
class FlowExtensionTest {
@@ -19,7 +20,6 @@ class FlowExtensionTest {
assertThat(result.toList())
.containsExactly(RemoteData.Loading, Unit.success())
- .inOrder()
}
@Test
@@ -30,7 +30,6 @@ class FlowExtensionTest {
assertThat(result.toList())
.containsExactly(RemoteData.Loading, error.failure())
- .inOrder()
}
@Test
@@ -49,7 +48,6 @@ class FlowExtensionTest {
assertThat(result.toList())
.containsExactly(RemoteData.NotAsked, RemoteData.Loading, error.failure(), dataAfterMap.success())
- .inOrder()
}
@Test
@@ -67,6 +65,5 @@ class FlowExtensionTest {
assertThat(result.toList())
.containsExactly(RemoteData.NotAsked, RemoteData.Loading, errorAfterMap.failure(), Unit.success())
- .inOrder()
}
}
diff --git a/remotedata-rx2/build.gradle.kts b/remotedata-rx2/build.gradle.kts
index 473c5f7..ae8c9bd 100644
--- a/remotedata-rx2/build.gradle.kts
+++ b/remotedata-rx2/build.gradle.kts
@@ -19,6 +19,8 @@ dependencies {
testImplementation(libs.testng)
}
+kotlin.jvmToolchain(11)
+
tasks.withType {
useTestNG()
}
diff --git a/remotedata-rx3/build.gradle.kts b/remotedata-rx3/build.gradle.kts
index 01ec4e9..1c2d130 100644
--- a/remotedata-rx3/build.gradle.kts
+++ b/remotedata-rx3/build.gradle.kts
@@ -19,6 +19,8 @@ dependencies {
testImplementation(libs.testng)
}
+kotlin.jvmToolchain(11)
+
tasks.withType {
useTestNG()
}
diff --git a/remotedata/build.gradle.kts b/remotedata/build.gradle.kts
index d438900..28a2bc9 100644
--- a/remotedata/build.gradle.kts
+++ b/remotedata/build.gradle.kts
@@ -5,7 +5,7 @@ plugins {
}
group = "com.carelesscoyotes.remotedata"
-version = "0.2"
+version = "0.3"
repositories {
mavenCentral()
@@ -14,19 +14,23 @@ repositories {
kotlin {
jvm()
linuxX64()
+ linuxArm64()
+ macosX64()
macosArm64()
+ ios()
+ iosSimulatorArm64()
sourceSets {
- named("commonMain") {
+ commonMain {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
- named("commonTest") {
+ commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
- implementation("com.willowtreeapps.assertk:assertk:0.25")
+ implementation(libs.assertk)
}
}
named("jvmTest") {
@@ -35,6 +39,8 @@ kotlin {
}
}
}
+
+ jvmToolchain(11)
}