summaryrefslogtreecommitdiff
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
parent7b86f410356941010402b2602eaf023b75438858 (diff)
Begin work on --bg tests
-rw-r--r--Makefile4
-rw-r--r--README6
-rw-r--r--test/bg.pngbin0 -> 9815 bytes
-rw-r--r--test/bg_451x500.pngbin0 -> 9687 bytes
-rw-r--r--test/bg_451x500_center.pngbin0 -> 6737 bytes
-rw-r--r--test/bg_451x500_fill.pngbin0 -> 15089 bytes
l---------test/bg_451x500_max.png1
-rw-r--r--test/bg_451x500_scale.pngbin0 -> 10842 bytes
-rw-r--r--test/bg_451x500_tile.pngbin0 -> 6755 bytes
-rw-r--r--test/bg_500x333.pngbin0 -> 9135 bytes
-rw-r--r--test/bg_500x333_center.pngbin0 -> 6344 bytes
-rw-r--r--test/bg_500x333_fill.pngbin0 -> 18419 bytes
l---------test/bg_500x333_max.png1
-rw-r--r--test/bg_500x333_scale.pngbin0 -> 11681 bytes
-rw-r--r--test/bg_500x333_tile.pngbin0 -> 9170 bytes
-rw-r--r--test/bg_all.pngbin0 -> 6525 bytes
-rwxr-xr-xtest/feh-bg.i52
-rwxr-xr-xtest/run-bg11
18 files changed, 71 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index fff6c0d..85cb600 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,9 @@ test: all
@PACKAGE=${PACKAGE} VERSION=${VERSION} prove test
test-x11: all
- @test/run-interactive
+ test/run-interactive
+ sleep 3
+ test/run-bg
install: install-man install-doc install-bin install-font install-img
diff --git a/README b/README
index cc382c2..a1db524 100644
--- a/README
+++ b/README
@@ -43,9 +43,9 @@ work without X, so they can safely be run even on a headless buildserver.
Testing (X):
Requires
- * perl >= 5.10
- * Test::More
- * X11::GUITest
+ * import (usually supplied by imagemagick)
+ * perl >= 5.10 with GD, Test::More and X11::GUITest
+ * twm
* Xnest
$ make test-x11
diff --git a/test/bg.png b/test/bg.png
new file mode 100644
index 0000000..0c1f09f
--- /dev/null
+++ b/test/bg.png
Binary files differ
diff --git a/test/bg_451x500.png b/test/bg_451x500.png
new file mode 100644
index 0000000..3b64670
--- /dev/null
+++ b/test/bg_451x500.png
Binary files differ
diff --git a/test/bg_451x500_center.png b/test/bg_451x500_center.png
new file mode 100644
index 0000000..99555af
--- /dev/null
+++ b/test/bg_451x500_center.png
Binary files differ
diff --git a/test/bg_451x500_fill.png b/test/bg_451x500_fill.png
new file mode 100644
index 0000000..18e1da9
--- /dev/null
+++ b/test/bg_451x500_fill.png
Binary files differ
diff --git a/test/bg_451x500_max.png b/test/bg_451x500_max.png
new file mode 120000
index 0000000..4721827
--- /dev/null
+++ b/test/bg_451x500_max.png
@@ -0,0 +1 @@
+bg_451x500_center.png \ No newline at end of file
diff --git a/test/bg_451x500_scale.png b/test/bg_451x500_scale.png
new file mode 100644
index 0000000..fd884f6
--- /dev/null
+++ b/test/bg_451x500_scale.png
Binary files differ
diff --git a/test/bg_451x500_tile.png b/test/bg_451x500_tile.png
new file mode 100644
index 0000000..1fcc1dd
--- /dev/null
+++ b/test/bg_451x500_tile.png
Binary files differ
diff --git a/test/bg_500x333.png b/test/bg_500x333.png
new file mode 100644
index 0000000..8fad57c
--- /dev/null
+++ b/test/bg_500x333.png
Binary files differ
diff --git a/test/bg_500x333_center.png b/test/bg_500x333_center.png
new file mode 100644
index 0000000..7db9571
--- /dev/null
+++ b/test/bg_500x333_center.png
Binary files differ
diff --git a/test/bg_500x333_fill.png b/test/bg_500x333_fill.png
new file mode 100644
index 0000000..eeec8ca
--- /dev/null
+++ b/test/bg_500x333_fill.png
Binary files differ
diff --git a/test/bg_500x333_max.png b/test/bg_500x333_max.png
new file mode 120000
index 0000000..13547b7
--- /dev/null
+++ b/test/bg_500x333_max.png
@@ -0,0 +1 @@
+bg_500x333_center.png \ No newline at end of file
diff --git a/test/bg_500x333_scale.png b/test/bg_500x333_scale.png
new file mode 100644
index 0000000..fee0647
--- /dev/null
+++ b/test/bg_500x333_scale.png
Binary files differ
diff --git a/test/bg_500x333_tile.png b/test/bg_500x333_tile.png
new file mode 100644
index 0000000..5c8e1a4
--- /dev/null
+++ b/test/bg_500x333_tile.png
Binary files differ
diff --git a/test/bg_all.png b/test/bg_all.png
new file mode 100644
index 0000000..5903c34
--- /dev/null
+++ b/test/bg_all.png
Binary files differ
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");
diff --git a/test/run-bg b/test/run-bg
new file mode 100755
index 0000000..df5d6ac
--- /dev/null
+++ b/test/run-bg
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+Xnest -geometry 500x500 :7 > /dev/null 2>&1 &
+pid=${!}
+
+# Wallpaper setting requires a window manager to work reliably
+DISPLAY=:7 twm > /dev/null 2>&1 &
+
+DISPLAY=:7 prove -v test/feh-bg.i
+
+kill ${pid}