diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2007-05-13 07:17:41 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2007-05-13 07:17:41 +0000 |
| commit | 22208ae39b3fa12917a14b6661df838474740306 (patch) | |
| tree | cc4be1ccfc7124383037e6720a94ccb1299e0e00 /src | |
| parent | Correcting extraction of "url(...)" for paint (diff) | |
| download | inkscape-22208ae39b3fa12917a14b6661df838474740306.tar.gz inkscape-22208ae39b3fa12917a14b6661df838474740306.zip | |
Initial set of style test. Will uncomment as style code is fixed.
(bzr r3014)
Diffstat (limited to 'src')
| -rw-r--r-- | src/style-test.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/style-test.h b/src/style-test.h index 135d03927..2e935f4fd 100644 --- a/src/style-test.h +++ b/src/style-test.h @@ -4,11 +4,74 @@ #include <cxxtest/TestSuite.h> +#include "style.h" class StyleTest : public CxxTest::TestSuite { public: + void testOne() + { + struct TestCase { + TestCase(gchar const* src, gchar const* dst = 0, gchar const* uri = 0) : src(src), dst(dst), uri(uri) {} + gchar const* src; + gchar const* dst; + gchar const* uri; + }; + + TestCase cases[] = { + TestCase("fill:none"), + TestCase("fill:currentColor"), + TestCase("fill:#ff00ff"), + + TestCase("fill:rgb(100%, 0%, 100%)", "fill:#ff00ff"), + TestCase("fill:rgb(255, 0, 255)", "fill:#ff00ff"), + +// TestCase("fill:#ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)"), + + TestCase("fill:url(#painter)", 0, "#painter"), +// TestCase("fill:url(#painter) none", 0, "#painter"), +// TestCase("fill:url(#painter) currentColor", 0, "#painter"), +// TestCase("fill:url(#painter) #ff00ff", 0, "#painter"), +// TestCase("fill:url(#painter) rgb(100%, 0%, 100%)", 0, "#painter"), +// TestCase("fill:url(#painter) rgb(255, 0, 255)", 0, "#painter"), + +// TestCase("fill:url(#painter) #ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)", +// "fill:url(#painter) #ff00ff icc-color(colorChange, 0.10000000000000001, 0.50000000000000000, 0.10000000000000001)", "#painter"), + +// TestCase("fill:url(#painter) inherit", 0, "#painter"), + TestCase("fill:inherit"), + TestCase(0) + }; + + for ( gint i = 0; cases[i].src; i++ ) { + SPStyle *style = sp_style_new(); + TS_ASSERT(style); + if ( style ) { + sp_style_merge_from_style_string( style, cases[i].src ); + + if ( cases[i].uri ) { + TS_ASSERT( style->fill.value.paint.uri ); + if ( style->fill.value.paint.uri ) { + TS_ASSERT_EQUALS( std::string(style->fill.value.paint.uri), std::string(cases[i].uri) ); + } + } else { + TS_ASSERT( !style->fill.value.paint.uri ); + } + + gchar *str0_set = sp_style_write_string( style, SP_STYLE_FLAG_IFSET ); + //printf("<<%s>>\n", str0_set); + if ( cases[i].dst ) { + TS_ASSERT_EQUALS( std::string(str0_set), std::string(cases[i].dst) ); + } else { + TS_ASSERT_EQUALS( std::string(str0_set), std::string(cases[i].src) ); + } + + g_free(str0_set); + sp_style_unref(style); + } + } + } }; |
