From 1f2631ad6b8be1d60420340dad0e812dbec460dd Mon Sep 17 00:00:00 2001 From: mertz Date: Sun, 12 Feb 2006 09:38:07 +0000 Subject: closing bug #57: mainloop before any update to avoid bug #48 --- Perl/t/Bbox-curve-multi-contour.t | 183 ++++++++++++++++++++------------------ 1 file changed, 96 insertions(+), 87 deletions(-) (limited to 'Perl') 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; -- cgit v1.1