From 095bf053334116797afc39682ecca76a0d1fe76c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 3 Oct 2010 11:43:32 +0200 Subject: More screenshot-based tests --- test/feh-scr.i | 143 ++++++++++++++++++++++++++++++++++++++++++ test/run-interactive | 2 +- test/scr/draw_all_multi | Bin 0 -> 11416 bytes test/scr/draw_all_one | Bin 0 -> 11113 bytes test/scr/feh_full_lwi | Bin 0 -> 17898 bytes test/scr/feh_lwi | Bin 0 -> 19070 bytes test/scr/feh_lwi_scroll_r | Bin 0 -> 19072 bytes test/scr/feh_lwi_scroll_rd | Bin 0 -> 19081 bytes test/scr/feh_lwi_scroll_rdr | Bin 0 -> 19075 bytes test/scr/feh_lwi_scroll_rdru | Bin 0 -> 19066 bytes test/scr/feh_lwi_scroll_rdrul | Bin 0 -> 19072 bytes test/scr/feh_scaledown_lwi | Bin 0 -> 19744 bytes test/scr/thumbnail_default | Bin 0 -> 1712 bytes 13 files changed, 144 insertions(+), 1 deletion(-) create mode 100755 test/feh-scr.i create mode 100644 test/scr/draw_all_multi create mode 100644 test/scr/draw_all_one create mode 100644 test/scr/feh_full_lwi create mode 100644 test/scr/feh_lwi create mode 100644 test/scr/feh_lwi_scroll_r create mode 100644 test/scr/feh_lwi_scroll_rd create mode 100644 test/scr/feh_lwi_scroll_rdr create mode 100644 test/scr/feh_lwi_scroll_rdru create mode 100644 test/scr/feh_lwi_scroll_rdrul create mode 100644 test/scr/feh_scaledown_lwi create mode 100644 test/scr/thumbnail_default (limited to 'test') diff --git a/test/feh-scr.i b/test/feh-scr.i new file mode 100755 index 0000000..a67b511 --- /dev/null +++ b/test/feh-scr.i @@ -0,0 +1,143 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; +use autodie qw/:all/; + +use Cwd; +use GD qw/:DEFAULT :cmp/; +use Test::More tests => 11; +use Time::HiRes qw/sleep/; +use X11::GUITest qw/:ALL/; + +my ($pid_xnest, $pid_twm); +my $win; +my ($width, $height); +my $pwd = getcwd(); + +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 same_files { + 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)); +} + +sub check_scr { + my ($file) = @_; + + system("import -silent -window root /tmp/feh_${$}.png"); + + ok( + same_files("test/scr/${file}", "/tmp/feh_${$}.png"), + "X root window is test/scr/${file}" + ); +} + +if (FindWindowLike(qr{^feh})) { + BAIL_OUT('It appears you have an open feh window. Please close it.'); +} + +feh_start( + "--draw-actions --draw-filename --info 'echo foo; echo bar' " + . '--action quux --action5 baz --action8 "nrm \'%f\'"', + 'test/bg/exact/in test/bg/large/w/in test/bg/large/h/in' +); +check_scr('draw_all_multi'); +feh_stop(); + +feh_start( + "--draw-actions --draw-filename --info 'echo foo; echo bar' " + . '--action quux --action5 baz --action8 "nrm \'%f\'"', + 'test/bg/exact/in' +); +check_scr('draw_all_one'); +feh_stop(); + +feh_start( + '--fullscreen', + 'test/bg/large/w/in' +); +check_scr('feh_full_lwi'); +feh_stop(); + +feh_start( + q{}, + 'test/bg/large/w/in' +); +check_scr('feh_lwi'); + +SendKeys('^({RIG})'); +check_scr('feh_lwi_scroll_r'); + +SendKeys('^({DOW})'); +check_scr('feh_lwi_scroll_rd'); + +SendKeys('^({RIG})'); +check_scr('feh_lwi_scroll_rdr'); + +SendKeys('^({UP})'); +check_scr('feh_lwi_scroll_rdru'); + +SendKeys('^({LEF})'); +check_scr('feh_lwi_scroll_rdrul'); + +feh_stop(); + +feh_start( + '--scale-down', + 'test/bg/large/w/in' +); +check_scr('feh_scaledown_lwi'); +feh_stop(); + +feh_start( + '--thumbnails', + 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm' +); +check_scr('thumbnail_default'); +feh_stop(); + +unlink("/tmp/feh_${$}.png"); diff --git a/test/run-interactive b/test/run-interactive index 6a3e5e3..fab6517 100755 --- a/test/run-interactive +++ b/test/run-interactive @@ -3,7 +3,7 @@ Xnest -geometry 500x500 :7 > /dev/null 2>&1 & pid=${!} -DISPLAY=:7 prove -v test/feh.i +DISPLAY=:7 prove test/feh-scr.i test/feh.i ret=${?} kill ${pid} diff --git a/test/scr/draw_all_multi b/test/scr/draw_all_multi new file mode 100644 index 0000000..d105fbe Binary files /dev/null and b/test/scr/draw_all_multi differ diff --git a/test/scr/draw_all_one b/test/scr/draw_all_one new file mode 100644 index 0000000..7a3b796 Binary files /dev/null and b/test/scr/draw_all_one differ diff --git a/test/scr/feh_full_lwi b/test/scr/feh_full_lwi new file mode 100644 index 0000000..e46cb05 Binary files /dev/null and b/test/scr/feh_full_lwi differ diff --git a/test/scr/feh_lwi b/test/scr/feh_lwi new file mode 100644 index 0000000..16855f7 Binary files /dev/null and b/test/scr/feh_lwi differ diff --git a/test/scr/feh_lwi_scroll_r b/test/scr/feh_lwi_scroll_r new file mode 100644 index 0000000..5003a88 Binary files /dev/null and b/test/scr/feh_lwi_scroll_r differ diff --git a/test/scr/feh_lwi_scroll_rd b/test/scr/feh_lwi_scroll_rd new file mode 100644 index 0000000..333b9e3 Binary files /dev/null and b/test/scr/feh_lwi_scroll_rd differ diff --git a/test/scr/feh_lwi_scroll_rdr b/test/scr/feh_lwi_scroll_rdr new file mode 100644 index 0000000..1e921f1 Binary files /dev/null and b/test/scr/feh_lwi_scroll_rdr differ diff --git a/test/scr/feh_lwi_scroll_rdru b/test/scr/feh_lwi_scroll_rdru new file mode 100644 index 0000000..455a2c2 Binary files /dev/null and b/test/scr/feh_lwi_scroll_rdru differ diff --git a/test/scr/feh_lwi_scroll_rdrul b/test/scr/feh_lwi_scroll_rdrul new file mode 100644 index 0000000..5003a88 Binary files /dev/null and b/test/scr/feh_lwi_scroll_rdrul differ diff --git a/test/scr/feh_scaledown_lwi b/test/scr/feh_scaledown_lwi new file mode 100644 index 0000000..47d5add Binary files /dev/null and b/test/scr/feh_scaledown_lwi differ diff --git a/test/scr/thumbnail_default b/test/scr/thumbnail_default new file mode 100644 index 0000000..2c52059 Binary files /dev/null and b/test/scr/thumbnail_default differ -- cgit v1.2.3