add a readme and example for win32, convert files from Win32 to Unix
[imager-screenshot.git] / t / 20x11.t
CommitLineData
0ddb7051
TC
1#!perl -w
2use strict;
3use Test::More;
4
5use Imager::Screenshot 'screenshot';
6
7Imager::Screenshot->have_x11
8 or plan skip_all => "No X11 support";
9
10# can we connect to a display
11my $display = Imager::Screenshot::x11_open()
12 or plan skip_all => "Cannot connect to a display: ".Imager->errstr;
13
14plan tests => 5;
15
16{
17 # should automatically connect and grab the root window
18 my $im = screenshot(id => 0)
19 or print "# ", Imager->errstr, "\n";
20
21 ok($im, "got a root screenshot, no display");
22}
23
24{
25 # use our supplied display
26 my $im = screenshot(display => $display, id => 0);
27 ok($im, "got a root screenshot, supplied display");
28}
29
30{
31 # use our supplied display - as a method
32 my $im = Imager::Screenshot->screenshot(display => $display, id => 0);
33 ok($im, "got a root screenshot, supplied display (method)");
34}
35
36{
37 # supply a junk window id
38 my $im = screenshot(display => $display, id => 0xFFFFFFF)
39 or print "# ", Imager->errstr, "\n";
40 ok(!$im, "should fail to get screenshot");
41 cmp_ok(Imager->errstr, '=~', 'BadWindow',
42 "check error");
43}
44
45Imager::Screenshot::x11_close($display);