summaryrefslogtreecommitdiff
path: root/test/feh.i
diff options
context:
space:
mode:
Diffstat (limited to 'test/feh.i')
-rwxr-xr-xtest/feh.i61
1 files changed, 59 insertions, 2 deletions
diff --git a/test/feh.i b/test/feh.i
index 0a38bf1..5edbce6 100755
--- a/test/feh.i
+++ b/test/feh.i
@@ -3,24 +3,43 @@ use strict;
use warnings;
use 5.010;
-use Test::More tests => 3;
+use Test::More tests => 12;
use X11::GUITest qw/
FindWindowLike
+ GetWindowName
StartApp
SendKeys
WaitWindowViewable
/;
+my $win;
+
sub feh_start {
my ($opts, $files) = @_;
+ my $id;
$opts //= q{};
$files //= 'test/ok.png';
StartApp("feh ${opts} ${files}");
- if (WaitWindowViewable(qr{^feh}) == 0) {
+ ($id) = WaitWindowViewable(qr{^feh});
+
+ if (not $id) {
BAIL_OUT("Unable to start feh ${opts} ${files}");
}
+
+ return $id;
+}
+
+sub feh_stop {
+ SendKeys('{ESC}');
+ for (1 .. 10) {
+ sleep(0.1);
+ if (FindWindowLike(qr{^feh}) == 0) {
+ return;
+ }
+ }
+ BAIL_OUT("Unclosed feh window still open, cannot continue");
}
sub test_no_win {
@@ -37,6 +56,23 @@ sub test_no_win {
BAIL_OUT("unclosed window still open, cannot continue");
}
+sub test_win_title {
+ my ($win, $wtitle) = @_;
+ my $rtitle;
+
+ for (1 .. 10) {
+ sleep(0.1);
+ $rtitle = GetWindowName($win);
+ if ($rtitle eq $wtitle) {
+ pass("Window has title: $wtitle");
+ return;
+ }
+ }
+ fail("Window has title: $wtitle");
+ diag("expected: $wtitle");
+ diag(" got: $rtitle");
+}
+
if (FindWindowLike(qr{^feh})) {
BAIL_OUT('It appears you have an open feh window. Please close it.');
}
@@ -46,3 +82,24 @@ for my $key (qw/q x {ESC}/) {
SendKeys($key);
test_no_win("$key pressed");
}
+
+$win = feh_start(q{}, 'test/ok.png');
+test_win_title($win, 'feh [1 of 1] - test/ok.png');
+feh_stop();
+
+$win = feh_start(q{}, 'test/ok.png test/ok.jpg test/ok.gif');
+test_win_title($win, 'feh [1 of 3] - test/ok.png');
+SendKeys('{RIG}');
+test_win_title($win, 'feh [2 of 3] - test/ok.jpg');
+SendKeys('{RIG}');
+test_win_title($win, 'feh [3 of 3] - test/ok.gif');
+SendKeys('{RIG}');
+test_win_title($win, 'feh [1 of 3] - test/ok.png');
+SendKeys('{LEF}');
+test_win_title($win, 'feh [3 of 3] - test/ok.gif');
+SendKeys('{DEL}');
+test_win_title($win, 'feh [1 of 2] - test/ok.png');
+SendKeys('{DEL}');
+test_win_title($win, 'feh [1 of 1] - test/ok.jpg');
+SendKeys('{DEL}');
+test_no_win("Removed all images from slideshow");