Skip to content

Commit

Permalink
feat: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKohan authored and Fishbowler committed Jan 4, 2025
1 parent 7c8a9bb commit 88d57b0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
39 changes: 39 additions & 0 deletions maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import java.io.File
import java.nio.file.Paths
import kotlin.system.measureTimeMillis
import maestro.orchestra.util.Env.withDefaultEnvVars
import javax.imageio.ImageIO

class IntegrationTest {

Expand Down Expand Up @@ -3279,6 +3280,44 @@ class IntegrationTest {
assertThat(action).isEqualTo(targetAction)
}

@Test
fun `Case 122 - Take cropped screenshot`() {
// Given
val commands = readCommands("122_take_cropped_screenshot")
val boundHeight = 100
val boundWidth = 100

val driver = driver {
element {
id = "element_id"
bounds = Bounds(0,0,boundHeight,boundWidth)
}
}

val device = driver.deviceInfo()
val dpr = device.heightPixels / device.heightGrid

// When
Maestro(driver).use {
orchestra(it).runFlow(commands)
}

// Then
// No test failure
driver.assertEvents(
listOf(
Event.TakeScreenshot,
)
)
val file = File("122_take_cropped_screenshot_with_filename.png")
val image = ImageIO.read(file)

assert(file.exists())
assert(image.width == (boundWidth * dpr))
assert(image.height == (boundHeight * dpr))
}


private fun orchestra(
maestro: Maestro,
) = Orchestra(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
appId: com.example.app
---
- takeScreenshot:
path: ${MAESTRO_FILENAME}_with_filename
cropOn:
id: element_id

0 comments on commit 88d57b0

Please sign in to comment.