File: Tkxs.t

package info (click to toggle)
perl-tk 1%3A804.036%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 35,284 kB
  • sloc: ansic: 349,560; perl: 52,292; sh: 12,678; makefile: 5,700; asm: 3,565; ada: 1,681; pascal: 1,082; cpp: 1,006; yacc: 883; cs: 879
file content (163 lines) | stat: -rwxr-xr-x 4,224 bytes parent folder | download | duplicates (9)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/perl -w
# -*- perl -*-

#
# $Id: $
# 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;
    }
}

my $all_tests = 37;

plan tests => $all_tests;

SKIP: {
    skip('Set $ENV{TEST_AUTHOR} to a true value to run.', $all_tests)
	unless $ENV{TEST_AUTHOR};

    my $mw = tkinit;
    $mw->geometry("+10+10");
    my $l = $mw->Label(-text => "The Tk.xs test")->pack;
    
    {
        my $winid = $mw->PointToWindow(1,1);
        ok(defined $winid, "PointToWindow: got window id <$winid>");
    }
    
    # XXX FontInfo_* ?
    # XXX LangFontRank ?
    
    {
        ok(Tk::BLACK, "Colors: Black");
        ok(Tk::WHITE, "White");
        ok(Tk::NORMAL_BG, "Normal bg");
        ok(Tk::ACTIVE_BG, "Active bg");
        ok(Tk::SELECT_BG, "Select bg");
        ok(Tk::SELECT_FG, "Select fg");
        ok(Tk::TROUGH, "Trough");
        ok(Tk::INDICATOR, "Indicator");
        ok(Tk::DISABLED, "Disabled");
    }
    
    {
        is($mw->Count, 1, "Exactly one main window");
        $mw->Synchronize();
        pass("Called pTk_Synchronize");
    }
    
    {
        my $time_before = time;
        my $timeofday   = Tk::timeofday;
        my $time_after  = time;
        cmp_ok($time_before-1, "<=", $timeofday, "Time of day");
        cmp_ok($time_after+1, ">=", $timeofday);
    }
    
    {
        my($x1,$y1) = $mw->GetPointerCoords;
        my($x2,$y2) = $mw->pointerxy;
        is($x1, $x2, "GetPointerCoords and pointerxy should get the same");
        is($y1, $y2);
    }
    
    {
        ok($mw->IsTopLevel, "IsTopLevel positive");
        ok(!$l->IsTopLevel, "IsTopLevel negative");
        ok($mw->IsWidget, "IsWidget positive on toplevel");
        ok($l->IsWidget, "IsWidget positive on label");
        my $l2 = $mw->Label; $l2->destroy;
        ok(!$l2->IsWidget, "IsWidget negative (destroyed label)");
    }
    
    {
        ok(!$mw->IsMapped, "Toplevel not yet mapped");
    }
    
    # From now on we have a mapped window
    $mw->update;
    
    {
        ok($mw->IsMapped, "Toplevel is now mapped");
    }
    
    {
        my($x1,$y1) = $mw->WindowXY;
        my($x2,$y2) = ($mw->rootx, $mw->rooty);
        my($x3,$y3) = $mw->GetRootCoords;
    
        is($x1,$x2, "WindowXY gets the same as rootx/rooty");
        is($y1,$y2);
        is("$x1/$y1", "$x3/$y3", "GetRootCoords also the same");
    }
    
    {
        my $MYBITMAP = __PACKAGE__ . "::mybitmap";
        my $hbits = pack("b8"x5,
                         ".....11.",
                         "...11.1.",
                         ".11...1.",
                         "...11.1.",
                         ".....11.");
        $mw->DefineBitmap($MYBITMAP => 8,5, $hbits);
        $mw->Label(-bitmap => $MYBITMAP)->pack;
        pass("Using bitmap defined with DefineBitmap");
    
        my $pixmapid = $mw->GetBitmap($MYBITMAP);
        ok(defined $pixmapid, "GetBitmap returned <$pixmapid>");
        my $invalid = $mw->GetBitmap("this_really_does_not_exist");
        ok(!defined $invalid, "Invalid GetBitmap");
    }
    
    {
        $mw->XSync(0);
        pass("Called XSync(0)");
        $mw->XSync(1);
        pass("Called XSync(1)");
    }
    
    {
        $mw->MoveWindow(11,11);
        my($x1,$y1) = $mw->GetRootCoords;
        is("$x1/$y1", "11/11", "MoveWindow on toplevel");
    
        $mw->MoveToplevelWindow(12,12);
        # no change in GetRootCoords here, is this intended?
        pass("Called MoveToplevelWindow");
    
        $mw->MoveResizeWindow(13,13,200,50);
        pass("Called MoveResizeWindow");
    
        $mw->ResizeWindow(100,50);
        pass("Called ResizeWindow");
    }
    
    {
        my $font = $l->cget(-font);
        my $psname;
        $font->PostscriptFontName($psname);
        ok($psname, "Found postscript font name <$psname>");
    }
    
    {
        local $TODO = "GetFocusWin does not seem to return anything";
        isa_ok($mw->GetFocusWin, "Tk::Widget", "GetFocusWin returns a widget");
    }
    
    # missing: UnmanageGeometry, DisableButtonEvents, MakeAtom,
    # SendClientMessage, GetVRootGeometry, Colormap, Display, ScreenNumber etc.
}

__END__