[Bps-public-commit] r11233 - WebChart/t

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Mar 27 10:14:10 EDT 2008


Author: sunnavy
Date: Thu Mar 27 10:14:08 2008
New Revision: 11233

Modified:
   WebChart/t/chart.t

Log:
don't use WebChart.pm in chart.t; also some tiny improvements

Modified: WebChart/t/chart.t
==============================================================================
--- WebChart/t/chart.t	(original)
+++ WebChart/t/chart.t	Thu Mar 27 10:14:08 2008
@@ -4,15 +4,10 @@
 use lib 't/lib';
 use Test::More qw/no_plan/;
 use WebChart::Test qw/is_file/;
-use WebChart;
+use WebChart::Renderer::Chart;
 
-# default renderer is Chart
-my $wc = WebChart->new( renderer => 'Chart' );
-isa_ok( $wc, 'WebChart' );
-isa_ok( $wc->renderer, 'WebChart::Renderer::Chart' );
-
-$wc = WebChart->new();
-isa_ok( $wc->renderer, 'WebChart::Renderer::Chart' );
+my $renderer = WebChart::Renderer::Chart->new();
+isa_ok( $renderer, 'WebChart::Renderer::Chart' );
 
 my $data = [
     [ '2004', '2005', '2006', '2007' ],    # labels
@@ -20,27 +15,37 @@
     [ 22,     25,     20,     21 ],        # second data set
 ];
 
-my ( $seg, $file ) = $wc->render(
-    type => 'bars',
-    data => $data,
+my ( $seg, $file ) = $renderer->render(
+    type    => 'bars',
+    data    => $data,
 );
 
-is_file( $file, 't/data/chart_bars_400x300.png', 'generated bars is right' );
-
-like( $seg, qr{<img src="/charts/.*png" />}, 'render bars works' );
-
-( $seg, $file ) = $wc->render(
-    type   => 'bars',
-    width  => 800,
-    height => 600,
-    data   => $data,
+is_file(
+    $file,
+    't/data/chart_bars_400x300.png',
+    'default width is 400, heigth is 300'
 );
 
-is_file( $file, 't/data/chart_bars_800x600.png', 'width and height args works' );
+like( $seg, qr{<img src="/charts/.*png" />}, 'default web_img_dir is /charts' );
 
-$seg = $wc->render(
+( $seg, $file ) = $renderer->render(
     type        => 'bars',
     data        => $data,
+    width       => 800,
+    height      => 600,
+    web_img_dir => '/pictures',
+);
+
+is_file(
+    $file,
+    't/data/chart_bars_800x600.png',
+    'width and height args work',
+);
+like( $seg, qr{<img src="/pictures/.*png" />}, 'web_img_dir arg works' );
+
+$seg = $renderer->render(
+    type      => 'bars',
+    data      => $data,
     css_class => 'foo bar',
 );
 
@@ -50,20 +55,26 @@
     'render bars with css class works'
 );
 
-# Pie
-
-($seg, $file) = $wc->render(
-    type        => 'pie',
-    data        => $data,
+$seg = $renderer->render(
+    type      => 'bars',
+    data      => $data,
+    css_class => ' ',
 );
 
 like(
     $seg,
     qr{<img src="/charts/.*png" />},
-    'render pie works'
+    'html segment will not contail class=.. if css_class is just blank',
 );
 
-is_file( $file, 't/data/chart_pie_400x300.png', 'generated pie is right' );
+# Pie
+
+( $seg, $file ) = $renderer->render(
+    type   => 'pie',
+    data   => $data,
+);
 
 like( $seg, qr{<img src="/charts/.*png" />}, 'render pie works' );
 
+is_file( $file, 't/data/chart_pie_400x300.png', 'generated pie is right' );
+



More information about the Bps-public-commit mailing list