Skip to content

Commit a892adc

Browse files
committed
Update additional test cases
1 parent de55e0f commit a892adc

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include
44
import com.fasterxml.jackson.databind.ObjectMapper
55
import com.fasterxml.jackson.module.kotlin.KotlinModule
66
import com.google.common.truth.Truth.assertThat
7+
import maestro.DeviceOrientation
78
import maestro.KeyCode
89
import maestro.Point
910
import org.intellij.lang.annotations.Language
@@ -590,6 +591,33 @@ internal class MaestroCommandSerializationTest {
590591
.isEqualTo(command)
591592
}
592593

594+
@Test
595+
fun `serialize SetOrientationCommand`() {
596+
// given
597+
val command = MaestroCommand(
598+
SetOrientationCommand(DeviceOrientation.PORTRAIT)
599+
)
600+
601+
// when
602+
val serializedCommandJson = command.toJson()
603+
val deserializedCommand = objectMapper.readValue(serializedCommandJson, MaestroCommand::class.java)
604+
605+
// then
606+
@Language("json")
607+
val expectedJson = """
608+
{
609+
"setOrientationCommand" : {
610+
"orientation" : "PORTRAIT",
611+
"optional" : false
612+
}
613+
}
614+
""".trimIndent()
615+
assertThat(serializedCommandJson)
616+
.isEqualTo(expectedJson)
617+
assertThat(deserializedCommand)
618+
.isEqualTo(command)
619+
}
620+
593621
private fun MaestroCommand.toJson(): String =
594622
objectMapper
595623
.writerWithDefaultPrettyPrinter()

maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package maestro.orchestra.yaml
22

33
import com.google.common.truth.Truth.assertThat
4+
import maestro.DeviceOrientation
45
import maestro.KeyCode
56
import maestro.ScrollDirection
67
import maestro.SwipeDirection
@@ -35,6 +36,7 @@ import maestro.orchestra.PressKeyCommand
3536
import maestro.orchestra.RepeatCommand
3637
import maestro.orchestra.RunFlowCommand
3738
import maestro.orchestra.RunScriptCommand
39+
import maestro.orchestra.SetOrientationCommand
3840
import maestro.orchestra.ScrollCommand
3941
import maestro.orchestra.ScrollUntilVisibleCommand
4042
import maestro.orchestra.SetAirplaneModeCommand
@@ -427,6 +429,10 @@ internal class YamlCommandReaderTest {
427429
sourceDescription = "023_runScript_test.js",
428430
label = "Run some special calculations"
429431
),
432+
SetOrientationCommand(
433+
orientation = Orientation.LANDSCAPE_LEFT,
434+
label = "Set the device orientation"
435+
),
430436
ScrollCommand(
431437
label = "Scroll down"
432438
),

maestro-orchestra/src/test/resources/YamlCommandReaderTest/023_labels.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ appId: com.example.app
8181
- runScript:
8282
file: "023_runScript_test.js"
8383
label: "Run some special calculations"
84+
- setOrientation:
85+
orientation: "LANDSCAPE_LEFT"
86+
label: "Set the device orientation"
8487
- scroll:
8588
label: "Scroll down"
8689
- scrollUntilVisible:

0 commit comments

Comments
 (0)