- Raise the swipe dominance threshold to 2.0 and add a 24pt activation distance so diagonal timeline scrolls never move bubbles or fire haptics, and snap the indicator back when a gesture turns vertical mid-drag. - Cover the stricter thresholds in MessageReplySwipeTests.
80 lines
2.7 KiB
Swift
80 lines
2.7 KiB
Swift
import CoreGraphics
|
|
import XCTest
|
|
@testable import Luma
|
|
|
|
final class MessageReplySwipeTests: XCTestCase {
|
|
func testHorizontalSwipeInEitherDirectionReplies() {
|
|
XCTAssertTrue(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: 70, height: 8),
|
|
predictedEndTranslation: CGSize(width: 72, height: 9)
|
|
))
|
|
XCTAssertTrue(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: -70, height: 8),
|
|
predictedEndTranslation: CGSize(width: -72, height: 9)
|
|
))
|
|
}
|
|
|
|
func testVerticalTimelineScrollDoesNotReply() {
|
|
XCTAssertFalse(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: 42, height: 80),
|
|
predictedEndTranslation: CGSize(width: 50, height: 105)
|
|
))
|
|
}
|
|
|
|
func testDiagonalTimelineScrollDoesNotReply() {
|
|
XCTAssertFalse(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: 54, height: 44),
|
|
predictedEndTranslation: CGSize(width: 76, height: 58)
|
|
))
|
|
XCTAssertEqual(
|
|
MessageReplySwipePolicy.offset(for: CGSize(width: 54, height: 44)),
|
|
0
|
|
)
|
|
}
|
|
|
|
func testShortSwipeDoesNotReply() {
|
|
XCTAssertFalse(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: 36, height: 4),
|
|
predictedEndTranslation: CGSize(width: 48, height: 5)
|
|
))
|
|
}
|
|
|
|
func testFastHorizontalFlickUsesPredictedEnd() {
|
|
XCTAssertTrue(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: -35, height: 3),
|
|
predictedEndTranslation: CGSize(width: -90, height: 7)
|
|
))
|
|
}
|
|
|
|
func testDiagonalScrollAtOldThresholdDoesNotReply() {
|
|
// width/height ≈ 1.5 passed the old 1.4 dominance and moved bubbles
|
|
// during scrolling; the stricter policy must stay silent.
|
|
XCTAssertFalse(MessageReplySwipePolicy.shouldReply(
|
|
translation: CGSize(width: 60, height: 40),
|
|
predictedEndTranslation: CGSize(width: 60, height: 40)
|
|
))
|
|
XCTAssertEqual(
|
|
MessageReplySwipePolicy.offset(for: CGSize(width: 60, height: 40)),
|
|
0
|
|
)
|
|
}
|
|
|
|
func testIndicatorStaysHiddenUntilActivationDistance() {
|
|
XCTAssertEqual(
|
|
MessageReplySwipePolicy.offset(for: CGSize(width: 20, height: 0)),
|
|
0
|
|
)
|
|
XCTAssertGreaterThan(
|
|
MessageReplySwipePolicy.offset(for: CGSize(width: 24, height: 0)),
|
|
0
|
|
)
|
|
}
|
|
|
|
func testVisualOffsetIsCapped() {
|
|
XCTAssertEqual(
|
|
MessageReplySwipePolicy.offset(for: CGSize(width: 500, height: 0)),
|
|
MessageReplySwipePolicy.maximumOffset
|
|
)
|
|
}
|
|
}
|