// The side page's drawer (NotesDrawer.swift; the owner, 22 Nov 2026: it pushes // the list and follows the finger): its width leaves a fifth of the list // showing; it springs open and closed by itself; a finger that takes hold // while it moves catches it where it is drawn; let go, a flick decides and a // slow let-go goes to the nearer end. import XCTest @testable import CottonUI #if os(iOS) @MainActor final class NotesDrawerTests: XCTestCase { /// Frames at 60 a second until it stands still, or `limit` frames. private func run(_ drawer: NotesDrawer, frames limit: Int = 120) { for _ in 0.. 0.1 && caught < 0.9, "mid-way after five frames: \(caught)") drawer.grab() XCTAssertEqual(drawer.shown, caught, "taken hold of, it stays where it is drawn") drawer.follow(-31.2) XCTAssertEqual(drawer.shown, caught - 0.1, accuracy: 0.0001, "it follows the finger from there, point for point") drawer.follow(1_000) XCTAssertEqual(drawer.shown, 1, "never past open") } func testLetGoAFlickDecidesElseTheNearerEnd() { let drawer = NotesDrawer() drawer.width = 312 drawer.grab() drawer.follow(100) XCTAssertFalse(drawer.release(0), "a slow let-go short of half way closes") run(drawer) XCTAssertEqual(drawer.shown, 0) drawer.grab() drawer.follow(200) XCTAssertTrue(drawer.release(0), "a slow let-go past half way opens") run(drawer) XCTAssertEqual(drawer.shown, 1) drawer.grab() drawer.follow(-40) XCTAssertFalse(drawer.release(-900), "a flick to the left closes, however little it moved") run(drawer) XCTAssertEqual(drawer.shown, 0) // A flick is over 400 points a second (DECISIONS.md "The drawer", as Android). drawer.grab() drawer.follow(40) XCTAssertFalse(drawer.release(350), "350 points a second is no flick: short of half way, it closes") run(drawer) drawer.grab() drawer.follow(40) XCTAssertTrue(drawer.release(450), "450 points a second is a flick: it opens") } func testReduceMotionGoesAtOnce() { let drawer = NotesDrawer() drawer.reduceMotion = true drawer.go(true) XCTAssertEqual(drawer.shown, 1) drawer.go(false) XCTAssertEqual(drawer.shown, 0) } } #endif