-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix FingerUp causing UITouch to end in start location (#35)
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Hammer | ||
import XCTest | ||
import Foundation | ||
|
||
final class DragTests: XCTestCase { | ||
|
||
func test_drag() throws { | ||
let view = TouchTestView() | ||
|
||
view.widthAnchor.constraint(equalToConstant: 300).isActive = true | ||
view.heightAnchor.constraint(equalToConstant: 300).isActive = true | ||
|
||
let eventGenerator = try EventGenerator(view: view) | ||
try eventGenerator.waitUntilHittable(timeout: 1) | ||
|
||
try eventGenerator.fingerDown(at: view.frame.center.offset(x: -50, y: 0)) | ||
try eventGenerator.fingerMove(to: view.frame.center.offset(x: 50, y: 0), duration: 0.3) | ||
try eventGenerator.fingerUp() | ||
|
||
let endPoint = view.touches.first!.location(in: view) | ||
XCTAssertEqual(endPoint, CGPoint(x: 200, y: 150), accuracy: 0.001) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import UIKit | ||
|
||
final class TouchTestView: UIView { | ||
|
||
var touches: Set<UITouch> = .init() | ||
|
||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
super.touchesBegan(touches, with: event) | ||
|
||
touches.forEach { self.touches.insert($0) } | ||
} | ||
|
||
} |