Skip to content

Commit

Permalink
Add paparazzi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Dec 23, 2023
1 parent d40d29c commit 59a9b82
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object SquigglySlider {
)

@Stable
class SquigglesAnimator(
class SquigglesAnimator internal constructor(
val animationProgress: State<Float>
)

Expand Down
33 changes: 25 additions & 8 deletions library/src/test/kotlin/me/saket/squiggles/SquigglySliderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,23 +33,41 @@ class SquigglySliderTest {
@Test fun `zero slider value`() {
paparazzi.snapshot {
Scaffold {
TODO()
SquigglySlider(
value = 0f,
onValueChange = {},
)
}
}
}

@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)),
)
}
}
}

@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)),
)
}
}
}
Expand All @@ -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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 59a9b82

Please sign in to comment.