package com.cottondb.cinemas import android.app.Application import androidx.activity.ComponentActivity import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.test.getUnclippedBoundsInRoot import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText 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 /** * 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() 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) } }