31 lines
1.9 KiB
PowerShell
31 lines
1.9 KiB
PowerShell
#Requires -Version 5.1
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference='Stop'
|
|
$root=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
|
$scratch=Join-Path ([IO.Path]::GetTempPath()) ('ms-private-gui-test-'+[guid]::NewGuid().ToString('N'))
|
|
try{
|
|
[IO.Directory]::CreateDirectory($scratch)|Out-Null
|
|
foreach($folder in @('src','config')){Copy-Item -LiteralPath (Join-Path $root $folder) -Destination $scratch -Recurse}
|
|
$source=[IO.File]::ReadAllText((Join-Path $root 'ms-private-GUI.ps1'))
|
|
$marker='[void]$form.ShowDialog()'
|
|
if(([regex]::Matches($source,[regex]::Escape($marker))).Count-ne1){throw 'GUI smoke test requires exactly one top-level window entry point.'}
|
|
# Construct the real controls and event handlers without opening a window or clicking mutation actions.
|
|
$check=@'
|
|
try{
|
|
if($tabs.TabPages.Count-ne6){throw 'Expected six GUI tabs.'}
|
|
if($capturePath.Parent-ne$network-or$stopCapture.Parent-ne$network-or$convertCapture.Parent-ne$network){throw 'Capture controls are not attached to the network tab.'}
|
|
if($stopCapture.Tag-ne'CaptureStop'-or$convertCapture.Tag-ne'CaptureConvert'){throw 'Capture controls target the wrong commands.'}
|
|
if($securityAudit.Parent-ne$maintenance){throw 'Security audit button is missing.'}
|
|
if($homeTab.Controls.Count-lt9){throw 'Home guide controls are missing.'}
|
|
Write-Output 'GUI construction smoke check passed. No window actions were invoked.'
|
|
}finally{$form.Dispose()}
|
|
'@
|
|
$path=Join-Path $scratch 'ms-private-GUI.ps1'
|
|
[IO.File]::WriteAllText($path,$source.Replace($marker,$check),[Text.UTF8Encoding]::new($false))
|
|
& $path
|
|
}finally{
|
|
$temp=[IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('\')+'\'
|
|
if(-not[IO.Path]::GetFullPath($scratch).StartsWith($temp,[StringComparison]::OrdinalIgnoreCase)){throw 'Unsafe GUI test cleanup path.'}
|
|
if([IO.Directory]::Exists($scratch)){[IO.Directory]::Delete($scratch,$true)}
|
|
}
|