diff --git a/docs/implementation-plan.v1.md b/docs/implementation-plan.v1.md index c0be358..0c0547a 100644 --- a/docs/implementation-plan.v1.md +++ b/docs/implementation-plan.v1.md @@ -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, diff --git a/docs/testing.md b/docs/testing.md index ee65146..fef9bad 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -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 diff --git a/internal/client/windowstray/native_windows_test.go b/internal/client/windowstray/native_windows_test.go index 186a2f6..349a221 100644 --- a/internal/client/windowstray/native_windows_test.go +++ b/internal/client/windowstray/native_windows_test.go @@ -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 { diff --git a/internal/client/windowstray/readiness.go b/internal/client/windowstray/readiness.go new file mode 100644 index 0000000..1c5b345 --- /dev/null +++ b/internal/client/windowstray/readiness.go @@ -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 +} diff --git a/internal/client/windowstray/readiness_test.go b/internal/client/windowstray/readiness_test.go new file mode 100644 index 0000000..9585843 --- /dev/null +++ b/internal/client/windowstray/readiness_test.go @@ -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) + } + }) + } +} diff --git a/internal/client/windowstray/tray_windows.go b/internal/client/windowstray/tray_windows.go index 6481421..bf13dbc 100644 --- a/internal/client/windowstray/tray_windows.go +++ b/internal/client/windowstray/tray_windows.go @@ -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 } } diff --git a/test/coverage.toml b/test/coverage.toml index 922a6dc..03d45f5 100644 --- a/test/coverage.toml +++ b/test/coverage.toml @@ -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"