diff --git a/src/style-test.h b/src/style-test.h
index 2f923dfa0c400ce7623ff04f82119b1f35c0f600..a2d5fcf24459bdcf7aa4d2b56495811cf654300d 100644 (file)
--- a/src/style-test.h
+++ b/src/style-test.h
#include <cxxtest/TestSuite.h>
+#include "test-helpers.h"
+
#include "style.h"
class StyleTest : public CxxTest::TestSuite
{
public:
+ SPDocument* _doc;
+
+ StyleTest() :
+ _doc(0)
+ {
+ }
+
+ virtual ~StyleTest()
+ {
+ if ( _doc )
+ {
+ sp_document_unref( _doc );
+ _doc = 0;
+ }
+ }
+
+ static void createSuiteSubclass( StyleTest*& dst )
+ {
+ dst = new StyleTest();
+ }
+
+// createSuite and destroySuite get us per-suite setup and teardown
+// without us having to worry about static initialization order, etc.
+ static StyleTest *createSuite()
+ {
+ StyleTest* suite = Inkscape::createSuiteAndDocument<StyleTest>( createSuiteSubclass );
+ return suite;
+ }
+
+ static void destroySuite( StyleTest *suite )
+ {
+ delete suite;
+ }
+
+ // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
void testOne()
{
TestCase("fill:rgb(100%, 0%, 100%)", "fill:#ff00ff"),
// TODO - fix this to preserve the string
-// TestCase("fill:url(#painter) rgb(100%, 0%, 100%)",
-// "fill:url(#painter) #ff00ff", "#painter"),
+ TestCase("fill:url(#painter) rgb(100%, 0%, 100%)",
+ "fill:url(#painter) #ff00ff", "#painter"),
TestCase("fill:rgb(255, 0, 255)", "fill:#ff00ff"),
// TODO - fix this to preserve the string
-// TestCase("fill:url(#painter) rgb(255, 0, 255)",
-// "fill:url(#painter) #ff00ff", "#painter"),
+ TestCase("fill:url(#painter) rgb(255, 0, 255)",
+ "fill:url(#painter) #ff00ff", "#painter"),
// 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) 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) #ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)", 0, "#painter"),
+ TestCase("fill:url(#painter) #ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)", 0, "#painter"),
// TestCase("fill:url(#painter) inherit", 0, "#painter"),
TestCase("fill:inherit"),
};
for ( gint i = 0; cases[i].src; i++ ) {
- SPStyle *style = sp_style_new(NULL);
+ SPStyle *style = sp_style_new(_doc);
TS_ASSERT(style);
if ( style ) {
sp_style_merge_from_style_string( style, cases[i].src );
if ( cases[i].uri ) {
- TS_ASSERT( style->fill.value.href );
+ TSM_ASSERT( cases[i].src, style->fill.value.href );
if ( style->fill.value.href ) {
TS_ASSERT_EQUALS( style->fill.value.href->getURI()->toString(), std::string(cases[i].uri) );
}
} else {
- TS_ASSERT( !style->fill.value.href );
+ TS_ASSERT( !style->fill.value.href || !style->fill.value.href->getObject() );
}
gchar *str0_set = sp_style_write_string( style, SP_STYLE_FLAG_IFSET );