mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 14:34:12 +02:00
feat(connector): track initial state in test runs
This commit is contained in:
parent
452756e3d3
commit
5f456bb898
@ -25,7 +25,11 @@ class TestRun (
|
|||||||
private val actions: List<Action>
|
private val actions: List<Action>
|
||||||
) : Screen {
|
) : Screen {
|
||||||
|
|
||||||
|
private val xpc = XPC()
|
||||||
|
private val xpcConnected = xpc.connected()
|
||||||
|
|
||||||
private var tested = mutableStateListOf<Boolean>()
|
private var tested = mutableStateListOf<Boolean>()
|
||||||
|
private val initState = getInitState()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
@ -37,6 +41,11 @@ class TestRun (
|
|||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
|
if (!xpcConnected) {
|
||||||
|
Text("Could not connect to the simulator!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Progress Indicator
|
// Progress Indicator
|
||||||
if (running) {
|
if (running) {
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
@ -50,7 +59,7 @@ class TestRun (
|
|||||||
) {
|
) {
|
||||||
LazyColumn {
|
LazyColumn {
|
||||||
items(actions) { action ->
|
items(actions) { action ->
|
||||||
ActionItem(action)
|
ActionItem(action, initState[action.step])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +84,9 @@ class TestRun (
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ActionItem(action: Action) {
|
private fun ActionItem(action: Action, initState: FloatArray) {
|
||||||
ListItem(
|
ListItem(
|
||||||
|
overlineContent = { Text("Initial State: ${initState[0]}") },
|
||||||
headlineContent = { Text(action.type) },
|
headlineContent = { Text(action.type) },
|
||||||
supportingContent = { Text("Goal: ${action.goal}") },
|
supportingContent = { Text("Goal: ${action.goal}") },
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
@ -103,16 +113,6 @@ class TestRun (
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun runSteps() {
|
private suspend fun runSteps() {
|
||||||
val xpc = XPC()
|
|
||||||
|
|
||||||
// Checks if the simulator is running before running the other tests
|
|
||||||
if (!xpc.connected()) {
|
|
||||||
for (action in actions) {
|
|
||||||
tested.add(false)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for (action in actions) {
|
for (action in actions) {
|
||||||
delay(1000L)
|
delay(1000L)
|
||||||
|
|
||||||
@ -123,4 +123,19 @@ class TestRun (
|
|||||||
tested.add(result)
|
tested.add(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getInitState(): Array<FloatArray> {
|
||||||
|
if (!xpc.connected()) {
|
||||||
|
return Array(actions.size) { FloatArray(0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
var initDrefs = arrayOf<String>()
|
||||||
|
for (action in actions) {
|
||||||
|
initDrefs += action.type
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = xpc.getStates(initDrefs)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,24 @@ class XPC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of all Datarefs
|
||||||
|
*
|
||||||
|
* @param drefs Array of Datarefs (maximum list size = 255)
|
||||||
|
*
|
||||||
|
* @return List of all the values for each Dataref
|
||||||
|
*/
|
||||||
|
@Throws(IllegalArgumentException::class)
|
||||||
|
fun getStates(drefs: Array<String>): Array<FloatArray> {
|
||||||
|
if (drefs.size > 255) {
|
||||||
|
throw IllegalArgumentException("The drefs cannot contain more than 255 elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = xpc.getDREFs(drefs)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a dataref in X-Plane to the set goal
|
* Sets a dataref in X-Plane to the set goal
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user