mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
feat: add SDK-free 3DoF tracking for VITURE Pro 2 (#1115)
* feat: itch.io store, library and installs for DRM-free Windows builds (#1064) * feat: add experimental SDK-free VITURE Pro 2 tracking * docs: record full-app Pro 2 hardware validation * docs: record successful Pro 2 user game test * fix: translate Pro 2 tracking notice for all supported locales * fix: respect model capabilities for glasses controls * fix: handle fold configuration during glasses probe --------- Co-authored-by: kingokksa <47888451+kingokksa@users.noreply.github.com> Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
1 parent
7482f797c7
commit
3d9f200a7e
66 files changed
+2974
-19
No files matched your search
@@ -13,6 +13,11 @@ import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.LooperMode
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
@@ -232,4 +237,95 @@ class GlassesCallbacksTest {
|
||||
field("sink").set(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pro2CallbacksUseSharedPoseAndRejectThePreviousConnection() {
|
||||
fun v2(gen: Long) = Glasses::class.java.getDeclaredMethod("v2Listener", Long::class.javaPrimitiveType)
|
||||
.apply { isAccessible = true }.invoke(Glasses, gen) as VitureV2Link.Listener
|
||||
var delivered: FloatArray? = null
|
||||
var timestamp = 0L
|
||||
field("sink").set(null, Glasses.PoseSink { x, y, z, w, time ->
|
||||
delivered = floatArrayOf(x, y, z, w)
|
||||
timestamp = time
|
||||
})
|
||||
try {
|
||||
val q = floatArrayOf(0f, 0f, 0.6f, 0.8f)
|
||||
v2(0).onPose(ByteArray(24), q, 100)
|
||||
assertEquals(null, delivered)
|
||||
v2(1).onPose(ByteArray(24), q, 101)
|
||||
org.junit.Assert.assertArrayEquals(q, delivered, 0f)
|
||||
assertEquals(101L, timestamp)
|
||||
assertEquals(1L, field("imuPackets").getLong(null))
|
||||
v2(1).onValue(VitureProtocol.MSG_GET_DISPLAY, 0x32)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertFalse(Glasses.state.value.sbs)
|
||||
v2(1).onValue(VitureProtocol.MSG_GET_BRIGHTNESS, 8)
|
||||
v2(1).onReady()
|
||||
v2(1).onTracking(true)
|
||||
v2(1).onLost()
|
||||
generation(2)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertEquals(2, Glasses.state.value.brightness)
|
||||
assertTrue(Glasses.state.value.connected)
|
||||
assertFalse(Glasses.state.value.supportsScreen3dof)
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
} finally { field("sink").set(null, null) }
|
||||
}
|
||||
|
||||
@Test fun pro2DemandEndingBeforeTheFirstRestartPoseStillStopsTheStream() {
|
||||
val writes = LinkedBlockingQueue<ByteArray>()
|
||||
val incoming = LinkedBlockingQueue<VitureV2Link.Received>()
|
||||
val firstPose = CountDownLatch(1)
|
||||
val firstRead = CountDownLatch(1)
|
||||
val delegate = Glasses::class.java.getDeclaredMethod("v2Listener", Long::class.javaPrimitiveType)
|
||||
.apply { isAccessible = true }.invoke(Glasses, 1L) as VitureV2Link.Listener
|
||||
val listener = object : VitureV2Link.Listener by delegate {
|
||||
override fun onPose(raw: ByteArray, q: FloatArray, timeNs: Long) {
|
||||
delegate.onPose(raw, q, timeNs)
|
||||
firstPose.countDown()
|
||||
}
|
||||
}
|
||||
val transport = object : VitureV2Link.Transport {
|
||||
override fun write(packet: ByteArray): Boolean { writes += packet; return true }
|
||||
override fun read(timeoutMs: Long): VitureV2Link.Received? {
|
||||
firstRead.countDown()
|
||||
return incoming.poll(timeoutMs, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
override fun close() {}
|
||||
}
|
||||
fun expectStream(stream: Int) = org.junit.Assert.assertArrayEquals(
|
||||
VitureV2Protocol.imuControl(stream), writes.poll(2, TimeUnit.SECONDS))
|
||||
fun updateImu() = Glasses::class.java.getDeclaredMethod("updateImu")
|
||||
.apply { isAccessible = true }.invoke(Glasses)
|
||||
val link = VitureV2Link(transport, listener)
|
||||
field("link").set(null, link)
|
||||
field("sink").set(null, null)
|
||||
try {
|
||||
expectStream(VitureV2Protocol.STREAM_POSE)
|
||||
assertTrue("Bootstrap write did not complete", firstRead.await(2, TimeUnit.SECONDS))
|
||||
val payload = ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0).putInt(1).putFloat(1f).putFloat(0f).putFloat(0f).putFloat(0f).array()
|
||||
incoming += VitureV2Link.Received(VitureV2Protocol.packet(VitureV2Protocol.EVENT_POSE, payload), System.nanoTime())
|
||||
assertTrue(firstPose.await(2, TimeUnit.SECONDS))
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
expectStream(VitureV2Protocol.STREAM_OFF)
|
||||
assertTrue(Glasses.state.value.supportsScreen3dof)
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
|
||||
field("sink").set(null, Glasses.PoseSink { _, _, _, _, _ -> })
|
||||
updateImu()
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
field("sink").set(null, null)
|
||||
updateImu()
|
||||
expectStream(VitureV2Protocol.STREAM_POSE)
|
||||
expectStream(VitureV2Protocol.STREAM_OFF)
|
||||
assertFalse(link.trackingActive)
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
} finally {
|
||||
generation(2)
|
||||
link.close()
|
||||
field("link").set(null, null)
|
||||
field("sink").set(null, null)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,58 @@ class GlassesUsbTest {
|
||||
assertEquals(listOf(gt), manager.requests)
|
||||
}
|
||||
|
||||
@Test fun pro2RequestsPermissionWithoutTheSdkAndDoesNotClaimCompanionProducts() {
|
||||
val pro2 = device(0x1301, name = "VITURE Luma Ultra")
|
||||
manager.devices[pro2.deviceName] = pro2
|
||||
refresh(ask = true)
|
||||
assertEquals("VITURE Pro 2", state.value.model)
|
||||
assertTrue(state.value.controllable)
|
||||
assertTrue(state.value.experimental)
|
||||
assertFalse(state.value.hardwareControls)
|
||||
assertFalse(state.value.supportsDisplayModeControl)
|
||||
assertFalse(state.value.supportsScreen3dof)
|
||||
assertFalse(state.value.supportsSpatial)
|
||||
assertEquals(listOf(pro2), manager.requests)
|
||||
assertEquals(null, Glasses.deviceModel(device(0x1301, 0x1234, "VITURE Pro 2")))
|
||||
assertEquals(null, Glasses.deviceModel(device(0x1102, name = "VITURE Pro 2")))
|
||||
assertEquals(null, Glasses.deviceModel(device(0x1302, name = "VITURE Pro 2")))
|
||||
val ultra = Glasses.deviceModel(device(0x1104)) as VitureProtocol.Model
|
||||
assertEquals(VitureProtocol.Family.ULTRA, ultra.family)
|
||||
assertTrue(ultra.needsSdk)
|
||||
}
|
||||
|
||||
@Test fun pro2PoseAvailabilityDoesNotEnableDisplayOrHardwareWrites() {
|
||||
val pro2 = device(0x1301)
|
||||
manager.devices[pro2.deviceName] = pro2
|
||||
manager.granted.add(pro2.deviceName)
|
||||
val sent = mutableListOf<Int>()
|
||||
field("linkDevice").set(null, pro2)
|
||||
field("link").set(null, object : GlassesLink {
|
||||
override val hasImu = true
|
||||
override fun send(msgId: Int, payload: ByteArray): Boolean { sent += msgId; return true }
|
||||
override fun close() {}
|
||||
})
|
||||
try {
|
||||
refresh()
|
||||
assertTrue(state.value.canControl)
|
||||
assertTrue(state.value.supportsScreen3dof)
|
||||
assertFalse(state.value.can3d)
|
||||
assertFalse(state.value.supportsDisplayModeControl)
|
||||
assertFalse(state.value.hardwareControls)
|
||||
assertEquals(0, state.value.brightnessMax)
|
||||
assertEquals(0, state.value.volumeMax)
|
||||
Glasses.sendMode(0x32)
|
||||
Glasses.setBrightness(5)
|
||||
Glasses.setVolume(5)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertTrue(sent.isEmpty())
|
||||
} finally {
|
||||
field("link").set(null, null)
|
||||
field("linkDevice").set(null, null)
|
||||
(field("handler").get(null) as Handler).removeCallbacksAndMessages(null)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun gtVendorRequestsPermissionAndRetainsMaxProductName() {
|
||||
val gt = device(0xaf50, 0x3941, "RayNeo GT MAX")
|
||||
manager.devices[gt.deviceName] = gt
|
||||
|
||||
@@ -130,6 +130,31 @@ class VitureProtocolTest {
|
||||
assertArrayEquals(floatArrayOf(0f, 0f, sin(half).toFloat(), cos(half).toFloat()), q, 1e-5f)
|
||||
}
|
||||
|
||||
@Test fun directPro2KeepsSdkOnlyFamiliesAndUnknownProductsIsolated() {
|
||||
val direct = VitureProtocol.model(0x1301, "VITURE Luma Ultra")!!
|
||||
assertEquals("VITURE Pro 2", direct.name)
|
||||
assertEquals(VitureProtocol.Family.PRO2, direct.family)
|
||||
assertFalse(direct.needsSdk)
|
||||
assertFalse(direct.hardwareControls)
|
||||
assertFalse(direct.supportsDisplayModeControl)
|
||||
assertFalse(direct.hasSunblock)
|
||||
assertEquals(0, direct.brightnessMax)
|
||||
assertEquals(0, direct.volumeMax)
|
||||
|
||||
for (pid in listOf(0x1101, 0x1104, 0x1201, 0x1211)) {
|
||||
val model = VitureProtocol.model(pid, null)!!
|
||||
assertTrue(model.needsSdk)
|
||||
assertTrue(model.hardwareControls)
|
||||
assertTrue(model.supportsDisplayModeControl)
|
||||
}
|
||||
assertNull(VitureProtocol.model(0x1102, "VITURE Pro 2"))
|
||||
assertNull(VitureProtocol.model(0x1302, "VITURE Pro 2"))
|
||||
val sdk = VitureProtocol.sdkModel("Pro 2")!!
|
||||
assertTrue(sdk.needsSdk)
|
||||
assertTrue(sdk.hardwareControls)
|
||||
assertTrue(sdk.supportsDisplayModeControl)
|
||||
}
|
||||
|
||||
@Test fun imuFallsBackToEuler() {
|
||||
val payload = ByteBuffer.allocate(12).putFloat(0f).putFloat(0f).putFloat(30f).array()
|
||||
val q = VitureProtocol.imuQuaternion(payload)!!
|
||||
|
||||
@@ -0,0 +1,404 @@
|
||||
package com.droiddeck.launcher.glasses
|
||||
|
||||
import com.droiddeck.launcher.gpu.HeadPose
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.math.sqrt
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class VitureV2LinkTest {
|
||||
private val transport = FakeTransport()
|
||||
private val listener = RecordingListener()
|
||||
private var link: VitureV2Link? = null
|
||||
|
||||
@After fun close() { link?.close() }
|
||||
|
||||
@Test fun writeAndAckDoNotBecomeReadyWithoutAValidPose() {
|
||||
val link = start()
|
||||
transport.feed(ack())
|
||||
transport.feed(pose(1).also { it[8] = (it[8].toInt() xor 1).toByte() })
|
||||
transport.feed(pose(2, floatArrayOf(0f, 0f, 0f, 0f)))
|
||||
transport.feed(VitureV2Protocol.packet(VitureV2Protocol.EVENT_RAW, ByteArray(56)))
|
||||
transport.flush()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.hasImu)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(0, listener.readyCount.get())
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
assertEquals(2L, link.badFrames)
|
||||
|
||||
val receiptTime = System.nanoTime()
|
||||
val valid = pose(3)
|
||||
transport.feed(valid, receiptTime)
|
||||
transport.flush()
|
||||
assertTrue(link.ready)
|
||||
assertTrue(link.hasImu)
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(listOf(true), listener.tracking)
|
||||
assertEquals(1, listener.poses.size)
|
||||
assertEquals(receiptTime, listener.poses.single().timeNs)
|
||||
assertArrayEquals(valid, listener.poses.single().raw)
|
||||
}
|
||||
|
||||
@Test fun duplicatesAndBackwardTicksAreDroppedWhileUnsignedWrapAdvances() {
|
||||
start()
|
||||
for (tick in listOf(0xFFFFFFFEL, 0xFFFFFFFEL, 0xFFFFFFFDL, 0L, 0L, 0xFFFFFFFFL, 1L)) {
|
||||
transport.feed(pose(tick))
|
||||
}
|
||||
transport.flush()
|
||||
assertEquals(3, listener.poses.size)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(listOf(true), listener.tracking)
|
||||
assertEquals(0L, link!!.badFrames)
|
||||
}
|
||||
|
||||
@Test fun poseCollectedDuringBootstrapWriteDoesNotEstablishReadiness() {
|
||||
transport.collectDuringNextWrite(pose(1))
|
||||
val link = start()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
|
||||
transport.feed(pose(2))
|
||||
transport.flush()
|
||||
assertTrue(link.ready)
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(1, listener.poses.size)
|
||||
}
|
||||
|
||||
@Test fun poseCollectedDuringResumeWriteDoesNotRestartTracking() {
|
||||
val link = startReady(100)
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.flush()
|
||||
|
||||
transport.collectDuringNextWrite(pose(101))
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.flush()
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.poses.size)
|
||||
|
||||
transport.feed(pose(102))
|
||||
transport.flush()
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(2, listener.poses.size)
|
||||
assertEquals(listOf(true, false, true), listener.tracking)
|
||||
}
|
||||
|
||||
@Test fun stoppingAndRestartingRequiresANewPoseAndRejectsQueuedOldSamples() {
|
||||
val link = startReady(100)
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0)))
|
||||
assertFalse(link.trackingActive)
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.feed(pose(101))
|
||||
transport.feed(ack())
|
||||
transport.flush()
|
||||
assertEquals(1, listener.poses.size)
|
||||
assertTrue(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
|
||||
val beforeRestart = System.nanoTime()
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.feed(pose(102), beforeRestart)
|
||||
transport.feed(ack())
|
||||
transport.flush()
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.poses.size)
|
||||
|
||||
transport.feed(pose(0))
|
||||
transport.flush()
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(2, listener.poses.size)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(listOf(true, false, true), listener.tracking)
|
||||
}
|
||||
|
||||
@Test fun onReadyCanStopBootstrapBeforeTheFirstPoseIsForwarded() {
|
||||
val link = start()
|
||||
listener.whenReady = { assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0))) }
|
||||
transport.feed(pose(1))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.flush()
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertTrue(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
}
|
||||
|
||||
@Test fun rapidStopStartCannotAcceptThePreviousStreamsPendingRead() {
|
||||
val link = startReady()
|
||||
val held = transport.hold(pose(2))
|
||||
try {
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0)))
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
} finally {
|
||||
held.release.countDown()
|
||||
}
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.flush()
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.poses.size)
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
|
||||
transport.feed(pose(3))
|
||||
transport.flush()
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(2, listener.poses.size)
|
||||
}
|
||||
|
||||
@Test fun onReadyCanCloseWithoutForwardingAPoseOrReportingLoss() {
|
||||
val link = start()
|
||||
listener.whenReady = link::close
|
||||
transport.feed(pose(1))
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
assertEquals(0, listener.lostCount.get())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun unsupportedSettersNeverProduceWritesAndQueriesKeepGenericIds() {
|
||||
val link = startReady()
|
||||
for ((id, payload) in listOf(
|
||||
VitureProtocol.MSG_BRIGHTNESS to byteArrayOf(3),
|
||||
VitureProtocol.MSG_VOLUME to byteArrayOf(3),
|
||||
VitureProtocol.MSG_DISPLAY to byteArrayOf(0x32),
|
||||
VitureProtocol.MSG_FILM to byteArrayOf(1),
|
||||
VitureProtocol.MSG_IMU_RATE to byteArrayOf(3),
|
||||
VitureProtocol.MSG_IMU to byteArrayOf(2),
|
||||
VitureProtocol.MSG_IMU to byteArrayOf(),
|
||||
VitureProtocol.MSG_GET_VOLUME to byteArrayOf(1),
|
||||
)) assertFalse("msgId=$id", link.send(id, payload))
|
||||
assertTrue(link.send(VitureProtocol.MSG_GET_IMU, byteArrayOf()))
|
||||
transport.flush()
|
||||
assertTrue(transport.writes.isEmpty())
|
||||
|
||||
val queries = listOf(
|
||||
Triple(VitureProtocol.MSG_GET_BRIGHTNESS, VitureV2Protocol.MSG_GET_BRIGHTNESS, 3),
|
||||
Triple(VitureProtocol.MSG_GET_VOLUME, VitureV2Protocol.MSG_GET_VOLUME, 5),
|
||||
Triple(VitureProtocol.MSG_GET_DISPLAY, VitureV2Protocol.MSG_GET_DISPLAY, 0x31),
|
||||
)
|
||||
for ((genericId, wireId, value) in queries) {
|
||||
assertTrue(link.send(genericId, byteArrayOf()))
|
||||
transport.expectWrite(VitureV2Protocol.packet(wireId))
|
||||
transport.feed(VitureV2Protocol.packet(wireId + VitureV2Protocol.RESPONSE_OFFSET,
|
||||
byteArrayOf(0, value.toByte())))
|
||||
}
|
||||
transport.feed(VitureV2Protocol.packet(VitureV2Protocol.MSG_GET_VOLUME + VitureV2Protocol.RESPONSE_OFFSET,
|
||||
byteArrayOf(1, 7)))
|
||||
transport.feed(VitureV2Protocol.packet(VitureV2Protocol.MSG_GET_VOLUME + VitureV2Protocol.RESPONSE_OFFSET,
|
||||
byteArrayOf(0, 7, 8)))
|
||||
transport.flush()
|
||||
assertEquals(queries.map { it.first to it.third }, listener.values)
|
||||
}
|
||||
|
||||
@Test fun failureToWriteBootstrapClosesTransportAndReportsLoss() {
|
||||
transport.failNextWrite.set(true)
|
||||
val link = VitureV2Link(transport, listener).also { this.link = it }
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.hasImu)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(0, listener.readyCount.get())
|
||||
assertEquals(1, listener.lostCount.get())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun rejectedStreamAckClosesWithoutMarkingTrackingActive() {
|
||||
val link = start()
|
||||
transport.feed(ack(status = 7))
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.lostCount.get())
|
||||
assertEquals(0, listener.readyCount.get())
|
||||
assertTrue(listener.tracking.isEmpty())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun readFailureClearsTrackingAndClosesTransport() {
|
||||
val link = startReady()
|
||||
transport.disconnect()
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
assertEquals(1, listener.lostCount.get())
|
||||
assertFalse(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun explicitCloseSendsOffOnceAndDoesNotReportLoss() {
|
||||
val link = startReady()
|
||||
link.close()
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
assertEquals(0, listener.lostCount.get())
|
||||
assertEquals(1, transport.closeCount.get())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
link.close()
|
||||
assertFalse(link.send(VitureProtocol.MSG_GET_BRIGHTNESS, byteArrayOf()))
|
||||
assertEquals(1, transport.closeCount.get())
|
||||
assertTrue(transport.writes.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun sharedPoseProducesTheSourceRightUpBackRelativeRotation() {
|
||||
startReady()
|
||||
val baseline = listener.poses.single().q
|
||||
val reference = HeadPose.recenter(HeadPose.fromGlasses(baseline[0], baseline[1], baseline[2], baseline[3]),
|
||||
centerView = true)
|
||||
val half = sqrt(0.5f)
|
||||
val rotations = listOf(
|
||||
floatArrayOf(half, half, 0f, 0f),
|
||||
floatArrayOf(half, 0f, half, 0f),
|
||||
floatArrayOf(half, 0f, 0f, half),
|
||||
floatArrayOf(0.5f, -0.5f, 0.5f, -0.5f),
|
||||
)
|
||||
rotations.forEachIndexed { index, q -> transport.feed(pose(index + 2L, q)) }
|
||||
transport.flush()
|
||||
for ((source, event) in rotations.zip(listener.poses.drop(1))) {
|
||||
val q = event.q
|
||||
val relative = HeadPose.relative(reference, HeadPose.fromGlasses(q[0], q[1], q[2], q[3]))
|
||||
assertArrayEquals(HeadPose.fromQuaternion(source[1], source[2], source[3], source[0]), relative, 1e-5f)
|
||||
}
|
||||
assertEquals(rotations.size + 1, listener.poses.size)
|
||||
}
|
||||
|
||||
private fun start(): VitureV2Link = VitureV2Link(transport, listener).also {
|
||||
link = it
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.flush()
|
||||
}
|
||||
|
||||
private fun startReady(tick: Long = 1): VitureV2Link = start().also {
|
||||
transport.feed(pose(tick))
|
||||
transport.flush()
|
||||
assertTrue(it.ready)
|
||||
}
|
||||
|
||||
private fun ack(status: Int = 0) = VitureV2Protocol.packet(
|
||||
VitureV2Protocol.MSG_IMU_CONTROL + VitureV2Protocol.RESPONSE_OFFSET, byteArrayOf(status.toByte()))
|
||||
|
||||
private fun pose(tick: Long, wxyz: FloatArray = floatArrayOf(1f, 0f, 0f, 0f)): ByteArray {
|
||||
val payload = ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0x126).putInt(tick.toInt())
|
||||
wxyz.forEach(payload::putFloat)
|
||||
return VitureV2Protocol.packet(VitureV2Protocol.EVENT_POSE, payload.array())
|
||||
}
|
||||
|
||||
private data class PoseEvent(val raw: ByteArray, val q: FloatArray, val timeNs: Long)
|
||||
|
||||
private class RecordingListener : VitureV2Link.Listener {
|
||||
val readyCount = AtomicInteger()
|
||||
val lostCount = AtomicInteger()
|
||||
val tracking = CopyOnWriteArrayList<Boolean>()
|
||||
val values = CopyOnWriteArrayList<Pair<Int, Int>>()
|
||||
val poses = CopyOnWriteArrayList<PoseEvent>()
|
||||
@Volatile var whenReady: (() -> Unit)? = null
|
||||
override fun onReady() { readyCount.incrementAndGet(); whenReady?.invoke() }
|
||||
override fun onValue(msgId: Int, value: Int) { values += msgId to value }
|
||||
override fun onPose(raw: ByteArray, q: FloatArray, timeNs: Long) { poses += PoseEvent(raw.copyOf(), q.copyOf(), timeNs) }
|
||||
override fun onTracking(active: Boolean) { tracking += active }
|
||||
override fun onLost() { lostCount.incrementAndGet() }
|
||||
}
|
||||
|
||||
private sealed interface ReadStep {
|
||||
data class Packet(val received: VitureV2Link.Received) : ReadStep
|
||||
data class Barrier(val reached: CountDownLatch) : ReadStep
|
||||
data class HeldPacket(
|
||||
val received: VitureV2Link.Received,
|
||||
val entered: CountDownLatch = CountDownLatch(1),
|
||||
val release: CountDownLatch = CountDownLatch(1),
|
||||
) : ReadStep
|
||||
data object Disconnected : ReadStep
|
||||
}
|
||||
|
||||
private class FakeTransport : VitureV2Link.Transport {
|
||||
val writes = LinkedBlockingQueue<ByteArray>(64)
|
||||
val closeCount = AtomicInteger()
|
||||
val failNextWrite = AtomicBoolean()
|
||||
private val collectedDuringWrite = AtomicReference<ByteArray?>()
|
||||
private val incoming = LinkedBlockingQueue<ReadStep>(128)
|
||||
private val closed = CountDownLatch(1)
|
||||
|
||||
override fun write(packet: ByteArray): Boolean {
|
||||
check(writes.offer(packet.copyOf()))
|
||||
val success = !failNextWrite.getAndSet(false)
|
||||
if (success) collectedDuringWrite.getAndSet(null)?.let { feed(it, System.nanoTime()) }
|
||||
return success
|
||||
}
|
||||
|
||||
override fun read(timeoutMs: Long): VitureV2Link.Received? = when (
|
||||
val step = incoming.poll(timeoutMs, TimeUnit.MILLISECONDS)
|
||||
) {
|
||||
is ReadStep.Packet -> step.received
|
||||
is ReadStep.Barrier -> { step.reached.countDown(); null }
|
||||
is ReadStep.HeldPacket -> {
|
||||
step.entered.countDown()
|
||||
check(step.release.await(2, TimeUnit.SECONDS))
|
||||
step.received
|
||||
}
|
||||
ReadStep.Disconnected -> throw IOException("Device disconnected")
|
||||
null -> null
|
||||
}
|
||||
|
||||
override fun close() { closeCount.incrementAndGet(); closed.countDown() }
|
||||
|
||||
fun feed(packet: ByteArray, timeNs: Long = System.nanoTime()) {
|
||||
check(incoming.offer(ReadStep.Packet(VitureV2Link.Received(packet.copyOf(), timeNs))))
|
||||
}
|
||||
|
||||
fun collectDuringNextWrite(packet: ByteArray) {
|
||||
check(collectedDuringWrite.compareAndSet(null, packet.copyOf()))
|
||||
}
|
||||
|
||||
fun disconnect() { check(incoming.offer(ReadStep.Disconnected)) }
|
||||
|
||||
fun hold(packet: ByteArray): ReadStep.HeldPacket {
|
||||
val held = ReadStep.HeldPacket(VitureV2Link.Received(packet.copyOf(), System.nanoTime()))
|
||||
check(incoming.offer(held))
|
||||
assertTrue("Worker did not enter the held read", held.entered.await(2, TimeUnit.SECONDS))
|
||||
return held
|
||||
}
|
||||
|
||||
fun expectWrite(expected: ByteArray) {
|
||||
assertArrayEquals(expected, writes.poll(2, TimeUnit.SECONDS))
|
||||
}
|
||||
|
||||
fun flush() {
|
||||
val reached = CountDownLatch(1)
|
||||
check(incoming.offer(ReadStep.Barrier(reached)))
|
||||
assertTrue("Worker did not consume queued reports", reached.await(2, TimeUnit.SECONDS))
|
||||
}
|
||||
|
||||
fun awaitClosed() { assertTrue("Transport did not close", closed.await(2, TimeUnit.SECONDS)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// Fixtures adapted from elasticjava/viture-v2, MIT, Copyright (c) 2026 Holger Bartnick.
|
||||
// Source: ece8c30485f7d357fefa362ae74f3eabac9b3899; see docs/third-party/viture-v2/.
|
||||
package com.droiddeck.launcher.glasses
|
||||
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import kotlin.math.sqrt
|
||||
|
||||
class VitureV2ProtocolTest {
|
||||
@Test fun requestsMatchUpstreamWireExamples() {
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 03 00 01 02"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 04 00 02 02"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_RAW))
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 00 00 00 00"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
assertArrayEquals(hex("10 00 22 31 00 00 00 00"),
|
||||
VitureV2Protocol.packet(VitureV2Protocol.MSG_GET_BRIGHTNESS))
|
||||
}
|
||||
|
||||
@Test fun requestBoundsAndStreamLimitsAreEnforced() {
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.packet(-1) }
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.packet(0x10000) }
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.packet(0, ByteArray(57)) }
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.imuControl(3) }
|
||||
assertThrows(IllegalArgumentException::class.java) {
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE, VitureV2Protocol.Rate.HZ_500)
|
||||
}
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 07 00 02 05"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_RAW, VitureV2Protocol.Rate.HZ_1000))
|
||||
val maximum = VitureV2Protocol.packet(0xFFFF, ByteArray(56) { 0xFF.toByte() })
|
||||
assertEquals(64, maximum.size)
|
||||
assertEquals(0x37C8, (maximum[6].toInt() and 0xFF) or ((maximum[7].toInt() and 0xFF) shl 8))
|
||||
assertNotNull(VitureV2Protocol.parse(maximum))
|
||||
}
|
||||
|
||||
@Test fun brightnessReplyMatchesUpstreamAndKeepsFailureStatus() {
|
||||
val frame = VitureV2Protocol.parse(hex("10 00 22 51 02 00 03 00 00 03"))!!
|
||||
val reply = VitureV2Protocol.reply(frame, VitureV2Protocol.MSG_GET_BRIGHTNESS)!!
|
||||
assertTrue(reply.success)
|
||||
assertEquals(0, reply.status)
|
||||
assertArrayEquals(byteArrayOf(3), reply.body)
|
||||
assertNull(VitureV2Protocol.reply(frame, VitureV2Protocol.MSG_GET_VOLUME))
|
||||
assertNull(VitureV2Protocol.reply(frame, -1))
|
||||
val failure = VitureV2Protocol.parse(hex("10 00 01 23 01 00 07 00 07"))!!
|
||||
val failedReply = VitureV2Protocol.reply(failure, VitureV2Protocol.MSG_IMU_CONTROL)!!
|
||||
assertFalse(failedReply.success)
|
||||
assertEquals(7, failedReply.status)
|
||||
assertTrue(failedReply.body.isEmpty())
|
||||
val noStatus = VitureV2Protocol.parse(hex("10 00 01 23 00 00 00 00"))!!
|
||||
assertNull(VitureV2Protocol.reply(noStatus, VitureV2Protocol.MSG_IMU_CONTROL))
|
||||
}
|
||||
|
||||
@Test fun validatesReceiveBoundsBeforeReadingHeader() {
|
||||
val valid = hex("10 00 22 51 02 00 03 00 00 03")
|
||||
for (size in listOf(-1, 0, 7, 9, 11, 65, Int.MAX_VALUE)) {
|
||||
assertNull("size=$size", VitureV2Protocol.parse(valid, size))
|
||||
}
|
||||
assertNull(VitureV2Protocol.parse(ByteArray(0)))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf(65)))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[0] = 0x11 }))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[1] = 1 }))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[6] = 0xFF.toByte() }))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[9] = 4 }))
|
||||
}
|
||||
|
||||
@Test fun rejectsOversizedAndTruncatedDeclaredPayloads() {
|
||||
val valid = hex("10 00 22 51 02 00 03 00 00 03")
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf(9)))
|
||||
val tooLong = valid.copyOf(64).also { it[4] = 57 }
|
||||
assertNull(VitureV2Protocol.parse(tooLong))
|
||||
tooLong[4] = 0xFF.toByte()
|
||||
tooLong[5] = 0xFF.toByte()
|
||||
assertNull(VitureV2Protocol.parse(tooLong))
|
||||
val padded = valid.copyOf(64)
|
||||
val parsed = VitureV2Protocol.parse(padded)!!
|
||||
assertArrayEquals(byteArrayOf(0, 3), parsed.payload)
|
||||
padded[9] = 8
|
||||
assertArrayEquals(byteArrayOf(0, 3), parsed.payload)
|
||||
}
|
||||
|
||||
@Test fun poseFixturePreservesDeviceCounterAndConvertsWxyzToNormalizedXyzw() {
|
||||
val frame = VitureV2Protocol.parse(hex(
|
||||
"10 00 08 73 18 00 9c 08 " +
|
||||
"26 01 00 00 59 d6 21 00 dd e3 2b 3e 52 5d 7c 3f dd 45 9a 3b e8 27 52 3a"
|
||||
))!!
|
||||
val pose = VitureV2Protocol.pose(frame)!!
|
||||
assertEquals(0x0021D659L, pose.deviceTick)
|
||||
assertEquals(0x126L, pose.unknown)
|
||||
val expected = floatArrayOf(Float.fromBits(0x3F7C5D52), Float.fromBits(0x3B9A45DD),
|
||||
Float.fromBits(0x3A5227E8), Float.fromBits(0x3E2BE3DD))
|
||||
val norm = sqrt(expected.sumOf { it.toDouble() * it }).toFloat()
|
||||
assertArrayEquals(expected.map { it / norm }.toFloatArray(), pose.quaternion, 1e-7f)
|
||||
assertEquals(1.0, pose.quaternion.sumOf { it.toDouble() * it }, 1e-6)
|
||||
}
|
||||
|
||||
@Test fun poseNormalizesSmallScaleErrorsWithoutChangingAxesOrCounter() {
|
||||
val payload = posePayload(0.5f, -0.5f, 0.5f, -0.5f)
|
||||
ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN).putInt(4, -1)
|
||||
val pose = VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, payload))!!
|
||||
assertEquals(0xFFFFFFFFL, pose.deviceTick)
|
||||
assertArrayEquals(floatArrayOf(-0.5f, 0.5f, -0.5f, 0.5f), pose.quaternion, 0f)
|
||||
val scaled = VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, posePayload(1.01f, 0f, 0f, 0f)))!!
|
||||
assertArrayEquals(floatArrayOf(0f, 0f, 0f, 1f), scaled.quaternion, 1e-7f)
|
||||
}
|
||||
|
||||
@Test fun rejectsMalformedPoseAndInvalidQuaternions() {
|
||||
val valid = posePayload(1f, 0f, 0f, 0f)
|
||||
assertNull(VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_RAW, valid)))
|
||||
for (size in listOf(0, 23, 25, 56)) {
|
||||
assertNull(VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, valid.copyOf(size))))
|
||||
}
|
||||
for (bad in listOf(0f, 0.5f, 2f, Float.MAX_VALUE, Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY)) {
|
||||
assertNull("w=$bad", VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, posePayload(bad, 0f, 0f, 0f))))
|
||||
}
|
||||
for (component in 1..3) {
|
||||
val payload = valid.copyOf()
|
||||
ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN).putFloat(8 + component * 4, Float.NaN)
|
||||
assertNull(VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, payload)))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun rawReadsUnalignedFloatsAndPreservesUnknownBytes() {
|
||||
val payload = rawPayload()
|
||||
val frame = event(VitureV2Protocol.EVENT_RAW, payload)
|
||||
val sample = VitureV2Protocol.raw(frame)!!
|
||||
assertEquals(0xFFFFFFFEL, sample.deviceTick)
|
||||
assertArrayEquals(floatArrayOf(1.5f, -2f, 0.25f), sample.gyroRadPerSec, 0f)
|
||||
assertArrayEquals(floatArrayOf(0.0024f, -0.3221f, -0.9287f), sample.accelG, 0f)
|
||||
assertArrayEquals(payload, sample.payload)
|
||||
frame.payload.fill(0)
|
||||
assertArrayEquals(payload, sample.payload)
|
||||
}
|
||||
|
||||
@Test fun rejectsMalformedRawAndNonfiniteMeasurementsButKeepsOpaqueTail() {
|
||||
val payload = rawPayload()
|
||||
assertNull(VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_POSE, payload)))
|
||||
for (size in listOf(0, 24, 33, 34, 55)) {
|
||||
assertNull(VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_RAW, payload.copyOf(size))))
|
||||
}
|
||||
for (offset in listOf(10, 14, 18, 22, 26, 30)) {
|
||||
for (bad in listOf(Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY)) {
|
||||
val invalid = payload.copyOf()
|
||||
ByteBuffer.wrap(invalid).order(ByteOrder.LITTLE_ENDIAN).putFloat(offset, bad)
|
||||
assertNull("offset=$offset, value=$bad", VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_RAW, invalid)))
|
||||
}
|
||||
}
|
||||
ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN).putFloat(46, Float.NaN)
|
||||
assertNotNull(VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_RAW, payload)))
|
||||
}
|
||||
|
||||
private fun event(msgId: Int, payload: ByteArray) =
|
||||
VitureV2Protocol.parse(VitureV2Protocol.packet(msgId, payload))!!
|
||||
|
||||
private fun posePayload(w: Float, x: Float, y: Float, z: Float) =
|
||||
ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0x126).putInt(123).putFloat(w).putFloat(x).putFloat(y).putFloat(z).array()
|
||||
|
||||
private fun rawPayload() = ByteBuffer.allocate(56).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0x126).putInt(-2).putShort(187)
|
||||
.putFloat(1.5f).putFloat(-2f).putFloat(0.25f)
|
||||
.putFloat(0.0024f).putFloat(-0.3221f).putFloat(-0.9287f)
|
||||
.putFloat(117.30f).putFloat(60.75f).putFloat(254.85f)
|
||||
.put(byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).array()
|
||||
|
||||
private fun hex(value: String) = value.split(' ').map { it.toInt(16).toByte() }.toByteArray()
|
||||
}
|
||||
@@ -30,6 +30,21 @@ import org.robolectric.annotation.Config
|
||||
class GlassesPanelTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
|
||||
@Test fun trackingOnlyDeviceHidesDisplayWritesButKeepsHeadTracking() {
|
||||
show(supportsDisplayModeControl = false)
|
||||
compose.onNodeWithTag("setting-glasses-hz").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-resolution-two_d").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-3d").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-3dof").assertExists()
|
||||
}
|
||||
|
||||
@Test fun trackingOnlyDeviceHidesVrDisplayWrites() {
|
||||
show(supportsDisplayModeControl = false, tab = GlassesTab.VR, steamVrRunning = true)
|
||||
compose.onNodeWithTag("setting-glasses-resolution-vr").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-3d-hz").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-auto3d").assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test fun flatResolutionMenuShowsPerEyeResolutionsBesideRefresh() {
|
||||
show()
|
||||
compose.onNodeWithTag("setting-glasses-hz").assertExists()
|
||||
@@ -397,6 +412,7 @@ class GlassesPanelTest {
|
||||
outputActive: Boolean = inSession,
|
||||
controlAvailable: Boolean = true,
|
||||
supportsScreen3dof: Boolean = true,
|
||||
supportsDisplayModeControl: Boolean = true,
|
||||
supportsSpatial: Boolean = false,
|
||||
supports30Hz: Boolean = false,
|
||||
sbs90: Boolean = true,
|
||||
@@ -406,6 +422,7 @@ class GlassesPanelTest {
|
||||
onRecenter: (() -> Unit)? = {},
|
||||
) {
|
||||
val state = GlassesState(present = true, connected = controlAvailable, controllable = true,
|
||||
supportsDisplayModeControl = supportsDisplayModeControl,
|
||||
displayId = Display.DEFAULT_DISPLAY + 1, width = if (stereo) 3840 else 1920, height = 1200,
|
||||
model = "VITURE Luma Ultra", sbs = stereo, sbs90 = sbs90, supportsScreen3dof = supportsScreen3dof,
|
||||
supports30Hz = supports30Hz, supportsSpatial = supportsSpatial, resolutions = listOf(
|
||||
|
||||
Reference in new issue
Block a user