54 lines · 2.4 KB · KotlinRaw
package com.cottondb.storyimport android.app.Applicationimport androidx.compose.foundation.horizontalScrollimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.PaddingValuesimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.rememberScrollStateimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.test.getBoundsInRootimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.unit.dpimport com.cottondb.story.ink.bleedimport org.junit.Assert.assertEqualsimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * The home's cast runs to the screen's edges as ink.html draws it (`.cast { margin: 0 -20px; padding: 0 20px }`): on the * emulator the faces were cut at the 20 dp side margin instead. Here ten invented faces in the home's list. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w400dp-h700dp-mdpi", application = Application::class)class StoryCastRowTest { @get:Rule val compose = createComposeRule() @Test fun the_cast_reaches_both_edges_and_starts_at_the_margin() { compose.setContent { LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(horizontal = 20.dp)) { item { Row( Modifier.fillMaxWidth().bleed(20.dp).horizontalScroll(rememberScrollState()).padding(horizontal = 20.dp).testTag("cast"), horizontalArrangement = Arrangement.spacedBy(16.dp), ) { (1..10).forEach { Box(Modifier.size(70.dp).testTag("face-$it")) } } } } } val cast = compose.onNodeWithTag("cast").getBoundsInRoot() assertEquals(0.dp, cast.left) assertEquals(400.dp, cast.right) assertEquals(20.dp, compose.onNodeWithTag("face-1").getBoundsInRoot().left) }}