From 4603a299ce7145cccd19263dcb78e6c8a9b15726 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Wed, 29 May 2024 15:01:45 +0200 Subject: [PATCH] ~test --- .../orion/viewer/test/espresso/ScrollTest.kt | 10 ++++++++-- .../orion/viewer/view/PageLayoutManager.kt | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/orion-viewer/src/androidTest/kotlin/universe/constellation/orion/viewer/test/espresso/ScrollTest.kt b/orion-viewer/src/androidTest/kotlin/universe/constellation/orion/viewer/test/espresso/ScrollTest.kt index 9978179b..4ef23cc9 100644 --- a/orion-viewer/src/androidTest/kotlin/universe/constellation/orion/viewer/test/espresso/ScrollTest.kt +++ b/orion-viewer/src/androidTest/kotlin/universe/constellation/orion/viewer/test/espresso/ScrollTest.kt @@ -17,6 +17,7 @@ import universe.constellation.orion.viewer.lastPageNum0 import universe.constellation.orion.viewer.prefs.GlobalOptions import universe.constellation.orion.viewer.test.framework.BookFile import universe.constellation.orion.viewer.test.framework.onActivity +import universe.constellation.orion.viewer.view.height @RunWith(Parameterized::class) class ScrollTest(bookDescription: BookFile, newUI: Boolean, configuration: Configuration): BaseViewerActivityTestWithConfig(bookDescription, bookDescription.toOpenIntent { @@ -58,9 +59,14 @@ class ScrollTest(bookDescription: BookFile, newUI: Boolean, configuration: Confi onView(withId(R.id.view)).perform(swipeDown()) activityScenarioRule.scenario.onActivity { assertEquals(it.controller!!.document.filePath, bookDescription.asPath()) - val first = it.controller!!.pageLayoutManager.activePages.first() + val pageLayoutManager = it.controller!!.pageLayoutManager + val first = pageLayoutManager.activePages.first() + val yPos = pageLayoutManager.getCenteredYInSinglePageMode( + first.layoutData.position.y, + first.height + ) assertEquals(0, first.pageNum) - assertEquals(0f, first.layoutData.position.y, 0.0f) + assertEquals(yPos, first.layoutData.position.y, 0.0f) } } diff --git a/orion-viewer/src/main/java/universe/constellation/orion/viewer/view/PageLayoutManager.kt b/orion-viewer/src/main/java/universe/constellation/orion/viewer/view/PageLayoutManager.kt index 1464459d..0921c149 100644 --- a/orion-viewer/src/main/java/universe/constellation/orion/viewer/view/PageLayoutManager.kt +++ b/orion-viewer/src/main/java/universe/constellation/orion/viewer/view/PageLayoutManager.kt @@ -8,6 +8,7 @@ import androidx.core.math.MathUtils import kotlinx.coroutines.CompletableJob import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.Job +import org.jetbrains.annotations.TestOnly import universe.constellation.orion.viewer.BuildConfig import universe.constellation.orion.viewer.Controller import universe.constellation.orion.viewer.LastPageInfo @@ -452,7 +453,8 @@ class PageLayoutManager(val controller: Controller, val scene: OrionDrawScene) { return null } - private fun getCenteredYInSinglePageMode(y: Float, pageHeight: Int): Float { + @TestOnly + fun getCenteredYInSinglePageMode(y: Float, pageHeight: Int): Float { if (isSinglePageMode) { if (pageHeight <= sceneHeight) { return (sceneHeight - pageHeight) / 2.0f