diff --git a/library/src/main/kotlin/me/saket/squiggles/SquigglySlider.kt b/library/src/main/kotlin/me/saket/squiggles/SquigglySlider.kt index dd87686..8301542 100644 --- a/library/src/main/kotlin/me/saket/squiggles/SquigglySlider.kt +++ b/library/src/main/kotlin/me/saket/squiggles/SquigglySlider.kt @@ -117,7 +117,7 @@ object SquigglySlider { ) @Stable - class SquigglesAnimator( + class SquigglesAnimator internal constructor( val animationProgress: State ) diff --git a/library/src/test/kotlin/me/saket/squiggles/SquigglySliderTest.kt b/library/src/test/kotlin/me/saket/squiggles/SquigglySliderTest.kt index 185f7cf..24b7d30 100644 --- a/library/src/test/kotlin/me/saket/squiggles/SquigglySliderTest.kt +++ b/library/src/test/kotlin/me/saket/squiggles/SquigglySliderTest.kt @@ -6,19 +6,23 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp import app.cash.paparazzi.DeviceConfig import app.cash.paparazzi.Paparazzi import com.android.ide.common.rendering.api.SessionParams.RenderingMode import org.junit.Rule import org.junit.Test +@OptIn(ExperimentalMaterial3Api::class) class SquigglySliderTest { @get:Rule val paparazzi = Paparazzi( deviceConfig = DeviceConfig.PIXEL_5, @@ -29,7 +33,10 @@ class SquigglySliderTest { @Test fun `zero slider value`() { paparazzi.snapshot { Scaffold { - TODO() + SquigglySlider( + value = 0f, + onValueChange = {}, + ) } } } @@ -37,7 +44,14 @@ class SquigglySliderTest { @Test fun `zero amplitude`() { paparazzi.snapshot { Scaffold { - TODO() + SquigglySlider( + value = 0.5f, + onValueChange = {}, + squigglesSpec = SquigglySlider.SquigglesSpec( + amplitude = 0.dp + ), + squigglesAnimator = SquigglySlider.SquigglesAnimator(animationProgress = mutableStateOf(0.5f)), + ) } } } @@ -45,7 +59,15 @@ class SquigglySliderTest { @Test fun `non-zero amplitude`() { paparazzi.snapshot { Scaffold { - TODO() + SquigglySlider( + value = 0.5f, + onValueChange = {}, + squigglesSpec = SquigglySlider.SquigglesSpec( + amplitude = 2.dp, + wavelength = 24.dp, + ), + squigglesAnimator = SquigglySlider.SquigglesAnimator(animationProgress = mutableStateOf(0.5f)), + ) } } } @@ -65,8 +87,3 @@ class SquigglySliderTest { } } } - -val Color.Companion.Whisper get() = Color(0XFFF8F5FA) -val Color.Companion.SeaBuckthorn get() = Color(0xFFF9A825) -val Color.Companion.Perfume get() = Color(0xFFD0BCFF) -val Color.Companion.GraySuit get() = Color(0xFFC1BAC9) diff --git a/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_non-zero amplitude.png b/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_non-zero amplitude.png new file mode 100644 index 0000000..0d69f2f Binary files /dev/null and b/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_non-zero amplitude.png differ diff --git a/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_zero amplitude.png b/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_zero amplitude.png new file mode 100644 index 0000000..8e71984 Binary files /dev/null and b/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_zero amplitude.png differ diff --git a/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_zero slider value.png b/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_zero slider value.png new file mode 100644 index 0000000..e9db955 Binary files /dev/null and b/library/src/test/snapshots/images/me.saket.squiggles_SquigglySliderTest_zero slider value.png differ