package com.cottondb.days import android.app.Application import androidx.compose.runtime.CompositionLocalProvider 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.test.onRoot import androidx.compose.ui.unit.Density 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 /** * RULE (DECISIONS "Show"): with a long group chosen at the largest text, search and "more" stay wholly on the screen. * On the emulator at text size 2.0 the group's name pushed the magnifier off the right edge (22 Nov 2026). */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w360dp-h700dp-mdpi", application = Application::class) class DaysTopBarTest { @get:Rule val compose = createComposeRule() @Test fun a_long_group_never_pushes_search_or_more_off_the_screen() { compose.setContent { val d = LocalDensity.current CompositionLocalProvider(LocalDensity provides Density(d.density, fontScale = 2f)) { TopBar( "Things for the long-planned trip to the Western Ghats in the monsoon", chosen = true, showName = "Show", searchName = "Search", more = "more" to "Settings", onShow = {}, onSearch = {}, onMore = {}, ) } } val edge = compose.onRoot().getBoundsInRoot().right val glass = compose.onNodeWithTag("days-search-open").getBoundsInRoot() val more = compose.onNodeWithTag("days-more-settings").getBoundsInRoot() assertTrue("search at ${glass.left}..${glass.right} inside $edge", glass.right <= edge && glass.right > glass.left) assertTrue("more at ${more.left}..${more.right} inside $edge", more.right <= edge && more.left >= glass.right) assertTrue(compose.onNodeWithTag("days-filter").getBoundsInRoot().right <= glass.left) } }