summaryrefslogtreecommitdiff
path: root/test/feh.i
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-06-18 12:42:50 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-06-18 12:42:50 +0200
commit86673296e39ae9168c459e3309b20effd69cfa9a (patch)
tree29a8b6b0012856e3c649028b406e08a0d9e4a13a /test/feh.i
parenta900b2a735131a3d10e60be511d9d914887cdd32 (diff)
downloadfeh-86673296e39ae9168c459e3309b20effd69cfa9a.zip
Tests for caption mode. Whee.
Diffstat (limited to 'test/feh.i')
-rwxr-xr-xtest/feh.i30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/feh.i b/test/feh.i
index c65f6f0..6519401 100755
--- a/test/feh.i
+++ b/test/feh.i
@@ -3,7 +3,7 @@ use strict;
use warnings;
use 5.010;
-use Test::More tests => 52;
+use Test::More tests => 55;
use Time::HiRes qw/sleep/;
use X11::GUITest qw/:ALL/;
@@ -78,6 +78,16 @@ sub test_win_title {
}
}
+sub slurp {
+ my ($file) = @_;
+ my $ret;
+ local $/ = undef;
+ open(my $fh, '<', $file) or die("Can't open $file: $!");
+ $ret = <$fh>;
+ close($fh) or die("Can't close $file: $!");
+ return($ret);
+}
+
if (FindWindowLike(qr{^feh})) {
BAIL_OUT('It appears you have an open feh window. Please close it.');
}
@@ -231,3 +241,21 @@ test_win_title($win, 'feh [3 of 3] - test/ok.jpg');
SendKeys('{RIG}');
test_win_title($win, 'feh [1 of 3] - test/ok.png');
feh_stop();
+
+feh_start('--caption-path .captions', 'test/ok.png');
+SendKeys('cFoo Bar Quux Moep~');
+feh_stop();
+ok(-d 'test/.captions', 'autocreated captions directory');
+is(slurp('test/.captions/ok.png.txt'), 'Foo Bar Quux Moep',
+ 'Correct caption saved');
+
+feh_start('--caption-path .captions', 'test/ok.png');
+SendKeys('c');
+SendKeys('{BKS}' x length('Foo Bar Quux Moep'));
+SendKeys('Foo Bar^(~)miep~');
+feh_stop();
+is(slurp('test/.captions/ok.png.txt'), "Foo Bar\nmiep",
+ 'Caption with newline + correct backspace');
+
+unlink('test/.captions/ok.png.txt');
+rmdir('test/.captions');