Cotton code
55 lines · 2.7 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.activity.ComponentActivityimport androidx.compose.ui.test.assertIsDisplayedimport androidx.compose.ui.test.hasTestTagimport androidx.compose.ui.test.junit4.createAndroidComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performScrollToNodeimport com.cottondb.messages.chat.ChatDataimport com.cottondb.messages.chat.ChatModelimport com.cottondb.messages.chat.Wordsimport kotlinx.coroutines.CoroutineScopeimport kotlinx.coroutines.SupervisorJobimport org.junit.Assert.assertTrueimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.RuntimeEnvironmentimport org.robolectric.annotation.Config/** * Seen on an emulator (21 Nov 2026), sideways at the largest text with the keyboard up: Add people (and New group) * kept the title and the fields fixed, and the people under them had no room at all, so nobody could be seen or * ticked while searching. The fields now scroll with the people, under the title and its button. A short window * stands for the keyboard. Invented numbers. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w800dp-h220dp-land-mdpi", application = Application::class)class ChoosePeopleTest {    @get:Rule val compose = createAndroidComposeRule<ComponentActivity>()    @Test    fun people_can_be_reached_under_the_fields_in_a_short_window() {        RuntimeEnvironment.setFontScale(2f)        val model = ChatModel(ChatData(null, null, Words { set, key -> "$set:$key" }, CoroutineScope(SupervisorJob()), null), CoroutineScope(SupervisorJob()))        compose.setContent {            WarmTheme(night = false) {                ChoosePeople(                    model, "New group", "Back", "Create", "Who's in it", "What the group is called",                    onBack = {}, onGo = { _, _ -> },                    find = { listOf("+15550100121" to "Asha Example", "+15550100122" to "Bina Example", "+15550100123" to "Chitra Example") },                )            }        }        compose.waitForIdle()        compose.onNodeWithTag("choose-list").performScrollToNode(hasTestTag("choose-+15550100123"))        compose.onNodeWithTag("choose-+15550100123").assertIsDisplayed()        // Whole: the room the people stand in holds a person's row, not a sliver of it.        val room = compose.onNodeWithTag("choose-list").fetchSemanticsNode().boundsInRoot.height        val row = compose.onNodeWithTag("choose-+15550100123").fetchSemanticsNode().size.height / compose.density.density        assertTrue("the people have ${room}dp, a row needs ${row}dp", room >= row)    }}