~ubuntu-branches/ubuntu/natty/perl-tk/natty

« back to all changes in this revision

Viewing changes to t/browseentry2.t

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Zander
  • Date: 2004-03-14 13:54:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314135444-prc09u2or4dbr3to
Tags: 1:800.025-2
Add xlibs-dev to Build-Depends:,
Closes: #237942

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
# -*- perl -*-
 
3
 
 
4
#
 
5
# $Id: browseentry2.t,v 1.9 2003/04/21 19:49:35 eserte Exp $
 
6
# Author: Slaven Rezic
 
7
#
 
8
 
 
9
use strict;
 
10
 
 
11
use Tk;
 
12
use Tk::BrowseEntry;
 
13
 
 
14
BEGIN {
 
15
    if (!eval q{
 
16
        use Test;
 
17
        1;
 
18
    }) {
 
19
        print "# tests only work with installed Test module\n";
 
20
        print "1..1\n";
 
21
        print "ok 1\n";
 
22
        exit;
 
23
    }
 
24
}
 
25
 
 
26
BEGIN { plan tests => 6 }
 
27
 
 
28
if (!defined $ENV{BATCH}) { $ENV{BATCH} = 1 }
 
29
 
 
30
my $top = new MainWindow;
 
31
 
 
32
my $var;
 
33
my $robe = $top->BrowseEntry
 
34
    (
 
35
     -label      => "readonly, classic style",
 
36
     -state      => 'readonly',
 
37
     -autolistwidth   => 1,     # list width is dynamically calculated
 
38
     -autolimitheight => 1,     # limit height of browseentry to number
 
39
                                # of items
 
40
     -browsecmd  => sub { warn "-browsecmd:  @_\n" }, # old plain callback
 
41
     -browse2cmd => sub { warn "-browse2cmd: @_\n" }, # -browsecmd with index as argument
 
42
     -variable   => \$var,
 
43
    )->pack;
 
44
 
 
45
$robe->insert("end", @INC);
 
46
 
 
47
ok(ref $robe, 'Tk::BrowseEntry');
 
48
ok($robe->isa('Tk::BrowseEntry'), 1);
 
49
 
 
50
my $var2;
 
51
my $robe2 = $top->BrowseEntry
 
52
    (
 
53
     -label      => "normal, windows style",
 
54
     -autolistwidth   => 1,     # list width is dynamically calculated
 
55
     -autolimitheight => 1,     # limit height of browseentry to number
 
56
                                # of items
 
57
     -style => 'MSWin32',
 
58
     -variable   => \$var2,
 
59
    )->pack;
 
60
$robe2->insert("end", 1, 2, 3, "a very long entry exceeding the normal width");
 
61
 
 
62
ok(ref $robe2, 'Tk::BrowseEntry');
 
63
ok($robe2->isa('Tk::BrowseEntry'), 1);
 
64
 
 
65
{
 
66
    my $var;
 
67
    my $robe = $top->BrowseEntry
 
68
        (
 
69
         -label      => "readonly, windows style",
 
70
         -autolistwidth   => 1,     # list width is dynamically calculated
 
71
         -autolimitheight => 1,     # limit height of browseentry to number
 
72
                                    # of items
 
73
         -style => 'MSWin32',
 
74
         -state => 'readonly',
 
75
         -variable   => \$var,
 
76
        )->pack;
 
77
    $robe->insert("end", 1, 2, 3, "a very long entry exceeding the normal width");
 
78
 
 
79
    ok(ref $robe, 'Tk::BrowseEntry');
 
80
    ok($robe->isa('Tk::BrowseEntry'), 1);
 
81
 
 
82
    $robe->configure(-variable => \$var);
 
83
}
 
84
 
 
85
$top->Button(-text => "Ok",
 
86
             -command => sub {
 
87
                $top->destroy;
 
88
            })->pack;
 
89
$top->after(60*1000, sub { $top->destroy });
 
90
 
 
91
if (!$ENV{BATCH}) {
 
92
    MainLoop;
 
93
}
 
94
 
 
95
__END__