summaryrefslogtreecommitdiff
path: root/test/feh-bg.i
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-10-02 22:51:38 +0200
committerDaniel Friesel <derf@finalrewind.org>2010-10-02 22:51:38 +0200
commit485d0c8c0a58b85c5c80f31627d89e3b5d449ff2 (patch)
tree7ed617eed72769306f0f7e8e4b9d9544bf8b715c /test/feh-bg.i
parent7b86f410356941010402b2602eaf023b75438858 (diff)
Begin work on --bg tests
Diffstat (limited to 'test/feh-bg.i')
-rwxr-xr-xtest/feh-bg.i52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/feh-bg.i b/test/feh-bg.i
new file mode 100755
index 0000000..b26feff
--- /dev/null
+++ b/test/feh-bg.i
@@ -0,0 +1,52 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+
+use GD qw/:DEFAULT :cmp/;
+use Test::More tests => 30;
+use Time::HiRes qw/sleep/;
+
+sub set_bg {
+ my ($mode, $file) = @_;
+
+ $file //= 'bg.png';
+
+ ok(
+ system("feh --bg-${mode} test/${file}") == 0,
+ "Ran feh --bg-${mode} test/${file}"
+ );
+}
+
+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_bg {
+ my ($file) = @_;
+
+ system("import -silent -window root /tmp/feh_${$}.png");
+
+ ok(
+ same_files("test/${file}", "/tmp/feh_${$}.png"),
+ "Wallpaper is test/${file}"
+ );
+}
+
+for my $mode (qw( center fill max scale tile )) {
+ set_bg($mode);
+ check_bg('bg_all.png');
+
+ set_bg($mode, 'bg_500x333.png');
+ check_bg("bg_500x333_${mode}.png");
+
+ set_bg($mode, 'bg_451x500.png');
+ check_bg("bg_451x500_${mode}.png");
+}
+
+unlink("/tmp/feh_${$}.png");