package com.cottondb.notesimport android.app.Applicationimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.setValueimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.test.getUnclippedBoundsInRootimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithContentDescriptionimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performClickimport androidx.compose.ui.text.font.FontFamilyimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.heightimport androidx.compose.ui.unit.widthimport com.cottondb.writing.theme.Writingimport com.cottondb.writing.theme.WritingThemeimport com.cottondb.writing.theme.WritingTypeimport kotlinx.serialization.json.Jsonimport kotlinx.serialization.json.jsonObjectimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertTrueimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * The list search's clear mark (the launch walk, 22 Nov 2026, Words on emulator-5556, 4,000 invented notes): TalkBack * read it as "close", a raw key, and it was 20 dp each way. It now says the core's words and is 48 dp to touch, and * the field keeps its height when the first letter brings the mark. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w400dp-h700dp-mdpi", application = Application::class)classNotesSearchClearTest { @get:Ruleval compose = createComposeRule()privateval theme = WritingTheme.of("linen", "Linen", Json.parseToJsonElement("""{"ground":"#F7F5F0","text":"#2E2E31","heading":"#1C1C1E","secondary":"#8A8A8F","accent":"#D2453A"}""").jsonObject)privateval type = WritingType(FontFamily.Default, 17f, 1.5f, 600f, FontFamily.Monospace)privatevar query by mutableStateOf("")privatefun show() { compose.setContent {Writing(theme, type) { androidx.compose.foundation.layout.Box(Modifier.testTag("search")) {SearchField("Search your notes", "Clear the search", query, 16.dp) { query = it.orEmpty() } } } } compose.waitForIdle() } @Test fun the_clear_mark_says_what_it_does_and_is_big_enough_to_touch() { query = "lantern" show()val clear = compose.onNodeWithContentDescription("Clear the search").assertExistsReturning()val bounds = clear.getUnclippedBoundsInRoot() assertTrue("the clear mark is ${bounds.width} wide", bounds.width >= 48.dp) assertTrue("the clear mark is ${bounds.height} tall", bounds.height >= 48.dp) clear.performClick() compose.waitForIdle() assertEquals("", query) } @Test fun the_field_keeps_its_height_when_the_mark_comes() { show()val before = compose.onNodeWithTag("search").getUnclippedBoundsInRoot().height compose.runOnIdle { query = "l" } compose.waitForIdle() assertEquals(before, compose.onNodeWithTag("search").getUnclippedBoundsInRoot().height) }privatefun androidx.compose.ui.test.SemanticsNodeInteraction.assertExistsReturning() = also { assertExists() }}