File: table.t

package info (click to toggle)
perl-tk 1%3A804.033-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 34,724 kB
  • ctags: 37,174
  • sloc: ansic: 349,541; perl: 52,192; sh: 17,904; makefile: 5,732; asm: 3,565; ada: 1,681; pascal: 1,089; cpp: 1,006; yacc: 883; cs: 879
file content (85 lines) | stat: -rwxr-xr-x 1,776 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl -w
# -*- perl -*-

#
# Author: Slaven Rezic
#

use strict;

use Tk;

BEGIN {
    if (!eval q{
	use Test::More;
	1;
    }) {
	print "1..0 # skip: no Test::More module\n";
	exit;
    }
}

plan tests => 16;

if (!defined $ENV{BATCH}) { $ENV{BATCH} = 1 }

my $mw = tkinit;
$mw->geometry("+10+10");

use_ok("Tk::Table");

my $table = $mw->Table(-rows => 10,
		       -columns => 10,
		       -scrollbars => "se",
		       -fixedrows => 1,
		       -fixedcolumns => 1,
		       -takefocus => 1,
		      );
isa_ok($table, "Tk::Table");
$table->pack(qw(-fill both -expand 1));

$table->put(0,0,"Simple Label");
my $simple_label_w = $table->get(0,0);
is($simple_label_w->cget("-text"), "Simple Label");

my $b = $table->Button(-text => "Simple Button");
$table->put(1,1,$b);
is($table->get(1,1), $b);

is($table->totalColumns, 2, "Number of occupied columns");
is($table->totalRows, 2, "Number of occupied rows");

$table->see(0,0);
pass("See method works with coordinates");
$table->see($b);
pass("See method works with widget");

my($b_row, $b_col) = $table->Posn($b);
is($b_row, 1, "Row of Simple Button");
is($b_col, 1, "Column of Simple Button");

is($table->Subwidget("xscrollbar"), undef,
   "Before update no scrollbars were created");
$table->update;
isa_ok($table->Subwidget("xscrollbar"), "Tk::Scrollbar",
       "x scrollbar");
isa_ok($table->Subwidget("yscrollbar"), "Tk::Scrollbar",
       "y scrollbar");

{
    my $b2 = $table->Button(-text => "2nd button");
    $table->put(0,1,$b2);
    is($table->get(0,1), $b2);

    ok Tk::Exists($b2), 'Button exists before clear() method';
    $table->clear;
    ok !Tk::Exists($b2), 'Button was destroyed by clear() method';
}

if ($ENV{BATCH}) {
    $mw->after(150, sub { $mw->destroy });
}

MainLoop;

__END__