From 5e35c24a9306b8030b39bfb68abde5e625f7900b Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 24 May 2026 18:57:47 +0800
Subject: [PATCH] Freeze App Store release pack

---
 Scripts/window_logic_qa.sh |  144 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 144 insertions(+), 0 deletions(-)

diff --git a/Scripts/window_logic_qa.sh b/Scripts/window_logic_qa.sh
index e898312..48f7b31 100755
--- a/Scripts/window_logic_qa.sh
+++ b/Scripts/window_logic_qa.sh
@@ -66,6 +66,11 @@
   fi
 }
 
+reset_dock_for_qa() {
+  killall Dock >/dev/null 2>&1 || true
+  sleep 1.5
+}
+
 send_keycode() {
   local keycode="$1"
   local modifiers="${2:-}"
@@ -86,6 +91,26 @@
 
 send_cmd_w() {
   osascript -e 'tell application "System Events" to keystroke "w" using {command down}'
+}
+
+close_settings_window() {
+  osascript <<'OSA' >/dev/null 2>&1 || true
+tell application "System Events"
+  tell process "TagLauncher"
+    repeat 20 times
+      repeat with windowRef in windows
+        try
+          if (name of windowRef as text) is not "" then
+            click button 1 of windowRef
+            return
+          end if
+        end try
+      end repeat
+      delay 0.1
+    end repeat
+  end tell
+end tell
+OSA
 }
 
 dismiss_reopen_dialog() {
@@ -434,6 +459,107 @@
     }
     print("PASS fullscreen overlay above target: overlayLayer=\(tag[0].layer) targetLayer=\(target.layer)")
 
+case "fullscreen-settings":
+    guard tag.count == 2 else { fail("fullscreen settings expected 2 TagLauncher windows, got \(tag.count)") }
+    assertTagLayer(tag)
+    guard let target = windows.first(where: { $0.name == "TagLauncherFullscreenQATargetFullscreen" }) else {
+        fail("fullscreen target disappeared after opening settings; TagLauncher likely switched to another Space")
+    }
+    guard !tag[0].name.isEmpty, tag[1].name.isEmpty else {
+        fail("fullscreen settings order wrong: \(tag.map(\.name))")
+    }
+    guard tag.allSatisfy({ $0.layer > target.layer }) else {
+        fail("TagLauncher settings stack is not above fullscreen target")
+    }
+    print("PASS fullscreen settings above target: tagLayers=\(tag.map(\.layer)) targetLayer=\(target.layer)")
+
+case "split-geometry":
+    func isSingleFullscreenWindow(_ windowFrame: CGRect, on screenFrame: CGRect) -> Bool {
+        let widthMatches = abs(windowFrame.width - screenFrame.width) <= 12
+        let heightMatches = windowFrame.height >= screenFrame.height * 0.88
+        let horizontallyAligned = abs(windowFrame.midX - screenFrame.midX) <= 12
+        let verticallyAligned = abs(windowFrame.maxY - screenFrame.maxY) <= 32
+        return widthMatches && heightMatches && horizontallyAligned && verticallyAligned
+    }
+
+    func hasSplitViewFullscreenWindows(_ windows: [CGRect], on screenFrame: CGRect) -> Bool {
+        let clippedWindows = windows.map { $0.intersection(screenFrame) }
+        let tallWindows = clippedWindows
+            .filter { frame in
+                frame.height >= screenFrame.height * 0.86
+                    && frame.width >= screenFrame.width * 0.20
+                    && frame.width <= screenFrame.width * 0.86
+                    && abs(frame.maxY - screenFrame.maxY) <= 32
+            }
+            .sorted { $0.minX < $1.minX }
+
+        guard tallWindows.count >= 2 else { return false }
+
+        for startIndex in tallWindows.indices {
+            var union = tallWindows[startIndex]
+            var lastMaxX = union.maxX
+
+            for window in tallWindows.dropFirst(startIndex + 1) {
+                let gap = window.minX - lastMaxX
+                if gap < -32 || gap > 48 {
+                    break
+                }
+                union = union.union(window)
+                lastMaxX = max(lastMaxX, window.maxX)
+
+                let touchesLeft = abs(union.minX - screenFrame.minX) <= 32
+                let touchesRight = abs(union.maxX - screenFrame.maxX) <= 32
+                let coversWidth = union.width >= screenFrame.width * 0.92
+                let coversHeight = union.height >= screenFrame.height * 0.86
+                if touchesLeft && touchesRight && coversWidth && coversHeight {
+                    return true
+                }
+            }
+        }
+
+        return false
+    }
+
+    let screen = CGRect(x: 0, y: 0, width: 1710, height: 1112)
+    let single = CGRect(x: 0, y: 39, width: 1710, height: 1073)
+    let splitHalf = [
+        CGRect(x: 0, y: 39, width: 853, height: 1073),
+        CGRect(x: 857, y: 39, width: 853, height: 1073)
+    ]
+    let splitThird = [
+        CGRect(x: 0, y: 39, width: 568, height: 1073),
+        CGRect(x: 572, y: 39, width: 1138, height: 1073)
+    ]
+    let desktopTiledWithLargeGap = [
+        CGRect(x: 0, y: 90, width: 700, height: 900),
+        CGRect(x: 900, y: 90, width: 700, height: 900)
+    ]
+    let desktopSideBySideBelowDock = [
+        CGRect(x: 0, y: 39, width: 856, height: 983),
+        CGRect(x: 854, y: 39, width: 856, height: 983)
+    ]
+    let halfOnly = [CGRect(x: 0, y: 39, width: 853, height: 1073)]
+
+    guard isSingleFullscreenWindow(single, on: screen) else {
+        fail("split geometry expected single fullscreen window to match")
+    }
+    guard hasSplitViewFullscreenWindows(splitHalf, on: screen) else {
+        fail("split geometry expected 50/50 Split View to match")
+    }
+    guard hasSplitViewFullscreenWindows(splitThird, on: screen) else {
+        fail("split geometry expected 33/67 Split View to match")
+    }
+    guard !hasSplitViewFullscreenWindows(desktopTiledWithLargeGap, on: screen) else {
+        fail("split geometry should not match ordinary tiled desktop windows")
+    }
+    guard !hasSplitViewFullscreenWindows(desktopSideBySideBelowDock, on: screen) else {
+        fail("split geometry should not match side-by-side desktop windows below the Dock")
+    }
+    guard !hasSplitViewFullscreenWindows(halfOnly, on: screen) else {
+        fail("split geometry should not match a single half-width window")
+    }
+    print("PASS split fullscreen geometry detection")
+
 case "screen-count":
     print("INFO screens=\(NSScreen.screens.count) frames=\(NSScreen.screens.map { NSStringFromRect($0.frame) })")
 
@@ -665,6 +791,7 @@
 
 log "==> Preparing QA defaults"
 defaults write "$DEFAULTS_DOMAIN" showDockIcon -bool true
+reset_dock_for_qa
 
 log "==> Starting clean app instance"
 prepare_isolated_app_instance
@@ -692,6 +819,9 @@
 sleep 0.4
 wait_swift_assert no-overlay
 
+log "==> QA split-view fullscreen geometry detection"
+swift_assert split-geometry
+
 run_fullscreen_space_case() {
   local dock_value="$1"
   log "==> QA fullscreen Space: overlay stays above the current fullscreen app (showDockIcon=$dock_value)"
@@ -701,6 +831,20 @@
   send_main_hotkey
   wait_swift_assert fullscreen-overlay
   assert_fullscreen_overlay_stable
+  log "==> QA fullscreen Space: quick search from appgrid does not switch Space"
+  send_keycode 49
+  sleep 0.4
+  assert_fullscreen_overlay_stable
+  send_keycode 53
+  sleep 0.3
+  wait_swift_assert fullscreen-overlay
+  log "==> QA fullscreen Space: settings from appgrid does not switch Space"
+  send_cmd_comma
+  sleep 0.7
+  wait_swift_assert fullscreen-settings
+  close_settings_window
+  sleep 0.5
+  wait_swift_assert fullscreen-overlay
   send_keycode 53
   sleep 0.4
   wait_swift_assert no-overlay

--
Gitblit v1.9.3