Make image viewer truly full screen
This commit is contained in:
1 parent
559e6c9226
commit
6d765ff6e4
3 files changed
+251
-9
No files matched your search
@@ -5,6 +5,80 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class SessionImageTest {
|
||||
@Test
|
||||
fun `a full-height image hides both bars`() {
|
||||
assertEquals(
|
||||
ViewerBars(status = true, navigation = true),
|
||||
viewerBars(
|
||||
imageWidth = 500,
|
||||
imageHeight = 1000,
|
||||
viewportWidth = 1000,
|
||||
viewportHeight = 2000,
|
||||
scale = 1f,
|
||||
offset = Offset.Zero,
|
||||
insets = ViewerBarInsets(status = 100, navigation = 100),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a letterboxed image leaves both bars visible`() {
|
||||
assertEquals(
|
||||
ViewerBars(),
|
||||
viewerBars(
|
||||
imageWidth = 1000,
|
||||
imageHeight = 500,
|
||||
viewportWidth = 1000,
|
||||
viewportHeight = 2000,
|
||||
scale = 1f,
|
||||
offset = Offset.Zero,
|
||||
insets = ViewerBarInsets(status = 100, navigation = 100),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `panning into the status bar hides only that bar`() {
|
||||
assertEquals(
|
||||
ViewerBars(status = true),
|
||||
viewerBars(
|
||||
imageWidth = 1000,
|
||||
imageHeight = 500,
|
||||
viewportWidth = 1000,
|
||||
viewportHeight = 2000,
|
||||
scale = 2f,
|
||||
offset = Offset(0f, -500f),
|
||||
insets = ViewerBarInsets(status = 100, navigation = 100),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `native scale reverses fitting a tall image`() {
|
||||
assertEquals(
|
||||
1.25f,
|
||||
nativeScale(
|
||||
imageWidth = 1000,
|
||||
imageHeight = 2000,
|
||||
viewportWidth = 1000,
|
||||
viewportHeight = 1600,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `native scale reverses enlarging a small image`() {
|
||||
assertEquals(
|
||||
0.5f,
|
||||
nativeScale(
|
||||
imageWidth = 500,
|
||||
imageHeight = 500,
|
||||
viewportWidth = 1000,
|
||||
viewportHeight = 1000,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `zoom keeps the region panned to in the center`() {
|
||||
assertEquals(
|
||||
|
||||
Reference in new issue
Block a user