Cotton code
50 lines · 2.1 KB · KotlinRaw
package com.cottondb.cinemasimport android.app.Applicationimport androidx.activity.ComponentActivityimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.sizeimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.test.getUnclippedBoundsInRootimport androidx.compose.ui.test.junit4.createAndroidComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.onNodeWithTextimport 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/** * Seen on the emulator (21 Nov 2026): at the end of S1 E2 of an invented series, "Next episode in 5" and "Stay here" * stood on the player's seek line and its time while its controls showed. While they show, the count now stands * above them; with them gone it keeps its place in the corner. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w400dp-h860dp-mdpi", application = Application::class)class NextEpisodeTest {    @get:Rule val compose = createAndroidComposeRule<ComponentActivity>()    private fun show(controls: Boolean) = compose.setContent {        Box(Modifier.size(400.dp, 800.dp)) {            NextEpisode("Next episode in 5", "Stay here", controls, {}, {}, Modifier.align(Alignment.BottomEnd))        }    }    @Test    fun the_count_stands_above_the_players_controls_while_they_show() {        show(controls = true)        val stay = compose.onNodeWithText("Stay here").getUnclippedBoundsInRoot()        assertTrue("Stay here ends at ${stay.bottom}, on the controls below ${800.dp - PLAYER_FOOT}", stay.bottom <= 800.dp - PLAYER_FOOT)    }    @Test    fun with_the_controls_gone_the_count_keeps_its_corner() {        show(controls = false)        val count = compose.onNodeWithTag("player-next").getUnclippedBoundsInRoot()        assertTrue("the count ends at ${count.bottom}", count.bottom > 800.dp - PLAYER_FOOT)    }}