- screenshot() on a non-toplevel Tk widget would crash when
[imager-screenshot.git] / t / 30tkx11.t
CommitLineData
b2239557
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
10my $display = Imager::Screenshot::x11_open()
11 or plan skip_all => "Cannot connect to display: ".Imager->errstr;
12
13Imager::Screenshot::x11_close($display);
14
15eval "use Tk;";
16$@
17 and plan skip_all => "Tk not available";
18
19my $mw = Tk::MainWindow->new;
20
6d2b10ba
TC
21$mw->can('windowingsystem')
22 or plan skip_all => 'Cannot determine windowing system';
b2239557
TC
23$mw->windowingsystem eq 'x11'
24 or plan skip_all => 'Tk windowing system not X11';
25
53ccbd1e
TC
26eval { $mw->geometry('+10+10'); };
27
e6d8f15b 28plan tests => 2;
b2239557 29
e6d8f15b
TC
30my ($im_mw, $im_label);
31my $label = $mw->Label(-text => "test: $0")->pack;
b2239557
TC
32$mw->after(100 =>
33 sub {
e6d8f15b
TC
34 $im_mw = screenshot(widget => $mw, decor => 1)
35 or print "# mw: ", Imager->errstr, "\n";
36 $im_label = screenshot(widget => $label)
37 or print "# label: ", Imager->errstr, "\n";
b2239557
TC
38 $mw->destroy;
39 });
40MainLoop();
e6d8f15b
TC
41ok($im_mw, "grab from a Tk widget (X11)");
42ok($im_label, "grab label from a Tk widget (X11)");