2 #ifndef SEEN_STYLE_TEST_H
3 #define SEEN_STYLE_TEST_H
5 #include <cxxtest/TestSuite.h>
7 #include "style.h"
9 class StyleTest : public CxxTest::TestSuite
10 {
11 public:
13 void testOne()
14 {
15 struct TestCase {
16 TestCase(gchar const* src, gchar const* dst = 0, gchar const* uri = 0) : src(src), dst(dst), uri(uri) {}
17 gchar const* src;
18 gchar const* dst;
19 gchar const* uri;
20 };
22 TestCase cases[] = {
23 TestCase("fill:none"),
24 TestCase("fill:currentColor"),
25 TestCase("fill:#ff00ff"),
27 TestCase("fill:rgb(100%, 0%, 100%)", "fill:#ff00ff"),
28 TestCase("fill:rgb(255, 0, 255)", "fill:#ff00ff"),
30 // TestCase("fill:#ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)"),
32 TestCase("fill:url(#painter)", 0, "#painter"),
33 // TestCase("fill:url(#painter) none", 0, "#painter"),
34 // TestCase("fill:url(#painter) currentColor", 0, "#painter"),
35 // TestCase("fill:url(#painter) #ff00ff", 0, "#painter"),
36 // TestCase("fill:url(#painter) rgb(100%, 0%, 100%)", 0, "#painter"),
37 // TestCase("fill:url(#painter) rgb(255, 0, 255)", 0, "#painter"),
39 // TestCase("fill:url(#painter) #ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)",
40 // "fill:url(#painter) #ff00ff icc-color(colorChange, 0.10000000000000001, 0.50000000000000000, 0.10000000000000001)", "#painter"),
42 // TestCase("fill:url(#painter) inherit", 0, "#painter"),
43 TestCase("fill:inherit"),
44 TestCase(0)
45 };
47 for ( gint i = 0; cases[i].src; i++ ) {
48 SPStyle *style = sp_style_new();
49 TS_ASSERT(style);
50 if ( style ) {
51 sp_style_merge_from_style_string( style, cases[i].src );
53 if ( cases[i].uri ) {
54 TS_ASSERT( style->fill.value.paint.uri );
55 if ( style->fill.value.paint.uri ) {
56 TS_ASSERT_EQUALS( std::string(style->fill.value.paint.uri), std::string(cases[i].uri) );
57 }
58 } else {
59 TS_ASSERT( !style->fill.value.paint.uri );
60 }
62 gchar *str0_set = sp_style_write_string( style, SP_STYLE_FLAG_IFSET );
63 //printf("<<%s>>\n", str0_set);
64 if ( cases[i].dst ) {
65 TS_ASSERT_EQUALS( std::string(str0_set), std::string(cases[i].dst) );
66 } else {
67 TS_ASSERT_EQUALS( std::string(str0_set), std::string(cases[i].src) );
68 }
70 g_free(str0_set);
71 sp_style_unref(style);
72 }
73 }
74 }
76 };
79 #endif // SEEN_STYLE_TEST_H
81 /*
82 Local Variables:
83 mode:c++
84 c-file-style:"stroustrup"
85 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
86 indent-tabs-mode:nil
87 fill-column:99
88 End:
89 */
90 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :