From 86673296e39ae9168c459e3309b20effd69cfa9a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 18 Jun 2010 12:42:50 +0200 Subject: Tests for caption mode. Whee. --- test/feh.i | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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'); -- cgit v1.2.3