Skip to content

Commit

Permalink
~test
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed May 29, 2024
1 parent dea42ae commit 4603a29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4603a29

Please sign in to comment.