diff --git a/Sources/SendKeysLib/Commands/MouseDragCommand.swift b/Sources/SendKeysLib/Commands/MouseDragCommand.swift index 1106b05..dac9d02 100644 --- a/Sources/SendKeysLib/Commands/MouseDragCommand.swift +++ b/Sources/SendKeysLib/Commands/MouseDragCommand.swift @@ -3,7 +3,7 @@ import Foundation public class MouseDragCommand: MouseMoveCommand { public override class var commandType: CommandType { return .mouseDrag } - private static let _expression = try! NSRegularExpression(pattern: "\\") + private static let _expression = try! NSRegularExpression(pattern: "\\") public override class var expression: NSRegularExpression { return _expression } public init(x1: Int?, y1: Int?, x2: Int, y2: Int, duration: TimeInterval, button: String?, modifiers: [String]) { diff --git a/Sources/SendKeysLib/Commands/MouseMoveCommand.swift b/Sources/SendKeysLib/Commands/MouseMoveCommand.swift index 75b9334..aa97355 100644 --- a/Sources/SendKeysLib/Commands/MouseMoveCommand.swift +++ b/Sources/SendKeysLib/Commands/MouseMoveCommand.swift @@ -3,7 +3,7 @@ import Foundation public class MouseMoveCommand: MouseClickCommand { public override class var commandType: CommandType { return .mouseMove } - private static let _expression = try! NSRegularExpression(pattern: "\\") + private static let _expression = try! NSRegularExpression(pattern: "\\") public override class var expression: NSRegularExpression { return _expression } var x1: Int? diff --git a/Tests/SendKeysTests/CommandIteratorTests.swift b/Tests/SendKeysTests/CommandIteratorTests.swift index 7070de2..7803f35 100644 --- a/Tests/SendKeysTests/CommandIteratorTests.swift +++ b/Tests/SendKeysTests/CommandIteratorTests.swift @@ -199,6 +199,15 @@ final class CommandIteratorTests: XCTestCase { ]) } + func testParsesMouseMoveWithNegativeCoordinates() throws { + let commands = getCommands(CommandsIterator("")) + XCTAssertEqual( + commands, + [ + MouseMoveCommand(x1: -1, y1: -2, x2: -3, y2: -4, duration: 0.1, modifiers: []) + ]) + } + func testParsesMouseMoveWithDurationAndModifiers() throws { let commands = getCommands(CommandsIterator("")) XCTAssertEqual( @@ -298,6 +307,15 @@ final class CommandIteratorTests: XCTestCase { ]) } + func testParsesMouseDragWithDurationWithNegativeCoordinates() throws { + let commands = getCommands(CommandsIterator("")) + XCTAssertEqual( + commands, + [ + MouseDragCommand(x1: -1, y1: -2, x2: -3, y2: -4, duration: 0.1, button: "left", modifiers: []) + ]) + } + func testParsesMouseDragWithDurationAndButton() throws { let commands = getCommands(CommandsIterator("")) XCTAssertEqual(