Skip to content

Commit

Permalink
Update additional test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
johntmcintosh committed Nov 2, 2024
1 parent de55e0f commit a892adc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a892adc

Please sign in to comment.