Wait for actual native board UI before fixture assertions
This commit is contained in:
@@ -64,14 +64,46 @@ function FixtureState($Board,[string]$Type,[int]$Stage){
|
||||
if($Type-eq'free'){$state.latestFreePlay=Clone $Board}else{$state.puzzleStates=@($state.puzzleStates|Where-Object stageId -ne $Stage)+@(Clone $Board)}
|
||||
return $state
|
||||
}
|
||||
function BoardScreen([string]$Path){
|
||||
Add-Type -AssemblyName System.Drawing;$image=[Drawing.Bitmap]::new($Path)
|
||||
$pixels=[Collections.Generic.List[object]]::new();$gold=0;$world=0
|
||||
try{
|
||||
if($image.Width-eq2400-and$image.Height-eq1080){
|
||||
foreach($point in @(@(80,70),@(380,70),@(80,140),@(380,140))){
|
||||
$pixel=$image.GetPixel($point[0],$point[1]);$pixels.Add(@{x=$point[0];y=$point[1];r=$pixel.R;g=$pixel.G;b=$pixel.B})
|
||||
if($pixel.R-ge230-and$pixel.G-ge185-and$pixel.G-le210-and$pixel.B-ge60-and$pixel.B-le90){$gold++}
|
||||
}
|
||||
foreach($x in @(600,1200,1800)){foreach($y in @(300,500,700)){
|
||||
$pixel=$image.GetPixel($x,$y);$pixels.Add(@{x=$x;y=$y;r=$pixel.R;g=$pixel.G;b=$pixel.B})
|
||||
if($pixel.R-gt20-or$pixel.G-gt20-or$pixel.B-gt20){$world++}
|
||||
}}
|
||||
}
|
||||
return @{ready=$gold-eq4-and$world-ge3;width=$image.Width;height=$image.Height;goldCorners=$gold;nonblackWorldSamples=$world;pixels=$pixels.ToArray()}
|
||||
}finally{$image.Dispose()}
|
||||
}
|
||||
function WaitBoard([string]$Name){
|
||||
$observations=[Collections.Generic.List[object]]::new();$ready=$false;$state=$null
|
||||
try{
|
||||
for($attempt=0;$attempt-lt30;$attempt++){
|
||||
$stepName="$Name-board-ready-$attempt";Step $stepName @() 500
|
||||
$png=Join-Path $EvidenceDir "$stepName.png";$screen=BoardScreen $png
|
||||
$state=Save "$stepName-save";$savePath=Join-Path $EvidenceDir "$stepName-save.json"
|
||||
$observations.Add(@{attempt=$attempt;utc=[DateTime]::UtcNow.ToString('o');png=$png;pngSha256=(Get-FileHash -LiteralPath $png).Hash;screen=$screen;save=$savePath;saveSha256=(Get-FileHash -LiteralPath $savePath).Hash})
|
||||
if($screen.ready){$ready=$true;break}
|
||||
}
|
||||
Check "$Name-board-ui-ready" $ready 'Actual 2400x1080 board: four golden Home-button corners and nonblack world samples; unchanged pulled save alone is never entry proof; at most 30 observations at 500ms intervals'
|
||||
Copy-Item -LiteralPath $observations[-1].save -Destination (Join-Path $EvidenceDir "$Name-entered.json")
|
||||
return $state
|
||||
}finally{@{ready=$ready;finishedUtc=[DateTime]::UtcNow.ToString('o');observations=$observations.ToArray()}|ConvertTo-Json -Depth 8|Set-Content -LiteralPath (Join-Path $EvidenceDir "$Name-board-readiness.json") -Encoding utf8}
|
||||
}
|
||||
function LoadFixture([string]$Name,$State,[string]$Type,[int]$Stage){
|
||||
Adb @('shell','am','force-stop',$package)|Out-Null
|
||||
$path=Join-Path $EvidenceDir "$Name-injected.json";$State|ConvertTo-Json -Depth 20|Set-Content -LiteralPath $path -Encoding utf8
|
||||
@{name=$Name;origin='Actual Fresh30/thirty-completed.json; explicitly labelled injected boundary case';originalFile=$originalPath;originalSha256=(Get-FileHash -LiteralPath $originalPath).Hash;fixtureSha256=(Get-FileHash -LiteralPath $path).Hash;changedFields=@('puzzleStates','latestFreePlay');preservedFields=@('schemaVersion','completedStageIds','seenTutorialIds');utc=[DateTime]::UtcNow.ToString('o')}|ConvertTo-Json -Depth 5|Set-Content -LiteralPath (Join-Path $EvidenceDir "$Name-origin.json")
|
||||
Adb @('push',$path,$remote)|Out-Null;Adb @('push',$path,($remote+'.bak'))|Out-Null
|
||||
StartHome "$Name-home"
|
||||
if($Type-eq'free'){Step "$Name-enter-free" @('shell','input','tap','1200','810') 1500}else{SelectStage "$Name-enter-puzzle" $Stage}
|
||||
return Save "$Name-entered"
|
||||
if($Type-eq'free'){Step "$Name-enter-free" @('shell','input','tap','1200','810') 0}else{SelectStage "$Name-enter-puzzle" $Stage}
|
||||
return WaitBoard $Name
|
||||
}
|
||||
function PreservesOtherSlots([string]$Name,$Before,$After,[string]$Type,[int]$Stage){
|
||||
Check "$Name-progress-preserved" ((Same $Before.completedStageIds $After.completedStageIds)-and(Same $Before.seenTutorialIds $After.seenTutorialIds)-and$After.schemaVersion-eq1) 'Completion/unlock/tutorial/schema unchanged'
|
||||
|
||||
Reference in New Issue
Block a user