summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-12-07 14:48:11 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-12-07 14:48:11 +0000
commit10d2b024859787aad075161d62f60d8a02d054a2 (patch)
tree5cc15653435725f9620c92cebda6fcecfcace5d4 /tests
parentb18f980f00c730e679ab47a1d58afdd3b080f0c9 (diff)
downloadzetacomponents-graph-10d2b024859787aad075161d62f60d8a02d054a2.zip
zetacomponents-graph-10d2b024859787aad075161d62f60d8a02d054a2.tar.gz
- Tested and improved handling of texts with different charsets in all drivers
Diffstat (limited to 'tests')
-rw-r--r--tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsFlash.swfbin0 -> 1039 bytes
-rw-r--r--tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsGD.pngbin0 -> 12468 bytes
-rw-r--r--tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsSVG.svg2
-rw-r--r--tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsGD.pngbin0 -> 12468 bytes
-rw-r--r--tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsSVG.svg2
-rw-r--r--tests/driver_svg_test.php18
-rw-r--r--tests/font_test.php256
7 files changed, 277 insertions, 1 deletions
diff --git a/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsFlash.swf b/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsFlash.swf
new file mode 100644
index 0000000..357b86b
--- /dev/null
+++ b/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsFlash.swf
Binary files differ
diff --git a/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsGD.png b/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsGD.png
new file mode 100644
index 0000000..70084b1
--- /dev/null
+++ b/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsGD.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsSVG.svg b/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsSVG.svg
new file mode 100644
index 0000000..012e3fb
--- /dev/null
+++ b/tests/data/compare/ezcGraphFontTest_testISO_8859_15SpecialCharsSVG.svg
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_1"/><g id="ezcGraphTextBox_2"><path d=" M 9.5000,51.0000 L 9.5000,9.5000 L 159.4000,9.5000 L 159.4000,51.0000 L 9.5000,51.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_3"/><text id="ezcGraphTextBox_2_text" x="10" text-length="148.4px" y="44" style="font-size: 40px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">öäüÖÄÜß</text></g></g></svg>
diff --git a/tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsGD.png b/tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsGD.png
new file mode 100644
index 0000000..70084b1
--- /dev/null
+++ b/tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsGD.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsSVG.svg b/tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsSVG.svg
new file mode 100644
index 0000000..9dba499
--- /dev/null
+++ b/tests/data/compare/ezcGraphFontTest_testUTF8SpecialCharsSVG.svg
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_1"/><g id="ezcGraphTextBox_2"><path d=" M 9.5000,51.0000 L 9.5000,9.5000 L 159.4000,9.5000 L 159.4000,51.0000 L 9.5000,51.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_3"/><text id="ezcGraphTextBox_2_text" x="10" text-length="148.4px" y="44" style="font-size: 40px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">&#xF6;&#xE4;&#xFC;&#xD6;&#xC4;&#xDC;&#xDF;</text></g></g></svg>
diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php
index 88da61d..2db6ded 100644
--- a/tests/driver_svg_test.php
+++ b/tests/driver_svg_test.php
@@ -1530,5 +1530,23 @@ class ezcGraphSvgDriverTest extends ezcTestCase
'Setting property value did not work for property idPrefix in class ezcGraphSvgDriverOptions'
);
}
+
+ public function testSvgDriverOptionsPropertyEncoding()
+ {
+ $options = new ezcGraphSvgDriverOptions();
+
+ $this->assertSame(
+ null,
+ $options->encoding,
+ 'Wrong default value for property idPrefix in class ezcGraphSvgDriverOptions'
+ );
+
+ $options->encoding = 'ISO-8859-15';
+ $this->assertSame(
+ 'ISO-8859-15',
+ $options->encoding,
+ 'Setting property value did not work for property idPrefix in class ezcGraphSvgDriverOptions'
+ );
+ }
}
?>
diff --git a/tests/font_test.php b/tests/font_test.php
index 460c64d..4b5208b 100644
--- a/tests/font_test.php
+++ b/tests/font_test.php
@@ -15,8 +15,10 @@
* @package ImageAnalysis
* @subpackage Tests
*/
-class ezcGraphFontTest extends ezcTestCase
+class ezcGraphFontTest extends ezcImageTestCase
{
+ protected $tempDir;
+
protected $basePath;
public static function suite()
@@ -26,9 +28,47 @@ class ezcGraphFontTest extends ezcTestCase
protected function setUp()
{
+ static $i = 0;
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
$this->basePath = dirname( __FILE__ ) . '/data/';
}
+ protected function tearDown()
+ {
+ unset( $this->driver );
+ if ( !$this->hasFailed() )
+ {
+ $this->removeTempDir();
+ }
+ }
+
+ /**
+ * Compares a generated image with a stored file
+ *
+ * @param string $generated Filename of generated image
+ * @param string $compare Filename of stored image
+ * @return void
+ */
+ protected function compare( $generated, $compare )
+ {
+ $this->assertTrue(
+ file_exists( $generated ),
+ 'No image file has been created.'
+ );
+
+ $this->assertTrue(
+ file_exists( $compare ),
+ 'Comparision image does not exist.'
+ );
+
+ if ( md5_file( $generated ) !== md5_file( $compare ) )
+ {
+ // Adding a diff makes no sense here, because created XML uses
+ // only two lines
+ $this->fail( 'Rendered image is not correct.');
+ }
+ }
+
public function testSetGeneralFont()
{
$chart = new ezcGraphPieChart();
@@ -632,5 +672,219 @@ class ezcGraphFontTest extends ezcTestCase
$this->fail( 'Expected ezcBasePropertyNotFoundException.' );
}
+
+ public function testUTF8SpecialCharsSVG()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $driver = new ezcGraphSvgDriver();
+ $driver->options->width = 200;
+ $driver->options->height = 100;
+
+ $driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $driver->drawTextBox(
+ 'öäüÖÄÜß',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testISO_8859_15SpecialCharsSVG()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $driver = new ezcGraphSvgDriver();
+ $driver->options->width = 200;
+ $driver->options->height = 100;
+ $driver->options->encoding = 'ISO-8859-15';
+
+ $driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $driver->drawTextBox(
+ mb_convert_encoding( 'öäüÖÄÜß', 'ISO-8859-15', 'UTF-8' ),
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testUTF8SpecialCharsGD()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $driver = new ezcGraphGdDriver();
+ $driver->options->font->path = $this->basePath . 'font.ttf';
+ $driver->options->width = 200;
+ $driver->options->height = 100;
+
+ $driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $return = $driver->drawTextBox(
+ 'öäüÖÄÜß',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $driver->render( $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
+ public function testISO_8859_15SpecialCharsGD()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $driver = new ezcGraphGdDriver();
+ $driver->options->font->path = $this->basePath . 'font.ttf';
+ $driver->options->width = 200;
+ $driver->options->height = 100;
+
+ $driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $return = $driver->drawTextBox(
+ mb_convert_encoding( 'öäüÖÄÜß', 'ISO-8859-15', 'UTF-8' ),
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $driver->render( $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
+ public function testUTF8SpecialCharsFlash()
+ {
+ $this->fail( 'No support for UTF-8 chars in SWFTextField. SWFText is not usable by driver for other reasons.' );
+ $filename = $this->tempDir . __FUNCTION__ . '.swf';
+
+ $driver = new ezcGraphFlashDriver();
+ $driver->options->font->path = $this->basePath . 'fdb_font.fdb';
+ $driver->options->width = 200;
+ $driver->options->height = 100;
+
+ $driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $driver->drawTextBox(
+ 'öäüÖÄÜß',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf'
+ );
+ }
+
+ public function testISO_8859_15SpecialCharsFlash()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.swf';
+
+ $driver = new ezcGraphFlashDriver();
+ $driver->options->font->path = $this->basePath . 'fdb_font.fdb';
+ $driver->options->width = 200;
+ $driver->options->height = 100;
+
+ $driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $driver->drawTextBox(
+ mb_convert_encoding( 'öäüÖÄÜß', 'ISO-8859-15', 'UTF-8' ),
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf'
+ );
+ }
}
?>
OpenPOWER on IntegriCloud