~ubuntu-branches/ubuntu/jaunty/horae/jaunty

« back to all changes in this revision

Viewing changes to 0CPAN/Tk-GBARR-2.06/t/1numentryplain.t

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2008-02-23 23:13:02 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080223231302-mnyyxs3icvrus4ke
Tags: 066-3
Apply patch to athena_parts/misc.pl for compatibility with 
perl-tk 804.28.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
BEGIN
2
 
  {
3
 
    $^W = 1;
4
 
    $| = 1;
5
 
 
6
 
    eval { require Test; };
7
 
    if ($@)
8
 
      {
9
 
        $^W=0;
10
 
        print "1..0\n";
11
 
        print STDERR "\n\tTest.pm module not installed.\n\tGrab it from CPAN.\n\t";
12
 
        exit;
13
 
      }
14
 
    Test->import;
15
 
  }
16
 
use strict;
17
 
use Tk;
18
 
 
19
 
BEGIN { plan tests => 10 };
20
 
 
21
 
my $mw = Tk::MainWindow->new;
22
 
 
23
 
my $nep;
24
 
{
25
 
   eval { require Tk::NumEntryPlain; };
26
 
   ok($@, "", 'Problem loading Tk::NumEntryPlain');
27
 
   eval { $nep = $mw->NumEntryPlain(); };
28
 
   ok($@, "", 'Problem creating NumEntryPlain widget');
29
 
   ok( Tk::Exists($nep) );
30
 
   eval { $nep->grid; };
31
 
   ok($@, "", '$text->grid problem');
32
 
   eval { $nep->update; };
33
 
   ok($@, "", '$nep->update problem');
34
 
}
35
 
##
36
 
## Check that -textvariable works for reading
37
 
##      (set work but not supported)
38
 
##
39
 
{
40
 
    my $num = 0;
41
 
    my $e = $mw->NumEntryPlain(-textvariable=>\$num);
42
 
    eval { $e->value(6); };
43
 
    ok($@, "", 'Problem setting value');
44
 
    ok($num, "6", "Textvariable is not updated");
45
 
 
46
 
    eval { $e->update; };
47
 
    ok($@, "", 'Problem in update after setting value');
48
 
}
49
 
 
50
 
##
51
 
## Check -increment, -bigincrement, -command and -browsecmd options
52
 
{
53
 
    my $command = 0;
54
 
    my $browsecmd = 0;
55
 
    my $e = $mw->NumEntryPlain(-increment    => 0.1,
56
 
                               -bigincrement => 50,
57
 
                               -command => sub { $command++ },
58
 
                               -browsecmd => sub { $browsecmd++ },
59
 
                              );
60
 
    ok($e->cget(-increment), 0.1);
61
 
    ok($e->cget(-bigincrement), 50);
62
 
 
63
 
    if (0) {
64
 
        # XXX eventGenerate does not work
65
 
        if ($Tk::VERSION < 800.017) {
66
 
            skip("No -warp option for eventGenerate", 1) for (1..3);
67
 
        } else {
68
 
            $e->update;
69
 
            my $x = $e->width/2;
70
 
            my $y = $e->height/2;
71
 
            $e->eventGenerate("<Motion>", '-x' => $x, '-y' => $y, -warp => 1);
72
 
            $e->eventGenerate("<Up>");
73
 
            ok($e->get, "1");
74
 
            ok($browsecmd, 1);
75
 
            $e->eventGenerate("<Return>",
76
 
                              '-x' => $x, '-y' => $y,
77
 
                              -warp => 1);
78
 
            ok($command, 1);
79
 
        }
80
 
    }
81
 
}
82