- wait for the widget to be displayed before doing the delay that
[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;
69cd9d17 32$label->waitVisibility;
b2239557
TC
33$mw->after(100 =>
34 sub {
e6d8f15b
TC
35 $im_mw = screenshot(widget => $mw, decor => 1)
36 or print "# mw: ", Imager->errstr, "\n";
37 $im_label = screenshot(widget => $label)
38 or print "# label: ", Imager->errstr, "\n";
b2239557
TC
39 $mw->destroy;
40 });
41MainLoop();
e6d8f15b
TC
42ok($im_mw, "grab from a Tk widget (X11)");
43ok($im_label, "grab label from a Tk widget (X11)");