From 1e20541fea609dba3ac563618082834f09bfdcf9 Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" Date: Tue, 15 Mar 2005 23:58:06 +0000 Subject: [PATCH] Bug 275705 - better diagnostics for charts. Patch by bugzilla@glob.com.au; r=gerv, a=myk. --- webtools/bugzilla/t/testchart.gif | Bin 0 -> 3751 bytes webtools/bugzilla/t/testchart.png | Bin 0 -> 2382 bytes webtools/bugzilla/t/testgd.png | Bin 0 -> 361 bytes webtools/bugzilla/testserver.pl | 106 ++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 webtools/bugzilla/t/testchart.gif create mode 100644 webtools/bugzilla/t/testchart.png create mode 100644 webtools/bugzilla/t/testgd.png diff --git a/webtools/bugzilla/t/testchart.gif b/webtools/bugzilla/t/testchart.gif new file mode 100644 index 0000000000000000000000000000000000000000..a4ed080a0265a19266fb6d1810488cb07a6c2a0b GIT binary patch literal 3751 zcmV;Y4p{L=Nk%v~VUPik0m1+P|Ns900077U0RR900IvYy;o$%P00000EC2ui0FVKY z0RRL32)f+}*y*TU5yZ>M)j$~<`XsWJk>%MR-&vb3yc&_h!@BhG{a7Zi~kI1BQ z$!t2G(5Q4uty-_xtai)odcWYXcuX#v&*-#z&2GEj@VIg&+6 zTkRjR4Wg&=jmhiz`uqI-{@CdL3A_dm9ug*SDCpen#R{9)DRGi78-GFMb zX#^+Ir$~=N)uuEH(;`l%YR%bmE5Vc^1c((7fvg9!63{w?lGUqQkzL-o?zU!Hfpz5f4fxP7Ku z6`KjM-hbG=$DMUG^@pH;3NGkCflE*b#DNcf7GP}y9^_z#$Zg0Wb5?x_qHPi8Mj{p# z{(#|$UZtpFd?gkKV~8?J$e#%4L_oj?KT5F5geKnTmWao72*8jO1i2&xPI3^X15Qra zq7N?`Srn2Z#|G zO%iEioNvuZryhfPUiYsGrhGqZ6m1+R~+m-r9kguRb~^n2SCdrJ9Yl{z(m`x<<9ijjXCy zWV14ryb6dYf!c06lC|t%`$VZcT%(=1IN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$b3!YbvCVqE~+)%_uuS`gFq5Lx;5-S==u z(b`^lPVgQ{`SJjp6gnBIviY?0RHm-{53%fp;Em!m1-cYQDu-PHclfH);%5;&lu`Ewn%$I@QeX4TQH{kVD7=@zs^l zt1XpWPe8^t9}9|D?M0-=wg z{$iJeQPpYf&PDWF;y~TG`d@x)$l2*Fz}V`vg6(W)8h6VyDtxtZh0lOv`jarNZAu_g z>1sASXnzMbRxx%qQ)}SkcnH-@W)CTZ;&XbD)lEQ&W-vmKbj$|uGTed33EE0_enlch zzqoa#%nnivN;*14Hs8>fxwl?{jkgdQq+fk z={?Zm{#u3A=TzjTw$ZCsOG0~Zl$CYMt?yMiP2N>pO#XUl{*!*-8crj8>yHIq2(ZvV z^U{EEAKsXy1j76t#cf+tZ?{8;@fjnTIAR$v-w=eHMY&9@nHq%12$^0oh)^es(u-zF zZI!5&1rT{_0K~8cc}dWI0R!X$n zsVTE*<>ryp`9h4khTcA-BJp75ayGFY;(qpWQFR?|*o+W)tzJNa9(~a8t0$SDA{9g5QHNm`k*&G@?2E8{!g( zEXA5LzoAxNWhM|pwV7`wQM4kP;5UuO6bz!jEHI78156{Ea{+&XHkZ6s#gI~56D>_C zO0UYZW6^=N4G`})`G^5Ipyro=3(f*TG-A zP9l06N4%g98S50K((0^;UnJE;{!Ls+XmnI@cQ3`+gy*EPRHDn#=oAf*;Q}dUDyTam zHcK0KAqk6{Hi`z1WP6*<{y5}4eQc%NH`4_=QexY=e?wPc$7m^o};s}yj#YQdy|9tt!wGR$7SuV%$_!e^|zs+=EvaZV!=PEaD{c(LaoK) z9KKu4$KlJ_o6)R7b4g3luCt=-^9I=xRI%OF4!ZxiXF_krt@IdOAN^QAd)?=FE0*o< lZ9rnZOXAu8zv$D(Y&qSZ0tMTKmwugwBElot4Xk+Se*ta18ixP? literal 0 HcmV?d00001 diff --git a/webtools/bugzilla/t/testgd.png b/webtools/bugzilla/t/testgd.png new file mode 100644 index 0000000000000000000000000000000000000000..72c6aa50647d8fed2515a7b3c141f4e224a3d30c GIT binary patch literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^DImB?%5O4-)~M2^Sg{927noWw2ZjL`>W?pZle!-f{5|*Hele zn^eq?Z-4&ZLtXgy<2ddAThg4e)CA9)-ecWkA9}l^T>3fVIRVx3g0P1*hi7&ahn$R? zbKT&1`; + $gdlib =~ s/\n$//; + if (!$gdlib) { + print "TEST-WARNING Failed to run gdlib-config, assuming gdlib " . + "version 1.x\n"; + $gdlib = '1.x'; + } + my $gd = $GD::VERSION; + + my $verstring = "GD version $gd, libgd version $gdlib"; + + $gdlib =~ s/^([^\.]+)\..*/$1/; + $gd =~ s/^([^\.]+)\..*/$1/; + + if ($gdlib == $gd) { + print "TEST-OK $verstring; Major versions match.\n"; + } else { + print "TEST-FAIL $verstring; Major versions do not match\n"; + } + } + + # Test GD + + eval { + my $image = new GD::Image(100, 100); + my $black = $image->colorAllocate(0, 0, 0); + my $white = $image->colorAllocate(255, 255, 255); + my $red = $image->colorAllocate(255, 0, 0); + my $blue = $image->colorAllocate(0, 0, 255); + $image->transparent($white); + $image->rectangle(0, 0, 99, 99, $black); + $image->arc(50, 50, 95, 75, 0, 360, $blue); + $image->fill(50, 50, $red); + + if ($image->can('png')) { + create_file('data/testgd-local.png', $image->png); + check_image('data/testgd-local.png', 't/testgd.png', 'GD', 'PNG'); + } else { + die "GD doesn't support PNG generation\n"; + } + }; + if ($@ ne '') { + print "TEST-FAILED GD returned: $@\n"; + } + + # Test Chart + + eval 'use Chart::Lines'; + if ($@) { + print "TEST-FAILED Chart::Lines is not installed\n"; + } else { + eval { + my $chart = Chart::Lines->new(400, 400); + + $chart->add_pt('foo', 30, 25); + $chart->add_pt('bar', 16, 32); + + my $type = $chart->can('gif') ? 'gif' : 'png'; + $chart->$type("data/testchart-local.$type"); + check_image("data/testchart-local.$type", "t/testchart.$type", + "Chart", uc($type)); + }; + if ($@ ne '') { + print "TEST-FAILED Chart returned: $@\n"; + } + } +} + sub fetch { my $url = shift; my $rtn; @@ -169,3 +245,33 @@ sub fetch { return($rtn); } +sub check_image { + my ($local_file, $test_file, $library, $image_type) = @_; + if (read_file($local_file) eq read_file($test_file)) { + print "TEST-OK $library library generated a good $image_type image\n"; + unlink $local_file; + } else { + print "TEST-WARNING $library library generated a $image_type that " . + "didn't match the expected image.\nIt has been saved as " . + "$local_file and should be compared with $test_file\n"; + } +} + +sub create_file { + my ($filename, $content) = @_; + open(FH, ">$filename") + or die "Failed to create $filename: $!\n"; + binmode FH; + print FH $content; + close FH; +} + +sub read_file { + my ($filename) = @_; + open(FH, $filename) + or die "Failed to open $filename: $!\n"; + binmode FH; + my $content = ; + close FH; + return $content; +}