package com.cottondb.messages.warm import android.app.Application import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onRoot import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import 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) } }