ravensight-playtest 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -16
- package/addons/desktop/RavensightDesktop.swift +367 -0
- package/addons/mobile/UITests/MobileInputTests.swift +67 -1
- package/addons/ravensight_driver/driver.gd +557 -4
- package/docs/ADAPTERS.md +37 -7
- package/docs/DESKTOP.md +117 -0
- package/docs/MOBILE.md +30 -3
- package/docs/UNITY.md +149 -0
- package/docs/UNREAL.md +123 -0
- package/docs/godot-driver.md +98 -1
- package/package.json +15 -5
- package/src/cli.js +26 -10
- package/src/commands/build.js +40 -0
- package/src/commands/feature.js +1 -1
- package/src/commands/hosted.js +78 -9
- package/src/commands/run.js +47 -13
- package/src/commands/validate.js +1 -1
- package/src/hosted/archivePreflight.js +31 -4
- package/src/hosted/buildStatus.js +26 -0
- package/src/hosted/buildUpload.js +24 -9
- package/src/hosted/nativeBuild.js +87 -0
- package/src/hosted/recordedRun.js +15 -3
- package/src/run/anygame/genre.js +98 -24
- package/src/run/anygame/genre2d.js +108 -0
- package/src/run/anygame/index.js +7 -4
- package/src/run/anygame/scene3d.js +562 -0
- package/src/run/anygame/shared-hashes.json +4 -2
- package/src/run/anygame/shared.js +3 -3
- package/src/run/args.js +15 -4
- package/src/run/drivers/desktop/app.js +104 -0
- package/src/run/drivers/desktop/common.js +336 -0
- package/src/run/drivers/desktop/driver.js +383 -0
- package/src/run/drivers/desktop/helper.js +98 -0
- package/src/run/drivers/desktop/keys.js +124 -0
- package/src/run/drivers/desktop/output.js +107 -0
- package/src/run/drivers/desktop/preflight.js +134 -0
- package/src/run/drivers/desktop3d.js +106 -0
- package/src/run/drivers/desktopSequence.js +72 -0
- package/src/run/drivers/godot-3d.js +298 -0
- package/src/run/drivers/godot.js +465 -30
- package/src/run/drivers/index.js +6 -0
- package/src/run/drivers/mobile/adb.js +25 -1
- package/src/run/drivers/mobile/frame.js +3 -2
- package/src/run/drivers/mobile/gestures.js +76 -0
- package/src/run/drivers/mobile/lock.js +51 -11
- package/src/run/drivers/mobile/multitouch.js +150 -0
- package/src/run/drivers/mobile/native.js +229 -31
- package/src/run/drivers/mobile/preflight.js +14 -1
- package/src/run/drivers/mobile/target.js +21 -1
- package/src/run/drivers/stdio.js +150 -12
- package/src/run/drivers/unity/app.js +72 -0
- package/src/run/drivers/unity/engine.js +58 -0
- package/src/run/drivers/unity/link.js +108 -0
- package/src/run/drivers/unity/logs.js +76 -0
- package/src/run/drivers/unreal/app.js +40 -0
- package/src/run/drivers/unreal/driver.js +686 -0
- package/src/run/drivers/unreal/frames.js +243 -0
- package/src/run/drivers/unreal/logs.js +276 -0
- package/src/run/drivers/unreal/preflight.js +61 -0
- package/src/run/drivers/web.js +211 -13
- package/src/run/drivers/webdriver.js +79 -12
- package/src/run/endScreen.js +88 -0
- package/src/run/engineErrors.js +16 -0
- package/src/run/featureLoop.js +1 -1
- package/src/run/fingers.js +99 -0
- package/src/run/focusForKeys.js +54 -0
- package/src/run/godotTesterProbes.js +21 -2
- package/src/run/honesty.js +11 -1
- package/src/run/inputs.js +3 -3
- package/src/run/intent.js +12 -0
- package/src/run/pauseHook.js +494 -0
- package/src/run/personaLoop.js +139 -10
- package/src/run/pixels.js +22 -10
- package/src/run/planGuard.js +103 -0
- package/src/run/replay.js +5 -1
- package/src/run/reportChecks.js +17 -4
- package/src/run/resume.js +6 -2
- package/src/run/sessions.js +170 -0
- package/src/run/startFrom.js +415 -0
- package/src/run/testerProbes.js +36 -5
- package/src/run/tools.js +191 -10
- package/src/run/view3dState.js +125 -0
- package/src/run/web3d.js +375 -0
- package/src/run/world3d.js +164 -0
- package/templates/godot-3d/README.md +3 -2
|
@@ -2,7 +2,7 @@ import XCTest
|
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
4
|
private enum BridgeError: Error {
|
|
5
|
-
case invalidConfiguration, invalidCommand, invalidCoordinate, applicationNotRunning, network, deadline
|
|
5
|
+
case invalidConfiguration, invalidCommand, invalidCoordinate, applicationNotRunning, network, deadline, unsupportedInput
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
@MainActor
|
|
@@ -105,6 +105,15 @@ final class MobileInputTests: XCTestCase {
|
|
|
105
105
|
let dy = ((command["toY"] as? NSNumber)?.doubleValue ?? 0) - ((command["y"] as? NSNumber)?.doubleValue ?? 0)
|
|
106
106
|
let velocity = XCUIGestureVelocity(rawValue: max(1, hypot(dx, dy) / duration))
|
|
107
107
|
start.press(forDuration: hold, thenDragTo: end, withVelocity: velocity, thenHoldForDuration: 0)
|
|
108
|
+
case "pinch":
|
|
109
|
+
// The system's own two finger pinch, around the middle of the app.
|
|
110
|
+
let scale = try number(command, "scale", maximum: 5)
|
|
111
|
+
guard scale >= 0.2, scale != 1 else { throw BridgeError.invalidCommand }
|
|
112
|
+
let duration = max(0.1, try number(command, "durationMs", fallback: 600) / 1000)
|
|
113
|
+
let speed = max(0.5, abs(log(scale)) / duration * 2)
|
|
114
|
+
target.pinch(withScale: CGFloat(scale), velocity: CGFloat(scale > 1 ? speed : -speed))
|
|
115
|
+
case "touches":
|
|
116
|
+
try synthesizeFingers(command, target)
|
|
108
117
|
case "type":
|
|
109
118
|
guard let text = command["text"] as? String, text.count <= 4096 else { throw BridgeError.invalidCommand }
|
|
110
119
|
target.typeText(text)
|
|
@@ -118,6 +127,63 @@ final class MobileInputTests: XCTestCase {
|
|
|
118
127
|
return [:]
|
|
119
128
|
}
|
|
120
129
|
|
|
130
|
+
// Two fingers at once, each on its own path and clock, as one synthesized event: the event paths XCTest itself
|
|
131
|
+
// plays gestures with. They are not public API, so each is looked up by name and a runner without them answers
|
|
132
|
+
// unsupportedInput, which the CLI reports as a limit of the tool. Points are the app's own, as `point` checks them.
|
|
133
|
+
private func synthesizeFingers(_ command: [String: Any], _ target: XCUIApplication) throws {
|
|
134
|
+
guard let fingers = command["fingers"] as? [[String: Any]], (1...2).contains(fingers.count) else { throw BridgeError.invalidCommand }
|
|
135
|
+
guard let pathClass = NSClassFromString("XCPointerEventPath") as? NSObject.Type,
|
|
136
|
+
let recordClass = NSClassFromString("XCSynthesizedEventRecord") as? NSObject.Type else { throw BridgeError.unsupportedInput }
|
|
137
|
+
typealias InitPath = @convention(c) (AnyObject, Selector, CGPoint, Double) -> AnyObject?
|
|
138
|
+
typealias MovePath = @convention(c) (AnyObject, Selector, CGPoint, Double) -> Void
|
|
139
|
+
typealias LiftPath = @convention(c) (AnyObject, Selector, Double) -> Void
|
|
140
|
+
typealias InitRecord = @convention(c) (AnyObject, Selector, NSString, Int) -> AnyObject?
|
|
141
|
+
typealias AddPath = @convention(c) (AnyObject, Selector, AnyObject) -> Void
|
|
142
|
+
typealias Synthesize = @convention(c) (AnyObject, Selector, AnyObject, @escaping @convention(block) (Bool, NSError?) -> Void) -> AnyObject?
|
|
143
|
+
func call<T>(_ object: AnyObject, _ name: String, as type: T.Type) throws -> (Selector, T) {
|
|
144
|
+
let selector = NSSelectorFromString(name)
|
|
145
|
+
guard let object = object as? NSObject, object.responds(to: selector) else { throw BridgeError.unsupportedInput }
|
|
146
|
+
return (selector, unsafeBitCast(object.method(for: selector), to: type))
|
|
147
|
+
}
|
|
148
|
+
let frame = target.frame
|
|
149
|
+
let at = { (raw: Any?) throws -> CGPoint in
|
|
150
|
+
guard let p = raw as? [String: Any], let x = (p["x"] as? NSNumber)?.doubleValue, let y = (p["y"] as? NSNumber)?.doubleValue,
|
|
151
|
+
x.isFinite, y.isFinite, frame.contains(CGPoint(x: x, y: y)) else { throw BridgeError.invalidCoordinate }
|
|
152
|
+
// The event paths take the screen's own points, which in landscape are not the app's: a point given as the app
|
|
153
|
+
// shows it landed a quarter turn away. XCTest turns it, as it does for its own gestures.
|
|
154
|
+
return target.coordinate(withNormalizedOffset: .zero).withOffset(CGVector(dx: x - frame.minX, dy: y - frame.minY)).screenPoint
|
|
155
|
+
}
|
|
156
|
+
let orientation = (target.value(forKey: "interfaceOrientation") as? NSNumber)?.intValue ?? 1
|
|
157
|
+
guard let recordAlloc = recordClass.perform(NSSelectorFromString("alloc"))?.takeUnretainedValue() else { throw BridgeError.unsupportedInput }
|
|
158
|
+
let (initRecord, makeRecord) = try call(recordAlloc, "initWithName:interfaceOrientation:", as: InitRecord.self)
|
|
159
|
+
guard let record = makeRecord(recordAlloc, initRecord, "ravensight touches" as NSString, orientation) else { throw BridgeError.unsupportedInput }
|
|
160
|
+
let (addSelector, add) = try call(record, "addPointerEventPath:", as: AddPath.self)
|
|
161
|
+
for finger in fingers {
|
|
162
|
+
guard let points = finger["path"] as? [Any], (1...6).contains(points.count) else { throw BridgeError.invalidCommand }
|
|
163
|
+
let start = try number(finger, "atMs", maximum: 3000) / 1000
|
|
164
|
+
let hold = max(0.04, try number(finger, "holdMs", fallback: 600, maximum: 4000) / 1000)
|
|
165
|
+
let path = try points.map(at)
|
|
166
|
+
guard let pathAlloc = pathClass.perform(NSSelectorFromString("alloc"))?.takeUnretainedValue() else { throw BridgeError.unsupportedInput }
|
|
167
|
+
let (initPath, makePath) = try call(pathAlloc, "initForTouchAtPoint:offset:", as: InitPath.self)
|
|
168
|
+
guard let eventPath = makePath(pathAlloc, initPath, path[0], start) else { throw BridgeError.unsupportedInput }
|
|
169
|
+
let (moveSelector, move) = try call(eventPath, "moveToPoint:atOffset:", as: MovePath.self)
|
|
170
|
+
for (index, point) in path.enumerated().dropFirst() {
|
|
171
|
+
move(eventPath, moveSelector, point, start + hold * Double(index) / Double(path.count - 1))
|
|
172
|
+
}
|
|
173
|
+
let (liftSelector, lift) = try call(eventPath, "liftUpAtOffset:", as: LiftPath.self)
|
|
174
|
+
lift(eventPath, liftSelector, start + hold)
|
|
175
|
+
add(record, addSelector, eventPath)
|
|
176
|
+
}
|
|
177
|
+
guard let synthesizer = (XCUIDevice.shared as NSObject).value(forKey: "eventSynthesizer") as AnyObject? else { throw BridgeError.unsupportedInput }
|
|
178
|
+
let (synthesizeSelector, synthesize) = try call(synthesizer, "synthesizeEvent:completion:", as: Synthesize.self)
|
|
179
|
+
var finished = false, succeeded = false
|
|
180
|
+
_ = synthesize(synthesizer, synthesizeSelector, record) { ok, _ in succeeded = ok; finished = true }
|
|
181
|
+
// The completion may come on this thread's run loop: it is turned, never blocked.
|
|
182
|
+
let deadline = Date().addingTimeInterval(10)
|
|
183
|
+
while !finished && Date() < deadline { RunLoop.current.run(until: Date().addingTimeInterval(0.02)) }
|
|
184
|
+
guard finished, succeeded else { throw BridgeError.unsupportedInput }
|
|
185
|
+
}
|
|
186
|
+
|
|
121
187
|
func testServe() throws {
|
|
122
188
|
continueAfterFailure = false
|
|
123
189
|
guard let raw = ProcessInfo.processInfo.environment["RAVENSIGHT_MOBILE_URL"],
|