diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | man/feh.pre | 27 | ||||
-rwxr-xr-x | scripts/checkopts.pl | 2 | ||||
-rw-r--r-- | share/applications/feh.pre | 2 | ||||
-rw-r--r-- | src/events.c | 28 | ||||
-rw-r--r-- | src/filelist.c | 3 | ||||
-rw-r--r-- | src/imlib.c | 6 | ||||
-rw-r--r-- | src/options.c | 5 | ||||
-rw-r--r-- | src/wallpaper.c | 38 | ||||
-rwxr-xr-x | test/feh-bg-i.t (renamed from test/feh-bg.i) | 35 | ||||
-rwxr-xr-x | test/feh-i.t | 461 | ||||
-rwxr-xr-x | test/feh-scr-i.t (renamed from test/feh-scr.i) | 177 | ||||
-rwxr-xr-x | test/feh.i | 453 | ||||
-rw-r--r-- | test/feh.t | 70 | ||||
-rwxr-xr-x | test/mandoc.t | 8 | ||||
-rwxr-xr-x | test/run-interactive | 2 |
17 files changed, 687 insertions, 646 deletions
@@ -1,3 +1,15 @@ +git HEAD + + * Allow non-centered wallpapers using the --geometry option + (Patch by Joel Bradshaw) + * Add ; flag to --info (as in "--info ';echo foo'") to disable info + display on startup + * Partially fix off-by-one pixel error when warping the pointer in the + bottom/right window border + * thumbnail mode: If --action is set, run specified command instead of + opening image on click. + * feh.desktop: Use feh %F since we support multiple files + Tue, 11 Jun 2013 08:27:24 +0200 Daniel Friesel <derf+feh@finalrewind.org> * Release v2.9.3 @@ -12,11 +12,11 @@ build-applications: @${MAKE} -C share/applications test: all - @PACKAGE=${PACKAGE} prove test + @PACKAGE=${PACKAGE} prove test/feh.t test/mandoc.t test-x11: all test/run-interactive - prove test/feh-bg.i + prove test/feh-bg-i.t install: install-man install-doc install-bin install-font install-img install: install-examples install-applications diff --git a/man/feh.pre b/man/feh.pre index 3c1b979..6831a6e 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -136,7 +136,8 @@ For animated images, only the first frame is shown. Specify a shell command as an action to perform on the image. In slideshow or multiwindow mode, the action will be run when the action_0 key is pressed, in list mode, it will be run for each file. In loadable/unloadable mode, it will -be run for each loadable/unloadable file, respectively. +be run for each loadable/unloadable file, respectively. In thumbnail mode, +clicking on an image will cause the action to run instead of opening the image. . .Pp . @@ -357,7 +358,7 @@ window becomes visible. Use .Cm --preload to get a progress bar. . -.It Cm --info Ar commandline +.It Cm --info Oo Ar flag Oc Ns Ar commandline . Execute .Ar commandline @@ -365,6 +366,13 @@ and display its output in the bottom left corner of the image. Can be used to display e.g. image dimensions or EXIF information. Supports .Sx FORMAT SPECIFIERS . . +If +.Ar flag +is set to +.Qo ; Qc , +the output will not be displayed by default, but has to be enabled by the +toggle_info key. +. .It Cm -k , --keep-http . When viewing files using HTTP, @@ -753,13 +761,26 @@ to your X startup script . .Pp . +For the +.Cm --bg-center +and +.Cm --bg-max +options, you can use the +.Cm --geometry +option to specify an offset from one side of the screen instead of +centering the image. Positive values will offset from the left/top +side, negative values from the bottom/right. +0 and -0 are both +valid and distinct values. +. +.Pp +. Note that all options except .Cm --bg-tile support Xinerama. For instance, if you have multiple screens connected and use e.g. .Cm --bg-center , .Nm -will center the image on each screen. +will center or appropriately offset the image on each screen. You may even specify more than one file, in that case, the first file is set on screen 0, the second on screen 1, and so on. . diff --git a/scripts/checkopts.pl b/scripts/checkopts.pl index ec82343..3a4b884 100755 --- a/scripts/checkopts.pl +++ b/scripts/checkopts.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -## Copyright © 2010 by Daniel Friesel <derf@derf.homelinux.org> +## Copyright © 2010 by Daniel Friesel <derf@finalrewind.org> ## License: WTFPL <http://sam.zoy.org/wtfpl> use strict; use warnings; diff --git a/share/applications/feh.pre b/share/applications/feh.pre index e8d9541..5d867a2 100644 --- a/share/applications/feh.pre +++ b/share/applications/feh.pre @@ -1,7 +1,7 @@ [Desktop Entry] Name=Feh Comment=Fast Imlib2-based Image Viewer -Exec=feh %f +Exec=feh %F Terminal=false Type=Application Icon=$IMAGEDIR$/feh.png diff --git a/src/events.c b/src/events.c index fadae9b..e6cf0ac 100644 --- a/src/events.c +++ b/src/events.c @@ -378,8 +378,12 @@ static void feh_event_handle_ButtonRelease(XEvent * ev) x /= winwid->zoom; y /= winwid->zoom; thumbfile = feh_thumbnail_get_file_from_coords(x, y); - if (thumbfile) - feh_thumbnail_show_fullsize(thumbfile); + if (thumbfile) { + if (opt.actions[0]) + feh_action_run(thumbfile, opt.actions[0]); + else + feh_thumbnail_show_fullsize(thumbfile); + } } } else { opt.mode = MODE_NORMAL; @@ -578,36 +582,38 @@ static void feh_event_handle_MotionNotify(XEvent * ev) winwidget_sanitise_offsets(winwid); - D(("im_x %d, im_w %d, off %d, mx %d\n", winwid->im_x, - winwid->im_w, winwid->click_offset_x, ev->xmotion.x)); + D(("im_x %d, im_w %d, off %d, mx %d, my %d\n", winwid->im_x, + winwid->im_w, winwid->click_offset_x, ev->xmotion.x, + ev->xmotion.y)); /* XWarpPointer generates a MotionNotify event which we will * parse. Since that event would undo the effect of the pointer * warp, we need to change the click_offset to compensate this. */ - if ((winwid->w - ev->xmotion.x <= 1) - && (winwid->click_offset_x >= winwid->w - 4)) + if ((winwid->w - ev->xmotion.x <= 1) && (winwid->im_x < 0)) { XWarpPointer(disp, None, winwid->win, 0, 0, 0, 0, 3, ev->xmotion.y); winwid->click_offset_x -= winwid->w - 4; } - else if ((ev->xmotion.x <= 1) && (winwid->click_offset_x - <= (winwid->im_w * winwid->zoom) - winwid->w - 3)) + // TODO needlessly warps for certain zoom levels + else if ((ev->xmotion.x <= 1) && (winwid->im_x > + (winwid->w - winwid->im_w * winwid->zoom))) { XWarpPointer(disp, None, winwid->win, 0, 0, 0, 0, winwid->w - 4, ev->xmotion.y); winwid->click_offset_x += winwid->w - 4; } else if ((winwid->h - ev->xmotion.y <= 1) - && (winwid->click_offset_y >= winwid->h - 4)) + && (winwid->im_y < 0)) { XWarpPointer(disp, None, winwid->win, 0, 0, 0, 0, ev->xmotion.x, 3); winwid->click_offset_y -= winwid->h - 4; } - else if ((ev->xmotion.y <= 1) && (winwid->click_offset_y - <= (winwid->im_h * winwid->zoom) - winwid->h - 3)) + // TODO needlessly warps for certain zoomlevels + else if ((ev->xmotion.y <= 1) && (winwid->im_y > + (winwid->h - winwid->im_h * winwid->zoom))) { XWarpPointer(disp, None, winwid->win, 0, 0, 0, 0, ev->xmotion.x, winwid->h - 4); diff --git a/src/filelist.c b/src/filelist.c index bbde98c..8d19e41 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -213,7 +213,8 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level) if ((!strncmp(path, "http://", 7)) || (!strncmp(path, "https://", 8)) - || (!strncmp(path, "ftp://", 6))) { + || (!strncmp(path, "ftp://", 6)) + || (!strncmp(path, "file://", 7))) { /* Its a url */ D(("Adding url %s to filelist\n", path)); filelist = gib_list_add_front(filelist, feh_file_new(path)); diff --git a/src/imlib.c b/src/imlib.c index 2047c63..36de346 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -243,8 +243,10 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return 0; /* Handle URLs */ - if ((!strncmp(file->filename, "http://", 7)) || (!strncmp(file->filename, "https://", 8)) - || (!strncmp(file->filename, "ftp://", 6))) { + if ((!strncmp(file->filename, "http://", 7)) + || (!strncmp(file->filename, "https://", 8)) + || (!strncmp(file->filename, "ftp://", 6)) + || (!strncmp(file->filename, "file://", 7))) { image_source = SRC_HTTP; if ((tmpname = feh_http_load_image(file->filename)) == NULL) diff --git a/src/options.c b/src/options.c index 627c7da..c6166d9 100644 --- a/src/options.c +++ b/src/options.c @@ -717,7 +717,10 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) break; case 234: opt.info_cmd = estrdup(optarg); - opt.draw_info = 1; + if (opt.info_cmd[0] == ';') + opt.info_cmd++; + else + opt.draw_info = 1; break; case 235: opt.force_aliasing = 1; diff --git a/src/wallpaper.c b/src/wallpaper.c index 30c3925..886beb6 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -104,8 +104,21 @@ static void feh_wm_set_bg_centered(Pixmap pmap, Imlib_Image im, int use_filelist if (use_filelist) feh_wm_load_next(&im); - offset_x = (w - gib_imlib_image_get_width(im)) >> 1; - offset_y = (h - gib_imlib_image_get_height(im)) >> 1; + if(opt.geom_flags & XValue) + if(opt.geom_flags & XNegative) + offset_x = (w - gib_imlib_image_get_width(im)) + opt.geom_x; + else + offset_x = opt.geom_x; + else + offset_x = (w - gib_imlib_image_get_width(im)) >> 1; + + if(opt.geom_flags & YValue) + if(opt.geom_flags & YNegative) + offset_y = (h - gib_imlib_image_get_height(im)) + opt.geom_y; + else + offset_y = opt.geom_y; + else + offset_y = (h - gib_imlib_image_get_height(im)) >> 1; gib_imlib_render_image_part_on_drawable_at_size(pmap, im, ((offset_x < 0) ? -offset_x : 0), @@ -161,6 +174,7 @@ static void feh_wm_set_bg_maxed(Pixmap pmap, Imlib_Image im, int use_filelist, { int img_w, img_h, border_x; int render_w, render_h, render_x, render_y; + int margin_x, margin_y; if (use_filelist) feh_wm_load_next(&im); @@ -173,8 +187,24 @@ static void feh_wm_set_bg_maxed(Pixmap pmap, Imlib_Image im, int use_filelist, render_w = ( border_x ? ((img_w * h) / img_h) : w); render_h = ( !border_x ? ((img_h * w) / img_w) : h); - render_x = x + ( border_x ? ((w - render_w) >> 1) : 0); - render_y = y + ( !border_x ? ((h - render_h) >> 1) : 0); + if(opt.geom_flags & XValue) + if(opt.geom_flags & XNegative) + margin_x = (w - render_w) + opt.geom_x; + else + margin_x = opt.geom_x; + else + margin_x = (w - render_w) >> 1; + + if(opt.geom_flags & YValue) + if(opt.geom_flags & YNegative) + margin_y = (h - render_h) + opt.geom_y; + else + margin_y = opt.geom_y; + else + margin_y = (h - render_h) >> 1; + + render_x = x + ( border_x ? margin_x : 0); + render_y = y + ( !border_x ? margin_y : 0); gib_imlib_render_image_on_drawable_at_size(pmap, im, render_x, render_y, diff --git a/test/feh-bg.i b/test/feh-bg-i.t index 0e3b546..1f22c9d 100755 --- a/test/feh-bg.i +++ b/test/feh-bg-i.t @@ -8,12 +8,13 @@ use GD qw/:DEFAULT :cmp/; use Test::More tests => 70; use Time::HiRes qw/sleep/; -my ($pid_xnest, $pid_twm); +my $scr_dir = '/tmp/feh-test-scr'; +my ( $pid_xnest, $pid_twm ); $ENV{HOME} = 'test'; sub set_bg { - my ($mode, $file) = @_; + my ( $mode, $file ) = @_; ok( system("feh --bg-${mode} test/bg/${file}") == 0, @@ -22,26 +23,28 @@ sub set_bg { } sub same_files { - my ($one, $two) = @_; + my ( $one, $two ) = @_; my $img_one = GD::Image->new($one); my $img_two = GD::Image->new($two); - return( ! ($img_one->compare($img_two) & GD_CMP_IMAGE)); + return ( !( $img_one->compare($img_two) & GD_CMP_IMAGE ) ); } sub check_bg { my ($file) = @_; - system("import -silent -window root /tmp/feh_${$}.png"); + system("import -silent -window root ${scr_dir}/feh_${$}.png"); - ok( - same_files("test/bg/${file}", "/tmp/feh_${$}.png"), - "Wallpaper is test/bg/${file}" - ); + ok( same_files( "test/bg/${file}", "${scr_dir}/feh_${$}.png" ), + "Wallpaper is test/bg/${file}" ); +} + +if ( not -d $scr_dir ) { + mkdir($scr_dir); } -if (($pid_xnest = fork()) == 0) { +if ( ( $pid_xnest = fork() ) == 0 ) { exec(qw( Xephyr -screen 500x500 :7 )); } @@ -49,7 +52,7 @@ sleep(0.5); $ENV{'DISPLAY'} = ':7'; -if (($pid_twm = fork()) == 0) { +if ( ( $pid_twm = fork() ) == 0 ) { exec('twm'); } @@ -57,23 +60,23 @@ sleep(0.5); for my $mode (qw( center fill max scale tile )) { - set_bg($mode, 'exact/in'); + set_bg( $mode, 'exact/in' ); check_bg('exact/out'); for my $type (qw( exact small large )) { for my $orientation (qw( w h )) { - set_bg($mode, "${type}/${orientation}/in"); + set_bg( $mode, "${type}/${orientation}/in" ); check_bg("${type}/${orientation}/${mode}"); } } } -kill(15, $pid_twm); +kill( 15, $pid_twm ); sleep(0.2); -kill(15, $pid_xnest); +kill( 15, $pid_xnest ); sleep(0.2); -unlink("/tmp/feh_${$}.png"); +unlink("${scr_dir}/feh_${$}.png"); unlink('test/.fehbg'); diff --git a/test/feh-i.t b/test/feh-i.t new file mode 100755 index 0000000..dd47ff6 --- /dev/null +++ b/test/feh-i.t @@ -0,0 +1,461 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; + +use Cwd; +use Test::More tests => 103; +use Time::HiRes qw/sleep/; +use X11::GUITest qw/:ALL/; + +my $win; +my ( $width, $height ); +my $pwd = getcwd(); + +$ENV{HOME} = 'test'; + +sub waitfor(&) { + my ($sub) = @_; + my $out; + for ( 1 .. 40 ) { + sleep(0.05); + $out = &{$sub}; + if ($out) { + return $out; + } + } + return 0; +} + +sub feh_start { + my ( $opts, $files ) = @_; + my $id; + + $opts //= q{}; + $files //= 'test/ok/png'; + + StartApp("feh ${opts} ${files}"); + ($id) = WaitWindowViewable(qr{^feh}); + + if ( not $id ) { + BAIL_OUT("Unable to start feh ${opts} ${files}"); + } + + if ( not SetInputFocus($id) ) { + BAIL_OUT("Unable to focus window"); + } + + return $id; +} + +sub feh_stop { + SendKeys('{ESC}'); + if ( not waitfor { not FindWindowLike(qr{^feh}) } ) { + BAIL_OUT("Unclosed feh window still open, cannot continue"); + } +} + +sub test_no_win { + my ($reason) = @_; + + if ( waitfor { not FindWindowLike(qr{^feh}) } ) { + pass("Window closed ($reason)"); + } + else { + fail("Window closed ($reason)"); + BAIL_OUT("unclosed window still open, cannot continue"); + } +} + +sub test_win_title { + my ( $win, $wtitle ) = @_; + my $rtitle; + + if ( waitfor { GetWindowName($win) eq $wtitle } ) { + pass("Window has title: $wtitle"); + } + else { + $rtitle = GetWindowName($win); + fail("Window has title: $wtitle"); + diag("expected: $wtitle"); + diag(" got: $rtitle"); + } +} + +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.'); +} + +for my $key (qw/q x {ESC}/) { + feh_start(); + 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('n'); +test_win_title( $win, 'feh [3 of 3] - test/ok/gif' ); +SendKeys('{SPA}'); +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('p'); +test_win_title( $win, 'feh [2 of 3] - test/ok/jpg' ); +SendKeys('{BAC}'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('p'); +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"); + +$win = feh_start( '--title \'feh %m %u/%l %n\'', + 'test/ok/png test/ok/jpg test/ok/gif' ); +test_win_title( $win, 'feh slideshow 1/3 png' ); +SendKeys('{RIG}'); +test_win_title( $win, 'feh slideshow 2/3 jpg' ); +feh_stop(); + +feh_start( '--cycle-once', 'test/ok/png test/ok/jpg' ); +for ( 1 .. 2 ) { + SendKeys('{RIG}'); +} +test_no_win("--cycle-once -> window closed"); + +feh_start( + '--cycle-once --slideshow-delay 0.5', + 'test/ok/png test/ok/jpg test/ok/gif' +); +sleep(1.5); +test_no_win('cycle-once + slideshow-delay -> window closed'); + +$win = feh_start( + '--cycle-once --slideshow-delay -0.01', + 'test/ok/png test/ok/jpg test/ok/gif' +); + +test_win_title( $win, 'feh [1 of 3] - test/ok/png [Paused]' ); + +SendKeys('h'); +test_no_win('cycle-once + negative delay + [h]'); + +$win = feh_start( q{}, 'test/ok/png test/ok/gif test/ok/gif test/ok/jpg' ); +for ( 1 .. 2 ) { + SendKeys('{END}'); + test_win_title( $win, 'feh [4 of 4] - test/ok/jpg' ); +} +for ( 1 .. 2 ) { + SendKeys('{HOM}'); + test_win_title( $win, 'feh [1 of 4] - test/ok/png' ); +} + +SendKeys('{PGU}'); +test_win_title( $win, 'feh [4 of 4] - test/ok/jpg' ); +SendKeys('{PGD}'); +test_win_title( $win, 'feh [1 of 4] - test/ok/png' ); +SendKeys('{PGD}'); +test_win_title( $win, 'feh [2 of 4] - test/ok/gif' ); + +feh_stop(); + +$win + = feh_start( '--slideshow-delay 1', 'test/ok/png test/ok/gif test/ok/jpg' ); +sleep(1.7); +test_win_title( $win, 'feh [3 of 3] - test/ok/jpg' ); +SendKeys('h'); +test_win_title( $win, 'feh [3 of 3] - test/ok/jpg [Paused]' ); +SendKeys('{RIG}'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png [Paused]' ); +SendKeys('h'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +sleep(0.8); +test_win_title( $win, 'feh [2 of 3] - test/ok/gif' ); +feh_stop(); + +$win = feh_start( + '--action3 ";echo foo" --action7 "echo foo" ' + . '--action8 ";touch feh_test_%u_%l" --action9 "rm feh_test_%u_%l"', + 'test/ok/png test/ok/gif test/ok/jpg' +); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('3'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('7'); +test_win_title( $win, 'feh [2 of 3] - test/ok/gif' ); +SendKeys('8'); +test_win_title( $win, 'feh [2 of 3] - test/ok/gif' ); +ok( -e 'feh_test_2_3', + 'feh action created file with correct format specifiers' ); +SendKeys('9'); +ok( waitfor { not -e 'feh_test_2_3' }, 'feh action removed file' ); +test_win_title( $win, 'feh [3 of 3] - test/ok/jpg' ); +feh_stop(); + +# .config/feh/keys +# Action Unbinding + non-conflicting none/shift/control/meta modifiers + +$ENV{XDG_CONFIG_HOME} = 'test/config/keys'; + +$win = feh_start( + '--action1 "touch a1" --action2 "touch a2" ' + . '--action3 "touch a3" --action4 "touch a4" ' + . '--action5 "touch a5" --action6 "touch a6" ', + 'test/ok/png test/ok/jpg test/ok/pnm' +); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('6'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('{RIG}'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('a'); +test_win_title( $win, 'feh [2 of 3] - test/ok/jpg' ); +SendKeys('b'); +test_win_title( $win, 'feh [3 of 3] - test/ok/pnm' ); +SendKeys('c'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('d'); +test_win_title( $win, 'feh [3 of 3] - test/ok/pnm' ); +SendKeys('e'); +test_win_title( $win, 'feh [2 of 3] - test/ok/jpg' ); +SendKeys('f'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('1'); +test_win_title( $win, 'feh [1 of 3] - test/ok/png' ); +SendKeys('x'); +ok( waitfor { -e 'a1' }, 'action 1 = X ok' ); +SendKeys('X'); +ok( waitfor { -e 'a2' }, 'action 2 = Shift+X ok' ); +SendKeys('^(x)'); +ok( waitfor { -e 'a3' }, 'action 3 = Ctrl+X ok' ); +SendKeys('^(X)'); +ok( waitfor { -e 'a4' }, 'action 4 = Ctrl+Shift+X ok' ); +SendKeys('%(x)'); +ok( waitfor { -e 'a5' }, 'action 5 = Alt+X ok' ); + +for my $f (qw(a1 a2 a3 a4 a5)) { + unlink($f); +} +feh_stop(); + +$ENV{XDG_CONFIG_HOME} = 'test/config/themes'; + +$win = feh_start( '-Ttest_general', 'test/ok/png test/ok/jpg' ); +SendKeys('1'); +ok( waitfor { -e 'a1' }, 'theme: action 1 okay' ); +unlink('a1'); +feh_stop(); + +$win = feh_start( '-Ttest_general --action1 "touch c1"', + 'test/ok/png test/ok/jpg' ); +SendKeys('1'); +ok( waitfor { -e 'c1' }, 'theme: commandline overrides theme' ); +unlink('c1'); +feh_stop(); + +$win = feh_start( '-Ttest_multiline', 'test/ok/png test/ok/jpg' ); +SendKeys('1'); +ok( waitfor { -e 'a1' }, 'multiline theme: first line ok' ); +SendKeys('2'); +ok( waitfor { -e 'a2' }, 'multiline theme: second line ok' ); +SendKeys('3'); +ok( waitfor { -e 'a3' }, 'multiline theme: last line ok' ); +for my $f (qw(a1 a2 a3)) { + unlink($f); +} +feh_stop(); + +delete $ENV{XDG_CONFIG_HOME}; + +$win = feh_start( q{}, 'test/ok/png ' x 100 ); +test_win_title( $win, 'feh [1 of 100] - test/ok/png' ); +SendKeys('{PGD}'); +test_win_title( $win, 'feh [6 of 100] - test/ok/png' ); +SendKeys('{PGD}'); +test_win_title( $win, 'feh [11 of 100] - test/ok/png' ); +SendKeys('{HOM PGU}'); +test_win_title( $win, 'feh [96 of 100] - test/ok/png' ); +feh_stop(); + +$win = feh_start( '--thumbnails -H 300 -W 310 --thumb-title "feh [%l] %f"', + 'test/ok/png test/ok/gif test/ok/jpg' ); +test_win_title( $win, 'feh [thumbnail mode]' ); +( $width, $height ) = ( GetWindowPos($win) )[ 2, 3 ]; +is( $width, 310, 'thumbnail win: Set correct width' ); +is( $height, 300, 'thumbnail win: Set correct height' ); +MoveMouseAbs( 30, 30 ); +ClickMouseButton(M_BTN1); +($win) = WaitWindowViewable(qr{test/ok/png$}); +ok( $win, 'Thumbnail mode: Window opened' ); +test_win_title( $win, 'feh [3] test/ok/png' ); +SetInputFocus($win); +SendKeys('x'); +ok( waitfor { not FindWindowLike(qr{^ok/png$}) }, 'Thumbnail mode: closed' ); + +MoveMouseAbs( 90, 30 ); +ClickMouseButton(M_BTN1); +($win) = WaitWindowViewable(qr{test/ok/gif$}); +ok( $win, 'Thumbnail mode: Window opened' ); +test_win_title( $win, 'feh [3] test/ok/gif' ); + +MoveMouseAbs( 150, 30 ); +ClickMouseButton(M_BTN1); +($win) = WaitWindowViewable(qr{test/ok/jpg$}); +ok( $win, 'Thumbnail mode: Other window opened' ); +test_win_title( $win, 'feh [3] test/ok/jpg' ); + +feh_stop(); + +feh_start( '--multiwindow', 'test/ok/png test/ok/gif test/ok/jpg' ); +ok( waitfor { FindWindowLike(qr{^feh - test/ok/png$}) }, 'multiwindow 1/3' ); +ok( waitfor { FindWindowLike(qr{^feh - test/ok/gif$}) }, 'multiwindow 2/3' ); +ok( waitfor { FindWindowLike(qr{^feh - test/ok/jpg$}) }, 'multiwindow 3/3' ); + +($win) = FindWindowLike(qr{^feh - test/ok/gif$}); +SetInputFocus($win); +SendKeys('x'); +ok( waitfor { not FindWindowLike(qr{^feh - test/ok/gif$}) }, 'win 1 closed' ); +ok( FindWindowLike(qr{^feh - test/ok/png$}), 'multiwindow 1/2' ); +ok( FindWindowLike(qr{^feh - test/ok/jpg$}), 'multiwindow 2/2' ); + +($win) = FindWindowLike(qr{^feh - test/ok/jpg$}); +SetInputFocus($win); +SendKeys('x'); +ok( waitfor { not FindWindowLike(qr{^feh - test/ok/jpg$}) }, 'win 2 closed' ); + +($win) = FindWindowLike(qr{^feh - test/ok/png$}); +SetInputFocus($win); +SendKeys('x'); +test_no_win('all multiwindows closed'); + +$win = feh_start( '--start-at test/ok/jpg', + 'test/ok/png test/ok/gif test/ok/jpg' ); +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/ok/.captions', 'autocreated captions directory' ); +is( + slurp('test/ok/.captions/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/ok/.captions/png.txt'), + "Foo Bar\nmiep", + 'Caption with newline + correct backspace' +); + +unlink('test/ok/.captions/png.txt'); +rmdir('test/ok/.captions'); + +$win = feh_start( '--filelist test/filelist', + 'test/ok/png test/ok/gif test/ok/png test/ok/jpg' ); +SendKeys('{DEL}'); +test_win_title( $win, "feh [1 of 3] - ${pwd}/test/ok/gif" ); +feh_stop(); + +is( slurp('test/filelist'), <<"EOF", 'Filelist saved' ); +${pwd}/test/ok/gif +${pwd}/test/ok/png +${pwd}/test/ok/jpg +EOF + +$win = feh_start( '--filelist test/filelist', q{} ); +test_win_title( $win, "feh [1 of 3] - ${pwd}/test/ok/gif" ); +feh_stop(); +unlink('test/filelist'); + +$win = feh_start('--geometry 423x232'); +( undef, undef, $width, $height ) = GetWindowPos($win); +is( $width, 423, '--geometry: correct width' ); +is( $height, 232, '--geometry: correct height' ); +feh_stop(); + +$win = feh_start('--fullscreen'); +( undef, undef, $width, $height ) = GetWindowPos($win); +ok( [ ( GetWindowPos($win) )[ 2, 3 ] ] ~~ [ GetScreenRes() ], + 'fullscreen uses full screen size' ); +feh_stop(); + +$win = feh_start( q{}, 'test/ok/png ' . 'test/fail/png ' x 7 . 'test/ok/gif' ); +test_win_title( $win, 'feh [1 of 9] - test/ok/png' ); +SendKeys('{RIG}'); +test_win_title( $win, 'feh [2 of 2] - test/ok/gif' ); +SendKeys('{LEF}'); +test_win_title( $win, 'feh [1 of 2] - test/ok/png' ); +SendKeys('{LEF}'); +test_win_title( $win, 'feh [2 of 2] - test/ok/gif' ); +feh_stop(); + +$win = feh_start(); +( undef, undef, $width, $height ) = GetWindowPos($win); +is( $width, 16, 'correct default window width' ); +is( $height, 16, 'correct default window height' ); + +ResizeWindow( $win, 25, 30 ); +( undef, undef, $width, $height ) = GetWindowPos($win); + +SKIP: { + if ( not( [ $width, $height ] ~~ [ 25, 30 ] ) ) { + skip( 'ResizeWindow failed', 2 ); + } + PressKey('w'); + ok( waitfor { [ ( GetWindowPos($win) )[ 2, 3 ] ] ~~ [ 16, 16 ] }, + 'w key resizes correctly' ); +} +feh_stop(); + +$win = feh_start( q{}, 'test/huge.png' ); +ok( + waitfor { + ( GetWindowPos($win) )[2] == ( GetScreenRes() )[0] + || ( GetWindowPos($win) )[3] == ( GetScreenRes() )[1]; + }, + 'Large window limited to screen size' +); +feh_stop(); + +$win = feh_start( '--no-screen-clip', 'test/huge.png' ); +ok( + waitfor { + [ ( GetWindowPos($win) )[ 2, 3 ] ] ~~ [ 4000, 3000 ]; + }, + 'disabled screen clip' +); +feh_stop(); + +# GH-35 "Custom window title crashes feh on unloadable files" +$win = feh_start( '--title "feh %h"', 'test/ok/png test/fail/png test/ok/jpg' ); +SendKeys('{RIG}'); +test_win_title( $win, 'feh 16' ); +feh_stop(); diff --git a/test/feh-scr.i b/test/feh-scr-i.t index d6d55b1..36cb494 100755 --- a/test/feh-scr.i +++ b/test/feh-scr-i.t @@ -10,18 +10,19 @@ use Test::More tests => 54; use Time::HiRes qw/sleep/; use X11::GUITest qw/:ALL/; -my ($pid_xnest, $pid_twm); +my ( $pid_xnest, $pid_twm ); my $win; -my ($width, $height); -my $pwd = getcwd(); +my ( $width, $height ); +my $pwd = getcwd(); my $test_id = 0; +my $scr_dir = '/tmp/feh-test-scr'; $ENV{HOME} = 'test'; sub waitfor(&) { my ($sub) = @_; my $out; - for (1 .. 10) { + for ( 1 .. 10 ) { sleep(0.05); $out = &{$sub}; if ($out) { @@ -32,20 +33,20 @@ sub waitfor(&) { } sub feh_start { - my ($opts, $files) = @_; + my ( $opts, $files ) = @_; my $id; - $opts //= q{}; + $opts //= q{}; $files //= 'test/ok/png'; StartApp("feh ${opts} ${files}"); ($id) = WaitWindowViewable(qr{^feh}); - if (not $id) { + if ( not $id ) { BAIL_OUT("Unable to start feh ${opts} ${files}"); } - if (not SetInputFocus($id)) { + if ( not SetInputFocus($id) ) { BAIL_OUT("Unable to focus window"); } @@ -54,30 +55,30 @@ sub feh_start { sub feh_stop { SendKeys('{ESC}'); - if (not waitfor { not FindWindowLike(qr{^feh}) }) { + if ( not waitfor { not FindWindowLike(qr{^feh}) } ) { BAIL_OUT("Unclosed feh window still open, cannot continue"); } } sub same_files { - my ($one, $two) = @_; + my ( $one, $two ) = @_; my $img_one = GD::Image->new($one); my $img_two = GD::Image->new($two); - if (not defined $img_one or not defined $img_two) { + if ( not defined $img_one or not defined $img_two ) { return 0; } - return( ! ($img_one->compare($img_two) & GD_CMP_IMAGE)); + return ( !( $img_one->compare($img_two) & GD_CMP_IMAGE ) ); } sub check_scr { my ($file) = @_; - system("import -silent -window root /tmp/feh_${$}.png"); + system("import -silent -window root ${scr_dir}/feh_${$}.png"); - return same_files("test/scr/${file}", "/tmp/feh_${$}.png"); + return same_files( "test/scr/${file}", "${scr_dir}/feh_${$}.png" ); } sub test_scr { @@ -86,22 +87,27 @@ sub test_scr { $test_id++; - if (waitfor { check_scr($file) }) { + if ( waitfor { check_scr($file) } ) { pass($msg); } else { fail($msg); - rename("/tmp/feh_${$}.png", "/tmp/feh_${$}_${test_id}_${file}.png"); + rename( "${scr_dir}/feh_${$}.png", + "${scr_dir}/feh_${$}_${test_id}_${file}.png" ); } } -if (FindWindowLike(qr{^feh})) { +if ( FindWindowLike(qr{^feh}) ) { BAIL_OUT('It appears you have an open feh window. Please close it.'); } +if ( not -d $scr_dir ) { + mkdir($scr_dir); +} + feh_start( "--draw-actions --draw-filename --info 'echo foo; echo bar' " - . '--action quux --action5 baz --action8 "nrm \'%f\'"', + . '--action quux --action5 baz --action8 "nrm \'%f\'"', 'test/bg/exact/in test/bg/large/w/in test/bg/large/h/in' ); test_scr('draw_all_multi'); @@ -109,29 +115,23 @@ feh_stop(); feh_start( "--draw-actions --draw-filename --info 'echo foo; echo bar' " - . '--action quux --action5 baz --action8 "nrm \'%f\'"', + . '--action quux --action5 baz --action8 "nrm \'%f\'"', 'test/bg/exact/in' ); test_scr('draw_all_one'); feh_stop(); -feh_start( - '--fullscreen', - 'test/bg/large/w/in' -); +feh_start( '--fullscreen', 'test/bg/large/w/in' ); test_scr('feh_full_lwi'); feh_stop(); -feh_start( - q{}, - 'test/bg/large/w/in' -); +feh_start( q{}, 'test/bg/large/w/in' ); test_scr('feh_lwi'); SendKeys('^({RIG})'); test_scr('feh_lwi_scroll_r'); -SendKeys('^({DOW})'); +SendKeys('^({DOWN})'); test_scr('feh_lwi_scroll_rd'); SendKeys('^({RIG})'); @@ -145,31 +145,21 @@ test_scr('feh_lwi_scroll_rdrul'); feh_stop(); -feh_start( - '--scale-down', - 'test/bg/large/w/in' -); +feh_start( '--scale-down', 'test/bg/large/w/in' ); test_scr('feh_scaledown_lwi'); feh_stop(); -feh_start( - '--thumbnails', - 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' -); +feh_start( '--thumbnails', 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' ); test_scr('thumbnail_default'); feh_stop(); -feh_start( - '--index --limit-width 400', - 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' -); +feh_start( '--index --limit-width 400', + 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' ); test_scr('index_w400'); feh_stop(); -feh_start( - '--fullindex --limit-width 400', - 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' -); +feh_start( '--fullindex --limit-width 400', + 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' ); test_scr('index_full_w400'); feh_stop(); @@ -180,37 +170,28 @@ feh_start( test_scr('index_full_w400'); feh_stop(); -feh_start( - '--index --limit-height 400', - 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' -); +feh_start( '--index --limit-height 400', + 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' ); test_scr('index_h400'); feh_stop(); -feh_start( - '--fullindex --limit-height 400', - 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' -); +feh_start( '--fullindex --limit-height 400', + 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' ); test_scr('index_full_h400'); feh_stop(); -feh_start( - '--geometry +10+20', - 'test/ok/png' -); +feh_start( '--geometry +10+20', 'test/ok/png' ); test_scr('geometry_offset_only'); feh_stop(); -feh_start( - '--caption-path .tc', - 'test/bg/exact/in' -); +feh_start( '--caption-path .tc', 'test/bg/exact/in' ); test_scr('caption_none'); SendKeys('c'); test_scr('caption_new'); -SendKeys('Picknick im Zenit metaphysischen Wiederscheins der astralen Kuhglocke'); +SendKeys( + 'Picknick im Zenit metaphysischen Wiederscheins der astralen Kuhglocke'); test_scr('caption_while'); SendKeys('~'); @@ -219,7 +200,7 @@ test_scr('caption_done'); SendKeys('c'); test_scr('caption_while'); -SendKeys('{BKS}' x 80); +SendKeys( '{BKS}' x 80 ); test_scr('caption_new'); SendKeys('~'); @@ -230,66 +211,43 @@ test_scr('caption_none'); feh_stop(); -feh_start( - '--info "echo \'%f\n%wx%h\'"', - 'test/bg/exact/in' -); +feh_start( '--info "echo \'%f\n%wx%h\'"', 'test/bg/exact/in' ); test_scr('draw_info'); feh_stop(); -feh_start( - '--info "echo \'%f\n%wx%h\'" --draw-tinted', - 'test/bg/exact/in' -); +feh_start( '--info "echo \'%f\n%wx%h\'" --draw-tinted', 'test/bg/exact/in' ); test_scr('draw_info_tinted'); feh_stop(); -feh_start( - '--draw-actions --action8 "nrm \'%f\'"', - 'test/bg/exact/in' -); +feh_start( '--draw-actions --action8 "nrm \'%f\'"', 'test/bg/exact/in' ); test_scr('draw_action'); feh_stop(); -feh_start( - '--draw-actions --action8 "nrm \'%f\'" --draw-tinted', - 'test/bg/exact/in' -); +feh_start( '--draw-actions --action8 "nrm \'%f\'" --draw-tinted', + 'test/bg/exact/in' ); test_scr('draw_action_tinted'); feh_stop(); -feh_start( - '--draw-filename', - 'test/bg/exact/in' -); +feh_start( '--draw-filename', 'test/bg/exact/in' ); test_scr('draw_filename'); feh_stop(); -feh_start( - '--draw-filename --draw-tinted', - 'test/bg/exact/in' -); +feh_start( '--draw-filename --draw-tinted', 'test/bg/exact/in' ); test_scr('draw_filename_tinted'); feh_stop(); -feh_start( - '--draw-filename --draw-actions --action8 "nrm \'%f\'"', - 'test/bg/exact/in' -); +feh_start( '--draw-filename --draw-actions --action8 "nrm \'%f\'"', + 'test/bg/exact/in' ); test_scr('draw_filename_action'); feh_stop(); feh_start( '--draw-filename --draw-actions --action8 "nrm \'%f\'" --draw-tinted', - 'test/bg/exact/in' -); + 'test/bg/exact/in' ); test_scr('draw_filename_action_tinted'); feh_stop(); -feh_start( - '--action8 "nrm \'%f\'"', - 'test/bg/exact/in' -); +feh_start( '--action8 "nrm \'%f\'"', 'test/bg/exact/in' ); test_scr('draw_nothing'); SendKeys('d'); @@ -306,14 +264,11 @@ test_scr('draw_nothing'); feh_stop(); -feh_start( - '--draw-tinted', - 'test/bg/exact/in' -); +feh_start( '--draw-tinted', 'test/bg/exact/in' ); test_scr('draw_nothing'); feh_stop(); -feh_start(q{}, 'test/bg/large/h/in'); +feh_start( q{}, 'test/bg/large/h/in' ); test_scr('feh_lhi'); SendKeys('{UP}'); @@ -331,41 +286,41 @@ test_scr('feh_lhi_iirr'); SendKeys('{UP}'); test_scr('feh_lhi_iirri'); -SendKeys('{DOW}'); +SendKeys('{DOWN}'); test_scr('feh_lhi_iirrio'); feh_stop(); -feh_start(q{}, 'test/bg/large/h/in'); +feh_start( q{}, 'test/bg/large/h/in' ); test_scr('feh_lhi'); -SendKeys('{DOW}'); +SendKeys('{DOWN}'); test_scr('feh_lhi_o'); -SendKeys('{DOW}'); +SendKeys('{DOWN}'); test_scr('feh_lhi_oo'); -SendKeys('{DOW}'); +SendKeys('{DOWN}'); test_scr('feh_lhi_ooo'); feh_stop(); -feh_start(q{}, 'test/bg/transparency'); +feh_start( q{}, 'test/bg/transparency' ); test_scr('feh_ibg_default'); feh_stop(); -feh_start('--image-bg checks', 'test/bg/transparency'); +feh_start( '--image-bg checks', 'test/bg/transparency' ); test_scr('feh_ibg_default'); feh_stop(); -feh_start('--image-bg black', 'test/bg/transparency'); +feh_start( '--image-bg black', 'test/bg/transparency' ); test_scr('feh_ibg_black'); feh_stop(); -feh_start('--image-bg white', 'test/bg/transparency'); +feh_start( '--image-bg white', 'test/bg/transparency' ); test_scr('feh_ibg_white'); feh_stop(); unlink('test/bg/exact/.tc/in.txt'); rmdir('test/bg/exact/.tc'); -unlink("/tmp/feh_${$}.png"); +unlink("${scr_dir}/feh_${$}.png"); diff --git a/test/feh.i b/test/feh.i deleted file mode 100755 index f9dddfb..0000000 --- a/test/feh.i +++ /dev/null @@ -1,453 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use 5.010; - -use Cwd; -use Test::More tests => 103; -use Time::HiRes qw/sleep/; -use X11::GUITest qw/:ALL/; - -my $win; -my ($width, $height); -my $pwd = getcwd(); - -$ENV{HOME} = 'test'; - -sub waitfor(&) { - my ($sub) = @_; - my $out; - for (1 .. 40) { - sleep(0.05); - $out = &{$sub}; - if ($out) { - return $out; - } - } - return 0; -} - -sub feh_start { - my ($opts, $files) = @_; - my $id; - - $opts //= q{}; - $files //= 'test/ok/png'; - - StartApp("feh ${opts} ${files}"); - ($id) = WaitWindowViewable(qr{^feh}); - - if (not $id) { - BAIL_OUT("Unable to start feh ${opts} ${files}"); - } - - if (not SetInputFocus($id)) { - BAIL_OUT("Unable to focus window"); - } - - return $id; -} - -sub feh_stop { - SendKeys('{ESC}'); - if (not waitfor { not FindWindowLike(qr{^feh}) }) { - BAIL_OUT("Unclosed feh window still open, cannot continue"); - } -} - -sub test_no_win { - my ($reason) = @_; - - if (waitfor { not FindWindowLike(qr{^feh}) }) { - pass("Window closed ($reason)"); - } - else { - fail("Window closed ($reason)"); - BAIL_OUT("unclosed window still open, cannot continue"); - } -} - -sub test_win_title { - my ($win, $wtitle) = @_; - my $rtitle; - - if (waitfor { GetWindowName($win) eq $wtitle }) { - pass("Window has title: $wtitle"); - } - else { - $rtitle = GetWindowName($win); - fail("Window has title: $wtitle"); - diag("expected: $wtitle"); - diag(" got: $rtitle"); - } -} - -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.'); -} - -for my $key (qw/q x {ESC}/) { - feh_start(); - 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('n'); -test_win_title($win, 'feh [3 of 3] - test/ok/gif'); -SendKeys('{SPA}'); -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('p'); -test_win_title($win, 'feh [2 of 3] - test/ok/jpg'); -SendKeys('{BAC}'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('p'); -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"); - -$win = feh_start('--title \'feh %m %u/%l %n\'', - 'test/ok/png test/ok/jpg test/ok/gif'); -test_win_title($win, 'feh slideshow 1/3 png'); -SendKeys('{RIG}'); -test_win_title($win, 'feh slideshow 2/3 jpg'); -feh_stop(); - -feh_start('--cycle-once', 'test/ok/png test/ok/jpg'); -for (1 .. 2) { - SendKeys('{RIG}'); -} -test_no_win("--cycle-once -> window closed"); - -feh_start('--cycle-once --slideshow-delay 0.5', - 'test/ok/png test/ok/jpg test/ok/gif'); -sleep(1.5); -test_no_win('cycle-once + slideshow-delay -> window closed'); - -$win = feh_start('--cycle-once --slideshow-delay -0.01', - 'test/ok/png test/ok/jpg test/ok/gif'); - -test_win_title($win, 'feh [1 of 3] - test/ok/png [Paused]'); - -SendKeys('h'); -test_no_win('cycle-once + negative delay + [h]'); - -$win = feh_start(q{}, 'test/ok/png test/ok/gif test/ok/gif test/ok/jpg'); -for (1 .. 2) { - SendKeys('{END}'); - test_win_title($win, 'feh [4 of 4] - test/ok/jpg'); -} -for (1 .. 2) { - SendKeys('{HOM}'); - test_win_title($win, 'feh [1 of 4] - test/ok/png'); -} - -SendKeys('{PGU}'); -test_win_title($win, 'feh [4 of 4] - test/ok/jpg'); -SendKeys('{PGD}'); -test_win_title($win, 'feh [1 of 4] - test/ok/png'); -SendKeys('{PGD}'); -test_win_title($win, 'feh [2 of 4] - test/ok/gif'); - -feh_stop(); - -$win = feh_start('--slideshow-delay 1', 'test/ok/png test/ok/gif test/ok/jpg'); -sleep(1.7); -test_win_title($win, 'feh [3 of 3] - test/ok/jpg'); -SendKeys('h'); -test_win_title($win, 'feh [3 of 3] - test/ok/jpg [Paused]'); -SendKeys('{RIG}'); -test_win_title($win, 'feh [1 of 3] - test/ok/png [Paused]'); -SendKeys('h'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -sleep(0.8); -test_win_title($win, 'feh [2 of 3] - test/ok/gif'); -feh_stop(); - -$win = feh_start( - '--action3 ";echo foo" --action7 "echo foo" ' . - '--action8 ";touch feh_test_%u_%l" --action9 "rm feh_test_%u_%l"', - 'test/ok/png test/ok/gif test/ok/jpg' -); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('3'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('7'); -test_win_title($win, 'feh [2 of 3] - test/ok/gif'); -SendKeys('8'); -test_win_title($win, 'feh [2 of 3] - test/ok/gif'); -ok(-e 'feh_test_2_3', 'feh action created file with correct format specifiers'); -SendKeys('9'); -ok(waitfor { not -e 'feh_test_2_3' }, 'feh action removed file'); -test_win_title($win, 'feh [3 of 3] - test/ok/jpg'); -feh_stop(); - - -# .config/feh/keys -# Action Unbinding + non-conflicting none/shift/control/meta modifiers - -$ENV{XDG_CONFIG_HOME} = 'test/config/keys'; - -$win = feh_start( - '--action1 "touch a1" --action2 "touch a2" ' . - '--action3 "touch a3" --action4 "touch a4" ' . - '--action5 "touch a5" --action6 "touch a6" ', - 'test/ok/png test/ok/jpg test/ok/pnm' -); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('6'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('{RIG}'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('a'); -test_win_title($win, 'feh [2 of 3] - test/ok/jpg'); -SendKeys('b'); -test_win_title($win, 'feh [3 of 3] - test/ok/pnm'); -SendKeys('c'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('d'); -test_win_title($win, 'feh [3 of 3] - test/ok/pnm'); -SendKeys('e'); -test_win_title($win, 'feh [2 of 3] - test/ok/jpg'); -SendKeys('f'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('1'); -test_win_title($win, 'feh [1 of 3] - test/ok/png'); -SendKeys('x'); -ok(waitfor { -e 'a1' }, 'action 1 = X ok'); -SendKeys('X'); -ok(waitfor { -e 'a2' }, 'action 2 = Shift+X ok'); -SendKeys('^(x)'); -ok(waitfor { -e 'a3' }, 'action 3 = Ctrl+X ok'); -SendKeys('^(X)'); -ok(waitfor { -e 'a4' }, 'action 4 = Ctrl+Shift+X ok'); -SendKeys('%(x)'); -ok(waitfor { -e 'a5' }, 'action 5 = Alt+X ok'); -for my $f (qw(a1 a2 a3 a4 a5)) { - unlink($f); -} -feh_stop(); - -$ENV{XDG_CONFIG_HOME} = 'test/config/themes'; - -$win = feh_start( - '-Ttest_general', - 'test/ok/png test/ok/jpg' -); -SendKeys('1'); -ok(waitfor { -e 'a1' }, 'theme: action 1 okay'); -unlink('a1'); -feh_stop(); - -$win = feh_start( - '-Ttest_general --action1 "touch c1"', - 'test/ok/png test/ok/jpg' -); -SendKeys('1'); -ok(waitfor { -e 'c1' }, 'theme: commandline overrides theme'); -unlink('c1'); -feh_stop(); - -$win = feh_start( - '-Ttest_multiline', - 'test/ok/png test/ok/jpg' -); -SendKeys('1'); -ok(waitfor { -e 'a1' }, 'multiline theme: first line ok'); -SendKeys('2'); -ok(waitfor { -e 'a2' }, 'multiline theme: second line ok'); -SendKeys('3'); -ok(waitfor { -e 'a3' }, 'multiline theme: last line ok'); -for my $f (qw(a1 a2 a3)) { - unlink($f); -} -feh_stop(); - -delete $ENV{XDG_CONFIG_HOME}; - - -$win = feh_start(q{}, 'test/ok/png ' x 100); -test_win_title($win, 'feh [1 of 100] - test/ok/png'); -SendKeys('{PGD}'); -test_win_title($win, 'feh [6 of 100] - test/ok/png'); -SendKeys('{PGD}'); -test_win_title($win, 'feh [11 of 100] - test/ok/png'); -SendKeys('{HOM PGU}'); -test_win_title($win, 'feh [96 of 100] - test/ok/png'); -feh_stop(); - -$win = feh_start('--thumbnails -H 300 -W 310 --thumb-title "feh [%l] %f"', - 'test/ok/png test/ok/gif test/ok/jpg'); -test_win_title($win, 'feh [thumbnail mode]'); -($width, $height) = (GetWindowPos($win))[2,3]; -is($width, 310, 'thumbnail win: Set correct width'); -is($height, 300, 'thumbnail win: Set correct height'); -MoveMouseAbs(30, 30); -ClickMouseButton(M_BTN1); -($win) = WaitWindowViewable(qr{test/ok/png$}); -ok($win, 'Thumbnail mode: Window opened'); -test_win_title($win, 'feh [3] test/ok/png'); -SetInputFocus($win); -SendKeys('x'); -ok(waitfor { not FindWindowLike(qr{^ok/png$}) }, 'Thumbnail mode: closed'); - -MoveMouseAbs(90, 30); -ClickMouseButton(M_BTN1); -($win) = WaitWindowViewable(qr{test/ok/gif$}); -ok($win, 'Thumbnail mode: Window opened'); -test_win_title($win, 'feh [3] test/ok/gif'); - -MoveMouseAbs(150,30); -ClickMouseButton(M_BTN1); -($win) = WaitWindowViewable(qr{test/ok/jpg$}); -ok($win, 'Thumbnail mode: Other window opened'); -test_win_title($win, 'feh [3] test/ok/jpg'); - -feh_stop(); - -feh_start('--multiwindow', 'test/ok/png test/ok/gif test/ok/jpg'); -ok(waitfor { FindWindowLike(qr{^feh - test/ok/png$}) }, 'multiwindow 1/3'); -ok(waitfor { FindWindowLike(qr{^feh - test/ok/gif$}) }, 'multiwindow 2/3'); -ok(waitfor { FindWindowLike(qr{^feh - test/ok/jpg$}) }, 'multiwindow 3/3'); - -($win) = FindWindowLike(qr{^feh - test/ok/gif$}); -SetInputFocus($win); -SendKeys('x'); -ok(waitfor { not FindWindowLike(qr{^feh - test/ok/gif$}) }, 'win 1 closed'); -ok(FindWindowLike(qr{^feh - test/ok/png$}), 'multiwindow 1/2'); -ok(FindWindowLike(qr{^feh - test/ok/jpg$}), 'multiwindow 2/2'); - -($win) = FindWindowLike(qr{^feh - test/ok/jpg$}); -SetInputFocus($win); -SendKeys('x'); -ok(waitfor { not FindWindowLike(qr{^feh - test/ok/jpg$}) }, 'win 2 closed'); - -($win) = FindWindowLike(qr{^feh - test/ok/png$}); -SetInputFocus($win); -SendKeys('x'); -test_no_win('all multiwindows closed'); - -$win = feh_start('--start-at test/ok/jpg', 'test/ok/png test/ok/gif test/ok/jpg'); -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/ok/.captions', 'autocreated captions directory'); -is(slurp('test/ok/.captions/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/ok/.captions/png.txt'), "Foo Bar\nmiep", - 'Caption with newline + correct backspace'); - -unlink('test/ok/.captions/png.txt'); -rmdir('test/ok/.captions'); - -$win = feh_start('--filelist test/filelist', - 'test/ok/png test/ok/gif test/ok/png test/ok/jpg'); -SendKeys('{DEL}'); -test_win_title($win, "feh [1 of 3] - ${pwd}/test/ok/gif"); -feh_stop(); - -is(slurp('test/filelist'), <<"EOF", 'Filelist saved'); -${pwd}/test/ok/gif -${pwd}/test/ok/png -${pwd}/test/ok/jpg -EOF - -$win = feh_start('--filelist test/filelist', q{}); -test_win_title($win, "feh [1 of 3] - ${pwd}/test/ok/gif"); -feh_stop(); -unlink('test/filelist'); - -$win = feh_start('--geometry 423x232'); -(undef, undef, $width, $height) = GetWindowPos($win); -is($width, 423, '--geometry: correct width'); -is($height, 232, '--geometry: correct height'); -feh_stop(); - -$win = feh_start('--fullscreen'); -(undef, undef, $width, $height) = GetWindowPos($win); -ok([(GetWindowPos($win))[2, 3]] ~~ [GetScreenRes()], - 'fullscreen uses full screen size'); -feh_stop(); - -$win = feh_start(q{}, 'test/ok/png ' . 'test/fail/png ' x 7 . 'test/ok/gif'); -test_win_title($win, 'feh [1 of 9] - test/ok/png'); -SendKeys('{RIG}'); -test_win_title($win, 'feh [2 of 2] - test/ok/gif'); -SendKeys('{LEF}'); -test_win_title($win, 'feh [1 of 2] - test/ok/png'); -SendKeys('{LEF}'); -test_win_title($win, 'feh [2 of 2] - test/ok/gif'); -feh_stop(); - -$win = feh_start(); -(undef, undef, $width, $height) = GetWindowPos($win); -is($width, 16, 'correct default window width'); -is($height, 16, 'correct default window height'); - -ResizeWindow($win, 25, 30); -(undef, undef, $width, $height) = GetWindowPos($win); - -SKIP: { - if (not ([$width, $height] ~~ [25, 30])) { - skip('ResizeWindow failed', 2) - } - PressKey('w'); - ok(waitfor { [(GetWindowPos($win))[2, 3]] ~~ [16, 16] }, - 'w key resizes correctly'); -} -feh_stop(); - -$win = feh_start(q{}, 'test/huge.png'); -ok(waitfor { - (GetWindowPos($win))[2] == (GetScreenRes())[0] - || (GetWindowPos($win))[3] == (GetScreenRes())[1] - }, - 'Large window limited to screen size'); -feh_stop(); - -$win = feh_start('--no-screen-clip', 'test/huge.png'); -ok(waitfor { - [(GetWindowPos($win))[2, 3]] ~~ [4000, 3000] - }, - 'disabled screen clip'); -feh_stop(); - -# GH-35 "Custom window title crashes feh on unloadable files" -$win = feh_start('--title "feh %h"', 'test/ok/png test/fail/png test/ok/jpg'); -SendKeys('{RIG}'); -test_win_title($win, 'feh 16'); -feh_stop(); @@ -6,11 +6,11 @@ use Test::Command tests => 71; $ENV{HOME} = 'test'; -my $feh = "src/feh"; -my $images_ok = 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm'; +my $feh = "src/feh"; +my $images_ok = 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm'; my $images_fail = 'test/fail/gif test/fail/jpg test/fail/png test/fail/pnm'; -my $images = "${images_ok} ${images_fail}"; -my $has_help = 0; +my $images = "${images_ok} ${images_fail}"; +my $has_help = 0; my $feh_name = $ENV{'PACKAGE'}; @@ -30,118 +30,115 @@ If you absolutely need to run it the other way, use EOF -if (length($feh_name) == 0) { +if ( length($feh_name) == 0 ) { die($err_no_env); } my $version = qx{$feh --version}; -if ($version =~ m{ Compile-time \s switches : \s .* help }ox) { +if ( $version =~ m{ Compile-time \s switches : \s .* help }ox ) { $has_help = 1; } -my $re_warning = - qr{${feh_name} WARNING: test/fail/... \- No Imlib2 loader for that file format\n}; -my $re_loadable = qr{test/ok/...}; -my $re_unloadable = qr{test/fail/...}; +my $re_warning + = qr{${feh_name} WARNING: test/fail/... \- No Imlib2 loader for that file format\n}; +my $re_loadable = qr{test/ok/...}; +my $re_unloadable = qr{test/fail/...}; my $re_list_action = qr{test/ok/... 16x16}; -my $cmd = Test::Command->new(cmd => "$feh --version"); +my $cmd = Test::Command->new( cmd => "$feh --version" ); $cmd->exit_is_num(0); $cmd->stderr_is_eq(''); -$cmd = Test::Command->new(cmd => "$feh --loadable $images"); +$cmd = Test::Command->new( cmd => "$feh --loadable $images" ); $cmd->exit_is_num(1); $cmd->stdout_like($re_loadable); $cmd->stderr_is_eq(''); $cmd = Test::Command->new( - cmd => "$feh --loadable --action 'echo touch %f' $images" -); + cmd => "$feh --loadable --action 'echo touch %f' $images" ); $cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/loadable_action'); $cmd->stderr_is_eq(''); $cmd = Test::Command->new( - cmd => "$feh --loadable --action ';echo touch %f' $images" -); + cmd => "$feh --loadable --action ';echo touch %f' $images" ); $cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/loadable_naction'); $cmd->stderr_is_eq(''); $cmd = Test::Command->new( - cmd => "$feh --unloadable --action 'echo rm %f' $images" -); + cmd => "$feh --unloadable --action 'echo rm %f' $images" ); $cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/unloadable_action'); $cmd->stderr_is_eq(''); $cmd = Test::Command->new( - cmd => "$feh --unloadable --action ';echo rm %f' $images" -); + cmd => "$feh --unloadable --action ';echo rm %f' $images" ); $cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/unloadable_naction'); $cmd->stderr_is_eq(''); -$cmd = Test::Command->new(cmd => "$feh --unloadable $images"); +$cmd = Test::Command->new( cmd => "$feh --unloadable $images" ); $cmd->exit_is_num(1); $cmd->stdout_like($re_unloadable); $cmd->stderr_is_eq(''); -$cmd = Test::Command->new(cmd => "$feh --list $images"); +$cmd = Test::Command->new( cmd => "$feh --list $images" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/default'); $cmd->stderr_like($re_warning); for my $sort (qw/name filename width height pixels size format/) { - $cmd = Test::Command->new(cmd => "$feh --list $images --sort $sort"); + $cmd = Test::Command->new( cmd => "$feh --list $images --sort $sort" ); $cmd->exit_is_num(0); $cmd->stdout_is_file("test/list/$sort"); $cmd->stderr_like($re_warning); } -$cmd = Test::Command->new(cmd => "$feh --list $images --sort format --reverse"); +$cmd + = Test::Command->new( cmd => "$feh --list $images --sort format --reverse" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/format_reverse'); $cmd->stderr_like($re_warning); $cmd = Test::Command->new( - cmd => "$feh --list --recursive --sort filename test/ok" -); + cmd => "$feh --list --recursive --sort filename test/ok" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/filename_recursive'); $cmd->stderr_is_eq(''); -$cmd = Test::Command->new(cmd => "$feh --customlist '%f; %h; %l; %m; %n; %p; " - . "%s; %t; %u; %w' $images"); +$cmd = Test::Command->new( cmd => "$feh --customlist '%f; %h; %l; %m; %n; %p; " + . "%s; %t; %u; %w' $images" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/custom'); $cmd->stderr_like($re_warning); -$cmd = Test::Command->new(cmd => "$feh --list --quiet $images"); +$cmd = Test::Command->new( cmd => "$feh --list --quiet $images" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/default'); $cmd->stderr_is_eq(''); -$cmd = Test::Command->new(cmd => - "$feh --quiet --list --action 'echo \"%f %wx%h\" >&2' $images"); +$cmd = Test::Command->new( + cmd => "$feh --quiet --list --action 'echo \"%f %wx%h\" >&2' $images" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/default'); $cmd->stderr_like($re_list_action); -$cmd = Test::Command->new(cmd => "$feh --list --min-dimension 20x20 $images_ok"); +$cmd + = Test::Command->new( cmd => "$feh --list --min-dimension 20x20 $images_ok" ); $cmd->exit_is_num(1); $cmd->stdout_is_eq(''); @@ -152,7 +149,8 @@ else { $cmd->stderr_is_file('test/no-loadable-files'); } -$cmd = Test::Command->new(cmd => "$feh --list --max-dimension 10x10 $images_ok"); +$cmd + = Test::Command->new( cmd => "$feh --list --max-dimension 10x10 $images_ok" ); $cmd->exit_is_num(1); $cmd->stdout_is_eq(''); @@ -163,13 +161,15 @@ else { $cmd->stderr_is_file('test/no-loadable-files'); } -$cmd = Test::Command->new(cmd => "$feh --list --min-dimension 16x16 $images_ok"); +$cmd + = Test::Command->new( cmd => "$feh --list --min-dimension 16x16 $images_ok" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/default'); $cmd->stderr_is_eq(''); -$cmd = Test::Command->new(cmd => "$feh --list --max-dimension 16x16 $images_ok"); +$cmd + = Test::Command->new( cmd => "$feh --list --max-dimension 16x16 $images_ok" ); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/default'); diff --git a/test/mandoc.t b/test/mandoc.t index d664289..3740809 100755 --- a/test/mandoc.t +++ b/test/mandoc.t @@ -8,13 +8,13 @@ use Test::More tests => 3; SKIP: { qx{mandoc -V}; - if ($? != 0) { + if ( $? != 0 ) { diag('mandoc not installed, test skipped. This is NOT fatal.'); - skip('mandoc not installed', 3); + skip( 'mandoc not installed', 3 ); } - for my $file ('feh', 'feh-cam', 'gen-cam-menu') { + for my $file ( 'feh', 'feh-cam', 'gen-cam-menu' ) { qx{mandoc -Tlint man/${file}.1}; - is($?, 0, "${file}.1: Valid mdoc syntax"); + is( $?, 0, "${file}.1: Valid mdoc syntax" ); } } diff --git a/test/run-interactive b/test/run-interactive index d801ac6..a342c22 100755 --- a/test/run-interactive +++ b/test/run-interactive @@ -3,7 +3,7 @@ Xephyr -screen 500x500 :7 > /dev/null 2>&1 & pid=${!} -DISPLAY=:7 prove test/feh-scr.i test/feh.i +DISPLAY=:7 prove test/feh-scr-i.t test/feh-i.t ret=${?} kill ${pid} |