This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-13 21:27:42 -04:00
1 parent 5fd47421f9
commit aecd2ebe1d
852 files changed
+4844 -46144

No files matched your search

@@ -21,7 +21,6 @@ class CardboardTest {
private fun assertVec(expected: FloatArray, actual: FloatArray) = assertArrayEquals(expected, actual, eps)
/** Rotation about a unit axis by an angle, as a quaternion (x, y, z, w). */
private fun quat(ax: Float, ay: Float, az: Float, deg: Double): FloatArray {
val h = deg * PI / 360.0
val s = sin(h).toFloat()
@@ -43,11 +42,8 @@ class CardboardTest {
}
@Test fun lensInsetLinesTheEyesUpWithTheLenses() {
// A 128 mm panel with 64 mm lenses: each viewport centre is 32 mm out, exactly under its lens.
assertEquals(0f, Cardboard.lensInset(128f, 64f), eps)
// A wider 150 mm panel: viewport centres 37.5 mm out, lenses 32 mm: 5.5 mm of a 75 mm viewport inwards.
assertEquals(5.5f / 75f, Cardboard.lensInset(150f, 64f), eps)
// A narrow panel puts the lens centres outside the viewport centres (negative inset).
assertEquals(true, Cardboard.lensInset(110f, 64f) < 0f)
assertEquals(0f, Cardboard.lensInset(0f, 64f), eps)
assertEquals(0f, Cardboard.lensInset(150f, 0f), eps)
@@ -62,7 +58,6 @@ class CardboardTest {
assertEquals(SteamVr.Status.READY, SteamVr.parse(answer("ok" to true, "installed" to true, "driver" to true)))
assertEquals(SteamVr.Status.RUNNING,
SteamVr.parse(answer("ok" to true, "installed" to true, "driver" to true, "running" to true)))
// The helper itself failed: the agent still says ok.
assertEquals(SteamVr.Status.UNAVAILABLE,
SteamVr.parse(answer("ok" to true, "installed" to true, "driver" to true).put("exitCode", 1)))
}
@@ -75,7 +70,6 @@ class CardboardTest {
}
assertTrue(SteamVr.succeeded("start", answer(true, exitCode = 0)))
assertTrue(SteamVr.succeeded("stop", answer(true, exitCode = 0)))
// The agent ran the request, but droiddeck-steamvr start failed (not installed, no driver).
assertFalse(SteamVr.succeeded("start", answer(true, exitCode = 1)))
assertFalse(SteamVr.succeeded("stop", answer(true, exitCode = 2)))
assertFalse(SteamVr.succeeded("start", answer(true)))
@@ -86,19 +80,14 @@ class CardboardTest {
}
@Test fun quaternionMatchesKnownRotations() {
// 90 degrees about z: x -> y.
val m = matrix(quat(0f, 0f, 1f, 90.0))
assertVec(floatArrayOf(0f, 1f, 0f), HeadPose.apply(m, floatArrayOf(1f, 0f, 0f)))
// Rotation vector without w: computed from the other three.
val q = HeadPose.quaternionFromRotationVector(floatArrayOf(0f, 0f, sin(PI / 4).toFloat()))
assertEquals(cos(PI / 4).toFloat(), q[3], eps)
}
@Test fun recenterMakesTheCurrentViewStraightAhead() {
// Phone upright in landscape, screen facing the viewer, who faces north-east-ish.
// Upright device: screen up = world up; looking direction = the screen's -z.
for (heading in listOf(0.0, 37.0, 140.0, -100.0)) {
// Start from "screen faces south, viewer looks north": device x = east, y = up, z = south.
val upright = floatArrayOf(1f, 0f, 0f, 0f, 0f, -1f, 0f, 1f, 0f)
val yaw = matrix(quat(0f, 0f, 1f, heading))
val screenToWorld = HeadPose.multiply(yaw, upright)
@@ -108,7 +97,6 @@ class CardboardTest {
@Test fun recenterKeepsPitchButDropsHeading() {
val upright = floatArrayOf(1f, 0f, 0f, 0f, 0f, -1f, 0f, 1f, 0f)
// Looking 30 degrees down, then turning 50 degrees: after a recentre the view is still 30 degrees down.
val pitched = HeadPose.multiply(upright, matrix(quat(1f, 0f, 0f, -30.0)))
val turned = HeadPose.multiply(matrix(quat(0f, 0f, 1f, 50.0)), pitched)
val pose = HeadPose.relative(HeadPose.recenter(turned), turned)
@@ -121,23 +109,18 @@ class CardboardTest {
@Test fun turningTheHeadTurnsTheView() {
val upright = floatArrayOf(1f, 0f, 0f, 0f, 0f, -1f, 0f, 1f, 0f)
val ref = HeadPose.recenter(upright)
// Turn the head 90 degrees to the left (counter-clockwise seen from above).
val turned = HeadPose.multiply(matrix(quat(0f, 0f, 1f, 90.0)), upright)
val forward = HeadPose.apply(HeadPose.relative(ref, turned), floatArrayOf(0f, 0f, -1f))
// The view now points to the left of the recentred forward direction: -x.
assertVec(floatArrayOf(-1f, 0f, 0f), forward)
}
@Test fun heldFlatTheViewStartsStraightAhead() {
// Screen facing up (device on a table, held like a tray, or lying back looking up at it).
for (m in listOf(HeadPose.IDENTITY, HeadPose.multiply(matrix(quat(0f, 0f, 1f, 30.0)), matrix(quat(1f, 0f, 0f, 20.0))))) {
assertVec(HeadPose.IDENTITY, HeadPose.relative(HeadPose.recenter(m), m))
}
}
@Test fun heldFlatTurningAtTheHipsPans() {
// Held flat, then the body turns 40 degrees to the left about the real vertical: the view
// turns left about its own up axis - it must not roll (the bug: yaw came out as a tilt).
val flat = HeadPose.IDENTITY
val ref = HeadPose.recenter(flat)
val turned = HeadPose.multiply(matrix(quat(0f, 0f, 1f, 40.0)), flat)
@@ -146,7 +129,6 @@ class CardboardTest {
val up = HeadPose.apply(pose, floatArrayOf(0f, 1f, 0f))
assertVec(floatArrayOf(-sin(PI * 40 / 180).toFloat(), 0f, -cos(PI * 40 / 180).toFloat()), forward)
assertVec(floatArrayOf(0f, 1f, 0f), up)
// Tipping the top edge down (pitching the tray towards you) looks down.
val tipped = HeadPose.multiply(flat, matrix(quat(1f, 0f, 0f, -20.0)))
val down = HeadPose.apply(HeadPose.relative(ref, tipped), floatArrayOf(0f, 0f, -1f))
assertEquals(-sin(PI / 9).toFloat(), down[1], eps)
@@ -154,7 +136,6 @@ class CardboardTest {
@Test fun fieldOfViewComesFromThePanelSeenThroughTheLens() {
val v2 = Cardboard.Viewer.CARDBOARD_V2
// A 74.7 mm tall panel 39.3 mm behind the lens: atan(37.35 / 39.3) = 43.5 degrees each way.
assertEquals(87.07f, Cardboard.fovDeg(v2, 74.7f), 0.05f)
assertEquals(v2.fallbackFovDeg, Cardboard.fovDeg(v2, 0f), eps)
assertEquals(Cardboard.Viewer.NONE.fallbackFovDeg, Cardboard.fovDeg(Cardboard.Viewer.NONE, 74.7f), eps)
@@ -165,11 +146,9 @@ class CardboardTest {
val n = sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]); floatArrayOf(q[0] / n, q[1] / n, q[2] / n, q[3] / n)
})
assertVec(r, HeadPose.toScreen(r, 0))
// ROTATION_90 (as input/PadMotion maps it): screen x is the device's -y, screen y the device's x.
val s90 = HeadPose.toScreen(r, 1)
assertVec(HeadPose.apply(r, floatArrayOf(0f, -1f, 0f)), HeadPose.apply(s90, floatArrayOf(1f, 0f, 0f)))
assertVec(HeadPose.apply(r, floatArrayOf(1f, 0f, 0f)), HeadPose.apply(s90, floatArrayOf(0f, 1f, 0f)))
// ROTATION_270 is the opposite turn; four quarter turns of 90 give the original back.
val s270 = HeadPose.toScreen(r, 3)
assertVec(HeadPose.apply(r, floatArrayOf(0f, 1f, 0f)), HeadPose.apply(s270, floatArrayOf(1f, 0f, 0f)))
assertVec(r, HeadPose.toScreen(HeadPose.toScreen(HeadPose.toScreen(HeadPose.toScreen(r, 1), 1), 1), 1))
@@ -34,7 +34,6 @@ class DriverBundleTest {
SessionPrefs.setLinuxDriver(context, "")
}
/** Enough of an AArch64 ELF for the importers: the header they read, then the libc they look for. */
private fun library(libc: String) = ByteArray(64).also {
byteArrayOf(0x7f, 'E'.code.toByte(), 'L'.code.toByte(), 'F'.code.toByte(), 2, 1).copyInto(it)
it[18] = 0xB7.toByte()
@@ -60,7 +60,6 @@ class DriverPairsTest {
listOf(
asset("Turnip-r4.zip", "r4", false, DriverPairs.BANNER),
asset("Turnip-r4-Linux.zip", "r4", true, DriverPairs.BANNER),
// The A8xx set's newest display build is r4, but its Linux half is only in r3.
asset("Turnip-r4-A8xx.zip", "r4", false, DriverPairs.BANNER_A8XX),
asset("Turnip-r3-A8xx-Linux.zip", "r3", true, DriverPairs.BANNER_A8XX),
asset("WN-Turnip-1.19-b_Axxx.zip", "v1.19", false, DriverPairs.WN_BALANCED),
@@ -5,7 +5,6 @@ import org.junit.Test
class GpuModelFallbackTest {
@Test fun aPlatformCodeNameGivesItsAdreno() {
// AYANEO's Pocket FIT: KGSL says "Adreno33v2", the platform says pineapple.
assertEquals(750, GpuInfo.platformModel("pineapple"))
assertEquals(740, GpuInfo.platformModel("KALAMA"))
assertEquals(830, GpuInfo.platformModel("sun"))
@@ -8,7 +8,6 @@ class SocNamesTest {
private fun props(vararg pairs: Pair<String, String>): (String) -> String = { pairs.toMap()[it].orEmpty() }
@Test fun theModelIsFoundWhereVendorsPutIt() {
// AYANEO Pocket FIT: ro.soc.model blank, the vendor property set, ro.fota.platform a branch name.
assertEquals("SG8350P", SocNames.model(props("ro.vendor.qti.soc_model" to "SG8350P", "ro.fota.platform" to "MSM_13.0")))
assertEquals("QCS8550", SocNames.model(props("ro.soc.model" to "QCS8550", "ro.vendor.qti.soc_model" to "other")))
assertEquals("", SocNames.model(props("ro.fota.platform" to "MSM_13.0")))