Skip to content

Commit

Permalink
Update test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed Sep 29, 2023
1 parent 76cb79d commit ad539c8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
api-level: [29]
api-level: [16, 25]
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.concurrent.CountDownLatch
@RunWith(Parameterized::class)
class RenderingAndNavigationTest(path: String) : InstrumentationTestCase() {

companion object {
companion object {
@JvmStatic
@Parameterized.Parameters(name = "Test simple navigation in {0}")
fun testData(): Iterable<Array<Any>> {
Expand All @@ -44,7 +44,9 @@ class RenderingAndNavigationTest(path: String) : InstrumentationTestCase() {
}
}

private val document = openTestBook(path)
private val document by lazy {
openTestBook(path)
}

private val deviceSize = Point(300, 350) //to split page on two screen - page size is 663x886

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ class RotationTest : InstrumentationTestCase() {

Assert.assertTrue(width != 0)
Assert.assertTrue(height != 0)
//OptionActions.FULL_SCREEN.doAction(getActivity(), true, false)
val orientation = activity.resources!!.configuration.orientation

val latch = CountDownLatch(1)
mActivityRule.runOnUiThread {
getController().changeOrinatation(if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) "PORTRAIT" else "LANDSCAPE")
latch.countDown()
}

latch.await()
Thread.sleep(1000)

try {
Assert.assertTrue("Orientation not changed: $orientation", orientation != activity.resources!!.configuration.orientation)

val width2 = view.sceneWidth
val height2 = view.sceneHeight
Assert.assertTrue("w1: $width, w2: $width2, original orientation: $orientation", width != width2)
Assert.assertTrue("h1: $height, h2: $$height2, original orientation: $orientation", height != height2)
} finally {
mActivityRule.runOnUiThread {
getController().changeOrinatation("PORTRAIT")
}
Thread.sleep(1000)
mActivityRule.finishActivity()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
abstract class BookTest(path: String) : BaseTest() {

protected val document = openTestBook(path)
protected val document by lazy { openTestBook(path) }

@After
fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ package universe.constellation.orion.viewer.test.framework

import android.content.Context
import android.content.Intent
import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule
import org.junit.Rule
import universe.constellation.orion.viewer.Controller
import universe.constellation.orion.viewer.OrionViewerActivity
import androidx.test.rule.ActivityTestRule


abstract class InstrumentationTestCase : TestUtil {

@Rule
@JvmField
@get:Rule
val mRuntimePermissionRule: GrantPermissionRule = GrantPermissionRule.grant(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE)

@Rule
@JvmField
var mActivityRule: ActivityTestRule<OrionViewerActivity> = ActivityTestRule(OrionViewerActivity::class.java, true, false)
@get:Rule
val mActivityRule: ActivityTestRule<OrionViewerActivity> = ActivityTestRule(OrionViewerActivity::class.java, true, false)

val activity: OrionViewerActivity
get() = mActivityRule.activity
Expand Down

0 comments on commit ad539c8

Please sign in to comment.