Cotton code
57 lines · 2.4 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.runtime.CompositionLocalProviderimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.LocalDensityimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.onRootimport androidx.compose.ui.unit.Densityimport androidx.compose.ui.unit.dpimport org.junit.Assert.assertTrueimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * FEEDBACK2 F (the owner's screenshots, 22 Nov 2026): scrolled content was cut by the floating switch. Each place kept a * fixed 96 dp at its foot, less than the switch and the navigation bar under it take at the largest text size (checked on * the emulator). The room is now the switch * measured as drawn. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w411dp-h891dp-xxhdpi", application = Application::class)class PillRoomTest {    @get:Rule val compose = createComposeRule()    @Test    fun the_room_at_a_places_foot_is_the_switch_as_drawn() {        var high = 0        compose.setContent {            val d = LocalDensity.current            CompositionLocalProvider(LocalDensity provides Density(d.density, fontScale = 2f)) {                WarmTheme(night = false) {                    Box(Modifier.fillMaxSize()) {                        Places(listOf("Chats", "Calls", "You"), 0, Modifier.align(Alignment.BottomCenter)) {}                    }                }            }        }        compose.waitForIdle()        val pill = compose.onNodeWithTag("chat-places").fetchSemanticsNode().boundsInRoot        val screen = compose.onRoot().fetchSemanticsNode().boundsInRoot        high = screen.height.toInt()        val density = Density(2.625f)        // The switch, 12 dp above the foot as PlacesRoot stands it.        val top = pill.top.toInt() - with(density) { 12.dp.roundToPx() }        val room = pillRoom(high, top, density)        val needs = with(density) { (high - top).toDp() }        assertTrue("the room clears the switch as drawn: $room for $needs", room >= needs)    }}