Exercise signed Windows native Save dialogs, file contents and Hand panning

This commit is contained in:
Codex committed 2026-11-30 18:24:36 +01:00
1 parent 21b587ec5e
commit 5d909d6519
3 files changed
+175 -31

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
param([int] $AppProcessId, [string] $Filename)
$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName UIAutomationClient,UIAutomationTypes
$ae = [System.Windows.Automation.AutomationElement]
$scope = [System.Windows.Automation.TreeScope]
$cond = [System.Windows.Automation.PropertyCondition]::new($ae::ProcessIdProperty, $AppProcessId)
$stop = [datetime]::UtcNow.AddSeconds(40)
do {
$top = $ae::RootElement.FindAll($scope::Children, $cond)
foreach ($window in $top) {
if ($window.Current.ClassName -ne '#32770') { continue }
$save = $window.FindFirst($scope::Descendants, [System.Windows.Automation.PropertyCondition]::new($ae::AutomationIdProperty, '1'))
if (!$save -or $save.Current.ControlType -ne [System.Windows.Automation.ControlType]::Button) { continue }
$edits = $window.FindAll($scope::Descendants, [System.Windows.Automation.PropertyCondition]::new($ae::ControlTypeProperty, [System.Windows.Automation.ControlType]::Edit))
$field = $edits | Where-Object { $_.Current.AutomationId -eq '1001' -or $_.Current.Name -like 'File name*' } | Select-Object -First 1
if (!$field) { continue }
$field.GetCurrentPattern([System.Windows.Automation.ValuePattern]::Pattern).SetValue($Filename)
Write-Host "Native picker '$($window.Current.Name)', confirmed '$Filename' with '$($save.Current.Name)'."
$save.GetCurrentPattern([System.Windows.Automation.InvokePattern]::Pattern).Invoke()
exit 0
}
Start-Sleep -Milliseconds 200
} until ([datetime]::UtcNow -gt $stop)
throw "No native file-name control in a dialog owned by process $AppProcessId."
+119
View File
@@ -0,0 +1,119 @@
"""Exercise Windows native file dialogs on the signed portable in an isolated hosted desktop."""
import hashlib
import json
import os
from pathlib import Path
import secrets
import socket
import subprocess
import sys
import tempfile
import time
root = Path(tempfile.mkdtemp(prefix="VectorCraft-GUI-"))
profile = root / "prefs"
profile.mkdir()
with socket.socket() as reserve:
reserve.bind(("127.0.0.1", 0))
port = reserve.getsockname()[1]
token = secrets.token_hex(32)
process = subprocess.Popen([sys.argv[1], "--control", str(port), "--automation-read-root", str(root),
"--automation-write-root", str(root)], env=dict(os.environ,
VECTORCRAFT_CONFIG_DIR=str(profile), VECTORCRAFT_CONTROL_TOKEN=token))
def wait(probe, message, timeout=35):
end = time.monotonic() + timeout
while time.monotonic() < end and process.poll() is None:
value = probe()
if value:
return value
time.sleep(.2)
raise AssertionError(message)
def connect():
try:
return socket.create_connection(("127.0.0.1", port), timeout=1)
except OSError:
return None
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
try:
sock = wait(connect, "Timed out connecting to signed application", 70)
sock.settimeout(30)
pipe = sock.makefile("rwb")
def call(method, **params):
pipe.write((json.dumps(dict(id=1, method=method, params=params))+"\n").encode())
pipe.flush()
result=json.loads(pipe.readline())
if not result.get("ok"):
raise RuntimeError((method,result))
return result.get("result")
def engine(command, **params):
return call("engine.execute",command=command,params=params)
def state():
return call("ui.inspect")
def title():
s=state()
return s["documents"][s["activeDocument"]]["title"]
def object_count():
return sum(len(layer["children"]) for layer in engine("document.inspect")["layers"])
def picker(filename, before):
# The native dialog is on its own thread; start the PID-scoped responder before invoking the UI action.
responder = subprocess.Popen(["powershell.exe","-NoProfile","-File",str(Path(__file__).with_name("qa-fill-save.ps1")),
"-AppProcessId",str(process.pid),"-Filename",str(filename)])
try:
before()
assert responder.wait(timeout=45)==0,filename
wait(lambda: filename.exists() and filename.stat().st_size>0, f"Missing {filename}")
wait(lambda: not state()["fileDialog"], "Picker did not close")
finally:
if responder.poll() is None:
responder.kill()
def shortcut(**mods):
return call("ui.key",key="s",cmd=True,ctrl=True,**mods)
call("auth",token=token)
engine("file.new",width=500,height=350)
engine("shape.rectangle",x=35,y=40,width=70,height=65)
original=root/"first.vectorcraft"
renamed=root/"renamed.vectorcraft"
copy=root/"saved copy.vectorcraft"
template=root/"saved template.vctemplate"
picker(original,shortcut)
wait(lambda: original.stem in title(), "Unnamed Save did not set title")
original_hash=digest(original)
engine("shape.rectangle",x=130,y=90,width=90,height=75)
picker(renamed,lambda: shortcut(shift=True))
wait(lambda: renamed.stem in title(), "Save As did not switch to new path")
assert digest(original)==original_hash
picker(copy,lambda: shortcut(alt=True))
assert renamed.stem in title()
# Save as Template has no shortcut; invoke its normal menu action.
picker(template,lambda: call("ui.menu.invoke",command="file.saveAsTemplate",params={}))
assert renamed.stem in title()
before=digest(renamed)
engine("shape.rectangle",x=210,y=60,width=40,height=50)
shortcut()
wait(lambda: digest(renamed)!=before, "Save did not update the working document")
assert digest(original)==original_hash
# Reopen each saved file; template opening creates an untitled document from its contents.
for path, count in [(original,1),(copy,2),(template,2),(renamed,3)]:
if path==template:
engine("file.newFromTemplate",path=str(path))
else:
engine("file.open",path=str(path))
wait(lambda: object_count()==count, f"{path.name} should contain {count} rectangles")
print(path.name,path.stat().st_size,digest(path),"objects:",count,flush=True)
view=state(); x,y,w,h=view["canvasRect"]
engine("tool.select",tool="selection")
call("ui.key",key="h")
wait(lambda: state()["tool"]=="hand","H failed to select Hand")
before=state()["view"]
call("ui.drag",x=x+w*.4,y=y+h*.4,toX=x+w*.4+60,toY=y+h*.4+40,steps=8)
after=state()["view"]
assert before["zoom"]==after["zoom"] and before["center"]!=after["center"],(before,after)
print("Hand selected by H moved the canvas centre",before["center"],after["center"],flush=True)
finally:
if process.poll() is None:
process.terminate()
+32 -31
View File
@@ -1,36 +1,37 @@
# Windows ARM64 build and smoke test.
#
# Release packages on arm64-windows are produced on x64 runners via cross-compilation
# (target: aarch64-pc-windows-msvc) using MSVC's ARM64 cross tools, then installed and run
# on GitHub Actions' native windows-11-arm runner.
name: Windows ARM64
# Nightly on main and on pushes to `release` (dependency and runner-image drift shows up within a
# day, and always before a release ships), and on PRs that change the Windows packaging itself.
name: Validate the signed Windows portable
on:
schedule:
- cron: "3 5 * * *"
push:
branches: [release]
pull_request:
paths:
- .github/workflows/windows-arm64.yml
- packaging/windows/**
workflow_dispatch:
concurrency:
group: windows-arm64-${{ github.ref }}
cancel-in-progress: true
inputs:
release:
description: Release tag containing the signed Windows portable
type: string
required: true
default: v0.25.1
permissions:
contents: read
jobs:
windows-arm64:
# Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos.
uses: storytold/craft-common-actions/.github/workflows/windows-arm64.yml@main
with:
app-name: vectorcraft
app-dir: VectorCraft
install-relative-path: Programs/ArtCraft/VectorCraft
install-scope: perUser
validate:
runs-on: windows-2022
timeout-minutes: 14
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Verify portable signature and exercise the native Windows file pickers
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.release }}
run: |
$ErrorActionPreference = 'Stop'
$download = Join-Path $env:RUNNER_TEMP 'vectorcraft-qa'
New-Item -ItemType Directory -Path $download | Out-Null
gh release download $env:RELEASE_TAG --pattern '*windows-x64-portable.zip' --dir $download
$asset = Get-ChildItem $download -Filter '*.zip' | Select-Object -First 1
Get-FileHash $asset.FullName
Expand-Archive $asset.FullName "$download/expanded"
$exe = Get-ChildItem "$download/expanded" -Recurse -Filter vectorcraft.exe | Select-Object -First 1
$signature = Get-AuthenticodeSignature $exe.FullName
if ($signature.Status -ne 'Valid') { throw "Authenticode: $($signature.Status) $($signature.StatusMessage)" }
$signature.SignerCertificate | Format-Table Subject, Thumbprint
python .github/qa-windows-saves.py $exe.FullName