[Bps-public-commit] r11287 - in WebChart/t: data

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Mar 31 03:32:44 EDT 2008


Author: sunnavy
Date: Mon Mar 31 03:32:43 2008
New Revision: 11287

Added:
   WebChart/t/data/xmlswf_bars.xml
   WebChart/t/data/xmlswf_pie.xml
   WebChart/t/xmlswf.t

Log:
added tests for xmlswf renderer

Added: WebChart/t/data/xmlswf_bars.xml
==============================================================================
--- (empty file)
+++ WebChart/t/data/xmlswf_bars.xml	Mon Mar 31 03:32:43 2008
@@ -0,0 +1,31 @@
+<chart>
+  <axis_category color="808080" size="11" />
+  <axis_ticks major_color="808080" />
+  <axis_value color="808080" size="11" />
+  <chart_data>
+    <row>
+      <string></string>
+      <string>2004</string>
+      <string>2005</string>
+      <string>2006</string>
+      <string>2007</string>
+    </row>
+    <row>
+      <string></string>
+      <number>14</number>
+      <number>15</number>
+      <number>17</number>
+      <number>22</number>
+    </row>
+    <row>
+      <string></string>
+      <number>22</number>
+      <number>25</number>
+      <number>20</number>
+      <number>21</number>
+    </row>
+  </chart_data>
+  <chart_type>column</chart_type>
+  <chart_value color="666666" position="cursor" size="11" />
+  <legend_label size="11" />
+</chart>

Added: WebChart/t/data/xmlswf_pie.xml
==============================================================================
--- (empty file)
+++ WebChart/t/data/xmlswf_pie.xml	Mon Mar 31 03:32:43 2008
@@ -0,0 +1,17 @@
+<chart>
+  <axis_category color="808080" size="11" />
+  <axis_ticks major_color="808080" />
+  <axis_value color="808080" size="11" />
+  <chart_data>
+    <row>
+      <string></string>
+      <string>22</string>
+      <string>25</string>
+      <string>20</string>
+      <string>21</string>
+    </row>
+  </chart_data>
+  <chart_type>3d pie</chart_type>
+  <chart_value color="666666" position="cursor" size="11" />
+  <legend_label size="11" />
+</chart>

Added: WebChart/t/xmlswf.t
==============================================================================
--- (empty file)
+++ WebChart/t/xmlswf.t	Mon Mar 31 03:32:43 2008
@@ -0,0 +1,93 @@
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More tests => 11;
+use WebChart::Test qw/is_file/;
+use WebChart::Renderer::XMLSWF;
+
+my $renderer = WebChart::Renderer::XMLSWF->new;
+isa_ok( $renderer, 'WebChart::Renderer::XMLSWF' );
+
+my $data = [
+    [ '2004', '2005', '2006', '2007' ],    # labels
+    [ 14,     15,     17,     22 ],        # first data set
+    [ 22,     25,     20,     21 ],        # second data set
+];
+
+my ( $seg, $file ) = $renderer->render(
+    type => 'bars',
+    data => $data,
+);
+
+is_file( $file, "t/data/xmlswf_bars.xml", 'xmlswf_bars.xml' );
+
+like(
+    $seg,
+    qr{src="/flash/xmlswf/charts.swf},
+    'default flash dir is /flash'
+);
+like(
+    $seg,
+    qr{library_path=/flash/xmlswf/charts_library},
+    'library_path is charts_library',
+);
+
+like(
+    $seg,
+    qr{width="400"},
+    'default width is 400'
+);
+
+like(
+    $seg,
+    qr{height="300"},
+    'default height is 300'
+);
+
+
+$seg = $renderer->render(
+    type        => 'bars',
+    data        => $data,
+    width       => 800,
+    height      => 600,
+    web_flash_dir => '/swf',
+    web_css_class => 'foo bar',
+);
+
+like(
+    $seg,
+    qr{src="/swf/xmlswf/charts.swf},
+    'setf web_flash_dir works'
+);
+like(
+    $seg,
+    qr{width="800"},
+    'set width works'
+);
+
+like(
+    $seg,
+    qr{height="600"},
+    'set height works'
+);
+
+like(
+    $seg,
+    qr{class="foo bar"},
+    'set web_css_class works'
+);
+
+# Pie
+
+( $seg, $file ) = $renderer->render(
+    type => 'pie',
+    data => $data,
+);
+
+is_file(
+    $file,
+    "t/data/xmlswf_pie.xml",
+    'generated pie is right'
+);
+



More information about the Bps-public-commit mailing list