Skip to content

Commit

Permalink
Add a bad test for #104
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Dec 9, 2024
1 parent d274f1a commit f743f3e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zoomable-image/core/src/androidTest/assets/fox_1000.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,43 @@ class ZoomableImageTest {
}
}

@Test fun retain_transformations_across_image_changes_with_the_same_aspect_ratio() {
var assetName by mutableStateOf("fox_1000.jpg")
lateinit var state: ZoomableImageState

rule.setContent {
ZoomableImage(
modifier = Modifier
.fillMaxSize()
.testTag("image"),
image = ZoomableImageSource.asset(assetName, subSample = true),
contentDescription = null,
state = rememberZoomableImageState(
rememberZoomableState(zoomSpec = ZoomSpec(maxZoomFactor = 5f))
).also { state = it },
)
}

rule.waitUntil {
state.isImageDisplayedInFullQuality
}
rule.onNodeWithTag("image").performTouchInput {
doubleClick(position = center + Offset(100f, 100f))
}
rule.runOnIdle {
dropshots.assertSnapshot(rule.activity, testName.methodName + "_[before]")
}

assetName = "fox_1500.jpg"
rule.waitUntil {
val isTargetImage = state.zoomableState.contentTransformation.contentSize == Size(1500f, 1000f)
state.isImageDisplayedInFullQuality && isTargetImage
}
rule.runOnIdle {
dropshots.assertSnapshot(rule.activity, testName.methodName + "_[after]")
}
}

@Test fun various_image_sizes_and_alignments(
@TestParameter alignment: AlignmentParam,
@TestParameter contentScale: ContentScaleParam,
Expand Down
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 f743f3e

Please sign in to comment.