summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-05-29 07:31:41 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-05-29 07:31:41 +0000
commite9f7f66fef8d66865eae4cf731bf502c19dc948e (patch)
tree90b2ae3b143e4e3139c71f42c5cdee9a2779331b /tests
parentcc7669f009a394d3ac90f8aef489438fbccd3e9c (diff)
downloadzetacomponents-graph-e9f7f66fef8d66865eae4cf731bf502c19dc948e.zip
zetacomponents-graph-e9f7f66fef8d66865eae4cf731bf502c19dc948e.tar.gz
- Fixed issue #10830: Automatically shorten labels if not enough space is
available
Diffstat (limited to 'tests')
-rw-r--r--tests/data/compare/ezcGraphFlashDriverTest_testShortenStringMoreChars.swfbin0 -> 514 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testShortenStringMoreChars.pngbin0 -> 599 bytes
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testShortenSingleChar.svg2
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testShortenStringFewChars.svg2
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testShortenStringManyWordsSplit.svg2
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testShortenStringMoreChars.svg2
-rw-r--r--tests/data/compare/ezcGraphSvgDriverTest_testShortenStringWordSplit.svg2
-rw-r--r--tests/driver_flash_test.php28
-rw-r--r--tests/driver_gd_test.php24
-rw-r--r--tests/driver_options_test.php47
-rw-r--r--tests/driver_svg_test.php148
11 files changed, 228 insertions, 29 deletions
diff --git a/tests/data/compare/ezcGraphFlashDriverTest_testShortenStringMoreChars.swf b/tests/data/compare/ezcGraphFlashDriverTest_testShortenStringMoreChars.swf
new file mode 100644
index 0000000..4ace166
--- /dev/null
+++ b/tests/data/compare/ezcGraphFlashDriverTest_testShortenStringMoreChars.swf
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testShortenStringMoreChars.png b/tests/data/compare/ezcGraphGdDriverTest_testShortenStringMoreChars.png
new file mode 100644
index 0000000..5df0996
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testShortenStringMoreChars.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testShortenSingleChar.svg b/tests/data/compare/ezcGraphSvgDriverTest_testShortenSingleChar.svg
new file mode 100644
index 0000000..6f62296
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testShortenSingleChar.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"><g id="ezcGraphTextBox_1"><path d=" M 9.5000,17.0000 L 9.5000,9.5000 L 14.1800,9.5000 L 14.1800,17.0000 L 9.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><text id="ezcGraphTextBox_1_text" x="10.0000" text-length="3.1800px" y="15.1000" style="font-size: 6px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">T</text></g></g></svg>
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringFewChars.svg b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringFewChars.svg
new file mode 100644
index 0000000..0670328
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringFewChars.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"><g id="ezcGraphTextBox_1"><path d=" M 9.5000,17.0000 L 9.5000,9.5000 L 17.3600,9.5000 L 17.3600,17.0000 L 9.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><text id="ezcGraphTextBox_1_text" x="10.0000" text-length="6.3600px" y="15.1000" style="font-size: 6px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Te</text></g></g></svg>
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringManyWordsSplit.svg b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringManyWordsSplit.svg
new file mode 100644
index 0000000..28b0bf9
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringManyWordsSplit.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"><g id="ezcGraphTextBox_1"><path d=" M 9.5000,17.0000 L 9.5000,9.5000 L 65.0600,9.5000 L 65.0600,17.0000 L 9.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><text id="ezcGraphTextBox_1_text" x="10.0000" text-length="54.0600px" y="15.1000" style="font-size: 6px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">foo bar foo bar..</text></g></g></svg>
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringMoreChars.svg b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringMoreChars.svg
new file mode 100644
index 0000000..91b7aa6
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringMoreChars.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"><g id="ezcGraphTextBox_1"><path d=" M 9.5000,17.0000 L 9.5000,9.5000 L 33.2600,9.5000 L 33.2600,17.0000 L 9.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><text id="ezcGraphTextBox_1_text" x="10.0000" text-length="22.2600px" y="15.1000" style="font-size: 6px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Tests..</text></g></g></svg>
diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringWordSplit.svg b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringWordSplit.svg
new file mode 100644
index 0000000..1feb931
--- /dev/null
+++ b/tests/data/compare/ezcGraphSvgDriverTest_testShortenStringWordSplit.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"><g id="ezcGraphTextBox_1"><path d=" M 9.5000,17.0000 L 9.5000,9.5000 L 49.1600,9.5000 L 49.1600,17.0000 L 9.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><text id="ezcGraphTextBox_1_text" x="10.0000" text-length="38.1600px" y="15.1000" style="font-size: 6px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Teststring..</text></g></g></svg>
diff --git a/tests/driver_flash_test.php b/tests/driver_flash_test.php
index 409475f..d9b4287 100644
--- a/tests/driver_flash_test.php
+++ b/tests/driver_flash_test.php
@@ -1274,15 +1274,15 @@ class ezcGraphFlashDriverTest extends ezcGraphTestCase
public function testDrawTooLongTextException()
{
- $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $filename = $this->tempDir . __FUNCTION__ . '.swf';
try
{
$this->driver->drawTextBox(
- 'This is very long text which is not supposed to fit in the bounding box.',
+ 'Teststring foo',
new ezcGraphCoordinate( 10, 10 ),
- 50,
- 20,
+ 1,
+ 6,
ezcGraph::LEFT
);
@@ -1296,6 +1296,26 @@ class ezcGraphFlashDriverTest extends ezcGraphTestCase
$this->fail( 'Expected ezcGraphFontRenderingException.' );
}
+ public function testShortenStringMoreChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.swf';
+
+ $this->driver->drawTextBox(
+ 'Teststring foo',
+ new ezcGraphCoordinate( 10, 10 ),
+ 24,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->swfCompare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf'
+ );
+ }
+
public function testDrawCircleRadialFill()
{
$filename = $this->tempDir . __FUNCTION__ . '.swf';
diff --git a/tests/driver_gd_test.php b/tests/driver_gd_test.php
index a11d38d..07690c0 100644
--- a/tests/driver_gd_test.php
+++ b/tests/driver_gd_test.php
@@ -1934,7 +1934,7 @@ class ezcGraphGdDriverTest extends ezcTestImageCase
$this->driver->drawTextBox(
'This is very long text which is not supposed to fit in the bounding box.',
new ezcGraphCoordinate( 10, 10 ),
- 50,
+ 1,
20,
ezcGraph::LEFT
);
@@ -2225,6 +2225,28 @@ class ezcGraphGdDriverTest extends ezcTestImageCase
);
}
+ public function testShortenStringMoreChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $this->driver->drawTextBox(
+ 'Teststring foo',
+ new ezcGraphCoordinate( 10, 10 ),
+ 24,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
public function testDrawJpeg()
{
$filename = $this->tempDir . __FUNCTION__ . '.jpg';
diff --git a/tests/driver_options_test.php b/tests/driver_options_test.php
index 705ade6..e544648 100644
--- a/tests/driver_options_test.php
+++ b/tests/driver_options_test.php
@@ -171,6 +171,53 @@ class ezcGraphDriverOptionsTest extends ezcTestImageCase
$this->fail( 'Expected ezcBaseValueException.' );
}
+ public function testDriverOptionsPropertyAutoShortenString()
+ {
+ $options = new ezcGraphSvgDriverOptions();
+
+ $this->assertSame(
+ true,
+ $options->autoShortenString,
+ 'Wrong default value for property autoShortenString in class ezcGraphDriverOptions'
+ );
+
+ $options->autoShortenString = false;
+ $this->assertSame(
+ false,
+ $options->autoShortenString,
+ 'Setting property value did not work for property autoShortenString in class ezcGraphDriverOptions'
+ );
+
+ try
+ {
+ $options->autoShortenString = 42;
+ }
+ catch ( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testDriverOptionsPropertyAutoShortenStringPostFix()
+ {
+ $options = new ezcGraphSvgDriverOptions();
+
+ $this->assertSame(
+ '..',
+ $options->autoShortenStringPostFix,
+ 'Wrong default value for property autoShortenStringPostFix in class ezcGraphDriverOptions'
+ );
+
+ $options->autoShortenStringPostFix = ' ...';
+ $this->assertSame(
+ ' ...',
+ $options->autoShortenStringPostFix,
+ 'Setting property value did not work for property autoShortenStringPostFix in class ezcGraphDriverOptions'
+ );
+ }
+
public function testPropertyNotFoundException()
{
$options = new ezcGraphSvgDriverOptions();
diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php
index 67e0096..e9dffa8 100644
--- a/tests/driver_svg_test.php
+++ b/tests/driver_svg_test.php
@@ -1433,30 +1433,6 @@ class ezcGraphSvgDriverTest extends ezcGraphTestCase
);
}
- public function testDrawTooLongTextException()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- try
- {
- $this->driver->drawTextBox(
- 'This is very long text which is not supposed to fit in the bounding box.',
- new ezcGraphCoordinate( 10, 10 ),
- 50,
- 20,
- ezcGraph::LEFT
- );
-
- $this->driver->render( $filename );
- }
- catch ( ezcGraphFontRenderingException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcGraphFontRenderingException.' );
- }
-
public function testSvgDriverOptionsPropertyAssumedNumericCharacterWidth()
{
$options = new ezcGraphSvgDriverOptions();
@@ -1816,5 +1792,129 @@ class ezcGraphSvgDriverTest extends ezcGraphTestCase
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
}
+
+ public function testShortenStringFailure()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ try
+ {
+ $this->driver->drawTextBox(
+ 'Test string',
+ new ezcGraphCoordinate( 10, 10 ),
+ 1,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+ }
+ catch ( ezcGraphFontRenderingException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphFontRenderingException.' );
+ }
+
+ public function testShortenSingleChar()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawTextBox(
+ 'Teststring foo',
+ new ezcGraphCoordinate( 10, 10 ),
+ 4,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testShortenStringFewChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawTextBox(
+ 'Teststring foo',
+ new ezcGraphCoordinate( 10, 10 ),
+ 8,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testShortenStringMoreChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawTextBox(
+ 'Teststring foo',
+ new ezcGraphCoordinate( 10, 10 ),
+ 24,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testShortenStringWordSplit()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawTextBox(
+ 'Teststring foo',
+ new ezcGraphCoordinate( 10, 10 ),
+ 40,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testShortenStringManyWordsSplit()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawTextBox(
+ 'foo bar foo bar foo bar foo bar',
+ new ezcGraphCoordinate( 10, 10 ),
+ 60,
+ 6,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
}
?>
OpenPOWER on IntegriCloud