Skip to content

Commit

Permalink
Write tests for _calculate_clickpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lruzicka committed Aug 25, 2020
1 parent 6442f88 commit 7556fe0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions t/03-testapi.t
Original file line number Diff line number Diff line change
Expand Up @@ -683,4 +683,32 @@ subtest 'autoinst_url' => sub {
is(autoinst_url('foo'), 'http://localhost:1/foo', 'we can configure the hostname that autoinst_url returns');
};

subtest '_calculate_clickpoint' => sub {
my %fake_needle = (
area => [{x => 10, y => 10, w => 20, h => 30}],
);
my %fake_needle_area = (x => 100, y => 100, w => 50, h => 40);
my %fake_click_point = (xpos => 20, ypos => 10);

# Everything is provided.
my ($x, $y) = testapi::_calculate_clickpoint(\%fake_needle, \%fake_needle_area, \%fake_click_point);
is($x, 120);
is($y, 110);

# Everything is provided but the click point is 'center'
($x, $y) = testapi::_calculate_clickpoint(\%fake_needle, \%fake_needle_area, "center");
is($x, 125);
is($y, 120);

# Just the area is provided and no click point.
($x, $y) = testapi::_calculate_clickpoint(\%fake_needle, \%fake_needle_area);
is($x, 125);
is($y, 120);

# Just the needle is provided and no area and click point.
($x, $y) = testapi::_calculate_clickpoint(\%fake_needle);
is($x, 20);
is($y, 25);
};

done_testing;

0 comments on commit 7556fe0

Please sign in to comment.