From af50104e98270c402b546430fd3e727a19feca1e Mon Sep 17 00:00:00 2001 From: Aleksei Tiurin Date: Fri, 5 Jul 2024 01:58:50 +0300 Subject: [PATCH] upd cmp docs --- .github/workflows/docs.yml | 2 +- docs/docs/compose/lazylist.md | 16 ++++++++++++++-- docs/docs/intro/configuration.md | 1 + docs/docs/intro/connect.md | 28 ++++++++++++++++++++++++++-- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f2edfce4..4964e8d7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ name: Build and deploy docs on: push: branches: - - docs + - master jobs: github-pages: diff --git a/docs/docs/compose/lazylist.md b/docs/docs/compose/lazylist.md index ca75bb86..64a5b616 100644 --- a/docs/docs/compose/lazylist.md +++ b/docs/docs/compose/lazylist.md @@ -123,6 +123,18 @@ class ComposeFriendListItem : UltronComposeListItem(){ ``` **Note: you have to use delegated initialisation with `by child`.** +For Compose Multiplatform `commonTest` you need to register Item class instances, like: + +```kotlin +composeList(.., initBlock = { + registerItem { ComposeFriendListItem() } + registerItem { AnotherListItem() } +}) +``` +It is required cause Kotlin Multiplatfor Project has limited reflation API for different platforms. + +You don't need to register Items for Android UI tests (and JVM). + Now you're able to get `ComposeFriendListItem` object using methods `getItem`, `getVisibleItem`, `getFirstVisibleItem`, `getLastVisibleItem` ```kotlin @@ -138,7 +150,7 @@ lazyList.getItem(hasTestTag(..)) Mark such methods with `private` visibility modifier. e.g. `getContactItem` ```kotlin object ComposeListPage : Page() { - private val lazyList = composeList(hasContentDescription(contactsListContentDesc)) + private val lazyList = composeList(hasContentDescription(contactsListContentDesc), ..) private fun getContactItem(contact: Contact): ComposeFriendListItem = lazyList.getItem(hasTestTag(contact.id)) class ComposeFriendListItem : UltronComposeListItem(){ @@ -168,7 +180,7 @@ It's pretty much the same as [simple node api](../compose/api.md), but extends i Let's start with approaches that you can use without additional efforts. For example, you have identified `LazyList` in your tests code like ```kotlin -val lazyList = composeList(listMatcher = hasTestTag("listTestTag")) +val lazyList = composeList(listMatcher = hasTestTag("listTestTag"), ..) class ComposeListItem : UltronComposeListItem() { val name by lazy { getChild(hasTestTag(contactNameTestTag)) } diff --git a/docs/docs/intro/configuration.md b/docs/docs/intro/configuration.md index c6b7342b..25d7222d 100644 --- a/docs/docs/intro/configuration.md +++ b/docs/docs/intro/configuration.md @@ -34,6 +34,7 @@ UltronComposeConfig.apply { lazyColumnOperationTimeoutMs = 15_000 operationPollingTimeoutMs = 100 lazyColumnItemSearchLimit = 100 + useUnmergedTree = true //set up this value as a default for all SemanticNodeInteractions } ``` diff --git a/docs/docs/intro/connect.md b/docs/docs/intro/connect.md index 4a75ef90..f9c11f37 100644 --- a/docs/docs/intro/connect.md +++ b/docs/docs/intro/connect.md @@ -18,7 +18,7 @@ repositories { } ``` -For Android application instrumented UI tests +### Android application instrumented UI tests ```kotlin dependencies { androidTestImplementation("com.atiurin:ultron-compose:") @@ -27,7 +27,8 @@ dependencies { } ``` -For Compose Multiplatform UI tests +### Compose Multiplatform UI tests + ```kotlin kotlin { sourceSets { @@ -36,4 +37,27 @@ kotlin { } } } +``` +Since Multiplatform support in alpha state it's possible to have some problems with `commonTest` usage. + +In this case you can specify dependencies in relevant part. +```kotlin +kotlin { + androidTarget { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + instrumentedTestVariant { + ... + dependencies { + implementation("com.atiurin:ultron-compose:") + } + } + } + sourceSets { + val desktopTest by getting { + dependencies { + implementation("com.atiurin:ultron-compose:") + } + } + } +} ``` \ No newline at end of file