diff --git a/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt b/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt index 3339c9a316..771d2789d5 100644 --- a/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt +++ b/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.KotlinModule import com.google.common.truth.Truth.assertThat +import maestro.DeviceOrientation import maestro.KeyCode import maestro.Point import org.intellij.lang.annotations.Language @@ -590,6 +591,33 @@ internal class MaestroCommandSerializationTest { .isEqualTo(command) } + @Test + fun `serialize SetOrientationCommand`() { + // given + val command = MaestroCommand( + SetOrientationCommand(DeviceOrientation.PORTRAIT) + ) + + // when + val serializedCommandJson = command.toJson() + val deserializedCommand = objectMapper.readValue(serializedCommandJson, MaestroCommand::class.java) + + // then + @Language("json") + val expectedJson = """ + { + "setOrientationCommand" : { + "orientation" : "PORTRAIT", + "optional" : false + } + } + """.trimIndent() + assertThat(serializedCommandJson) + .isEqualTo(expectedJson) + assertThat(deserializedCommand) + .isEqualTo(command) + } + private fun MaestroCommand.toJson(): String = objectMapper .writerWithDefaultPrettyPrinter() diff --git a/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt b/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt index 19db099240..2f5e4f9496 100644 --- a/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt +++ b/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt @@ -1,6 +1,7 @@ package maestro.orchestra.yaml import com.google.common.truth.Truth.assertThat +import maestro.DeviceOrientation import maestro.KeyCode import maestro.ScrollDirection import maestro.SwipeDirection @@ -35,6 +36,7 @@ import maestro.orchestra.PressKeyCommand import maestro.orchestra.RepeatCommand import maestro.orchestra.RunFlowCommand import maestro.orchestra.RunScriptCommand +import maestro.orchestra.SetOrientationCommand import maestro.orchestra.ScrollCommand import maestro.orchestra.ScrollUntilVisibleCommand import maestro.orchestra.SetAirplaneModeCommand @@ -427,6 +429,10 @@ internal class YamlCommandReaderTest { sourceDescription = "023_runScript_test.js", label = "Run some special calculations" ), + SetOrientationCommand( + orientation = Orientation.LANDSCAPE_LEFT, + label = "Set the device orientation" + ), ScrollCommand( label = "Scroll down" ), diff --git a/maestro-orchestra/src/test/resources/YamlCommandReaderTest/023_labels.yaml b/maestro-orchestra/src/test/resources/YamlCommandReaderTest/023_labels.yaml index 92fe7ac7ef..b00b5c70cc 100644 --- a/maestro-orchestra/src/test/resources/YamlCommandReaderTest/023_labels.yaml +++ b/maestro-orchestra/src/test/resources/YamlCommandReaderTest/023_labels.yaml @@ -81,6 +81,9 @@ appId: com.example.app - runScript: file: "023_runScript_test.js" label: "Run some special calculations" +- setOrientation: + orientation: "LANDSCAPE_LEFT" + label: "Set the device orientation" - scroll: label: "Scroll down" - scrollUntilVisible: