Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #86

Merged
merged 18 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9de2dba
Merge pull request #75 from KakaoCup/master
Vacxe Jan 2, 2024
d5f85c9
[klistnode] Adds allowed getter for SemanticsNodeInteractionsProvider
PStrelchenko Jun 23, 2024
e15dcd5
[klistnode] Adds allowed getter for NodeMatcher in BaseNode
PStrelchenko Jun 23, 2024
4c1175b
[klistnode] Adds method for deffered initialization of BaseNode const…
PStrelchenko Jun 23, 2024
39117d6
[klistnode] Adds KNode for list items
PStrelchenko Jun 23, 2024
8160125
[klistnode] Adds KNode for lists
PStrelchenko Jun 23, 2024
517a78c
[klistnode] Adds semantics keys for list item index and list length f…
PStrelchenko Jun 23, 2024
ae54a95
[klistnode] Fixes function names collision in BaseNode
PStrelchenko Jun 23, 2024
00911d2
[klistnode] Changes packaging options for sample app to enable Layout…
PStrelchenko Jun 23, 2024
b5e8333
[klistnode] Takes into account the value of a global variable Kakao.O…
PStrelchenko Jun 23, 2024
b60f80e
[klistnode] Overrides performScrollToIndex action to a more reliable …
PStrelchenko Jun 23, 2024
cef68cb
[klistnode] Adds addtional factory methods for KListNode
PStrelchenko Jun 23, 2024
c19cfb7
[klistnode] Adds tests for KListNode
PStrelchenko Jun 23, 2024
4ee605a
[klistnode] Removes detekt suppression
PStrelchenko Jun 23, 2024
778b21d
[klistnode] Fixes error with scroll to index action
PStrelchenko Jun 23, 2024
c3a7521
[klistnode] Fixes review comment -- replace 'requireSemanticsProvider…
PStrelchenko Jun 24, 2024
3472121
[klistnode] Fixes review comment -- replace 'requireNodeMatcher' with…
PStrelchenko Jun 24, 2024
0386c4f
Merge pull request #85 from PStrelchenko/klistnode_implementation
Vacxe Jun 25, 2024
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
Prev Previous commit
Next Next commit
[klistnode] Fixes function names collision in BaseNode
  • Loading branch information
PStrelchenko committed Jun 23, 2024
commit ae54a95aab3905e59307751c486d3fa604f0b55d
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ abstract class BaseNode<out T : BaseNode<T>> constructor(
nodeProvider = NodeProvider(
nodeMatcher = NodeMatcher(
matcher = combineSemanticMatchers(),
position = getNodeMatcher().position,
useUnmergedTree = getNodeMatcher().useUnmergedTree
position = requireNodeMatcher().position,
useUnmergedTree = requireNodeMatcher().useUnmergedTree
),
semanticsProvider = getSemanticsProvider()
semanticsProvider = requireSemanticsProvider()
),
parentDelegate = parentNode?.delegate
)
Expand All @@ -66,7 +66,7 @@ abstract class BaseNode<out T : BaseNode<T>> constructor(
NodeMatcher::class.java,
BaseNode::class.java,
).newInstance(
semanticsProvider,
requireSemanticsProvider(),
ViewBuilder().apply(function).build(),
this,
)
Expand All @@ -76,16 +76,16 @@ abstract class BaseNode<out T : BaseNode<T>> constructor(
* Allowed getter for [nodeMatcher].
* Any [NodeMatcher] must be initialized before use.
*/
fun getNodeMatcher(): NodeMatcher {
fun requireNodeMatcher(): NodeMatcher {
return this.nodeMatcher
?: throw KakaoComposeException("NodeMatcher is null: Provide via constructor or use `initSemantics` method`")
}

/**
* Allowed getter for [semanticsProvider].
* Allowed getter for [requireSemanticsProvider].
* Any [SemanticsNodeInteractionsProvider] must be initialized before use.
*/
fun getSemanticsProvider(): SemanticsNodeInteractionsProvider {
fun requireSemanticsProvider(): SemanticsNodeInteractionsProvider {
return this.semanticsProvider.orGlobal().checkNotNull()
}

Expand All @@ -111,10 +111,10 @@ abstract class BaseNode<out T : BaseNode<T>> constructor(
var parent = this.parentNode

while (parent != null) {
semanticsMatcherList.add(hasAnyAncestor(parent.getNodeMatcher().matcher))
semanticsMatcherList.add(hasAnyAncestor(parent.requireNodeMatcher().matcher))
parent = parent.parentNode
}
semanticsMatcherList.add(this.getNodeMatcher().matcher)
semanticsMatcherList.add(this.requireNodeMatcher().matcher)

return semanticsMatcherList.reduce { finalMatcher, matcher -> finalMatcher and matcher }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.kakaocup.compose.node.element

import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
import io.github.kakaocup.compose.KakaoCompose
import io.github.kakaocup.compose.node.core.ComposeMarker
import io.github.kakaocup.compose.node.core.BaseNode
import io.github.kakaocup.compose.node.builder.NodeMatcher
Expand Down Expand Up @@ -34,7 +33,7 @@ open class ComposeScreen<out T : ComposeScreen<T>> : BaseNode<T> {
) : super(semanticsProvider, nodeMatcher)

fun onNode(viewBuilderAction: ViewBuilder.() -> Unit) = KNode(
getSemanticsProvider(),
requireSemanticsProvider(),
viewBuilderAction,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
import androidx.compose.ui.test.filter
import androidx.compose.ui.test.filterToOne
import androidx.compose.ui.test.onChildren
import io.github.kakaocup.compose.KakaoCompose
import io.github.kakaocup.compose.exception.KakaoComposeException
import io.github.kakaocup.compose.node.assertion.LazyListNodeAssertions
import io.github.kakaocup.compose.node.builder.NodeMatcher
import io.github.kakaocup.compose.node.builder.ViewBuilder
Expand Down Expand Up @@ -69,15 +67,15 @@ class KLazyListNode(
}.provideItem

performScrollToIndex(position)
val semanticsNode = getSemanticsProvider()
val semanticsNode = requireSemanticsProvider()
.onNode(semanticsMatcher)
.onChildren()
.filterToOne(positionMatcher(position))
.fetchSemanticsNode()

function(provideItem(
semanticsNode,
getSemanticsProvider()
requireSemanticsProvider()
) as T)
}

Expand All @@ -98,15 +96,15 @@ class KLazyListNode(

performScrollToNode(nodeMatcher.matcher)

val semanticsNode = getSemanticsProvider()
val semanticsNode = requireSemanticsProvider()
.onNode(semanticsMatcher)
.onChildren()
.filter(nodeMatcher.matcher)[nodeMatcher.position]
.fetchSemanticsNode()

return provideItem(
semanticsNode,
getSemanticsProvider()
requireSemanticsProvider()
) as T
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class KListItemNode<out T : KListItemNode<T>> protected constructor() : Bas
val instance = T::class.java.getDeclaredConstructor().newInstance()

instance.initSemantics(
semanticsProvider = listNode.getSemanticsProvider(),
semanticsProvider = listNode.requireSemanticsProvider(),
nodeMatcher = NodeMatcher(
matcher = SemanticsMatcher(
description = "Semantics node id = ${semanticsNode.id}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import io.github.kakaocup.compose.node.builder.NodeMatcher
import io.github.kakaocup.compose.node.builder.ViewBuilder
import io.github.kakaocup.compose.node.core.BaseNode
import io.github.kakaocup.compose.node.element.KNode
import io.github.kakaocup.compose.utilities.checkNotNull
import io.github.kakaocup.compose.utilities.orGlobal

/**
* A slightly modified copy of [io.github.kakaocup.compose.node.element.lazylist.KLazyListNode].
Expand Down Expand Up @@ -111,7 +109,7 @@ class KListNode(
performScrollToNode(childMatcher.matcher)
}
} else {
getSemanticsProvider()
requireSemanticsProvider()
.onNode(rootNodeMatcher, this.useUnmergedTree)
.onChildren()
.filter(childMatcher.matcher)[childMatcher.position]
Expand Down Expand Up @@ -144,7 +142,7 @@ class KListNode(
}
}
} else {
getSemanticsProvider()
requireSemanticsProvider()
.onNode(rootNodeMatcher, this.useUnmergedTree)
.onChildren()
.filter(childMatcher.matcher)[childMatcher.position]
Expand Down Expand Up @@ -364,7 +362,7 @@ class KListNode(
performScrollToNode(childMatcher.matcher)
}

val semanticsNode = getSemanticsProvider()
val semanticsNode = requireSemanticsProvider()
.onNode(rootNodeMatcher, this.useUnmergedTree)
.onChildren()
.filter(childMatcher.matcher)[childMatcher.position]
Expand Down Expand Up @@ -412,7 +410,7 @@ class KListNode(
// Warning!
// Within lazy collections, `filterToOne` cannot be used on child nodes.
// In Compose version 1.5.5, the semantic tree of lazy collections MAY CONTAIN DUPLICATES.
val semanticsNode = getSemanticsProvider()
val semanticsNode = requireSemanticsProvider()
.onNode(rootNodeMatcher, this.useUnmergedTree)
.onChildren()
.filter(childMatcher.matcher)[childMatcher.position]
Expand Down