aboutsummaryrefslogtreecommitdiff
path: root/Perl
diff options
context:
space:
mode:
authormertz2006-02-12 09:38:07 +0000
committermertz2006-02-12 09:38:07 +0000
commit1f2631ad6b8be1d60420340dad0e812dbec460dd (patch)
tree12f65851f908ed0ed70ee455988cc39cdf7deb7a /Perl
parent4445c1cb53a232283c50711f4e82d9e2d1ddb647 (diff)
downloadtkzinc-1f2631ad6b8be1d60420340dad0e812dbec460dd.zip
tkzinc-1f2631ad6b8be1d60420340dad0e812dbec460dd.tar.gz
tkzinc-1f2631ad6b8be1d60420340dad0e812dbec460dd.tar.bz2
tkzinc-1f2631ad6b8be1d60420340dad0e812dbec460dd.tar.xz
closing bug #57:
mainloop before any update to avoid bug #48
Diffstat (limited to 'Perl')
-rw-r--r--Perl/t/Bbox-curve-multi-contour.t183
1 files changed, 96 insertions, 87 deletions
diff --git a/Perl/t/Bbox-curve-multi-contour.t b/Perl/t/Bbox-curve-multi-contour.t
index 7afc43c..38111f9 100644
--- a/Perl/t/Bbox-curve-multi-contour.t
+++ b/Perl/t/Bbox-curve-multi-contour.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
#
-# $Id: Bbox-curve-multi-contour.t,v 1.1 2005-06-23 18:16:12 mertz Exp $
+# $Id: Bbox-curve-multi-contour.t,v 1.2 2006-02-12 09:38:07 mertz Exp $
# Author: Christophe Mertz mertz@intuilab.com, adapted from a script
# reported by Daniel Etienne for a bug report in Tk::Zinc 3.3.0
#
@@ -40,101 +40,110 @@ like ($zinc, qr/^Tk::Zinc=HASH/ , "zinc has been created");
my $n = 8;
+## test cannot be run directly since $zinc->update does not work properly
+## when not in a mainloop
+## so I use a timer to trigger tests after entering the mainloop
-# first
-my $group = $zinc->add('group', 1);
-$zinc->coords($group, [100, 250]);
-
-my $curve = $zinc->add('curve', $group, [],
- -fillrule => 'nonzero',
- -closed => 1,
- -filled => 1,
- -fillcolor => 'black',
- -linecolor => 'red',
- );
-my $arc = $zinc->add('arc', $group, [-50, -50, 50, 50]);
-$zinc->contour($curve, 'add', 1, $arc);
-$zinc->remove($arc);
-
-for (1..$n) {
- my $arc = $zinc->add('arc', $group, [-15, -70, 15, -40]);
- $zinc->rotate($arc, ($_-1)*(360/$n), 'degree');
+$zinc->after(10, \&testExecute);
+
+Tk::MainLoop;
+
+sub testExecute {
+
+ # first
+ my $group = $zinc->add('group', 1);
+ $zinc->coords($group, [100, 250]);
+
+ my $curve = $zinc->add('curve', $group, [],
+ -fillrule => 'nonzero',
+ -closed => 1,
+ -filled => 1,
+ -fillcolor => 'black',
+ -linecolor => 'red',
+ );
+ my $arc = $zinc->add('arc', $group, [-50, -50, 50, 50]);
$zinc->contour($curve, 'add', 1, $arc);
$zinc->remove($arc);
-}
-
-ok(&similarFlatArray ([$zinc->bbox($group)],
- [28,178, 172, 322], # beware this coordinates are
- # not exactly the good one
- [2,2, 2,2 ],
- ),
- "bbox of left figure");
-
-
-# second
-$group = $zinc->add('group', 1);
-$zinc->coords($group, [350, 250]);
-
-$curve = $zinc->add('curve', $group, [],
- -fillrule => 'nonzero',
- -closed => 1,
- -filled => 1,
- -fillcolor => 'black',
- -linecolor => 'red',
- );
-$arc = $zinc->add('arc', $group, [-30, -30, 30, 30]);
-$zinc->contour($curve, 'add', 1, $arc);
-$zinc->remove($arc);
-
-for (1..$n) {
- my $arc = $zinc->add('arc', $group, [-15, -70, 15, -40]);
- $zinc->rotate($arc, ($_-1)*(360/$n), 'degree');
+
+ for (1..$n) {
+ my $arc = $zinc->add('arc', $group, [-15, -70, 15, -40]);
+ $zinc->rotate($arc, ($_-1)*(360/$n), 'degree');
+ $zinc->contour($curve, 'add', 1, $arc);
+ $zinc->remove($arc);
+ }
+
+ ok(&similarFlatArray ([$zinc->bbox($group)],
+ [28,178, 172, 322], # beware this coordinates are
+ # not exactly the good one
+ [2,2, 2,2 ],
+ ),
+ "bbox of left figure");
+
+
+ # second
+ $group = $zinc->add('group', 1);
+ $zinc->coords($group, [350, 250]);
+
+ $curve = $zinc->add('curve', $group, [],
+ -fillrule => 'nonzero',
+ -closed => 1,
+ -filled => 1,
+ -fillcolor => 'black',
+ -linecolor => 'red',
+ );
+ $arc = $zinc->add('arc', $group, [-30, -30, 30, 30]);
$zinc->contour($curve, 'add', 1, $arc);
$zinc->remove($arc);
-}
-&showbbox($group);
-ok(&similarFlatArray ([$zinc->bbox($group)],
- [278,178, 422,322], # beware this coordinates are
- # not exactly the good one
- [2,2, 2,2 ],
- ),
- "bbox of middle figure");
-
-
-# third
-$group = $zinc->add('group', 1);
-$zinc->coords($group, [600, 250]);
-
-$curve = $zinc->add('curve', $group, [],
- -fillrule => 'nonzero',
- -closed => 1,
- -filled => 1,
- -fillcolor => 'black',
- -linecolor => 'red',
- );
-$arc = $zinc->add('arc', $group, [-30, -30, 30, 30]);
-$zinc->contour($curve, 'add', 1, $arc);
-$zinc->remove($arc);
-$n = 3*$n;
-for (1..$n) {
- $arc = $zinc->add('arc', $group, [-5, -70, 5, -40]);
- $zinc->rotate($arc, ($_-1)*(360/$n), 'degree');
+
+ for (1..$n) {
+ my $arc = $zinc->add('arc', $group, [-15, -70, 15, -40]);
+ $zinc->rotate($arc, ($_-1)*(360/$n), 'degree');
+ $zinc->contour($curve, 'add', 1, $arc);
+ $zinc->remove($arc);
+ }
+ &showbbox($group);
+ ok(&similarFlatArray ([$zinc->bbox($group)],
+ [278,178, 422,322], # beware this coordinates are
+ # not exactly the good one
+ [2,2, 2,2 ],
+ ),
+ "bbox of middle figure");
+
+
+ # third
+ $group = $zinc->add('group', 1);
+ $zinc->coords($group, [600, 250]);
+
+ $curve = $zinc->add('curve', $group, [],
+ -fillrule => 'nonzero',
+ -closed => 1,
+ -filled => 1,
+ -fillcolor => 'black',
+ -linecolor => 'red',
+ );
+ $arc = $zinc->add('arc', $group, [-30, -30, 30, 30]);
$zinc->contour($curve, 'add', 1, $arc);
$zinc->remove($arc);
-}
-&showbbox($group);
-ok(&similarFlatArray ([$zinc->bbox($group)],
- [528,178, 672, 322], # beware this coordinates are
- # not exactly the good one
- [2,2, 2,2 ],
- ),
- "bbox of right figure");
-
+ $n = 3*$n;
+ for (1..$n) {
+ $arc = $zinc->add('arc', $group, [-5, -70, 5, -40]);
+ $zinc->rotate($arc, ($_-1)*(360/$n), 'degree');
+ $zinc->contour($curve, 'add', 1, $arc);
+ $zinc->remove($arc);
+ }
+ &showbbox($group);
+ ok(&similarFlatArray ([$zinc->bbox($group)],
+ [528,178, 672, 322], # beware this coordinates are
+ # not exactly the good one
+ [2,2, 2,2 ],
+ ),
+ "bbox of right figure");
+
+ diag("############## end of text test");
+ exit;
-$zinc->update;
-#sleep 2;
+}
-#MainLoop;