Skip to content

Commit

Permalink
upd cmp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tiurin committed Jul 4, 2024
1 parent 3916eef commit af50104
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and deploy docs
on:
push:
branches:
- docs
- master

jobs:
github-pages:
Expand Down
16 changes: 14 additions & 2 deletions docs/docs/compose/lazylist.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -138,7 +150,7 @@ lazyList.getItem<ComposeFriendListItem>(hasTestTag(..))
Mark such methods with `private` visibility modifier. e.g. `getContactItem`
```kotlin
object ComposeListPage : Page<ComposeListPage>() {
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(){
Expand Down Expand Up @@ -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)) }
Expand Down
1 change: 1 addition & 0 deletions docs/docs/intro/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand Down
28 changes: 26 additions & 2 deletions docs/docs/intro/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {
}
```

For Android application instrumented UI tests
### Android application instrumented UI tests
```kotlin
dependencies {
androidTestImplementation("com.atiurin:ultron-compose:<latest_version>")
Expand All @@ -27,7 +27,8 @@ dependencies {
}
```

For Compose Multiplatform UI tests
### Compose Multiplatform UI tests

```kotlin
kotlin {
sourceSets {
Expand All @@ -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:<latest_version>")
}
}
}
sourceSets {
val desktopTest by getting {
dependencies {
implementation("com.atiurin:ultron-compose:<latest_version>")
}
}
}
}
```

0 comments on commit af50104

Please sign in to comment.