| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
BEGIN { |
| 4 |
if (!eval q{ |
| 5 |
use Test::More; |
| 6 |
1; |
| 7 |
}) { |
| 8 |
print "1..0 # skip: no Test::More module\n"; |
| 9 |
exit; |
| 10 |
} |
| 11 |
} |
| 12 |
plan tests => 2; |
| 13 |
|
| 14 |
my($icon)=<<'END'; |
| 15 |
/* XPM */ |
| 16 |
static char * junk_xpm[] = { |
| 17 |
"10 10 6 1", |
| 18 |
" c #000000", |
| 19 |
". c #FFFFFF", |
| 20 |
"X c #B129F8", |
| 21 |
"o c #F869A6", |
| 22 |
"O c #00FF00", |
| 23 |
"+ c #1429F8", |
| 24 |
" X..oo.+. ", |
| 25 |
" .X....+. ", |
| 26 |
" ..X...+. ", |
| 27 |
" o..X.... ", |
| 28 |
" oo..X... ", |
| 29 |
" .oo..X.. ", |
| 30 |
" ......X. ", |
| 31 |
" .+.....X ", |
| 32 |
" .+..oo.. ", |
| 33 |
" .+...oo. "}; |
| 34 |
END |
| 35 |
use Tk; |
| 36 |
my $mw = tkinit; |
| 37 |
$mw->geometry("+20+20"); |
| 38 |
my $label = $mw->Label(-image=>$mw->Pixmap(-data=>$icon))->pack; |
| 39 |
pass("Loaded and displayed pixmap"); |
| 40 |
eval { $mw->Pixmap(-file => "__nonexistingpixmap__") }; |
| 41 |
like($@, qr{(\QCannot open '__nonexistingpixmap__' in mode 'r'\E |
| 42 |
|\Qcouldn't read file "__nonexistingpixmap__": No such file or directory\E |
| 43 |
)}x, "Non-existing xpm error"); |
| 44 |
$mw->after(500,[destroy => $mw]); |
| 45 |
MainLoop; |