63 lines
2.8 KiB
PowerShell
63 lines
2.8 KiB
PowerShell
param([Parameter(Mandatory)][string]$Executable)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
. "$PSScriptRoot/files_commands_ui.ps1"
|
|
|
|
$dpi = [FilesCommandsUi]::SetThreadDpiAwarenessContext([IntPtr](-4))
|
|
$process = $null
|
|
try {
|
|
$process = Start-Process -FilePath (Resolve-Path -LiteralPath $Executable) -PassThru
|
|
$main = Wait-For 'the Files window' {
|
|
$process.Refresh()
|
|
if ($process.MainWindowHandle -ne [IntPtr]::Zero) { $process.MainWindowHandle }
|
|
}
|
|
[void][FilesCommandsUi]::ShowWindow($main, 9)
|
|
$width = [int](350 * [FilesCommandsUi]::GetDpiForWindow($main) / 96)
|
|
if (![FilesCommandsUi]::SetWindowPos($main, [IntPtr]::Zero, 0, 0, $width, 0, 22)) {
|
|
throw 'Could not narrow the Files window.'
|
|
}
|
|
Invoke-FilesCommand $main 'Space Analyzer'
|
|
$dialog = Wait-For 'the visible Space Analyzer' {
|
|
$candidate = [IntPtr]::Zero
|
|
while (($candidate = [FilesCommandsUi]::FindWindowEx([IntPtr]::Zero, $candidate, '#32770', 'Space Analyzer')) -ne [IntPtr]::Zero) {
|
|
[uint32]$owner = 0
|
|
[void][FilesCommandsUi]::GetWindowThreadProcessId($candidate, [ref]$owner)
|
|
if ($owner -eq $process.Id -and [FilesCommandsUi]::IsWindowVisible($candidate)) { return $candidate }
|
|
}
|
|
}
|
|
|
|
$outer = [FilesCommandsUi+Rect]::new()
|
|
if (![FilesCommandsUi]::GetWindowRect($dialog, [ref]$outer)) { throw 'Could not measure the Space Analyzer.' }
|
|
$previousRight = $outer.Left
|
|
$firstLeft = 0
|
|
$midY = 0
|
|
foreach ($id in 492, 493, 494, 1, 2) {
|
|
$button = [FilesCommandsUi]::GetDlgItem($dialog, $id)
|
|
$rect = [FilesCommandsUi+Rect]::new()
|
|
if (![FilesCommandsUi]::IsWindowVisible($button) -or ![FilesCommandsUi]::GetWindowRect($button, [ref]$rect)) {
|
|
throw "Space Analyzer footer button $id was unavailable."
|
|
}
|
|
if ($rect.Left -le $previousRight -or $rect.Right -ge $outer.Right -or $rect.Bottom -ge $outer.Bottom) {
|
|
throw "Space Analyzer footer button $id was clipped or overlapped at narrow width."
|
|
}
|
|
if ($id -eq 492) {
|
|
$firstLeft = $rect.Left
|
|
$midY = $rect.Top + $rect.Bottom
|
|
} elseif ([Math]::Abs($midY - $rect.Top - $rect.Bottom) -gt 1) {
|
|
throw "Space Analyzer footer button $id was outside the shared button row."
|
|
}
|
|
$previousRight = $rect.Right
|
|
}
|
|
if ([Math]::Abs(($firstLeft + $previousRight) - ($outer.Left + $outer.Right)) -gt 2) {
|
|
throw 'Space Analyzer footer buttons were off center.'
|
|
}
|
|
'Verified the full and centered Space Analyzer footer at narrow width.'
|
|
} finally {
|
|
# End this fixture without saving its temporary window dimensions.
|
|
if ($process -and !$process.HasExited) {
|
|
$process.Kill()
|
|
$process.WaitForExit()
|
|
}
|
|
if ($dpi) { [void][FilesCommandsUi]::SetThreadDpiAwarenessContext($dpi) }
|
|
}
|