mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
4e4ecdea0d
* test(ios): expand simulator e2e coverage * test(ios): make coverage checks host portable * test(ios): handle deep link confirmation * test(ios): fix deep link prompt selector * ci: stabilize full simulator nightly * test(ios): stabilize permission prompt lifecycle * test(e2e): wait for route-specific landmarks * test(e2e): reset permissions from inactive app * test(e2e): redeliver trusted cold deep links * test(ios): verify orientation native readback * test(ios): stabilize simulator permission coverage * test(ios): wait for tab target after deep link * test(ios): paginate full event timeline * test(ios): simplify event pagination coverage * test(ios): stabilize simulator e2e coverage * test(ios): model simulator recorder lifetime * ci(test-app): cache fixture dependencies * fix(ci): isolate test app cache by node * fix(ios): settle fixture route navigation * test(ci): waive unbenchmarked ios system UI help * fix(ios): tolerate delayed simulator scale lookup * 0.20.1 * test(ci): remove superseded system UI waiver * fix(ios): harden simulator e2e reliability * chore: clarify Apple runner CI steps * fix(ios): wait before fixture home snapshot * fix(ios): require exact catalog navigation * chore(ci): format rebased workflows * fix(ios): retry unobserved fixture navigation * refactor(test): remove iOS e2e workarounds * fix(ci): verify fixture artifact provenance * fix(ci): align fixture artifact fingerprints * fix(ci): use unified Android helper packager * perf(ci): scope fixture build concurrency * chore: format fixture artifact tests * test(ios): update split Apple coverage owner * fix(ios): accept deep-link confirmation alerts
93 lines
2.6 KiB
Swift
93 lines
2.6 KiB
Swift
import XCTest
|
|
|
|
private enum OrientationObservationTiming {
|
|
static let pollInterval: TimeInterval = 0.05
|
|
static let timeout: TimeInterval = 2
|
|
}
|
|
|
|
extension RunnerTests {
|
|
func executeRotateCommand(_ command: Command) -> Response {
|
|
guard let orientation = command.orientation?.trimmingCharacters(in: .whitespacesAndNewlines),
|
|
!orientation.isEmpty
|
|
else {
|
|
return Response(ok: false, error: ErrorPayload(message: "rotate requires orientation"))
|
|
}
|
|
let supportedOrientations = [
|
|
"portrait",
|
|
"portrait-upside-down",
|
|
"landscape-left",
|
|
"landscape-right",
|
|
]
|
|
guard supportedOrientations.contains(orientation) else {
|
|
return Response(
|
|
ok: false,
|
|
error: ErrorPayload(message: "unsupported rotate orientation: \(orientation)")
|
|
)
|
|
}
|
|
guard let observedOrientation = rotateDevice(to: orientation) else {
|
|
return Response(
|
|
ok: false,
|
|
error: ErrorPayload(message: "unable to observe device orientation after rotate")
|
|
)
|
|
}
|
|
guard observedOrientation == orientation else {
|
|
return Response(
|
|
ok: false,
|
|
error: ErrorPayload(
|
|
message: "device orientation is \(observedOrientation), expected \(orientation)"
|
|
)
|
|
)
|
|
}
|
|
return Response(
|
|
ok: true,
|
|
data: DataPayload(message: "rotate", orientation: observedOrientation)
|
|
)
|
|
}
|
|
|
|
private func rotateDevice(to orientationName: String) -> String? {
|
|
#if os(macOS) || os(tvOS) || os(visionOS)
|
|
return nil
|
|
#else
|
|
switch orientationName {
|
|
case "portrait":
|
|
XCUIDevice.shared.orientation = .portrait
|
|
case "portrait-upside-down":
|
|
XCUIDevice.shared.orientation = .portraitUpsideDown
|
|
case "landscape-left":
|
|
XCUIDevice.shared.orientation = .landscapeLeft
|
|
case "landscape-right":
|
|
XCUIDevice.shared.orientation = .landscapeRight
|
|
default:
|
|
return nil
|
|
}
|
|
let deadline = Date().addingTimeInterval(OrientationObservationTiming.timeout)
|
|
repeat {
|
|
if observedDeviceOrientation() == orientationName {
|
|
return orientationName
|
|
}
|
|
sleepFor(OrientationObservationTiming.pollInterval)
|
|
} while Date() < deadline
|
|
return observedDeviceOrientation()
|
|
#endif
|
|
}
|
|
|
|
private func observedDeviceOrientation() -> String? {
|
|
#if os(macOS) || os(tvOS) || os(visionOS)
|
|
return nil
|
|
#else
|
|
switch XCUIDevice.shared.orientation {
|
|
case .portrait:
|
|
return "portrait"
|
|
case .portraitUpsideDown:
|
|
return "portrait-upside-down"
|
|
case .landscapeLeft:
|
|
return "landscape-left"
|
|
case .landscapeRight:
|
|
return "landscape-right"
|
|
default:
|
|
return nil
|
|
}
|
|
#endif
|
|
}
|
|
}
|