@@ -288,6 +288,29 @@ final class RunnerTests: XCTestCase {
288288 let holdDuration = min ( max ( ( command. durationMs ?? 60 ) / 1000.0 , 0.016 ) , 10.0 )
289289 dragAt ( app: activeApp, x: x, y: y, x2: x2, y2: y2, holdDuration: holdDuration)
290290 return Response ( ok: true , data: DataPayload ( message: " dragged " ) )
291+ case . dragSeries:
292+ guard let x = command. x, let y = command. y, let x2 = command. x2, let y2 = command. y2 else {
293+ return Response ( ok: false , error: ErrorPayload ( message: " dragSeries requires x, y, x2, and y2 " ) )
294+ }
295+ let count = max ( Int ( command. count ?? 1 ) , 1 )
296+ let pauseMs = max ( command. pauseMs ?? 0 , 0 )
297+ let pattern = command. pattern ?? " one-way "
298+ if pattern != " one-way " && pattern != " ping-pong " {
299+ return Response ( ok: false , error: ErrorPayload ( message: " dragSeries pattern must be one-way or ping-pong " ) )
300+ }
301+ let holdDuration = min ( max ( ( command. durationMs ?? 60 ) / 1000.0 , 0.016 ) , 10.0 )
302+ for idx in 0 ..< count {
303+ let reverse = pattern == " ping-pong " && ( idx % 2 == 1 )
304+ if reverse {
305+ dragAt ( app: activeApp, x: x2, y: y2, x2: x, y2: y, holdDuration: holdDuration)
306+ } else {
307+ dragAt ( app: activeApp, x: x, y: y, x2: x2, y2: y2, holdDuration: holdDuration)
308+ }
309+ if idx < count - 1 && pauseMs > 0 {
310+ Thread . sleep ( forTimeInterval: pauseMs / 1000.0 )
311+ }
312+ }
313+ return Response ( ok: true , data: DataPayload ( message: " drag series " ) )
291314 case . type:
292315 guard let text = command. text else {
293316 return Response ( ok: false , error: ErrorPayload ( message: " type requires text " ) )
@@ -1022,6 +1045,7 @@ enum CommandType: String, Codable {
10221045 case tapSeries
10231046 case longPress
10241047 case drag
1048+ case dragSeries
10251049 case type
10261050 case swipe
10271051 case findText
@@ -1053,6 +1077,8 @@ struct Command: Codable {
10531077 let count : Double ?
10541078 let intervalMs : Double ?
10551079 let tapBatch : Bool ?
1080+ let pauseMs : Double ?
1081+ let pattern : String ?
10561082 let x2 : Double ?
10571083 let y2 : Double ?
10581084 let durationMs : Double ?
0 commit comments