Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions Tools/windows/Tests/ValidationRunner.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,96 @@
param(
[switch]$DialogSheet768Only
)

$ErrorActionPreference = "Stop"

function Test-DialogSheet768SourceContract([string] $source) {
if ($source -notmatch 'function Write-UiaDialogSheet768Observation\(' -or
$source -notmatch 'function Test-UiaDialogSheet768Geometry\(' -or
$source -notmatch 'UIA_DIALOG_SHEET_768_EVIDENCE=' -or
@([regex]::Matches(
$source,
'Write-UiaDialogSheet768Observation '
)).Count -lt 3) {
throw "RED: UIA live gate lacks the three-surface owned geometry and PrintWindow conformance probe for #768"
}
foreach ($required in @(
'"rename-loop" "initial" $false',
'"delete-loop" "confirmation" $false',
'"new-loop" "main-no-overflow" $false',
'"new-loop" "goal-overflow" $true'
)) {
if (-not $source.Contains($required)) {
throw "RED: UIA live gate omitted #768 scene contract $required"
}
}
if (@([regex]::Matches(
$source, '\[GraphCodeUiaGateState\]::IsDirectChild\('
)).Count -lt 2 -or
@([regex]::Matches($source, 'Save-UiaShellWindowCapture ')).Count -lt 2) {
throw "RED: UIA #768 probe lacks exact native hierarchy or both PrintWindow captures"
}
$tokens = $null
$errors = $null
$ast = [Management.Automation.Language.Parser]::ParseInput(
$source, [ref]$tokens, [ref]$errors)
if ($errors.Count -ne 0) { throw "RED: UIA live gate #768 geometry source does not parse" }
$geometry = $ast.Find({
param($node)
$node -is [Management.Automation.Language.FunctionDefinitionAst] -and
$node.Name -ceq "Test-UiaDialogSheet768Geometry"
}, $true)
if ($null -eq $geometry) { throw "RED: UIA #768 geometry decision is missing" }
. ([scriptblock]::Create($geometry.Extent.Text))
$valid = [pscustomobject]@{
expectedActionIds = @(2, 1)
expectedDpi = 96
expectedOverflow = $true
dpi = 96
ownerBounds = @(0, 0, 800, 600)
hostBounds = @(100, 50, 700, 550)
hostClient = @(0, 0, 600, 500)
viewportBounds = @(100, 50, 700, 486)
contentBounds = @(100, 20, 690, 920)
actions = @(
[pscustomobject]@{ id = 2; offscreen = $false; bounds = @(120, 500, 220, 534) },
[pscustomobject]@{ id = 1; offscreen = $false; bounds = @(560, 500, 680, 534) }
)
}
$decision = Test-UiaDialogSheet768Geometry $valid
if (-not $decision.accepted -or -not $decision.overflow) {
throw "RED: UIA #768 geometry accepted-control fixture was rejected"
}
$mutations = @(
@{ name = "dpi"; expected = "dpi-mismatch"; apply = { param($value) $value.dpi = 144 } },
@{ name = "owner"; expected = "host-outside-owner"; apply = { param($value) $value.hostBounds = @(201, 50, 801, 550) } },
@{ name = "content"; expected = "content-displaced"; apply = { param($value) $value.contentBounds = @(1000, 20, 1010, 920) } },
@{ name = "frame"; expected = "host-client-frame-mismatch"; apply = { param($value) $value.hostClient = @(0, 0, 580, 500) } },
@{ name = "actions"; expected = "footer-action-order-mismatch"; apply = { param($value) $value.actions[0].id = 7 } },
@{ name = "offscreen"; expected = "footer-offscreen"; apply = { param($value) $value.actions[1].offscreen = $true } },
@{ name = "footer"; expected = "footer-overlaps-viewport"; apply = { param($value) $value.actions[0].bounds = @(120, 480, 220, 514) } },
@{ name = "overflow"; expected = "unexpected-overflow"; apply = { param($value) $value.expectedOverflow = $false } }
)
foreach ($mutation in $mutations) {
$candidate = [Management.Automation.PSSerializer]::Deserialize(
[Management.Automation.PSSerializer]::Serialize($valid))
& $mutation.apply $candidate
$result = Test-UiaDialogSheet768Geometry $candidate
if ($result.accepted -or $result.reason -cne $mutation.expected) {
throw "RED: UIA #768 geometry $($mutation.name) mutation was not refused as $($mutation.expected)"
}
}
}

if ($DialogSheet768Only) {
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..\..\..")
Test-DialogSheet768SourceContract (
Get-Content -LiteralPath (Join-Path $repoRoot "Tools\windows\uia-live-gate.ps1") -Raw
)
Write-Host "ValidationRunner.Tests.ps1 DialogSheet768: PASS; executed=9"
exit 0
}

function Test-MultiProjectProtocolContracts([string] $stubSource, [string] $gateSource, [string] $stubPath, [string] $pwsh) {
foreach ($source in @($stubSource, $gateSource)) {
$errors = $null
Expand Down Expand Up @@ -3684,6 +3775,7 @@ try {
if ($uiaErrors.Count -ne 0) {
throw "RED: UIA live gate source does not parse"
}
Test-DialogSheet768SourceContract $uiaLiveGateSource
if ($uiaLiveGateSource -notmatch '\[switch\]\$CycleHierarchyOnly' -or
$uiaLiveGateSource -notmatch 'PostFixtureMutation\(\$shellWindow, 23\)' -or
$uiaLiveGateSource -notmatch 'UIA_CYCLE_HIERARCHY_EVIDENCE=' -or
Expand Down
11 changes: 9 additions & 2 deletions Tools/windows/ValidationRunner/Ui/NativeUiSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ void Lookup(string id, IntPtr parent, int controlId, IntPtr expected) =>
IntPtr viewport = Create("GraphCodeSheetViewport", prompt);
IntPtr content = Create("GraphCodeWindowsDialogContent", viewport);
IntPtr edit = Create("EDIT", content, 9904);
Lookup("ui.native.lookup.named-direct-viewport", prompt, 9904, edit);
Check("ui.native.lookup.named-direct-viewport", () => ActivationCases.Require(
GraphCodeUiaGateState.ControlById(prompt, 9904) == edit &&
GraphCodeUiaGateState.IsDirectChild(prompt, viewport) &&
GraphCodeUiaGateState.IsDirectChild(viewport, content),
"RED: prompt lookup or native direct-child ownership differs"));
Check("ui.native.lookup.hidden-write-read", () => ActivationCases.Require(
!PromptLookupFixture.IsWindowVisible(prompt) &&
GraphCodeUiaGateState.SetEditTextById(prompt, 9904, "owned fixture") &&
Expand Down Expand Up @@ -366,7 +370,10 @@ void Lookup(string id, IntPtr parent, int controlId, IntPtr expected) =>
IntPtr deepViewport = Create("GraphCodeSheetViewport", wrapper);
IntPtr deepContent = Create("GraphCodeWindowsDialogContent", deepViewport);
Create("EDIT", deepContent, 9904);
Lookup("ui.native.lookup.direct-viewport-required", deepRoot, 9904, IntPtr.Zero);
Check("ui.native.lookup.direct-viewport-required", () => ActivationCases.Require(
GraphCodeUiaGateState.ControlById(deepRoot, 9904) == IntPtr.Zero &&
!GraphCodeUiaGateState.IsDirectChild(deepRoot, deepViewport),
"RED: prompt lookup accepted a viewport below the required direct child"));
IntPtr nativeRoot = NewRoot("GraphCodeSheetHost");
IntPtr nativeViewport = Create("GraphCodeSheetViewport", nativeRoot);
IntPtr nativeContent = Create("GraphCodeNativeForm", nativeViewport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ public static bool IsControlOwnedBy(IntPtr parent, IntPtr control, int controlId
return parent != IntPtr.Zero && control != IntPtr.Zero &&
GetDlgCtrlID(control) == controlId && GetAncestor(control, 2) == parent;
}
public static bool IsDirectChild(IntPtr parent, IntPtr child) {
return parent != IntPtr.Zero && child != IntPtr.Zero && GetAncestor(child, 1) == parent;
}
public static int ControlIdOf(IntPtr control) {
return control == IntPtr.Zero ? 0 : GetDlgCtrlID(control);
}
Expand Down
Loading
Loading