Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions platforms/android/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ The sample is a separate Gradle composite (`samples/MobileBuyIntegration/setting
- Tests use **Robolectric** (`@RunWith(RobolectricTestRunner::class)`) to exercise Android framework code without a device.
- Main-thread tasks are drained with `shadowOf(Looper.getMainLooper()).runToEndOfTasks()`. If a test involves posted work and seems flaky, check whether this is being called.
- Assertion library is **AssertJ**; mocking is **Mockito** + **Mockito-Kotlin**. Don't introduce new assertion/mocking libraries without discussion.
- Mockito is pinned at **4.x** intentionally — Mockito 5.x requires JVM target 11, and the library is on 1.8. Noted in `lib/build.gradle` with `// noinspection NewerVersionAvailable` comments.
- Tests live in the same package as the class under test (file name: `ClassNameTest.kt`).

## Conventions

- **`-Xexplicit-api=strict`** is on (`lib/build.gradle`). Every public class, method, field, and property must have an explicit visibility modifier. "Accidentally public" is not a thing here. This is a consumer-protection rule — if you see a public-by-default declaration, it was deliberate.
- **Max line length: 140** (detekt-enforced). Detekt config: `lib/detekt.config.yml`.
- **MIT license header required on every new source file.** Format: copy the top comment of any existing `.kt` or `.java` file in `lib/src/main` or `lib/src/test`. Enforced in CI via the repo-root `scripts/check_license_headers.rb`.
- **Library JVM target: 1.8.** Intentional for consumer compatibility; don't raise without a major-version discussion.
- **Library JVM target: 11.** Consumers must build with JDK 11+ to consume the AAR. Raising further is a major-version discussion.
- **Library Kotlin `apiVersion` / `languageVersion` are pinned at 2.0.** Set in `lib/build.gradle` so the AAR's bytecode stays consumable by Kotlin 2.0+ projects even though the compiler itself is on a newer 2.x. Bumping this pin is the consumer-facing breaking change, not bumping the compiler — treat it as a planned major-version event.

## Public API surface
Expand Down
2 changes: 0 additions & 2 deletions platforms/android/lib/api/lib.api
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,6 @@ public final class com/shopify/checkoutkit/Configuration {
public final fun component3 ()Lcom/shopify/checkoutkit/ErrorRecovery;
public final fun component4 ()Lcom/shopify/checkoutkit/Platform;
public final fun component5 ()Lcom/shopify/checkoutkit/LogLevel;
public final fun copy (Lcom/shopify/checkoutkit/ColorScheme;Lcom/shopify/checkoutkit/Preloading;Lcom/shopify/checkoutkit/ErrorRecovery;Lcom/shopify/checkoutkit/Platform;Lcom/shopify/checkoutkit/LogLevel;)Lcom/shopify/checkoutkit/Configuration;
public static synthetic fun copy$default (Lcom/shopify/checkoutkit/Configuration;Lcom/shopify/checkoutkit/ColorScheme;Lcom/shopify/checkoutkit/Preloading;Lcom/shopify/checkoutkit/ErrorRecovery;Lcom/shopify/checkoutkit/Platform;Lcom/shopify/checkoutkit/LogLevel;ILjava/lang/Object;)Lcom/shopify/checkoutkit/Configuration;
public fun equals (Ljava/lang/Object;)Z
public final fun getColorScheme ()Lcom/shopify/checkoutkit/ColorScheme;
public final fun getErrorRecovery ()Lcom/shopify/checkoutkit/ErrorRecovery;
Expand Down
13 changes: 5 additions & 8 deletions platforms/android/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ext {

junit_version = '4.13.2'
robolectric_version = '4.16.1'
mockito_core_version = '4.11.0'
mockito_kotlin_version = '4.1.0'
mockito_core_version = '5.23.0'
mockito_kotlin_version = '5.4.0'
assertj_version = '3.27.7'
awaitility_version = '4.3.0'
detekt_formatting_version = '1.23.8'
Expand Down Expand Up @@ -62,8 +62,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
testOptions {
unitTests.includeAndroidResources = true
Expand All @@ -88,7 +88,7 @@ android {

tasks.withType(KotlinJvmCompile).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
jvmTarget.set(JvmTarget.JVM_11)
// Pin language/API version so bytecode stays consumable by Kotlin 2.0+ consumers
// even though the compiler is on a newer 2.x. Kotlin 1.9 is deprecated by the 2.x
// compiler, so 2.0 is the lowest pin we can hold without taking deprecation warnings;
Expand All @@ -107,11 +107,8 @@ dependencies {

testImplementation "junit:junit:$junit_version"
testImplementation "org.robolectric:robolectric:$robolectric_version"
// noinspection NewerVersionAvailable -- mockito 5 requires jvm target 1.11
testImplementation "org.mockito:mockito-core:$mockito_core_version"
// noinspection NewerVersionAvailable -- mockito 5 requires jvm target 1.11
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockito_kotlin_version"
// noinspection NewerVersionAvailable -- mockito 5 requires jvm target 1.11
testImplementation "org.mockito:mockito-android:$mockito_core_version"
testImplementation "org.assertj:assertj-core:$assertj_version"
testImplementation "org.awaitility:awaitility:$awaitility_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package com.shopify.checkoutkit
* - Enabling/disabling preloading,
* - Specifying the colorScheme that should be used for checkout.
*/
@ConsistentCopyVisibility
public data class Configuration internal constructor(
var colorScheme: ColorScheme = ColorScheme.Automatic(),
var preloading: Preloading = Preloading(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ class CheckoutDialogTest {
val dialog = ShadowDialog.getLatestDialog() as CheckoutDialog
val webView = dialog.currentWebView()
webView.loadUrl("https://shopify.com/checkouts/c/abc/step2")
shadowOf(webView).setCanGoBack(true)
// ShadowWebView doesn't auto-track loadUrl in history; push two entries so canGoBack() returns true.
shadowOf(webView).pushEntryToHistory("https://shopify.com/checkouts/c/abc")
shadowOf(webView).pushEntryToHistory("https://shopify.com/checkouts/c/abc/step2")
shadowOf(Looper.getMainLooper()).runToEndOfTasks()

dialog.onBackPressedDispatcher.onBackPressed()
Expand All @@ -583,7 +585,8 @@ class CheckoutDialogTest {
val dialog = ShadowDialog.getLatestDialog() as CheckoutDialog
val webView = dialog.currentWebView()
webView.loadUrl("https://shopify.com/cn-12345/thank-you")
shadowOf(webView).setCanGoBack(true)
shadowOf(webView).pushEntryToHistory("https://shopify.com/checkouts/c/abc")
shadowOf(webView).pushEntryToHistory("https://shopify.com/cn-12345/thank-you")
shadowOf(Looper.getMainLooper()).runToEndOfTasks()

dialog.onBackPressedDispatcher.onBackPressed()
Expand Down
Loading