fix(windows): accept successful tray readiness HRESULTs

This commit is contained in:
cabbage committed 2026-10-27 09:21:22 +00:00
1 parent ae5e979761
commit 0735908ca9
7 files changed
+71 -2

No files matched your search

+3 -1
View File
@@ -2295,7 +2295,9 @@ sessions remain independent. The double-click installer keeps its original
interactive process alive, waits for the UAC child process's successful exit,
starts the installed tray with the original user's token, and waits up to ten
seconds for `Shell_NotifyIconGetRect` to confirm the registered icon before
showing success. A failed/cancelled installation must not start a tray; failure
showing success. Apply `SUCCEEDED(HRESULT)` (signed 32-bit result >= 0), not an
equality check against `S_OK`: Explorer can return `S_FALSE` with valid icon
coordinates. A failed/cancelled installation must not start a tray; failure
to start the tray must explicitly report the already-installed service rather
than claiming complete success. No sign-out or reboot is required.
Run its Win32 message pump on one locked OS thread,
+10
View File
@@ -233,6 +233,16 @@ visible/responsive when its service is absent or its IPC peer stalls. Windows
may put a new application icon under its hidden-icons arrow; do not rewrite the
user's global notification-area preferences to force pinning.
Regression `BH-WINTRAY-06` checks successful HRESULTs (`S_OK` and `S_FALSE`)
versus actual failures. On the Windows 10 fixture, the installed, responsive
tray returned `S_FALSE` (`1`) with valid icon coordinates; a readiness check
that accepts only zero falsely times out. Native `BH-WINTRAY-07` calls the
installer's readiness check against the already-installed icon; require a
non-skipped pass on an installed interactive fixture. It skips if that
desktop has no RVBox tray. The native window-lifecycle check also exercises
readiness for its test icon. Preserve the user's icon visibility preferences
during verification.
Suite output is capped by the checked-in harness policy (10 MiB by default) and
stored as `artifacts/suite.log`. A failed run remains inspectable and can be
moved back to `ready` with `recover`, then resumed with the same run ID and
@@ -239,6 +239,19 @@ func TestNativeTrayIconLayout_HP_WINTRAY_03(t *testing.T) {
}
}
func TestNativeInstalledTrayReadiness_BH_WINTRAY_07(t *testing.T) {
class, _ := winapi.UTF16PtrFromString("RVBoxTrayWindowV1")
hwnd, _, _ := procFindWindow.Call(uintptr(unsafe.Pointer(class)), 0)
if hwnd == 0 {
t.Skip("requires an installed tray on this interactive desktop")
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
if err := WaitReady(ctx); err != nil {
t.Fatalf("existing installed icon was falsely reported unready: %v", err)
}
}
func TestNativeTrayWindowLifecycle_HP_WINTRAY_04(t *testing.T) {
var session uint32
if err := winapi.ProcessIdToSessionId(winapi.GetCurrentProcessId(), &session); err != nil {
+8
View File
@@ -0,0 +1,8 @@
package windowstray
// iconQuerySucceeded follows SUCCEEDED(HRESULT), including S_FALSE. Explorer
// can return S_FALSE with valid icon coordinates; requiring S_OK falsely reports
// a tray startup failure. HRESULT is signed 32-bit even in a 64-bit syscall.
func iconQuerySucceeded(result uintptr) bool {
return int32(result) >= 0
}
@@ -0,0 +1,24 @@
package windowstray
import "testing"
func TestTrayReadinessAcceptsSuccessfulHRESULT_BH_WINTRAY_06(t *testing.T) {
for _, tc := range []struct {
name string
result uintptr
ready bool
}{
{"S_OK", 0, true},
{"S_FALSE with registered icon", 1, true},
{"other successful HRESULT", 0x00040000, true},
{"E_FAIL", 0x80004005, false},
{"E_INVALIDARG", 0x80070057, false},
{"E_ACCESSDENIED", 0x80070005, false},
} {
t.Run(tc.name, func(t *testing.T) {
if got := iconQuerySucceeded(tc.result); got != tc.ready {
t.Fatalf("HRESULT %#x: ready=%v, want %v", tc.result, got, tc.ready)
}
})
}
}
+1 -1
View File
@@ -509,7 +509,7 @@ func WaitReady(ctx context.Context) error {
id := identifier{Size: uint32(unsafe.Sizeof(identifier{})), HWnd: hwnd, UID: trayIconID}
var rect rectangle
result, _, _ := procShellIconRect.Call(uintptr(unsafe.Pointer(&id)), uintptr(unsafe.Pointer(&rect)))
if int32(result) == 0 {
if iconQuerySucceeded(result) {
return nil
}
}
+12
View File
@@ -365,6 +365,18 @@ layer = "integration"
status = "implemented"
tests = ["internal/client/windowstray/native_windows_test.go:TestNativeTrayRejectionBeforeRead_BH_WINTRAY_05"]
[[requirements]]
id = "BH-WINTRAY-06"
layer = "unit"
status = "implemented"
tests = ["internal/client/windowstray/readiness_test.go:TestTrayReadinessAcceptsSuccessfulHRESULT_BH_WINTRAY_06"]
[[requirements]]
id = "BH-WINTRAY-07"
layer = "integration"
status = "implemented"
tests = ["internal/client/windowstray/native_windows_test.go:TestNativeInstalledTrayReadiness_BH_WINTRAY_07"]
[[requirements]]
id = "BH-WINTRAY-01"
layer = "unit"