Repository navigation
遮罩测试的第三方置顶窗口在自己的线程上建和销毁,不再留下来挡后面的测试 - #220
Merged
Merged
Conversation
thirdPartyTopmost 在测试 goroutine 当时的系统线程上建窗口,清理时 goroutine 可能已经换了线程,DestroyWindow 失败且没人检查,置顶的 Static 窗口留在假模拟器 主窗口的位置上,后面靠 WindowFromPoint 判断的测试全挂。 改成在锁住线程、自己泵消息的 goroutine 上建窗口和销毁,销毁失败报错;线程随 goroutine 结束,窗口也跟着没。另外两处:两台重叠的测试里桌面上别的动静把 f1 提回 f2 上面时重新提一次 f2(这是测试的前提,不是要验的东西);置顶状态测试超时 时打出 z 序的现场,下次再挂能直接看。只改测试。
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
internal/win的遮罩测试(#217 带进来的)时过时不过,#218 的检查因此一直红。只改测试,不动产品代码。原因
thirdPartyTopmost在测试 goroutine 当时所在的系统线程上建了一个置顶的STATIC小窗口,没有锁线程。清理时 goroutine 可能已经换了线程,DestroyWindow只能销毁本线程建的窗口,于是失败;返回值没检查,没人知道。Go 的系统线程一般不退出,这个置顶窗口就留在测试进程里,正好在所有假模拟器主窗口的位置上。后面靠WindowFromPoint判断的TestCoversOfTwoOverlappingEmulatorsStayWithTheirWindows、TestPassThroughThatDoesNotTakeHidesTheCover拿到的都是它(挡住的是 class "Static"),所以失败;跨轮以后连TestCoverNeverGoesOverAThirdPartyTopmostWindow自己也会被上一轮留下的窗口压住。改法
thirdPartyTopmost起一个锁住线程、自己泵消息的 goroutine,在上面建窗口;清理时让同一个线程DestroyWindow,失败就t.Errorf,5 秒没回也报错。线程保持锁定,goroutine 结束时线程也结束,就算销毁失败窗口也跟着没。做法和win_test.go的testWindows、wintest假模拟器一样。删掉了重复的procDestroyWindowT,用包里已有的procDestroyWindow。TestCoversOfTwoOverlappingEmulatorsStayWithTheirWindows:f2 在 f1 上面是测试的前提,不是要验的东西。等待期间如果桌面上别的动静把 f1 提回 f2 上面,就再提一次 f2(并t.Logf)。f1 的遮罩跑到 f2 上面不会让 f1 到 f2 上面,所以这种错照样抓得到。TestCoverFollowsTheTopmostStateOfTheEmulatorWindow:超时时把 z 序现场打出来(遮罩是否置顶、遮罩下面是谁、工具栏上面是谁和它们的类名),下次再挂能直接看。跑了多少次
本机 Windows,
go test ./internal/win -run 'TestCoverNeverGoesOverAThirdPartyTopmostWindow|TestCoverFollowsTheTopmostState|TestCoversOfTwoOverlapping|TestPassThroughThatDoesNotTake':./internal/win× 30 轮go test ./internal/win/...一轮gofmt、go vet ./...干净。整包 30 轮在本机要 20 分钟左右,超过go test默认的 10 分钟,要带-timeout。