blob: 1f22c9da671c91739e05b1232dcc4ec3b758b7e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use autodie qw/:all/;
use GD qw/:DEFAULT :cmp/;
use Test::More tests => 70;
use Time::HiRes qw/sleep/;
my $scr_dir = '/tmp/feh-test-scr';
my ( $pid_xnest, $pid_twm );
$ENV{HOME} = 'test';
sub set_bg {
my ( $mode, $file ) = @_;
ok(
system("feh --bg-${mode} test/bg/${file}") == 0,
"Ran feh --bg-${mode} test/bg/${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 ${scr_dir}/feh_${$}.png");
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 ) {
exec(qw( Xephyr -screen 500x500 :7 ));
}
sleep(0.5);
$ENV{'DISPLAY'} = ':7';
if ( ( $pid_twm = fork() ) == 0 ) {
exec('twm');
}
sleep(0.5);
for my $mode (qw( center fill max scale tile )) {
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" );
check_bg("${type}/${orientation}/${mode}");
}
}
}
kill( 15, $pid_twm );
sleep(0.2);
kill( 15, $pid_xnest );
sleep(0.2);
unlink("${scr_dir}/feh_${$}.png");
unlink('test/.fehbg');
|