-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISSUE-602: Update Kakao lib version to 0.4.5 - with a tests that woul…
…dn't work previously.
- Loading branch information
1 parent
f1028e4
commit 779763f
Showing
9 changed files
with
231 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...Test/kotlin/com/kaspersky/kaspresso/composesupport/sample/screen/ComposeLazyListScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.kaspersky.kaspresso.composesupport.sample.screen | ||
|
||
import androidx.compose.ui.semantics.SemanticsNode | ||
import androidx.compose.ui.test.SemanticsMatcher | ||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider | ||
import com.kaspersky.kaspresso.composesupport.sample.features.lazylist.ListItemPositionSemantics | ||
import com.kaspersky.kaspresso.composesupport.sample.features.lazylist.ListLengthSemantics | ||
import com.kaspersky.kaspresso.composesupport.sample.resources.C | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import io.github.kakaocup.compose.node.element.KNode | ||
import io.github.kakaocup.compose.node.element.lazylist.KLazyListItemNode | ||
import io.github.kakaocup.compose.node.element.lazylist.KLazyListNode | ||
|
||
class ComposeLazyListScreen(semanticsProvider: SemanticsNodeInteractionsProvider) : | ||
ComposeScreen<ComposeLazyListScreen>( | ||
semanticsProvider = semanticsProvider, | ||
) { | ||
val list: KLazyListNode = | ||
KLazyListNode( | ||
semanticsProvider = semanticsProvider, | ||
viewBuilderAction = { hasTestTag(C.Tag.scroll_screen_multi_text_list) }, | ||
itemTypeBuilder = { | ||
itemType(::LazyListScreenItemNode) | ||
}, | ||
positionMatcher = { position -> SemanticsMatcher.expectValue(ListItemPositionSemantics, position) }, | ||
lengthSemanticsPropertyKey = ListLengthSemantics | ||
) | ||
} | ||
class LazyListScreenItemNode( | ||
semanticsNode: SemanticsNode, | ||
semanticsProvider: SemanticsNodeInteractionsProvider | ||
) : KLazyListItemNode<LazyListScreenItemNode>( | ||
semanticsNode, | ||
semanticsProvider | ||
) { | ||
val text1: KNode = | ||
child { | ||
useUnmergedTree = true | ||
hasTestTag(C.Tag.multi_text_text1) | ||
} | ||
val text2: KNode = | ||
child { | ||
useUnmergedTree = true | ||
hasTestTag(C.Tag.multi_text_text2) | ||
} | ||
val text3: KNode = | ||
child { | ||
useUnmergedTree = true | ||
hasTestTag(C.Tag.multi_text_text3) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...roidTest/kotlin/com/kaspersky/kaspresso/composesupport/sample/test/ComposeLazyListTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.kaspersky.kaspresso.composesupport.sample.test | ||
|
||
import androidx.compose.ui.test.ExperimentalTestApi | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.kaspersky.components.composesupport.config.withComposeSupport | ||
import com.kaspersky.kaspresso.composesupport.sample.MainActivity | ||
import com.kaspersky.kaspresso.composesupport.sample.resources.C | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeLazyListScreen | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeMainScreen | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.LazyListScreenItemNode | ||
import com.kaspersky.kaspresso.kaspresso.Kaspresso | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import io.github.kakaocup.compose.node.element.ComposeScreen.Companion.onComposeScreen | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ComposeLazyListTest : TestCase( | ||
kaspressoBuilder = Kaspresso.Builder.withComposeSupport() | ||
) { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
|
||
@OptIn(ExperimentalTestApi::class) | ||
@Test | ||
fun test() = run { | ||
step("Open LazyList screen") { | ||
onComposeScreen<ComposeMainScreen>(composeTestRule) { | ||
lazyListButton { | ||
performClick() | ||
} | ||
} | ||
} | ||
step("Verify Lazy List") { | ||
onComposeScreen<ComposeLazyListScreen>(composeTestRule) { | ||
list { | ||
assertIsDisplayed() | ||
assertLengthEquals(C.Tag.scroll_screen_multi_text_items.size) | ||
|
||
repeat(C.Tag.scroll_screen_multi_text_items.size) { i -> | ||
childAt<LazyListScreenItemNode>(i) { | ||
text1 { | ||
assertIsDisplayed() | ||
assertTextContains("text1_$i") | ||
} | ||
text2 { | ||
assertIsDisplayed() | ||
assertTextContains("text2_$i") | ||
} | ||
text3 { | ||
assertIsDisplayed() | ||
assertTextContains("text3_$i") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../kotlin/com/kaspersky/kaspresso/composesupport/sample/features/lazylist/LazyListScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.kaspersky.kaspresso.composesupport.sample.features.lazylist | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.wrapContentSize | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.itemsIndexed | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.semantics.SemanticsPropertyKey | ||
import androidx.compose.ui.semantics.SemanticsPropertyReceiver | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.semantics.testTag | ||
import androidx.compose.ui.unit.dp | ||
import com.kaspersky.kaspresso.composesupport.sample.resources.C | ||
|
||
@Composable | ||
fun LazyListScreen() { | ||
LazyColumn( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(8.dp) | ||
.testTag(C.Tag.scroll_screen_multi_text_list) | ||
.lazyListLength(C.Tag.scroll_screen_multi_text_items.size) | ||
.semantics { testTag = C.Tag.scroll_screen_multi_text } | ||
|
||
) { | ||
itemsIndexed( | ||
C.Tag.scroll_screen_multi_text_items | ||
) { index, item -> | ||
Row(modifier = Modifier.lazyListItemPosition(index).padding(8.dp).border(BorderStroke(1.dp, Color.Green))) { | ||
Column( | ||
modifier = Modifier.fillMaxWidth().wrapContentSize().padding(8.dp) | ||
) { | ||
Text( | ||
text = item.text1, | ||
modifier = Modifier.testTag(C.Tag.multi_text_text1) | ||
) | ||
Text( | ||
text = item.text2, | ||
modifier = Modifier.testTag(C.Tag.multi_text_text2) | ||
) | ||
Text( | ||
text = item.text3, | ||
modifier = Modifier.testTag(C.Tag.multi_text_text3) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
val ListItemPositionSemantics: SemanticsPropertyKey<Int> = SemanticsPropertyKey("ListItemPosition") | ||
var SemanticsPropertyReceiver.lazyListItemPosition: Int by ListItemPositionSemantics | ||
|
||
fun Modifier.lazyListItemPosition(position: Int): Modifier = semantics { lazyListItemPosition = position } | ||
|
||
val ListLengthSemantics: SemanticsPropertyKey<Int> = SemanticsPropertyKey("ListLength") | ||
var SemanticsPropertyReceiver.lazyListLength: Int by ListLengthSemantics | ||
|
||
fun Modifier.lazyListLength(length: Int): Modifier = semantics { lazyListLength = length } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters