| 1 |
# -*- perl -*- |
| 2 |
BEGIN { $|=1; $^W=1; } |
| 3 |
|
| 4 |
use strict; |
| 5 |
use Test; |
| 6 |
|
| 7 |
BEGIN { plan tests => 8 }; |
| 8 |
|
| 9 |
use Tk; |
| 10 |
use Tk::Widget; |
| 11 |
use Tk::Derived; |
| 12 |
use Tk::Frame; |
| 13 |
use Tk::Button; |
| 14 |
|
| 15 |
|
| 16 |
my $mw = Tk::MainWindow->new; |
| 17 |
eval { $mw->geometry('+10+10'); }; # This works for mwm and interactivePlacement |
| 18 |
|
| 19 |
## |
| 20 |
## Tests Component and therefore Subwidget, Delegate a bit |
| 21 |
## |
| 22 |
{ |
| 23 |
print "testing Component() method\n"; |
| 24 |
|
| 25 |
eval <<'EOTEST'; |
| 26 |
|
| 27 |
package Tk::tests::Composite; |
| 28 |
use vars '@ISA'; |
| 29 |
@ISA=qw/Tk::Derived Tk::Frame/; |
| 30 |
Construct Tk::Widget 'testComponent'; |
| 31 |
sub Populate |
| 32 |
{ |
| 33 |
my ($cw,$args) = @_; |
| 34 |
$cw->SUPER::Populate($args); |
| 35 |
my $b1 = $cw->Component('Button'=>'b1', -delegate=>["invoke"]); |
| 36 |
$b1->pack; |
| 37 |
$cw; |
| 38 |
} |
| 39 |
package main; |
| 40 |
EOTEST |
| 41 |
ok ($@, '', "Can't define widget to test Component()"); |
| 42 |
eval { $mw->update; }; |
| 43 |
ok ($@, '', "Idletask problem of define widget to test Component()"); |
| 44 |
|
| 45 |
my $test; |
| 46 |
eval { $test = $mw->testComponent; }; |
| 47 |
ok ($@, '', "Can't create testCompoment widget"); |
| 48 |
eval { $mw->update; }; |
| 49 |
ok ($@, '', "Idletask problem after creation of testComponent"); |
| 50 |
|
| 51 |
my $subw; |
| 52 |
eval { $subw = $test->Subwidget('b1'); }; |
| 53 |
ok ($@, '', "Ooops, problem with Subwidget method"); |
| 54 |
# This relies on the fact that testComponent has only one child |
| 55 |
my $child = ($test->children)[0]; |
| 56 |
ok($subw, $child, "Ooops, Advertise problem in Component();"); |
| 57 |
|
| 58 |
#clean up |
| 59 |
eval { $test->destroy; }; |
| 60 |
ok($@, '', "problem destroying testComponent widget"); |
| 61 |
eval { $mw->update; }; |
| 62 |
ok($@, '', "Idletask problem after destroy of testComponent"); |
| 63 |
} |
| 64 |
|
| 65 |
1; |
| 66 |
__END__ |
| 67 |
|