| 1 |
# -*- perl -*- |
| 2 |
BEGIN { $^W=1; $|=1; } |
| 3 |
|
| 4 |
use strict; |
| 5 |
use Test; |
| 6 |
use Tk; |
| 7 |
|
| 8 |
BEGIN { plan tests => 33, |
| 9 |
# todo => [18,26,32] |
| 10 |
}; |
| 11 |
|
| 12 |
my $mw = Tk::MainWindow->new; |
| 13 |
eval { $mw->geometry('+10+10'); }; # This works for mwm and interactivePlacement |
| 14 |
|
| 15 |
my $tixgrid; |
| 16 |
{ |
| 17 |
eval { require Tk::TixGrid; }; |
| 18 |
ok($@, "", 'Problem loading Tk::TixGrid'); |
| 19 |
eval { $tixgrid = $mw->TixGrid(); }; |
| 20 |
ok($@, "", 'Problem creating TixGrid widget'); |
| 21 |
ok( Tk::Exists($tixgrid) ); |
| 22 |
eval { $tixgrid->grid; }; |
| 23 |
ok($@, "", '$tixgrid->grid problem'); |
| 24 |
} |
| 25 |
## |
| 26 |
## TixGrid->nearest gives always a 'TCL panic' if tixgrid is visible in Tk800.003 |
| 27 |
## |
| 28 |
## ptksh> p $tg->nearest(10,10) |
| 29 |
## No results |
| 30 |
## Tcl_Panic at (eval 7) line 1. |
| 31 |
## |
| 32 |
{ |
| 33 |
my @entry; |
| 34 |
eval { @entry = $tixgrid->nearest(10,10); }; # there should be no entry |
| 35 |
ok($@ eq ""); |
| 36 |
ok( |
| 37 |
scalar(@entry), |
| 38 |
0, |
| 39 |
"nearest returned array of size " . @entry . " instead of 0. " . |
| 40 |
join('|','@entry=', @entry,'') |
| 41 |
); |
| 42 |
|
| 43 |
## Make widget visible, nearest -> SEGV |
| 44 |
$tixgrid->update; |
| 45 |
eval { @entry = $tixgrid->nearest(10,10); }; # there should be no entry |
| 46 |
ok($@ eq ""); |
| 47 |
|
| 48 |
} |
| 49 |
## |
| 50 |
## Tk800.004: selectionSet ignores -selectunit |
| 51 |
## selectionClear also does not work. |
| 52 |
## |
| 53 |
{ |
| 54 |
my $g = $mw->TixGrid->grid; |
| 55 |
|
| 56 |
# populate |
| 57 |
eval |
| 58 |
{ |
| 59 |
for my $x (0..10) |
| 60 |
{ |
| 61 |
for my $y (0..10) |
| 62 |
{ |
| 63 |
$g->set($x,$y, -itemtype=>'text', -text=>"($x,$y)" ); |
| 64 |
} |
| 65 |
} |
| 66 |
}; |
| 67 |
ok($@, "", "Problem populate TixGrid with items"); |
| 68 |
|
| 69 |
my $b = ''; |
| 70 |
|
| 71 |
# test column selection |
| 72 |
eval { $g->configure(-selectunit=>'column'); }; ok($@, "", "Problem col configure -selectunit=>column"); |
| 73 |
eval { $g->selection('set', 1,1); }; ok($@, "", "problem col set selection"); |
| 74 |
eval { $b=$g->selection('includes', 1,1); }; ok($@, "", "problem selection includes"); |
| 75 |
eval { $g->update; }; ok($@, "", "problem col update"); |
| 76 |
|
| 77 |
eval { $b=$g->selection('includes', 1,1); }; ok($@, "", "problem selection includes"); |
| 78 |
ok($b, 1, "oops col selection does not contain the item"); |
| 79 |
eval { $b=$g->selection('includes', 1,0=>1,10);}; ok($b, 1, "oops col selection does not contain the col"); |
| 80 |
eval { $g->update; }; ok($@, "", "problem col update"); |
| 81 |
|
| 82 |
eval { $g->selectionClear(1,5); }; ok($@, "", "problem col sel clear"); |
| 83 |
# eval { $b=$g->selection('includes', 1,1); }; ok($b, "", "oops col selection is not cleared"); |
| 84 |
|
| 85 |
# test row selection |
| 86 |
eval { $g->configure(-selectunit=>'row'); }; ok($@, "", "Problem row configure -selectunit=>row"); |
| 87 |
eval { $g->selection('set', 2,2); }; ok($@, "", "problem row set selection"); |
| 88 |
eval { $g->update; }; ok($@, "", "problem row update"); |
| 89 |
eval { $b=$g->selection('includes',2,2); }; ok($b, 1, "oops row selection does not contain the item"); |
| 90 |
eval { $b=$g->selection('includes',0,2=>10,2); }; ok($b, 1, "oops row selection does not contain the row"); |
| 91 |
eval { $g->update; }; ok($@, "", "problem row update"); |
| 92 |
eval { $g->selectionClear(5,2); }; ok($@, "", "problem row sel clear"); |
| 93 |
# eval { $b=$g->selection('includes', 2,2); }; ok($b, "", "oops row selection is not cleared"); |
| 94 |
|
| 95 |
# test cell selection |
| 96 |
eval { $g->configure(-selectunit=>'cell'); }; ok($@, "", "Problem cell configure -selectunit=>cell"); |
| 97 |
eval { $g->selection('set', 3,3); }; ok($@, "", "problem cell set selection"); |
| 98 |
eval { $b=$g->update; }; ok($@, "", "problem cell update"); |
| 99 |
eval { $b=$g->selection('includes', 3,3); }; ok($b, 1, "oops cell selection does not contain the item"); |
| 100 |
eval { $b=$g->selection('includes', 2,3); }; ok($b, 0, "oops cell selection contain a not selected item"); |
| 101 |
# eval { $b=$g->selection('includes', 2,2); }; ok($b, 0, "oops cell selection contain a not selected item"); |
| 102 |
eval { $b=$g->selection('includes', 4,3); }; ok($b, 0, "oops cell selection contain a not selected item"); |
| 103 |
eval { $b=$g->selection('includes', 3,4); }; ok($b, 0, "oops cell selection contain a not selected item"); |
| 104 |
eval { $g->update; }; ok($@, "", "problem cell update"); |
| 105 |
eval { $g->selectionClear(3,3); }; ok($@, "", "problem cell sel clear"); |
| 106 |
# eval { $b=$g->selection('includes', 3,3); }; ok($b, 0, "oops cell selection not cleared"); |
| 107 |
} |
| 108 |
|
| 109 |
1; |
| 110 |
__END__ |
| 111 |
|