package com.cottondb.story import android.app.Application import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.test.getBoundsInRoot import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp import com.cottondb.story.ink.BarChips import com.cottondb.story.ink.Chip 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 /** * At the phone's largest text (font scale 2) the writing bar's chips stay whole: Note was squeezed to a column of single * letters standing over the mic (the emulator, 21 Nov 2026). Here the bar's chips in the room a 400 dp phone leaves them. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h700dp-mdpi", application = Application::class) class StoryLargeTextTest { @get:Rule val compose = createComposeRule() @Test fun the_bar_chips_stay_whole_at_the_largest_text() { compose.setContent { val density = LocalDensity.current CompositionLocalProvider(LocalDensity provides Density(density.density, fontScale = 2f)) { Row(Modifier.width(400.dp)) { BarChips(Modifier.weight(1f)) { Chip("Caspian", "speaker", on = true, caret = true) {} Chip("Action", "action", on = false) {} Chip("Note", "note", on = false) {} } androidx.compose.foundation.layout.Box(Modifier.size(34.dp)) androidx.compose.foundation.layout.Box(Modifier.size(34.dp)) } } } val chips = listOf("speaker", "action", "note").map { compose.onNodeWithTag(it).getBoundsInRoot() } val note = chips[2] val action = chips[1] // Whole: as tall as Action (one line of words), not a column of letters. assertTrue("Note squeezed: $note against $action", note.bottom - note.top <= action.bottom - action.top + 1.dp) // No two chips overlap. for (i in chips.indices) for (j in i + 1 until chips.size) { val a = chips[i]; val b = chips[j] val apart = a.right <= b.left || b.right <= a.left || a.bottom <= b.top || b.bottom <= a.top assertTrue("chips $i and $j overlap: $a $b", apart) } // And none reaches over the mic and Send at the row's end. assertTrue(chips.all { it.right <= 332.dp }) } }