| | |
| | | osascript -e 'tell application "System Events" to keystroke space using {option down, shift down}' |
| | | } |
| | | |
| | | send_quick_search_hotkey() { |
| | | swift - <<'SWIFT' >/dev/null 2>&1 |
| | | import CoreGraphics |
| | | import Foundation |
| | | |
| | | let source = CGEventSource(stateID: .hidSystemState) |
| | | let down = CGEvent(keyboardEventSource: source, virtualKey: 49, keyDown: true)! |
| | | down.flags = [.maskSecondaryFn] |
| | | down.post(tap: .cghidEventTap) |
| | | usleep(80_000) |
| | | let up = CGEvent(keyboardEventSource: source, virtualKey: 49, keyDown: false)! |
| | | up.flags = [.maskSecondaryFn] |
| | | up.post(tap: .cghidEventTap) |
| | | SWIFT |
| | | } |
| | | |
| | | send_cmd_comma() { |
| | | osascript -e 'tell application "System Events" to keystroke "," using {command down}' |
| | | } |
| | |
| | | log "PASS Dock tile count: $names" |
| | | } |
| | | |
| | | assert_no_dock_tile() { |
| | | local output count names |
| | | output="$(osascript <<'OSA' |
| | | tell application "System Events" |
| | | tell process "Dock" |
| | | set tagCount to 0 |
| | | set tagNames to {} |
| | | repeat with itemRef in UI elements of list 1 |
| | | try |
| | | set itemName to name of itemRef as text |
| | | if itemName is "TagLauncher" then |
| | | set tagCount to tagCount + 1 |
| | | set end of tagNames to itemName |
| | | end if |
| | | end try |
| | | end repeat |
| | | return (tagCount as text) & "|" & (tagNames as text) |
| | | end tell |
| | | end tell |
| | | OSA |
| | | )" |
| | | count="${output%%|*}" |
| | | names="${output#*|}" |
| | | if [[ "$count" != "0" ]]; then |
| | | echo "FAIL: expected no TagLauncher Dock tile, got $count ($names)" >&2 |
| | | return 1 |
| | | fi |
| | | log "PASS no TagLauncher Dock tile" |
| | | } |
| | | |
| | | click_taglauncher_dock_tile() { |
| | | local coords x y |
| | | coords="$(osascript <<'OSA' |
| | | tell application "System Events" |
| | | tell process "Dock" |
| | | repeat with itemRef in UI elements of list 1 |
| | | try |
| | | if (name of itemRef as text) is "TagLauncher" then |
| | | set itemPosition to position of itemRef |
| | | set itemSize to size of itemRef |
| | | set centerX to (item 1 of itemPosition) + ((item 1 of itemSize) / 2) |
| | | set centerY to (item 2 of itemPosition) + ((item 2 of itemSize) / 2) |
| | | return (centerX as integer as text) & " " & (centerY as integer as text) |
| | | end if |
| | | end try |
| | | end repeat |
| | | error "TagLauncher Dock tile not found" |
| | | end tell |
| | | end tell |
| | | OSA |
| | | )" |
| | | read -r x y <<<"$coords" |
| | | click_xy "$x" "$y" |
| | | } |
| | | |
| | | assert_frontmost_taglauncher() { |
| | | local frontmost |
| | | frontmost="$(osascript -e 'tell application "System Events" to get name of first application process whose frontmost is true')" |
| | |
| | | let dockWindows = windows.filter { $0.owner == "Dock" } |
| | | guard dockWindows.isEmpty else { fail("Dock should be hidden while overlay is visible; found \(dockWindows.count) Dock windows") } |
| | | print("PASS overlay: tagLayer=\(tag[0].layer) menubarLayer=24 dockWindows=0") |
| | | |
| | | case "quick-search": |
| | | guard tag.count == 2 else { fail("quick search expected overlay plus panel, got \(tag.count)") } |
| | | assertTagLayer(tag) |
| | | let overlays = tag.filter(isOverlayWindow) |
| | | let quickSearch = tag.filter(isQuickSearchWindow) |
| | | guard overlays.count == 1, quickSearch.count == 1 else { |
| | | fail("quick search stack wrong: names=\(tag.map(\.name)) bounds=\(tag.map(\.bounds))") |
| | | } |
| | | print("PASS quick search stack: tagLayers=\(tag.map(\.layer))") |
| | | |
| | | case "settings": |
| | | guard tag.count == 2 else { fail("settings expected 2 TagLauncher windows, got \(tag.count)") } |
| | |
| | | let overlayX = dimension(overlayBounds, "X") |
| | | let overlayY = dimension(overlayBounds, "Y") |
| | | print("\(Int(round(overlayX + 120))) \(Int(round(overlayY + 160)))") |
| | | case "overlay-center": |
| | | guard let overlay = tag.max(by: { lhs, rhs in |
| | | let lhsBounds = lhs[kCGWindowBounds as String] as? NSDictionary ?? [:] |
| | | let rhsBounds = rhs[kCGWindowBounds as String] as? NSDictionary ?? [:] |
| | | let lhsArea = dimension(lhsBounds, "Width") * dimension(lhsBounds, "Height") |
| | | let rhsArea = dimension(rhsBounds, "Width") * dimension(rhsBounds, "Height") |
| | | return lhsArea < rhsArea |
| | | }), let overlayBounds = overlay[kCGWindowBounds as String] as? NSDictionary else { |
| | | let screen = NSScreen.screens.first?.frame ?? CGRect(x: 0, y: 0, width: 1200, height: 800) |
| | | print("\(Int(round(screen.midX))) \(Int(round(screen.midY)))") |
| | | exit(0) |
| | | } |
| | | let overlayX = dimension(overlayBounds, "X") |
| | | let overlayY = dimension(overlayBounds, "Y") |
| | | let overlayWidth = dimension(overlayBounds, "Width") |
| | | let overlayHeight = dimension(overlayBounds, "Height") |
| | | print("\(Int(round(overlayX + overlayWidth / 2))) \(Int(round(overlayY + overlayHeight / 2)))") |
| | | case "quick-search-result": |
| | | guard let quickSearch = tag.first(where: { window in |
| | | let name = (window[kCGWindowName as String] as? String) ?? "" |
| | | let bounds = window[kCGWindowBounds as String] as? NSDictionary ?? [:] |
| | | let width = dimension(bounds, "Width") |
| | | let height = dimension(bounds, "Height") |
| | | return name.isEmpty |
| | | && width >= 500 |
| | | && width <= 900 |
| | | && height >= 120 |
| | | && height <= 850 |
| | | }), let bounds = quickSearch[kCGWindowBounds as String] as? NSDictionary else { |
| | | fputs("FAIL: could not find quick search bounds\n", stderr) |
| | | exit(1) |
| | | } |
| | | let x = dimension(bounds, "X") |
| | | let y = dimension(bounds, "Y") |
| | | let width = dimension(bounds, "Width") |
| | | print("\(Int(round(x + width * 0.35))) \(Int(round(y + 125)))") |
| | | case "fullscreen-target-center": |
| | | guard let target = raw.first(where: { ($0[kCGWindowName as String] as? String) == "TagLauncherFullscreenQATargetFullscreen" }), |
| | | let bounds = target[kCGWindowBounds as String] as? NSDictionary else { |
| | |
| | | click_xy "$x" "$y" |
| | | } |
| | | |
| | | hover_quick_search_results() { |
| | | local coords x y |
| | | coords="$(swift "$coords_swift" quick-search-result)" |
| | | read -r x y <<<"$coords" |
| | | for offset in 0 42 84 126 84 42 0; do |
| | | move_xy "$x" "$((y + offset))" |
| | | sleep 0.08 |
| | | done |
| | | } |
| | | |
| | | click_quick_search_result() { |
| | | local coords x y |
| | | coords="$(swift "$coords_swift" quick-search-result)" |
| | | read -r x y <<<"$coords" |
| | | click_xy "$x" "$y" |
| | | } |
| | | |
| | | page_scroll_appgrid() { |
| | | local coords |
| | | coords="$(swift "$coords_swift" overlay-center)" |
| | | read -r x y <<<"$coords" |
| | | move_xy "$x" "$y" |
| | | sleep 0.15 |
| | | swift - <<'SWIFT' |
| | | import CoreGraphics |
| | | if let event = CGEvent( |
| | | scrollWheelEvent2Source: nil, |
| | | units: .pixel, |
| | | wheelCount: 1, |
| | | wheel1: -900, |
| | | wheel2: 0, |
| | | wheel3: 0 |
| | | ) { |
| | | event.post(tap: .cghidEventTap) |
| | | } |
| | | SWIFT |
| | | sleep 0.25 |
| | | } |
| | | |
| | | kill_fullscreen_qa_target() { |
| | | if [[ -n "${FULLSCREEN_QA_PID:-}" ]]; then |
| | | kill "$FULLSCREEN_QA_PID" >/dev/null 2>&1 || true |
| | |
| | | sleep 1.5 |
| | | assert_single_qa_app_instance |
| | | assert_single_dock_tile |
| | | swift_assert no-overlay |
| | | for _ in {1..3}; do |
| | | "$APP_BUNDLE/Contents/MacOS/TagLauncher" >/dev/null 2>&1 & |
| | | sleep 0.25 |
| | | done |
| | | sleep 2.0 |
| | | assert_single_qa_app_instance |
| | | assert_single_dock_tile |
| | | swift_assert no-overlay |
| | | for _ in {1..3}; do |
| | | "$APP_BUNDLE/Contents/MacOS/TagLauncher" --hide >/dev/null 2>&1 & |
| | | sleep 0.25 |
| | |
| | | sleep 2.0 |
| | | assert_single_qa_app_instance |
| | | assert_single_dock_tile |
| | | swift_assert no-overlay |
| | | log "==> QA Dock reopen: showDockIcon=true opens App Grid from explicit app reopen" |
| | | click_taglauncher_dock_tile |
| | | sleep 1.0 |
| | | wait_swift_assert overlay |
| | | send_keycode 53 |
| | | sleep 0.4 |
| | | wait_swift_assert no-overlay |
| | | log "==> QA hidden Dock: main hotkey opens App Grid without showing Dock tile" |
| | | defaults write "$DEFAULTS_DOMAIN" showDockIcon -bool false |
| | | prepare_isolated_app_instance |
| | | assert_no_dock_tile |
| | | send_main_hotkey |
| | | sleep 0.8 |
| | | wait_swift_assert overlay |
| | | assert_no_dock_tile |
| | | send_keycode 53 |
| | | sleep 0.4 |
| | | wait_swift_assert no-overlay |
| | | kill_all_taglauncher_instances |
| | | sleep 0.4 |
| | | swift_assert no-overlay |
| | | prepare_isolated_app_instance |
| | | assert_no_dock_tile |
| | | log "==> QA hidden Dock: Fn+Space Quick Search hover does not resurrect App Grid" |
| | | send_quick_search_hotkey |
| | | sleep 0.8 |
| | | wait_swift_assert quick-search |
| | | hover_quick_search_results |
| | | sleep 0.8 |
| | | wait_swift_assert quick-search |
| | | assert_no_dock_tile |
| | | send_quick_search_hotkey |
| | | sleep 0.8 |
| | | wait_swift_assert no-overlay |
| | | assert_no_dock_tile |
| | | kill_all_taglauncher_instances |
| | | sleep 0.4 |
| | | swift_assert no-overlay |
| | | prepare_isolated_app_instance |
| | | assert_no_dock_tile |
| | | log "==> QA hidden Dock: clicking Quick Search result closes without showing App Grid" |
| | | send_quick_search_hotkey |
| | | sleep 0.8 |
| | | wait_swift_assert quick-search |
| | | click_quick_search_result |
| | | sleep 1.4 |
| | | wait_swift_assert no-overlay |
| | | assert_no_dock_tile |
| | | kill_all_taglauncher_instances |
| | | sleep 0.4 |
| | | swift_assert no-overlay |
| | |
| | | log "==> QA fullscreen Space: quick search from appgrid does not switch Space" |
| | | send_keycode 49 |
| | | sleep 0.4 |
| | | wait_swift_assert quick-search |
| | | assert_fullscreen_overlay_stable |
| | | send_keycode 53 |
| | | sleep 0.3 |
| | |
| | | swift_assert file-panel |
| | | send_keycode 53 |
| | | sleep 0.3 |
| | | send_cmd_w |
| | | close_settings_window |
| | | sleep 0.9 |
| | | swift_assert overlay |
| | | assert_frontmost_taglauncher |
| | |
| | | swift_assert overlay |
| | | send_keycode 53 |
| | | sleep 0.4 |
| | | swift_assert no-overlay |
| | | |
| | | log "==> QA 4/7: appgrid scroll keeps Space and Esc keyboard routing" |
| | | show_overlay |
| | | for _ in {1..5}; do |
| | | page_scroll_appgrid |
| | | send_keycode 49 |
| | | sleep 0.35 |
| | | swift_assert quick-search |
| | | send_keycode 53 |
| | | sleep 0.25 |
| | | swift_assert overlay |
| | | done |
| | | page_scroll_appgrid |
| | | send_keycode 53 |
| | | sleep 0.35 |
| | | swift_assert no-overlay |
| | | |
| | | log "==> QA 5/7: clicking outside quick search closes search, not appgrid" |
| | |
| | | SWIFT |
| | | done < <(swift "$screens_swift") |
| | | else |
| | | rg -Fq 'screenContainingCurrentPointer() ??' "$ROOT_DIR/Apptag/ApptagApp.swift" |
| | | rg -Fq 'NSMouseInRect(mousePoint, $0.frame, false)' "$ROOT_DIR/Apptag/ApptagApp.swift" |
| | | rg -Fq 'statusMenuScreenForNextOverlay = overlayController.screenContainingCurrentPointer()' "$ROOT_DIR/Apptag/ApptagApp.swift" |
| | | rg -Fq 'screenContainingCurrentPointer() ??' "$ROOT_DIR/Apptag/OverlayWindowController.swift" |
| | | rg -Fq 'NSMouseInRect(mousePoint, $0.frame, false)' "$ROOT_DIR/Apptag/OverlayWindowController.swift" |
| | | log "PASS screen-following static path: single physical display here; code selects NSScreen under current pointer" |
| | | fi |
| | | |