#ifndef SEEN_STYLE_TEST_H
#define SEEN_STYLE_TEST_H
#include <cxxtest/TestSuite.h>
#include "test-helpers.h"
#include "style.h"
{
StyleTest() :
_doc(0)
{
}
{
if ( _doc )
{
_doc = 0;
}
}
{
}
// createSuite and destroySuite get us per-suite setup and teardown
// without us having to worry about static initialization order, etc.
{
return suite;
}
{
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// Reading and writing style string
void testOne()
{
struct TestCase {
TestCase(gchar const* src, gchar const* dst = 0, gchar const* uri = 0) : src(src), dst(dst), uri(uri) {}
};
TestCase("fill:none"),
TestCase("fill:currentColor"),
TestCase("fill:#ff00ff"),
// TODO - fix this to preserve the string
TestCase("fill:url(#painter) rgb(100%, 0%, 100%)",
"fill:url(#painter) #ff00ff", "#painter"),
// TODO - fix this to preserve the string
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) rgb(100%, 0%, 100%)", 0, "#painter"),
// TestCase("fill:url(#painter) rgb(255, 0, 255)", 0, "#painter"),
// TestCase("fill:url(#painter) inherit", 0, "#painter"),
TestCase("fill:inherit"),
// General tests (in general order of appearance in sp_style_read), SPIPaint tested above
TestCase("visibility:collapse"),
TestCase("visibility:visible"),
TestCase("color:#ff0000"),
// TestCase("color:currentColor"), SVG 1.1 does not allow color value 'currentColor'
// Font shorthand
TestCase("font:bold 12px Arial",
"font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12px;line-height:normal;font-family:Arial"),
TestCase("font:bold 12px/24px 'Times New Roman'",
"font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12px;line-height:24px;font-family:\'Times New Roman\'"),
// From CSS 3 Fonts (examples):
TestCase("font: 12pt/15pt sans-serif",
"font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:15pt;font-family:sans-serif"),
TestCase("font: 80% sans-serif",
"font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80%;line-height:normal;font-family:sans-serif"),
TestCase("font: x-large/110% 'new century schoolbook', serif",
"font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:x-large;line-height:110%;font-family:\'new century schoolbook\', serif"),
TestCase("font: bold italic large Palatino, serif",
"font-style:italic;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:large;line-height:normal;font-family:Palatino, serif"),
TestCase("font: normal small-caps 120%/120% fantasy",
"font-style:normal;font-variant:small-caps;font-weight:normal;font-stretch:normal;font-size:120%;line-height:120%;font-family:fantasy"),
TestCase("font: condensed oblique 12pt 'Helvetica Neue', serif;",
"font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:16px;line-height:normal;font-family:\'Helvetica Neue\', serif"),
TestCase("font-family:Arial"),
// TestCase("font-variant:normal;font-stretch:normal;-inkscape-font-specification:Nimbus Roman No9 L Bold Italic"),
// Needs to be fixed (quotes should be around each font-family):
TestCase("font-size:12px"),
TestCase("font-size:medium"),
TestCase("font-size:smaller"),
TestCase("font-weight:normal"),
TestCase("font-weight:bolder"),
TestCase("font-variant-ligatures:normal"),
TestCase("font-variant-ligatures:no-common-ligatures"),
TestCase("font-variant-ligatures:discretionary-ligatures"),
TestCase("font-variant-ligatures:historical-ligatures"),
TestCase("font-variant-ligatures:no-contextual"),
TestCase("font-variant-ligatures:no-common-ligatures historical-ligatures"),
TestCase("font-variant-ligatures:historical-ligatures no-contextual"),
TestCase("font-variant-position:normal"),
TestCase("font-variant-position:sub"),
TestCase("font-variant-position:super"),
TestCase("font-variant-caps:normal"),
TestCase("font-variant-caps:small-caps"),
TestCase("font-variant-caps:all-small-caps"),
TestCase("font-variant-numeric:normal"),
TestCase("font-variant-numeric:lining-nums"),
TestCase("font-variant-numeric:oldstyle-nums"),
TestCase("font-variant-numeric:proportional-nums"),
TestCase("font-variant-numeric:tabular-nums"),
TestCase("font-variant-numeric:diagonal-fractions"),
TestCase("font-variant-numeric:stacked-fractions"),
TestCase("font-variant-numeric:ordinal"),
TestCase("font-variant-numeric:slashed-zero"),
TestCase("font-variant-numeric:tabular-nums slashed-zero"),
TestCase("font-variant-numeric:tabular-nums proportional-nums", "font-variant-numeric:proportional-nums"),
// Should be moved down
// SPITextDecoration
// The default value for 'text-decoration-color' is 'currentColor', but
// we cannot set the default to that value yet. (We need to switch
// SPIPaint to SPIColor and then add the ability to set default.)
// TestCase("text-decoration: underline",
// "text-decoration: underline;text-decoration-line: underline;text-decoration-color:currentColor"),
// TestCase("text-decoration: overline underline",
// "text-decoration: underline overline;text-decoration-line: underline overline;text-decoration-color:currentColor"),
TestCase("text-decoration: underline wavy #0000ff",
"text-decoration: underline;text-decoration-line: underline;text-decoration-style:wavy;text-decoration-color:#0000ff"),
TestCase("text-decoration: double overline underline #ff0000",
"text-decoration: underline overline;text-decoration-line: underline overline;text-decoration-style:double;text-decoration-color:#ff0000"),
// SPITextDecorationLine
TestCase("text-decoration-line: underline",
"text-decoration: underline;text-decoration-line: underline"),
// SPITextDecorationStyle
TestCase("text-decoration-style:solid"),
TestCase("text-decoration-style:dotted"),
// SPITextDecorationColor
TestCase("text-decoration-color:#ff00ff"),
// Should be moved up
TestCase("line-height:1.5"),
TestCase("word-spacing:normal"),
// ...
TestCase("baseline-shift:sub"),
TestCase("baseline-shift:12.5%"),
TestCase("baseline-shift:2px"),
// ...
TestCase("marker-start:url(#Arrow)"),
TestCase("marker-mid:url(#Arrow)"),
TestCase("marker-end:url(#Arrow)"),
TestCase("stroke-dashoffset:10px"),
// ...
//TestCase("filter:url(#myfilter)"), // SPIFilter segfault in read
TestCase("filter:inherit"),
TestCase("opacity:0.1;fill:#ff0000;stroke:#0000ff;stroke-width:2px"),
TestCase("opacity:0.1;fill:#ff0000;stroke:#0000ff;stroke-width:2px;stroke-dasharray:1, 2, 3, 4;stroke-dashoffset:15"),
#ifdef WITH_SVG2
TestCase("paint-order:normal"),
#endif
TestCase(0)
};
// std::cout << "Test one: " << i << std::endl;
}
} else {
}
// std::cout << " " << str0_set << " " << std::string(cases[i].dst) << std::endl;
} else {
// std::cout << " " << str0_set << " " << std::string(cases[i].src) << std::endl;
}
}
}
// Testing operator==
void testTwo()
{
struct TestCase {
bool match;
};
// SPIFloat
// SPIScale24
// SPILength
// SPILengthOrNormal
// SPIEnum
// SPIString and SPIFontString
// Default is not set by class... value is NULL which cannot be compared
// TestCase("font-family:sans-serif", "", true ), // Default
// SPIColor
// SPIPaint
// Needs URL defined as in test 1
//TestCase("fill:url(#xxx)", "fill:url(#yyy)", false),
// SPIPaintOrder
//TestCase("paint-order:fill stroke markers", "", true ), // Default
//TestCase("paint-order:fill stroke markers", "paint-order:normal", true ),
// SPIDashArray
// SPIFilter
// SPIFontSize
// SPIBaselineShift
// SPITextDecorationLine
TestCase("text-decoration-line:underline overline", "text-decoration-line:underline overline", true ),
// SPITextDecorationStyle
// SPITextDecoration
// TestCase("text-decoration:none", "text-decoration-color:currentColor", true ), // Default
// Terminate
TestCase(0,0,0)
};
// std::cout << "Test two: " << i << std::endl;
// std::cout << "Test:" << std::endl;
// std::cout << " C: |" << cases[i].src << "| |" << cases[i].dst << "|" << std::endl;
// std::cout << " S: |" << style_src.write( SP_STYLE_FLAG_IFSET, NULL ) << "| |"
// << style_dst.write( SP_STYLE_FLAG_IFSET, NULL ) << "|" <<std::endl;
// std::cout << "End Test\n" << std::endl;
}
}
// Test of cascade
void testThree()
{
struct TestCase {
};
// SPIFloat
// SPIScale24
// 'opacity' does not inherit
// SPILength
// ex, em cannot be equal
//TestCase("text-indent:2ex", "text-indent:2ex", "text-indent:2ex" ),
// SPILengthOrNormal
// ex, em cannot be equal
// TestCase("letter-spacing:10em", "letter-spacing:10em", "letter-spacing:10em" ),
// SPIEnum
// SPIString and SPIFontString
// SPIPaint
// SPIPaintOrder
// SPIDashArray
// SPIFilter
// SPIFontSize
// SPIBaselineShift
// SPITextDecorationLine
"text-decoration-line:underline" ),
// SPITextDecorationStyle
// SPITextDecoration
// Terminate
TestCase(0,0,0)
};
// std::cout << "Test three: " << i << std::endl;
// std::cout << "Test:" << std::endl;
// std::cout << " Input: ";
// std::cout << " Parent: " << cases[i].parent
// << " Child: " << cases[i].child
// << " Result: " << cases[i].result << std::endl;
// std::cout << " Write: ";
// std::cout << " Parent: " << style_parent.write( SP_STYLE_FLAG_IFSET )
// << " Child: " << style_child.write( SP_STYLE_FLAG_IFSET )
// << " Result: " << style_result.write( SP_STYLE_FLAG_IFSET ) << std::endl;
// std::cout << "End Test: *************\n" << std::endl;
}
}
};
#endif // SEEN_STYLE_TEST_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :