| 470 | }; |
| 471 | |
| 472 | int main( int argc, char **argv ) |
| 473 | { |
| 474 | map<string,TestBase*> tests; |
| 475 | |
| 476 | tests["arc"] = new TestArc(); |
| 477 | tests["arc_negative"] = new TestArcNegative(); |
| 478 | tests["clip"] = new TestClip(); |
| 479 | tests["clip_image"] = new TestClipImage(); |
| 480 | tests["curve_rectangle"] = new TestCurveRectangle(); |
| 481 | tests["curve_to"] = new TestCurveTo(); |
| 482 | tests["dash"] = new TestDash(); |
| 483 | tests["fill_and_stroke"] = new TestFillAndStroke(); |
| 484 | tests["fill_style"] = new TestFillStyle(); |
| 485 | tests["gradient"] = new TestGradient(); |
| 486 | tests["image"] = new TestImage(); |
| 487 | tests["image_pattern"] = new TestImagePattern(); |
| 488 | tests["multi_segment_caps"] = new TestMultiSegmentCaps(); |
| 489 | tests["set_line_cap"] = new TestSetLineCap(); |
| 490 | tests["set_line_join"] = new TestSetLineJoin(); |
| 491 | tests["text"] = new TestText(); |
| 492 | tests["text_align_center"] = new TestTextAlignCenter(); |
| 493 | tests["text_extents"] = new TestTextExtents(); |
| 494 | #if defined( TEST_PNG ) |
| 495 | { |
| 496 | std::cout << "-= Testing PNG =-" << std::endl; |
| 497 | fli::cairo::SurfaceImage surface( 512, 512 ); |
| 498 | for( map<string,TestBase*>::const_iterator it = tests.begin(); it != tests.end(); ++it ) { |
| 499 | fli::cairo::Context ctx( &surface ); |
| 500 | std::cout << "Running test: " << it->first << std::endl; |
| 501 | fli::fill( &surface.getSurface(), fli::Color8u( 255, 255, 255 ) ); |
| 502 | it->second->run( ctx ); |
| 503 | surface.writeToPng( it->first + ".png" ); |
| 504 | } |
| 505 | } |
| 506 | #endif |
| 507 | |
| 508 | #if defined( TEST_PDF ) |
| 509 | { |
| 510 | std::cout << "-= Testing PDF =-" << std::endl; |
| 511 | fli::cairo::SurfacePDF surface( "tests.pdf", 512, 512 ); |
| 512 | fli::cairo::Context ctx( &surface ); |
| 513 | ctx.save(); |
| 514 | for( map<string,TestBase*>::const_iterator it = tests.begin(); it != tests.end(); ++it ) { |
| 515 | std::cout << "Running test: " << it->first << std::endl; |
| 516 | it->second->run( ctx ); |
| 517 | ctx.showPage(); |
| 518 | ctx.restore(); |
| 519 | ctx.save(); |
| 520 | } |
| 521 | } |
| 522 | #endif |
| 523 | |
| 524 | #if defined( TEST_SVG ) |
| 525 | { |
| 526 | std::cout << "-= Testing SVG =-" << std::endl; |
| 527 | for( map<string,TestBase*>::const_iterator it = tests.begin(); it != tests.end(); ++it ) { |
| 528 | fli::cairo::SurfaceSVG surface( ( it->first + ".svg" ).c_str(), 512, 512 ); |
| 529 | fli::cairo::Context ctx( &surface ); |