Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/demos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<module>common</module>
</modules>
<properties>
<cn1.plugin.version>7.0.208</cn1.plugin.version>
<cn1.version>7.0.208</cn1.version>
<cn1.plugin.version>7.0.209</cn1.plugin.version>
<cn1.version>7.0.209</cn1.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<java-tests.version>11</java-tests.version>
Expand Down
20 changes: 19 additions & 1 deletion scripts/ios/tests/HelloCodenameOneUITests.swift.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class HelloCodenameOneUITests: XCTestCase {
}

private func captureScreenshot(named name: String) throws {
let shot = XCUIScreen.main.screenshot()
let shot = bestScreenshot()

// Save into sandbox tmp (optional – mainly for local debugging)
let pngURL = outputDirectory.appendingPathComponent("\(name).png")
Expand All @@ -52,6 +52,24 @@ final class HelloCodenameOneUITests: XCTestCase {
emitScreenshotPayloads(for: shot, name: name)
}

private func bestScreenshot() -> XCUIScreenshot {
let screenShot = XCUIScreen.main.screenshot()
let appShot = app.screenshot()
let screenBytes = screenShot.pngRepresentation.count
let appBytes = appShot.pngRepresentation.count

if appBytes > screenBytes && appBytes > 0 {
return appShot
}
if screenBytes == 0 && appBytes > 0 {
return appShot
}
if appBytes == 0 && screenBytes > 0 {
return screenShot
}
return screenBytes >= appBytes ? screenShot : appShot
}

/// Wait for foreground + a short settle time
private func waitForStableFrame(timeout: TimeInterval = 30, settle: TimeInterval = 1.2) {
_ = app.wait(for: .runningForeground, timeout: timeout)
Expand Down
Loading
Loading