From bedb145ee1413482763707fe73787b622cb52cbf Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sat, 13 Jun 2026 16:08:40 +0800
Subject: [PATCH] Fix Finder tab space activation
---
C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 0 deletions(-)
diff --git a/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift b/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift
index b83efb7..042e94c 100644
--- a/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift
+++ b/C1.source/Tests/AlignerCoreTests/AlignerCoreTests.swift
@@ -377,6 +377,162 @@
XCTAssertNil(WindowEnumerationPolicy.window(from: tinyRecord))
}
+ func testFinderTabSpaceAttributionInheritsFullscreenHostSpaceForMatchingFrame() {
+ let finderApp = AlignerApp(
+ bundleIdentifier: "com.apple.finder",
+ name: "访达",
+ category: .finder,
+ processIdentifier: 74678
+ )
+ let frame = CGRect(x: 0, y: 0, width: 960, height: 1080)
+ let host = WindowEnumerationRecord(
+ id: 33112,
+ app: finderApp,
+ title: "下载",
+ size: frame.size,
+ frame: frame,
+ subrole: .standard,
+ isFullscreen: true,
+ hasAXBacking: true,
+ spaceIDs: [843]
+ )
+ let inactiveTab = WindowEnumerationRecord(
+ id: 42286,
+ app: finderApp,
+ title: "Appcache",
+ size: frame.size,
+ frame: frame,
+ subrole: .standard,
+ hasAXBacking: false,
+ isOnscreen: false
+ )
+
+ let attributed = FinderTabSpaceAttributionPolicy.attributedRecords([inactiveTab, host])
+
+ XCTAssertEqual(attributed[0].spaceIDs, [843])
+ XCTAssertTrue(attributed[0].isFullscreen)
+ }
+
+ func testFinderTabSpaceAttributionDoesNotGuessNoSpaceWindowsWithoutHostOverlap() {
+ let finderApp = AlignerApp(
+ bundleIdentifier: "com.apple.finder",
+ name: "访达",
+ category: .finder,
+ processIdentifier: 74678
+ )
+ let otherApp = AlignerApp(
+ bundleIdentifier: "com.example.Other",
+ name: "Other",
+ category: .generic,
+ processIdentifier: 74678
+ )
+ let hostFrame = CGRect(x: 0, y: 0, width: 960, height: 1080)
+ let farFrame = CGRect(x: 1200, y: 0, width: 500, height: 600)
+ let host = WindowEnumerationRecord(
+ id: 33112,
+ app: finderApp,
+ title: "下载",
+ size: hostFrame.size,
+ frame: hostFrame,
+ subrole: .standard,
+ isFullscreen: true,
+ hasAXBacking: true,
+ spaceIDs: [843]
+ )
+ let farFinderTab = WindowEnumerationRecord(
+ id: 42286,
+ app: finderApp,
+ title: "Appcache",
+ size: farFrame.size,
+ frame: farFrame,
+ subrole: .standard,
+ hasAXBacking: false,
+ isOnscreen: false
+ )
+ let nonFinderWindow = WindowEnumerationRecord(
+ id: 50222,
+ app: otherApp,
+ title: "Appcache",
+ size: hostFrame.size,
+ frame: hostFrame,
+ subrole: .standard,
+ hasAXBacking: false,
+ isOnscreen: false
+ )
+
+ let attributed = FinderTabSpaceAttributionPolicy.attributedRecords([farFinderTab, nonFinderWindow, host])
+
+ XCTAssertEqual(attributed[0].spaceIDs, [])
+ XCTAssertFalse(attributed[0].isFullscreen)
+ XCTAssertEqual(attributed[1].spaceIDs, [])
+ XCTAssertFalse(attributed[1].isFullscreen)
+ }
+
+ func testFinderTabSpaceAttributionHandlesFinderSplitViewHostsByFrame() {
+ let finderApp = AlignerApp(
+ bundleIdentifier: "com.apple.finder",
+ name: "访达",
+ category: .finder,
+ processIdentifier: 74678
+ )
+ let leftFrame = CGRect(x: 0, y: 0, width: 960, height: 1080)
+ let rightFrame = CGRect(x: 960, y: 0, width: 960, height: 1080)
+ let leftHost = WindowEnumerationRecord(
+ id: 33112,
+ app: finderApp,
+ title: "下载",
+ size: leftFrame.size,
+ frame: leftFrame,
+ subrole: .standard,
+ isFullscreen: true,
+ hasAXBacking: true,
+ spaceIDs: [843]
+ )
+ let rightHost = WindowEnumerationRecord(
+ id: 41557,
+ app: finderApp,
+ title: "应用程序",
+ size: rightFrame.size,
+ frame: rightFrame,
+ subrole: .standard,
+ isFullscreen: true,
+ hasAXBacking: true,
+ spaceIDs: [843]
+ )
+ let leftInactiveTab = WindowEnumerationRecord(
+ id: 42286,
+ app: finderApp,
+ title: "Appcache",
+ size: leftFrame.size,
+ frame: leftFrame,
+ subrole: .standard,
+ hasAXBacking: false,
+ isOnscreen: false
+ )
+ let rightInactiveTab = WindowEnumerationRecord(
+ id: 61385,
+ app: finderApp,
+ title: "build",
+ size: rightFrame.size,
+ frame: rightFrame,
+ subrole: .standard,
+ hasAXBacking: false,
+ isOnscreen: false
+ )
+
+ let attributed = FinderTabSpaceAttributionPolicy.attributedRecords([
+ leftInactiveTab,
+ rightInactiveTab,
+ leftHost,
+ rightHost
+ ])
+
+ XCTAssertEqual(attributed[0].spaceIDs, [843])
+ XCTAssertEqual(attributed[1].spaceIDs, [843])
+ XCTAssertTrue(attributed[0].isFullscreen)
+ XCTAssertTrue(attributed[1].isFullscreen)
+ }
+
func testWindowEnumerationPolicyKeepsMinimizedAndFullscreenCGOnlyOffscreenWindows() {
let minimized = makeWindowRecord(
title: "Minimized Document.md",
--
Gitblit v1.9.3