Skip to content

Commit

Permalink
WIP (append to: last verify_sound_image commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-richardson committed Nov 23, 2022
1 parent d4297e3 commit 84436b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions basetest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Create a media fragment time from a given framenumber
=cut

sub _framenumber_to_timerange ($frame) {
return [sprintf("%.2f", $frame / 24.0), sprintf("%.2f", ($frame + 1) / 24.0)];
return defined($frame) ? [sprintf("%.2f", $frame / 24.0), sprintf("%.2f", ($frame + 1) / 24.0)] : undef;
}

sub record_screenmatch ($self, $img, $match, $tags = [], $failed_needles = [], $frame = undef) {
Expand All @@ -139,7 +139,7 @@ sub record_screenmatch ($self, $img, $match, $tags = [], $failed_needles = [], $
json => $serialized_match->{json},
tags => [@$tags], # make a copy
properties => [@$properties], # make a copy
frametime => defined($frame) ? _framenumber_to_timerange($frame) : undef,
frametime => _framenumber_to_timerange($frame),
screenshot => $self->next_resultname('png'),
result => 'ok',
};
Expand Down
10 changes: 6 additions & 4 deletions t/17-basetest.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sub fake_read_json ($fd) {
}
elsif ($cmd eq 'backend_verify_image') {
return {ret => {found => {needle => {name => 'foundneedle', file => 'foundneedle.json'}, area => [{x => 1, y => 2, similarity => 100}]}, candidates => []}} unless $suppress_match;
return {ret => {candidates => [{name => 'foundneedle', file => 'foundneedle.json'}]}};
return {ret => {candidates => [{name => 'candidate_needle', file => 'candidate_needle.json'}]}};
}
elsif ($cmd eq 'last_milestone_console') {
return {};
Expand Down Expand Up @@ -486,9 +486,11 @@ subtest verify_sound_image => sub {
is($res->{needle}->{name}, 'foundneedle', 'needle name was returned');
# $suppress_match = 'yes';
# my $test_without_match = basetest->new();
# $res = $test_without_match->verify_sound_image("$FindBin::Bin/data/frame1.ppm", 'notapath2', 'check');
# is($res->{result}->{$status}, 'unk', 'no needle match: unknown status correct');
# is($res->{result}, 'fail', 'no needle match: overall fail correct');
# diag explain $res;
# $res = $test_without_match->verify_sound_image("$FindBin::Bin/data/frame1.ppm", "$FindBin::Bin/data/frame2.ppm", 'check');
# diag explain $res;
# is($res->{details}->{status}, 'unk', 'no needle match: unknown status correct') or diag explain $res->{details};
# is($res->{details}, 'fail', 'no needle match: overall fail correct') or diag explain $res->{details};
};

subtest rollback_activated_consoles => sub {
Expand Down

0 comments on commit 84436b8

Please sign in to comment.