Commit | Line | Data |
---|---|---|
b2239557 TC |
1 | #!perl -w |
2 | use strict; | |
3 | use Test::More; | |
4 | ||
5 | use Imager::Screenshot 'screenshot'; | |
6 | ||
7 | Imager::Screenshot->have_x11 | |
8 | or plan skip_all => "No X11 support"; | |
9 | ||
10 | my $display = Imager::Screenshot::x11_open() | |
11 | or plan skip_all => "Cannot connect to display: ".Imager->errstr; | |
12 | ||
13 | Imager::Screenshot::x11_close($display); | |
14 | ||
15 | eval "use Tk;"; | |
16 | $@ | |
17 | and plan skip_all => "Tk not available"; | |
18 | ||
19 | my $mw = Tk::MainWindow->new; | |
20 | ||
21 | $mw->windowingsystem eq 'x11' | |
22 | or plan skip_all => 'Tk windowing system not X11'; | |
23 | ||
24 | plan tests => 1; | |
25 | ||
26 | my $im; | |
27 | $mw->Label(-text => "test: $0")->pack; | |
28 | $mw->after(100 => | |
29 | sub { | |
30 | $im = screenshot(widget => $mw, decor => 1) | |
31 | or print "# ", Imager->errstr, "\n"; | |
32 | $mw->destroy; | |
33 | }); | |
34 | MainLoop(); | |
35 | ok($im, "grab from a Tk widget (X11)"); |