package com.cottondb.storyimport android.app.Applicationimport androidx.activity.ComponentActivityimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.pager.HorizontalPagerimport androidx.compose.foundation.pager.PagerStateimport androidx.compose.foundation.pager.rememberPagerStateimport androidx.compose.material3.Textimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.test.junit4.createAndroidComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performTouchInputimport androidx.compose.ui.test.swipeLeftimport com.cottondb.story.ink.InkSheetimport org.junit.Assert.assertEqualsimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * A sheet over a scene (a line's acts, Where and when, the direction) keeps a sideways swipe on it: the scenes' pager under * it stays on its scene. On the emulator a sideways swipe on a line's acts turned to the next scene and the sheet went. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w400dp-h700dp-mdpi", application = Application::class)classStorySceneSheetTest { @get:Ruleval compose = createAndroidComposeRule<ComponentActivity>()privatelateinitvar pager: PagerState/** Three invented scenes as ScenesPager pages them; the first shows a line's acts when [sheet]. */privatefun scenes(sheet: Boolean) { compose.setContent { pager = rememberPagerState { 3 }HorizontalPager(pager, Modifier.fillMaxSize().testTag("pager")) { at ->Box(Modifier.fillMaxSize()) {Text("Scene ${at + 1}")if (sheet && at == 0) InkSheet("Arlo", "Close", "acts", onClose = {}) { Text("Move later") } } } } } @Test fun a_sideways_swipe_on_a_sheet_keeps_its_scene() { scenes(sheet = true) compose.onNodeWithTag("acts").performTouchInput { swipeLeft(startX = right - 10f, endX = left + 10f, durationMillis = 250) } compose.waitForIdle() assertEquals(0, pager.currentPage) } @Test fun without_a_sheet_the_swipe_turns_the_scene() { scenes(sheet = false) compose.onNodeWithTag("pager").performTouchInput { swipeLeft(startX = right - 10f, endX = left + 10f, durationMillis = 250) } compose.waitForIdle() assertEquals(1, pager.currentPage) }}