From 2abe0bb681044d972e171189395a2afdbc39bf28 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 15 Aug 2017 22:39:32 +0200 Subject: Fix inverted y sign for glyph positioning This is causing vertical glyph positioning to move in the wrong direction e.g. marks go below base glyph instead of above. Seems to be a regression introduced in: commit 83dac189ff21c59be9b4f912e0d0e9690e710a4d Author: Tavmjong Bah Date: Tue Nov 3 13:19:36 2015 +0100 Rearrange code to make handling of baseline clearer. (bzr r14430.1.3) --- testfiles/rendering_tests/CMakeLists.txt | 1 + .../expected_rendering/test-glyph-y-pos-large.png | Bin 0 -> 73316 bytes .../expected_rendering/test-glyph-y-pos.png | Bin 0 -> 13723 bytes testfiles/rendering_tests/test-glyph-y-pos.svg | 26 +++++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png create mode 100644 testfiles/rendering_tests/test-glyph-y-pos.svg (limited to 'testfiles') diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt index 3f838628a..739f9789d 100644 --- a/testfiles/rendering_tests/CMakeLists.txt +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -2,6 +2,7 @@ #add your test here (do not put the .svg extension) set(RENDERING_TESTS test-empty + test-glyph-y-pos ) diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png new file mode 100644 index 000000000..0bd76e68e Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png new file mode 100644 index 000000000..27833a1bb Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png differ diff --git a/testfiles/rendering_tests/test-glyph-y-pos.svg b/testfiles/rendering_tests/test-glyph-y-pos.svg new file mode 100644 index 000000000..28200c79b --- /dev/null +++ b/testfiles/rendering_tests/test-glyph-y-pos.svg @@ -0,0 +1,26 @@ + + + + + + + G̃g̃X̃x̃ + G̃g̃X̃x̃ + G̃g̃X̃x̃ + + + Composed Glyphs + + -- cgit v1.2.3 From f7e6b3725686becd2b8d034cc572417e5a272cba Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 15 Aug 2017 22:41:53 +0200 Subject: Fix RTL glyph widths in vertical orientation The vertical branch seems to be broken, removing it makes RTL text in vertical orientation work again. --- testfiles/rendering_tests/CMakeLists.txt | 1 + .../expected_rendering/test-rtl-vertical-large.png | Bin 0 -> 50034 bytes .../expected_rendering/test-rtl-vertical.png | Bin 0 -> 8677 bytes testfiles/rendering_tests/test-rtl-vertical.svg | 25 +++++++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png create mode 100644 testfiles/rendering_tests/test-rtl-vertical.svg (limited to 'testfiles') diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt index 739f9789d..8b77927a0 100644 --- a/testfiles/rendering_tests/CMakeLists.txt +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -3,6 +3,7 @@ set(RENDERING_TESTS test-empty test-glyph-y-pos + test-rtl-vertical ) diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png new file mode 100644 index 000000000..a96c2bfdb Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png new file mode 100644 index 000000000..3dccfca78 Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png differ diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg new file mode 100644 index 000000000..feb454ed6 --- /dev/null +++ b/testfiles/rendering_tests/test-rtl-vertical.svg @@ -0,0 +1,25 @@ + + + + + + + أبجد + أبجد + + + RTL text in vertical mode + + -- cgit v1.2.3 From b0e00d7b7fd82a4c4abcd28b467fd83ed6ee6164 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 18 Aug 2017 00:45:37 +0200 Subject: Fix vertical RTL text with upright orientation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When orientation is upright we don’t want Pango to use the natural gravity of the text (that would be the mixed orientation). This also changes the positioning of combining marks in such case. It is still wrong, however, but it matches Pango output now. --- .../expected_rendering/test-glyph-y-pos-large.png | Bin 73316 -> 73451 bytes .../expected_rendering/test-glyph-y-pos.png | Bin 13723 -> 13746 bytes .../expected_rendering/test-rtl-vertical-large.png | Bin 50034 -> 55017 bytes .../expected_rendering/test-rtl-vertical.png | Bin 8677 -> 9995 bytes testfiles/rendering_tests/test-rtl-vertical.svg | 1 + 5 files changed, 1 insertion(+) (limited to 'testfiles') diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png index 0bd76e68e..0720e797c 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png index 27833a1bb..4104e6560 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png index a96c2bfdb..3d8eba4ea 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png index 3dccfca78..44676e4d9 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png differ diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg index feb454ed6..e17b94d39 100644 --- a/testfiles/rendering_tests/test-rtl-vertical.svg +++ b/testfiles/rendering_tests/test-rtl-vertical.svg @@ -18,6 +18,7 @@ أبجد أبجد + أبجد RTL text in vertical mode -- cgit v1.2.3 From 42c84a546461fd30d838124870c705476cfbd693 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 20 Sep 2017 14:44:00 +0200 Subject: Update expected renderings. --- .../expected_rendering/test-glyph-y-pos-large.png | Bin 73451 -> 72482 bytes .../expected_rendering/test-glyph-y-pos.png | Bin 13746 -> 13500 bytes 2 files changed, 0 insertions(+), 0 deletions(-) (limited to 'testfiles') diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png index 0720e797c..756dc2c47 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png index 4104e6560..f4a8069be 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png differ -- cgit v1.2.3 From 66eb773e415c972774da3262d0cc00fae37a64db Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 25 Sep 2017 12:48:59 +0200 Subject: Minor code cleanup and better handling of non-spacing marks in upright vertical text. --- .../expected_rendering/test-glyph-y-pos-large.png | Bin 72482 -> 72842 bytes .../expected_rendering/test-glyph-y-pos.png | Bin 13500 -> 13506 bytes 2 files changed, 0 insertions(+), 0 deletions(-) (limited to 'testfiles') diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png index 756dc2c47..e60f4772d 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png index f4a8069be..85a3050a8 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png differ -- cgit v1.2.3 From f3b7c2a55feb6f11fb724e682185dfe27e2ae6d6 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Thu, 28 Sep 2017 21:05:47 +0200 Subject: Tests: Fix problematic rendering test Renderin was different between 32-bit and 64-bit builds of Inkscape, likely due to rounding issues, see https://gitlab.com/inkscape/inkscape/merge_requests/71#note_40940240) --- .../expected_rendering/test-rtl-vertical-large.png | Bin 55017 -> 54382 bytes .../expected_rendering/test-rtl-vertical.png | Bin 9995 -> 9856 bytes testfiles/rendering_tests/test-rtl-vertical.svg | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) (limited to 'testfiles') diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png index 3d8eba4ea..84abe78ff 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png index 44676e4d9..ea8836f51 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png differ diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg index e17b94d39..a959c1880 100644 --- a/testfiles/rendering_tests/test-rtl-vertical.svg +++ b/testfiles/rendering_tests/test-rtl-vertical.svg @@ -17,7 +17,7 @@ أبجد - أبجد + بجد أبجد -- cgit v1.2.3 From 2b1f55d53447df339c09a693afd6a1c7adf402ba Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 11 Oct 2017 17:52:17 +0200 Subject: Add test file for previous commit (!important rule). --- testfiles/rendering_tests/CMakeLists.txt | 1 + .../selector-important-002-large.png | Bin 0 -> 11306 bytes .../expected_rendering/selector-important-002.png | Bin 0 -> 921 bytes .../rendering_tests/selector-important-002.svg | 58 +++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 testfiles/rendering_tests/expected_rendering/selector-important-002-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/selector-important-002.png create mode 100644 testfiles/rendering_tests/selector-important-002.svg (limited to 'testfiles') diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt index 8b77927a0..361ab45a4 100644 --- a/testfiles/rendering_tests/CMakeLists.txt +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -4,6 +4,7 @@ set(RENDERING_TESTS test-empty test-glyph-y-pos test-rtl-vertical + selector-important-002 ) diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-002-large.png b/testfiles/rendering_tests/expected_rendering/selector-important-002-large.png new file mode 100644 index 000000000..e92eef0a4 Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/selector-important-002-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-002.png b/testfiles/rendering_tests/expected_rendering/selector-important-002.png new file mode 100644 index 000000000..b0af9bd12 Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/selector-important-002.png differ diff --git a/testfiles/rendering_tests/selector-important-002.svg b/testfiles/rendering_tests/selector-important-002.svg new file mode 100644 index 000000000..e5a66b68e --- /dev/null +++ b/testfiles/rendering_tests/selector-important-002.svg @@ -0,0 +1,58 @@ + + + Style "!important" — 002 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From b50500c7c14ab8ba6b06bf264ea3cd2dca12fa65 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 13 Oct 2017 10:54:58 +0200 Subject: Migrate style-test to GTest. --- testfiles/CMakeLists.txt | 3 +- testfiles/src/cxxtests-to-migrate/style-test.h | 537 ------------------------ testfiles/src/style-test.cpp | 555 +++++++++++++++++++++++++ 3 files changed, 557 insertions(+), 538 deletions(-) delete mode 100644 testfiles/src/cxxtests-to-migrate/style-test.h create mode 100644 testfiles/src/style-test.cpp (limited to 'testfiles') diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index e7198a39f..554ab8fda 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -14,7 +14,8 @@ set(TEST_SOURCES color-profile-test dir-util-test sp-object-test - object-set-test) + object-set-test + style-test) set(TEST_LIBS gmock_main diff --git a/testfiles/src/cxxtests-to-migrate/style-test.h b/testfiles/src/cxxtests-to-migrate/style-test.h deleted file mode 100644 index c6bb665e0..000000000 --- a/testfiles/src/cxxtests-to-migrate/style-test.h +++ /dev/null @@ -1,537 +0,0 @@ -#ifndef SEEN_STYLE_TEST_H -#define SEEN_STYLE_TEST_H - -#include - -#include "test-helpers.h" - -#include "style.h" - -class StyleTest : public CxxTest::TestSuite -{ -public: - SPDocument* _doc; - - StyleTest() : - _doc(0) - { - } - - virtual ~StyleTest() - { - if ( _doc ) - { - _doc->doUnref(); - _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( createSuiteSubclass ); - return suite; - } - - static void destroySuite( StyleTest *suite ) - { - delete 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) {} - 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"), - // TODO - fix this to preserve the string - 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:#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)", 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:hidden"), // SPIEnum - TestCase("visibility:collapse"), - TestCase("visibility:visible"), - TestCase("display:none"), // SPIEnum - TestCase("overflow:visible"), // SPIEnum - TestCase("overflow:auto"), // SPIEnum - - TestCase("color:#ff0000"), - TestCase("color:blue", "color:#0000ff"), - // 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:sans-serif"), // SPIString, text_private - 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-family:Georgia, 'Minion Web'","font-family:Georgia, \'Minion Web\'"), - TestCase("font-size:12", "font-size:12px"), // SPIFontSize - TestCase("font-size:12px"), - TestCase("font-size:12pt", "font-size:16px"), - TestCase("font-size:medium"), - TestCase("font-size:smaller"), - TestCase("font-style:italic"), // SPIEnum - TestCase("font-variant:small-caps"), // SPIEnum - TestCase("font-weight:100"), // SPIEnum - TestCase("font-weight:normal"), - TestCase("font-weight:bolder"), - TestCase("font-stretch:condensed"), // SPIEnum - - TestCase("font-variant-ligatures:none"), // SPILigatures - 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:common-ligatures", "font-variant-ligatures:normal"), - TestCase("font-variant-ligatures:contextual", "font-variant-ligatures:normal"), - 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 - TestCase("text-indent:12em"), // SPILength? - TestCase("text-align:center"), // SPIEnum - - // 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:24px"), // SPILengthOrNormal - TestCase("line-height:1.5"), - TestCase("letter-spacing:2px"), // SPILengthOrNormal - TestCase("word-spacing:2px"), // SPILengthOrNormal - TestCase("word-spacing:normal"), - TestCase("text-transform:lowercase"), // SPIEnum - // ... - TestCase("baseline-shift:baseline"), // SPIBaselineShift - TestCase("baseline-shift:sub"), - TestCase("baseline-shift:12.5%"), - TestCase("baseline-shift:2px"), - - TestCase("opacity:0.1"), // SPIScale24 - // ... - TestCase("stroke-width:2px"), // SPILength - TestCase("stroke-linecap:round"), // SPIEnum - TestCase("stroke-linejoin:round"), // SPIEnum - TestCase("stroke-miterlimit:4"), // SPIFloat - TestCase("marker:url(#Arrow)"), // SPIString - TestCase("marker-start:url(#Arrow)"), - TestCase("marker-mid:url(#Arrow)"), - TestCase("marker-end:url(#Arrow)"), - TestCase("stroke-opacity:0.5"), // SPIScale24 - TestCase("stroke-dasharray:0, 1, 0, 1"), // SPIDashArray - TestCase("stroke-dasharray:0 1 0 1","stroke-dasharray:0, 1, 0, 1"), - TestCase("stroke-dasharray:0 1 2 3","stroke-dasharray:0, 1, 2, 3"), - TestCase("stroke-dashoffset:13"), // SPILength - 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:stroke"), // SPIPaintOrder - TestCase("paint-order:normal"), - TestCase("paint-order: markers stroke fill", "paint-order:markers stroke fill"), - -#endif - TestCase(0) - }; - - for ( gint i = 0; cases[i].src; i++ ) { - // std::cout << "Test one: " << i << std::endl; - SPStyle style(_doc); - style.mergeString( cases[i].src ); - if ( cases[i].uri ) { - 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 || !style.fill.value.href->getObject() ); - } - - std::string str0_set = style.write(SP_STYLE_FLAG_IFSET ); - - if ( cases[i].dst ) { - // std::cout << " " << str0_set << " " << std::string(cases[i].dst) << std::endl; - TS_ASSERT_EQUALS( str0_set, std::string(cases[i].dst) ); - } else { - // std::cout << " " << str0_set << " " << std::string(cases[i].src) << std::endl; - TS_ASSERT_EQUALS( str0_set, std::string(cases[i].src) ); - } - } - } - - // Testing operator== - void testTwo() - { - struct TestCase { - TestCase(gchar const* src, gchar const* dst, bool match) : - src(src), dst(dst), match(match) {} - gchar const* src; - gchar const* dst; - bool match; - }; - - TestCase cases[] = { - - // SPIFloat - TestCase("stroke-miterlimit:4", "stroke-miterlimit:4", true ), - TestCase("stroke-miterlimit:4", "stroke-miterlimit:2", false), - TestCase("stroke-miterlimit:4", "", true ), // Default - - // SPIScale24 - TestCase("opacity:0.3", "opacity:0.3", true ), - TestCase("opacity:0.3", "opacity:0.6", false), - TestCase("opacity:1.0", "", true ), // Default - - // SPILength - TestCase("text-indent:3", "text-indent:3", true ), - TestCase("text-indent:6", "text-indent:3", false), - TestCase("text-indent:6px", "text-indent:3", false), - TestCase("text-indent:1px", "text-indent:12pc", false), - TestCase("text-indent:2ex", "text-indent:2ex", false), - - // SPILengthOrNormal - TestCase("letter-spacing:normal", "letter-spacing:normal", true ), - TestCase("letter-spacing:2", "letter-spacing:normal", false), - TestCase("letter-spacing:normal", "letter-spacing:2", false), - TestCase("letter-spacing:5px", "letter-spacing:5px", true ), - TestCase("letter-spacing:10px", "letter-spacing:5px", false), - TestCase("letter-spacing:10em", "letter-spacing:10em", false), - - // SPIEnum - TestCase("text-anchor:start", "text-anchor:start", true ), - TestCase("text-anchor:start", "text-anchor:middle", false), - TestCase("text-anchor:start", "", true ), // Default - TestCase("text-anchor:start", "text-anchor:junk", true ), // Bad value - - TestCase("font-weight:normal", "font-weight:400", true ), - TestCase("font-weight:bold", "font-weight:700", true ), - - - // SPIString and SPIFontString - TestCase("font-family:Arial", "font-family:Arial", true ), - TestCase("font-family:A B", "font-family:A B", true ), - TestCase("font-family:A B", "font-family:A C", false), - // Default is not set by class... value is NULL which cannot be compared - // TestCase("font-family:sans-serif", "", true ), // Default - - // SPIColor - TestCase("color:blue", "color:blue", true ), - TestCase("color:blue", "color:red", false), - TestCase("color:red", "color:#ff0000", true ), - - // SPIPaint - TestCase("fill:blue", "fill:blue", true ), - TestCase("fill:blue", "fill:red", false), - TestCase("fill:currentColor", "fill:currentColor", true ), - TestCase("fill:url(#xxx)", "fill:url(#xxx)", true ), - // Needs URL defined as in test 1 - //TestCase("fill:url(#xxx)", "fill:url(#yyy)", false), - - // SPIPaintOrder - TestCase("paint-order:markers", "paint-order:markers", true ), - TestCase("paint-order:markers", "paint-order:stroke", false), - //TestCase("paint-order:fill stroke markers", "", true ), // Default - TestCase("paint-order:normal", "paint-order:normal", true ), - //TestCase("paint-order:fill stroke markers", "paint-order:normal", true ), - - // SPIDashArray - TestCase("stroke-dasharray:0 1 2 3","stroke-dasharray:0 1 2 3",true ), - TestCase("stroke-dasharray:0 1", "stroke-dasharray:0 2", false), - - // SPIFilter - - // SPIFontSize - TestCase("font-size:12px", "font-size:12px", true ), - TestCase("font-size:12px", "font-size:24px", false), - TestCase("font-size:12ex", "font-size:24ex", false), - TestCase("font-size:medium", "font-size:medium", true ), - TestCase("font-size:medium", "font-size:large", false), - - // SPIBaselineShift - TestCase("baseline-shift:baseline", "baseline-shift:baseline", true ), - TestCase("baseline-shift:sub", "baseline-shift:sub", true ), - TestCase("baseline-shift:sub", "baseline-shift:super", false), - TestCase("baseline-shift:baseline", "baseline-shift:sub", false), - TestCase("baseline-shift:10px", "baseline-shift:10px", true ), - TestCase("baseline-shift:10px", "baseline-shift:12px", false), - - - // SPITextDecorationLine - TestCase("text-decoration-line:underline", "text-decoration-line:underline", true ), - TestCase("text-decoration-line:underline", "text-decoration-line:overline", false), - TestCase("text-decoration-line:underline overline", "text-decoration-line:underline overline", true ), - TestCase("text-decoration-line:none", "", true ), // Default - - - // SPITextDecorationStyle - TestCase("text-decoration-style:solid", "text-decoration-style:solid", true ), - TestCase("text-decoration-style:dotted", "text-decoration-style:solid", false), - TestCase("text-decoration-style:solid", "", true ), // Default - - // SPITextDecoration - TestCase("text-decoration:underline", "text-decoration:underline", true ), - TestCase("text-decoration:underline", "text-decoration:overline", false), - TestCase("text-decoration:underline overline","text-decoration:underline overline",true ), - TestCase("text-decoration:overline underline","text-decoration:underline overline",true ), - // TestCase("text-decoration:none", "text-decoration-color:currentColor", true ), // Default - - - // Terminate - TestCase(0,0,0) - }; - for ( gint i = 0; cases[i].src; i++ ) { - // std::cout << "Test two: " << i << std::endl; - SPStyle style_src(_doc); - SPStyle style_dst(_doc); - - style_src.mergeString( cases[i].src ); - style_dst.mergeString( cases[i].dst ); - - // 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 ) << "|" < + * + * Copyright (C) 2017 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include + +#include "gtest/gtest.h" + +#include "style.h" + +namespace { + +class StyleRead { + +public: + StyleRead(std::string const &src, std::string const &dst, std::string const &uri) : + src(src), dst(dst), uri(uri) + { + } + + StyleRead(std::string const &src, std::string const &dst) : + src(src), dst(dst), uri("") + { + } + + StyleRead(std::string const &src) : + src(src), dst(src), uri("") + { + } + + std::string src; + std::string dst; + std::string uri; + +}; + +std::vector getStyleData() +{ + StyleRead all_style_data[] = { + + // Paint ----------------------------------------------- + StyleRead("fill:none" ), + StyleRead("fill:currentColor" ), + StyleRead("fill:#ff00ff" ), + StyleRead("fill:rgb(100%, 0%, 100%)", "fill:#ff00ff" ), + StyleRead("fill:rgb(255, 0, 255)", "fill:#ff00ff" ), + + // TODO - fix this to preserve the string + // StyleRead("fill:url(#painter) rgb(100%, 0%, 100%)", + // "fill:url(#painter) #ff00ff", "#painter" ), + + // TODO - fix this to preserve the string + //StyleRead("fill:url(#painter) rgb(255, 0, 255)", + // "fill:url(#painter) #ff00ff", "#painter"), + + +// StyleRead("fill:#ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)"), + +// StyleRead("fill:url(#painter)", "", "#painter"), +// StyleRead("fill:url(#painter) none", "", "#painter"), +// StyleRead("fill:url(#painter) currentColor", "", "#painter"), +// StyleRead("fill:url(#painter) #ff00ff", "", "#painter"), +// StyleRead("fill:url(#painter) rgb(100%, 0%, 100%)", "", "#painter"), +// StyleRead("fill:url(#painter) rgb(255, 0, 255)", "", "#painter"), + +// StyleRead("fill:url(#painter) #ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)", "", "#painter"), + +// StyleRead("fill:url(#painter) inherit", "", "#painter"), + + StyleRead("fill:inherit"), + + + // General tests (in general order of appearance in sp_style_read), SPIPaint tested above + StyleRead("visibility:hidden"), // SPIEnum + StyleRead("visibility:collapse"), + StyleRead("visibility:visible"), + StyleRead("display:none"), // SPIEnum + StyleRead("overflow:visible"), // SPIEnum + StyleRead("overflow:auto"), // SPIEnum + + StyleRead("color:#ff0000"), + StyleRead("color:blue", "color:#0000ff"), + // StyleRead("color:currentColor"), SVG 1.1 does not allow color value 'currentColor' + + // Font shorthand + StyleRead("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"), + StyleRead("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): + StyleRead("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"), + //StyleRead("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"), + //StyleRead("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"), + StyleRead("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"), + //StyleRead("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"), + StyleRead("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"), + + StyleRead("font-family:sans-serif"), // SPIString, text_private + StyleRead("font-family:Arial"), + // StyleRead("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): + StyleRead("font-family:Georgia, 'Minion Web'","font-family:Georgia, \'Minion Web\'"), + StyleRead("font-size:12", "font-size:12px"), // SPIFontSize + StyleRead("font-size:12px"), + StyleRead("font-size:12pt", "font-size:16px"), + StyleRead("font-size:medium"), + StyleRead("font-size:smaller"), + StyleRead("font-style:italic"), // SPIEnum + StyleRead("font-variant:small-caps"), // SPIEnum + StyleRead("font-weight:100"), // SPIEnum + StyleRead("font-weight:normal"), + StyleRead("font-weight:bolder"), + StyleRead("font-stretch:condensed"), // SPIEnum + + StyleRead("font-variant-ligatures:none"), // SPILigatures + StyleRead("font-variant-ligatures:normal"), + StyleRead("font-variant-ligatures:no-common-ligatures"), + StyleRead("font-variant-ligatures:discretionary-ligatures"), + StyleRead("font-variant-ligatures:historical-ligatures"), + StyleRead("font-variant-ligatures:no-contextual"), + StyleRead("font-variant-ligatures:common-ligatures", "font-variant-ligatures:normal"), + StyleRead("font-variant-ligatures:contextual", "font-variant-ligatures:normal"), + StyleRead("font-variant-ligatures:no-common-ligatures historical-ligatures"), + StyleRead("font-variant-ligatures:historical-ligatures no-contextual"), + StyleRead("font-variant-position:normal"), + StyleRead("font-variant-position:sub"), + StyleRead("font-variant-position:super"), + StyleRead("font-variant-caps:normal"), + StyleRead("font-variant-caps:small-caps"), + StyleRead("font-variant-caps:all-small-caps"), + StyleRead("font-variant-numeric:normal"), + StyleRead("font-variant-numeric:lining-nums"), + StyleRead("font-variant-numeric:oldstyle-nums"), + StyleRead("font-variant-numeric:proportional-nums"), + StyleRead("font-variant-numeric:tabular-nums"), + StyleRead("font-variant-numeric:diagonal-fractions"), + StyleRead("font-variant-numeric:stacked-fractions"), + StyleRead("font-variant-numeric:ordinal"), + StyleRead("font-variant-numeric:slashed-zero"), + StyleRead("font-variant-numeric:tabular-nums slashed-zero"), + StyleRead("font-variant-numeric:tabular-nums proportional-nums", "font-variant-numeric:proportional-nums"), + + // Should be moved down + StyleRead("text-indent:12em"), // SPILength? + StyleRead("text-align:center"), // SPIEnum + + // 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.) + // StyleRead("text-decoration: underline", + // "text-decoration: underline;text-decoration-line: underline;text-decoration-color:currentColor"), + // StyleRead("text-decoration: overline underline", + // "text-decoration: underline overline;text-decoration-line: underline overline;text-decoration-color:currentColor"), + + StyleRead("text-decoration: underline wavy #0000ff", + "text-decoration: underline;text-decoration-line: underline;text-decoration-style:wavy;text-decoration-color:#0000ff"), + StyleRead("text-decoration: double overline underline #ff0000", + "text-decoration: underline overline;text-decoration-line: underline overline;text-decoration-style:double;text-decoration-color:#ff0000"), + + // SPITextDecorationLine + StyleRead("text-decoration-line: underline", + "text-decoration: underline;text-decoration-line: underline"), + + // SPITextDecorationStyle + StyleRead("text-decoration-style:solid"), + StyleRead("text-decoration-style:dotted"), + + // SPITextDecorationColor + StyleRead("text-decoration-color:#ff00ff"), + + // Should be moved up + StyleRead("line-height:24px"), // SPILengthOrNormal + StyleRead("line-height:1.5"), + StyleRead("letter-spacing:2px"), // SPILengthOrNormal + StyleRead("word-spacing:2px"), // SPILengthOrNormal + StyleRead("word-spacing:normal"), + StyleRead("text-transform:lowercase"), // SPIEnum + // ... + StyleRead("baseline-shift:baseline"), // SPIBaselineShift + StyleRead("baseline-shift:sub"), + StyleRead("baseline-shift:12.5%"), + StyleRead("baseline-shift:2px"), + + StyleRead("opacity:0.1"), // SPIScale24 + // ... + StyleRead("stroke-width:2px"), // SPILength + StyleRead("stroke-linecap:round"), // SPIEnum + StyleRead("stroke-linejoin:round"), // SPIEnum + StyleRead("stroke-miterlimit:4"), // SPIFloat + StyleRead("marker:url(#Arrow)"), // SPIString + StyleRead("marker-start:url(#Arrow)"), + StyleRead("marker-mid:url(#Arrow)"), + StyleRead("marker-end:url(#Arrow)"), + StyleRead("stroke-opacity:0.5"), // SPIScale24 + StyleRead("stroke-dasharray:0, 1, 0, 1"), // SPIDashArray + StyleRead("stroke-dasharray:0 1 0 1","stroke-dasharray:0, 1, 0, 1"), + StyleRead("stroke-dasharray:0 1 2 3","stroke-dasharray:0, 1, 2, 3"), + StyleRead("stroke-dashoffset:13"), // SPILength + StyleRead("stroke-dashoffset:10px"), + // ... + //StyleRead("filter:url(#myfilter)"), // SPIFilter segfault in read + StyleRead("filter:inherit"), + + StyleRead("opacity:0.1;fill:#ff0000;stroke:#0000ff;stroke-width:2px"), + StyleRead("opacity:0.1;fill:#ff0000;stroke:#0000ff;stroke-width:2px;stroke-dasharray:1, 2, 3, 4;stroke-dashoffset:15"), + + StyleRead("paint-order:stroke"), // SPIPaintOrder + StyleRead("paint-order:normal"), + StyleRead("paint-order: markers stroke fill", "paint-order:markers stroke fill"), + + }; + + size_t count = sizeof(all_style_data) / sizeof(all_style_data[0]); + std::vector vect(all_style_data, all_style_data + count); + return vect; +} + +TEST(StyleTest, Read) { + std::vector all_style = getStyleData(); + EXPECT_GT(all_style.size(), 0); + for (auto i : all_style) { + + SPStyle style; + style.mergeString (i.src.c_str()); + + if (!i.uri.empty()) { + //EXPECT_EQ (style.fill.value.href->getURI()->toString(), i.uri); + } + + std::string out = style.write(); + if (i.dst.empty()) { + // std::cout << "out: " << out << std::endl; + // std::cout << "i.src: " << i.src << std::endl; + EXPECT_EQ (out, i.src); + } else { + // std::cout << "out: " << out << std::endl; + // std::cout << "i.dst: " << i.dst << std::endl; + EXPECT_EQ (out, i.dst); + } + } +} + + +// ------------------------------------------------------------------------------------ + +class StyleMatch { + +public: + StyleMatch(std::string const &src, std::string const &dst, bool const &match) : + src(src), dst(dst), match(match) + { + } + + std::string src; + std::string dst; + bool match; + +}; + +std::vector getStyleMatchData() +{ + StyleMatch all_style_data[] = { + + // SPIFloat + StyleMatch("stroke-miterlimit:4", "stroke-miterlimit:4", true ), + StyleMatch("stroke-miterlimit:4", "stroke-miterlimit:2", false), + StyleMatch("stroke-miterlimit:4", "", true ), // Default + + // SPIScale24 + StyleMatch("opacity:0.3", "opacity:0.3", true ), + StyleMatch("opacity:0.3", "opacity:0.6", false), + StyleMatch("opacity:1.0", "", true ), // Default + + // SPILength + StyleMatch("text-indent:3", "text-indent:3", true ), + StyleMatch("text-indent:6", "text-indent:3", false), + StyleMatch("text-indent:6px", "text-indent:3", false), + StyleMatch("text-indent:1px", "text-indent:12pc", false), + StyleMatch("text-indent:2ex", "text-indent:2ex", false), + + // SPILengthOrNormal + StyleMatch("letter-spacing:normal", "letter-spacing:normal", true ), + StyleMatch("letter-spacing:2", "letter-spacing:normal", false), + StyleMatch("letter-spacing:normal", "letter-spacing:2", false), + StyleMatch("letter-spacing:5px", "letter-spacing:5px", true ), + StyleMatch("letter-spacing:10px", "letter-spacing:5px", false), + StyleMatch("letter-spacing:10em", "letter-spacing:10em", false), + + // SPIEnum + StyleMatch("text-anchor:start", "text-anchor:start", true ), + StyleMatch("text-anchor:start", "text-anchor:middle", false), + StyleMatch("text-anchor:start", "", true ), // Default + StyleMatch("text-anchor:start", "text-anchor:junk", true ), // Bad value + + StyleMatch("font-weight:normal", "font-weight:400", true ), + StyleMatch("font-weight:bold", "font-weight:700", true ), + + + // SPIString and SPIFontString + StyleMatch("font-family:Arial", "font-family:Arial", true ), + StyleMatch("font-family:A B", "font-family:A B", true ), + StyleMatch("font-family:A B", "font-family:A C", false), + // Default is not set by class... value is NULL which cannot be compared + // StyleMatch("font-family:sans-serif", "", true ), // Default + + // SPIColor + StyleMatch("color:blue", "color:blue", true ), + StyleMatch("color:blue", "color:red", false), + StyleMatch("color:red", "color:#ff0000", true ), + + // SPIPaint + StyleMatch("fill:blue", "fill:blue", true ), + StyleMatch("fill:blue", "fill:red", false), + StyleMatch("fill:currentColor", "fill:currentColor", true ), + StyleMatch("fill:url(#xxx)", "fill:url(#xxx)", true ), + // Needs URL defined as in test 1 + //StyleMatch("fill:url(#xxx)", "fill:url(#yyy)", false), + + // SPIPaintOrder + StyleMatch("paint-order:markers", "paint-order:markers", true ), + StyleMatch("paint-order:markers", "paint-order:stroke", false), + //StyleMatch("paint-order:fill stroke markers", "", true ), // Default + StyleMatch("paint-order:normal", "paint-order:normal", true ), + //StyleMatch("paint-order:fill stroke markers", "paint-order:normal", true ), + + // SPIDashArray + StyleMatch("stroke-dasharray:0 1 2 3","stroke-dasharray:0 1 2 3",true ), + StyleMatch("stroke-dasharray:0 1", "stroke-dasharray:0 2", false), + + // SPIFilter + + // SPIFontSize + StyleMatch("font-size:12px", "font-size:12px", true ), + StyleMatch("font-size:12px", "font-size:24px", false), + StyleMatch("font-size:12ex", "font-size:24ex", false), + StyleMatch("font-size:medium", "font-size:medium", true ), + StyleMatch("font-size:medium", "font-size:large", false), + + // SPIBaselineShift + StyleMatch("baseline-shift:baseline", "baseline-shift:baseline", true ), + StyleMatch("baseline-shift:sub", "baseline-shift:sub", true ), + StyleMatch("baseline-shift:sub", "baseline-shift:super", false), + StyleMatch("baseline-shift:baseline", "baseline-shift:sub", false), + StyleMatch("baseline-shift:10px", "baseline-shift:10px", true ), + StyleMatch("baseline-shift:10px", "baseline-shift:12px", false), + + + // SPITextDecorationLine + StyleMatch("text-decoration-line:underline", "text-decoration-line:underline", true ), + StyleMatch("text-decoration-line:underline", "text-decoration-line:overline", false), + StyleMatch("text-decoration-line:underline overline", "text-decoration-line:underline overline", true ), + StyleMatch("text-decoration-line:none", "", true ), // Default + + + // SPITextDecorationStyle + StyleMatch("text-decoration-style:solid", "text-decoration-style:solid", true ), + StyleMatch("text-decoration-style:dotted", "text-decoration-style:solid", false), + StyleMatch("text-decoration-style:solid", "", true ), // Default + + // SPITextDecoration + StyleMatch("text-decoration:underline", "text-decoration:underline", true ), + StyleMatch("text-decoration:underline", "text-decoration:overline", false), + StyleMatch("text-decoration:underline overline","text-decoration:underline overline",true ), + StyleMatch("text-decoration:overline underline","text-decoration:underline overline",true ), + // StyleMatch("text-decoration:none", "text-decoration-color:currentColor", true ), // Default + + }; + + size_t count = sizeof(all_style_data) / sizeof(all_style_data[0]); + std::vector vect(all_style_data, all_style_data + count); + return vect; +} + +TEST(StyleTest, Match) { + std::vector all_style = getStyleMatchData(); + EXPECT_GT(all_style.size(), 0); + for (auto i : all_style) { + + SPStyle style_src; + SPStyle style_dst; + + style_src.mergeString( i.src.c_str() ); + style_dst.mergeString( i.dst.c_str() ); + + // std::cout << "Test:" << std::endl; + // std::cout << " C: |" << i.src + // << "| |" << i.dst << "|" << std::endl; + // std::cout << " S: |" << style_src.write( SP_STYLE_FLAG_IFSET ) + // << "| |" << style_dst.write( SP_STYLE_FLAG_IFSET ) << "|" < getStyleCascadeData() +{ + + StyleCascade all_style_data[] = { + + // SPIFloat + StyleCascade("stroke-miterlimit:6", "stroke-miterlimit:2", "stroke-miterlimit:2" ), + StyleCascade("stroke-miterlimit:6", "", "stroke-miterlimit:6" ), + StyleCascade("", "stroke-miterlimit:2", "stroke-miterlimit:2" ), + + // SPIScale24 + StyleCascade("opacity:0.3", "opacity:0.3", "opacity:0.3" ), + StyleCascade("opacity:0.3", "opacity:0.6", "opacity:0.6" ), + // 'opacity' does not inherit + StyleCascade("opacity:0.3", "", "opacity:1.0" ), + StyleCascade("", "opacity:0.3", "opacity:0.3" ), + StyleCascade("opacity:0.5", "opacity:inherit", "opacity:0.5" ), + StyleCascade("", "", "opacity:1.0" ), + + // SPILength + StyleCascade("text-indent:3", "text-indent:3", "text-indent:3" ), + StyleCascade("text-indent:6", "text-indent:3", "text-indent:3" ), + StyleCascade("text-indent:6px", "text-indent:3", "text-indent:3" ), + StyleCascade("text-indent:1px", "text-indent:12pc", "text-indent:12pc" ), + // ex, em cannot be equal + //StyleCascade("text-indent:2ex", "text-indent:2ex", "text-indent:2ex" ), + StyleCascade("text-indent:3", "", "text-indent:3" ), + StyleCascade("text-indent:3", "text-indent:inherit", "text-indent:3" ), + + // SPILengthOrNormal + StyleCascade("letter-spacing:normal", "letter-spacing:normal", "letter-spacing:normal" ), + StyleCascade("letter-spacing:2", "letter-spacing:normal", "letter-spacing:normal" ), + StyleCascade("letter-spacing:normal", "letter-spacing:2", "letter-spacing:2" ), + StyleCascade("letter-spacing:5px", "letter-spacing:5px", "letter-spacing:5px" ), + StyleCascade("letter-spacing:10px", "letter-spacing:5px", "letter-spacing:5px" ), + // ex, em cannot be equal + // StyleCascade("letter-spacing:10em", "letter-spacing:10em", "letter-spacing:10em" ), + + // SPIEnum + StyleCascade("text-anchor:start", "text-anchor:start", "text-anchor:start" ), + StyleCascade("text-anchor:start", "text-anchor:middle", "text-anchor:middle" ), + StyleCascade("text-anchor:start", "", "text-anchor:start" ), + StyleCascade("text-anchor:start", "text-anchor:junk", "text-anchor:start" ), + StyleCascade("text-anchor:end", "text-anchor:inherit", "text-anchor:end" ), + + StyleCascade("font-weight:400", "font-weight:400", "font-weight:400" ), + StyleCascade("font-weight:400", "font-weight:700", "font-weight:700" ), + StyleCascade("font-weight:400", "font-weight:bolder", "font-weight:700" ), + StyleCascade("font-weight:700", "font-weight:bolder", "font-weight:900" ), + StyleCascade("font-weight:400", "font-weight:lighter", "font-weight:100" ), + StyleCascade("font-weight:200", "font-weight:lighter", "font-weight:100" ), + + StyleCascade("font-stretch:condensed","font-stretch:expanded", "font-stretch:expanded" ), + StyleCascade("font-stretch:condensed","font-stretch:wider", "font-stretch:semi-condensed" ), + + // SPIString and SPIFontString + + // SPIPaint + + // SPIPaintOrder + + // SPIDashArray + + // SPIFilter + + // SPIFontSize + + // SPIBaselineShift + + + // SPITextDecorationLine + StyleCascade("text-decoration-line:overline", "text-decoration-line:underline", + "text-decoration-line:underline" ), + + // SPITextDecorationStyle + + // SPITextDecoration + }; + + size_t count = sizeof(all_style_data) / sizeof(all_style_data[0]); + std::vector vect(all_style_data, all_style_data + count); + return vect; + +} + +TEST(StyleTest, Cascade) { + std::vector all_style = getStyleCascadeData(); + EXPECT_GT(all_style.size(), 0); + for (auto i : all_style) { + + SPStyle style_parent; + SPStyle style_child; + SPStyle style_result; + + style_parent.mergeString( i.parent.c_str() ); + style_child.mergeString( i.child.c_str() ); + style_result.mergeString( i.result.c_str() ); + + // std::cout << "Test:" << std::endl; + // std::cout << " Input: "; + // std::cout << " Parent: " << i.parent + // << " Child: " << i.child + // << " Result: " << 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; + + style_child.cascade( &style_parent ); + + EXPECT_TRUE(style_child == style_result ); + } +} + + +} // namespace + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 4cc0e04066adecf85955a9d6be972a4ba4d83f8b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 13 Oct 2017 13:05:06 +0200 Subject: Implement !important rule handling for inline-style. Work from Jabier. Added "!important" rule tests to style-test.cpp. --- testfiles/src/style-test.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'testfiles') diff --git a/testfiles/src/style-test.cpp b/testfiles/src/style-test.cpp index 9fd25f31a..8c0f4dd5f 100644 --- a/testfiles/src/style-test.cpp +++ b/testfiles/src/style-test.cpp @@ -226,7 +226,27 @@ std::vector getStyleData() StyleRead("paint-order:normal"), StyleRead("paint-order: markers stroke fill", "paint-order:markers stroke fill"), - }; + // !important (in order of appearance in style-internal.h) + StyleRead("stroke-miterlimit:4 !important"), // SPIFloat + StyleRead("stroke-opacity:0.5 !important"), // SPIScale24 + StyleRead("stroke-width:2px !important"), // SPILength + StyleRead("line-height:24px !important"), // SPILengthOrNormal + StyleRead("line-height:normal !important"), + StyleRead("font-stretch:condensed !important"), // SPIEnum + StyleRead("marker:url(#Arrow) !important"), // SPIString + StyleRead("color:#0000ff !important"), // SPIColor + StyleRead("fill:none !important"), // SPIPaint + StyleRead("fill:currentColor !important"), + StyleRead("fill:#ff00ff !important"), + StyleRead("paint-order:stroke !important"), // SPIPaintOrder + StyleRead("paint-order:normal !important"), + StyleRead("stroke-dasharray:0, 1, 0, 1 !important"), // SPIDashArray + StyleRead("font-size:12px !important"), // SPIFontSize + StyleRead("baseline-shift:baseline !important"), // SPIBaselineShift + StyleRead("baseline-shift:sub !important"), + //StyleRead("text-decoration-line: underline !important"), // SPITextDecorationLine + + }; size_t count = sizeof(all_style_data) / sizeof(all_style_data[0]); std::vector vect(all_style_data, all_style_data + count); -- cgit v1.2.3 From 8fcafa5b89139302eb7cb7433dacfc804ae77d9a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 13 Oct 2017 14:10:03 +0200 Subject: Add test file for previous commit (!important rule for inline-style). --- testfiles/rendering_tests/CMakeLists.txt | 1 + .../selector-important-003-large.png | Bin 0 -> 11308 bytes .../expected_rendering/selector-important-003.png | Bin 0 -> 925 bytes .../rendering_tests/selector-important-003.svg | 57 +++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 testfiles/rendering_tests/expected_rendering/selector-important-003-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/selector-important-003.png create mode 100644 testfiles/rendering_tests/selector-important-003.svg (limited to 'testfiles') diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt index 361ab45a4..8db01d97a 100644 --- a/testfiles/rendering_tests/CMakeLists.txt +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -5,6 +5,7 @@ set(RENDERING_TESTS test-glyph-y-pos test-rtl-vertical selector-important-002 + selector-important-003 ) diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-003-large.png b/testfiles/rendering_tests/expected_rendering/selector-important-003-large.png new file mode 100644 index 000000000..91cb3afa9 Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/selector-important-003-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/selector-important-003.png b/testfiles/rendering_tests/expected_rendering/selector-important-003.png new file mode 100644 index 000000000..dfe3dbc5a Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/selector-important-003.png differ diff --git a/testfiles/rendering_tests/selector-important-003.svg b/testfiles/rendering_tests/selector-important-003.svg new file mode 100644 index 000000000..831319f5c --- /dev/null +++ b/testfiles/rendering_tests/selector-important-003.svg @@ -0,0 +1,57 @@ + + + Style "!important" — 003 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 5c009e15be8446c010a4103a9626653c7819274a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 16 Oct 2017 11:39:26 +0200 Subject: Update properties for SVG 2 text. Partial work from Alex Roman --- testfiles/src/attributes-test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'testfiles') diff --git a/testfiles/src/attributes-test.cpp b/testfiles/src/attributes-test.cpp index f6881fc09..da9a8d592 100644 --- a/testfiles/src/attributes-test.cpp +++ b/testfiles/src/attributes-test.cpp @@ -51,7 +51,7 @@ std::vector getKnownAttrs() attindex.html lacks attributeName, begin, additive, font, marker; I've added these manually. - SVG 2: white-space, shape-inside, shape-outside, shape-padding, shape-margin + SVG 2: white-space, shape-inside, shape-subtrace, shape-padding, shape-margin */ AttributeInfo all_attrs[] = { AttributeInfo("attributeName", true), @@ -174,6 +174,7 @@ std::vector getKnownAttrs() AttributeInfo("image-rendering", true), AttributeInfo("in", true), AttributeInfo("in2", true), + AttributeInfo("inline-size", true), AttributeInfo("intercept", true), AttributeInfo("isolation", true), AttributeInfo("k", true), @@ -274,7 +275,7 @@ std::vector getKnownAttrs() AttributeInfo("seed", true), AttributeInfo("shape-inside", true), AttributeInfo("shape-margin", true), - AttributeInfo("shape-outside", true), + AttributeInfo("shape-subtract", true), AttributeInfo("shape-padding", true), AttributeInfo("shape-rendering", true), AttributeInfo("slope", true), -- cgit v1.2.3 From 15fe5b74c46cbe12da26ef3c5543c5e0bd8d64c1 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 28 Oct 2017 12:32:03 +0200 Subject: Trying libFuzzer --- testfiles/CMakeLists.txt | 8 + testfiles/fuzz-dict | 521 +++++++++++++++++++++++++++++++++++++++++++++++ testfiles/fuzzer.cpp | 15 ++ 3 files changed, 544 insertions(+) create mode 100644 testfiles/fuzz-dict create mode 100644 testfiles/fuzzer.cpp (limited to 'testfiles') diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 554ab8fda..5dba0258b 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -31,3 +31,11 @@ foreach(source ${TEST_SOURCES}) add_dependencies(tests ${source}) endforeach() add_subdirectory(rendering_tests) + +if(WITH_FUZZ) + add_executable(fuzz fuzzer.cpp) + target_link_libraries(fuzz inkscape_base -lFuzzer "-fsanitize=address" + "-fsanitize-coverage=edge,trace-pc-guard,indirect-calls,trace-cmp,trace-div,trace-gep" + "-fno-omit-frame-pointer") + +endif() diff --git a/testfiles/fuzz-dict b/testfiles/fuzz-dict new file mode 100644 index 000000000..7eee0d0a0 --- /dev/null +++ b/testfiles/fuzz-dict @@ -0,0 +1,521 @@ +"100" +"200" +"300" +"400" +"500" +"600" +"700" +"800" +"900" +"a" +"accent-height" +"accumulate" +"additive" +"after-edge" +"alignment-baseline" +"all" +"alphabetic" +"altGlyph" +"altGlyphDef" +"altGlyphItem" +"amplitude" +"animate" +"animateColor" +"animateMotion" +"animateTransform" +"arabic-form" +"ascent" +attr_encoding=" encoding=\"1\"" +attr_generic=" a=\"1\"" +attr_href=" href=\"1\"" +"attributeName" +"attributeType" +attr_standalone=" standalone=\"no\"" +attr_version=" version=\"1\"" +attr_xml_base=" xml:base=\"1\"" +attr_xml_id=" xml:id=\"1\"" +attr_xml_lang=" xml:lang=\"1\"" +attr_xmlns=" xmlns=\"1\"" +attr_xml_space=" xml:space=\"1\"" +"auto" +"azimuth" +"baseFrequency" +"baseline" +"baseline-shift" +"baseProfile" +"bbox" +"before-edge" +"begin" +"bevel" +"bias" +"bidi-override" +"blink" +"block" +"bold" +"bolder" +"butt" +"by" +"calcMode" +"cap-height" +"caption" +"central" +"circle" +"class" +"clip" +"clip-path" +"clipPath" +"clipPathUnits" +"clip-rule" +"collapse" +"color" +"color-interpolation" +"color-interpolation-filters" +"color-profile" +"color-rendering" +"compact" +"condensed" +"contentScriptType" +"contentStyleType" +"crispEdges" +"crosshair" +"currentColor" +"cursor" +"cx" +"cy" +"d" +"default" +"defs" +"desc" +"descent" +"diffuseConstant" +"direction" +"display" +"divisor" +"dominant-baseline" +"dur" +"dx" +"dy" +"edgeMode" +"elevation" +"ellipse" +"embed" +"enable-background" +"end" +entity_builtin="<" +entity_decimal="" +entity_external="&a;" +entity_hex="" +"e-resize" +"evenodd" +"expanded" +"exponent" +"externalResourcesRequired" +"extra-condensed" +"extra-expanded" +"feBlend" +"feColorMatrix" +"feComponentTransfer" +"feComposite" +"feConvolveMatrix" +"feDiffuseLighting" +"feDisplacementMap" +"feDistantLight" +"feFlood" +"feFuncA" +"feFuncB" +"feFuncG" +"feFuncR" +"feGaussianBlur" +"feImage" +"feMerge" +"feMergeNode" +"feMorphology" +"feOffset" +"fePointLight" +"feSpecularLighting" +"feSpotLight" +"feTile" +"feTurbulence" +"fill" +"fill-opacity" +"fill-rule" +"filter" +"filterRes" +"filterUnits" +"flood-color" +"flood-opacity" +"font" +"font-face" +"font-face-format" +"font-face-name" +"font-face-src" +"font-face-uri" +"font-family" +"font-size" +"font-size-adjust" +"font-stretch" +"font-style" +"font-variant" +"font-weight" +"foreignObject" +"format" +"from" +"fx" +"fy" +"g" +"g1" +"g2" +"geometricPrecision" +"glyph" +"glyph-name" +"glyph-orientation-horizontal" +"glyph-orientation-vertical" +"glyphRef" +"gradientTransform" +"gradientUnits" +"hanging" +"height" +"help" +"hidden" +"hkern" +"horiz-adv-x" +"horiz-origin-x" +"horiz-origin-y" +"icon" +"id" +"ideographic" +"image" +"image-rendering" +"in" +"in2" +"individual" +"inherit" +"inline" +"inline-table" +"intercept" +"italic" +"k" +"k1" +"k2" +"k3" +"k4" +"kernelMatrix" +"kernelUnitLength" +"kerning" +"keyPoints" +"keySplines" +"keyTimes" +"lang" +"lengthAdjust" +"letter-spacing" +"lighter" +"lighting-color" +"limitingConeAngle" +"line" +"linearGradient" +"linearRGB" +"'line-height'" +"line-through" +"list-item" +"local" +"lr" +"lr-tb" +"ltr" +"marker" +"marker-end" +"markerHeight" +"marker-mid" +"marker-start" +"markerUnits" +"markerWidth" +"mask" +"maskContentUnits" +"maskUnits" +"mathematical" +"max" +"media" +"menu" +"message-box" +"metadata" +"method" +"middle" +"min" +"missing-glyph" +"miter" +"mode" +"move" +"mpath" +"name" +"narrower" +"ne-resize" +"new" +"no-change" +"none" +"nonzero" +"normal" +"n-resize" +"numOctaves" +"nw-resize" +"oblique" +"offset" +"onabort" +"onactivate" +"onbegin" +"onclick" +"onend" +"onerror" +"onfocusin" +"onfocusout" +"onload" +"onmousedown" +"onmousemove" +"onmouseout" +"onmouseover" +"onmouseup" +"onrepeat" +"onresize" +"onscroll" +"onunload" +"onzoom" +"opacity" +"operator" +"optimizeLegibility" +"optimizeQuality" +"optimizeSpeed" +"order" +"orient" +"orientation" +"origin" +"overflow" +"overline" +"overline-position" +"overline-thickness" +"paint" +"painted" +"panose-1" +"path" +"pathLength" +"pattern" +"patternContentUnits" +"patternTransform" +"patternUnits" +"pointer" +"pointer-events" +"points" +"pointsAtX" +"pointsAtY" +"pointsAtZ" +"polygon" +"polyline" +"preserveAlpha" +"preserveAspectRatio" +"primitiveUnits" +"properties" +"r" +"radialGradient" +"radius" +"rect" +"refX" +"refY" +"rendering-intent" +"repeatCount" +"repeatDur" +"requiredExtensions" +"requiredFeatures" +"reset-size" +"restart" +"result" +"rl" +"rl-tb" +"rotate" +"round" +"rtl" +"run-in" +"rx" +"ry" +"scale" +"script" +"scroll" +"see" +"seed" +"semi-condensed" +"semi-expanded" +"se-resize" +"set" +"shape-rendering" +"slope" +"small-caps" +"small-caption" +"spacing" +"Specifying" +"specularConstant" +"specularExponent" +"spreadMethod" +"square" +"s-resize" +"sRGB" +"start" +"startOffset" +"status-bar" +"stdDeviation" +"stemh" +"stemv" +"stitchTiles" +"stop" +"stop-color" +"stop-opacity" +"strikethrough-position" +"strikethrough-thickness" +"string" +string_any="ANY" +string_brackets="[]" +string_cdata="CDATA" +string_col_fallback=":fallback" +string_col_generic=":a" +string_col_include=":include" +string_dashes="--" +string_empty_dblquotes="\"\"" +string_empty="EMPTY" +string_empty_quotes="''" +string_entities="ENTITIES" +string_entity="ENTITY" +string_fixed="#FIXED" +string_id="ID" +string_idref="IDREF" +string_idrefs="IDREFS" +string_implied="#IMPLIED" +string_nmtoken="NMTOKEN" +string_nmtokens="NMTOKENS" +string_notation="NOTATION" +string_parentheses="()" +string_pcdata="#PCDATA" +string_percent="%a" +string_public="PUBLIC" +string_required="#REQUIRED" +string_schema=":schema" +string_system="SYSTEM" +string_ucs4="UCS-4" +string_utf16="UTF-16" +string_utf8="UTF-8" +string_xmlns="xmlns:" +"stroke" +"stroke-dasharray" +"stroke-dashoffset" +"stroke-linecap" +"stroke-linejoin" +"stroke-miterlimit" +"stroke-opacity" +"stroke-width" +"style" +"sub" +"super" +"surfaceScale" +"svg" +"switch" +"sw-resize" +"symbol" +"systemLanguage" +"table" +"table-caption" +"table-cell" +"table-column" +"table-column-group" +"table-footer-group" +"table-header-group" +"table-row" +"table-row-group" +"tableValues" +tag_attlist="" +tag_doctype="" +tag_open_close="" +tag_open_exclamation="" +tag_xml_q="" +"target" +"targetX" +"targetY" +"tb" +"tb-rl" +"text" +"text-after-edge" +"text-anchor" +"text-before-edge" +"text-decoration" +"textLength" +"textPath" +"text-rendering" +"title" +"to" +"transform" +"tref" +"tspan" +"type" +"u1" +"u2" +"ultra-condensed" +"ultra-expanded" +"underline" +"underline-position" +"underline-thickness" +"unicode" +"unicode-bidi" +"unicode-range" +"units-per-em" +"use" +"use-script" +"v-alphabetic" +"values" +"version" +"vert-adv-y" +"vert-origin-x" +"vert-origin-y" +"v-hanging" +"v-ideographic" +"view" +"viewBox" +"viewTarget" +"visibility" +"visible" +"visibleFill" +"visiblePainted" +"visibleStroke" +"vkern" +"v-mathematical" +"wait" +"wider" +"width" +"widths" +"word-spacing" +"w-resize" +"writing-mode" +"x" +"x1" +"x2" +"xChannelSelector" +"x-height" +"xlink:actuate" +"xlink:arcrole" +"xlink:href" +"xlink:role" +"xlink:show" +"xlink:title" +"xlink:type" +#XML +"xml:base" +"xml:lang" +"xml:space" +"y" +"y1" +"y2" +"yChannelSelector" +"z" +"zoomAndPan" diff --git a/testfiles/fuzzer.cpp b/testfiles/fuzzer.cpp new file mode 100644 index 000000000..6dd09e753 --- /dev/null +++ b/testfiles/fuzzer.cpp @@ -0,0 +1,15 @@ +#include "xml/repr.h" +#include "inkscape.h" +#include "document.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + g_type_init(); + Inkscape::GC::init(); + if ( !Inkscape::Application::exists() ) + Inkscape::Application::create("", false); + //void* a= sp_repr_read_mem((const char*)data, size, 0); + SPDocument *doc = SPDocument::createNewDocFromMem( (const char*)data, size, 0); + if(doc) + doc->doUnref(); + return 0; +} -- cgit v1.2.3 From 7e6670263c3a42dfe70a4e97009f25259d7f6a4c Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 28 Oct 2017 18:46:05 +0200 Subject: simpler structure -- compilers and flags have to be given externally --- testfiles/CMakeLists.txt | 9 +- testfiles/fuzz-dict | 521 ----------------------------------------------- testfiles/fuzzer.dict | 521 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 526 insertions(+), 525 deletions(-) delete mode 100644 testfiles/fuzz-dict create mode 100644 testfiles/fuzzer.dict (limited to 'testfiles') diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 5dba0258b..923898fc3 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -34,8 +34,9 @@ add_subdirectory(rendering_tests) if(WITH_FUZZ) add_executable(fuzz fuzzer.cpp) - target_link_libraries(fuzz inkscape_base -lFuzzer "-fsanitize=address" - "-fsanitize-coverage=edge,trace-pc-guard,indirect-calls,trace-cmp,trace-div,trace-gep" - "-fno-omit-frame-pointer") - + if(EXISTS ${LIB_FUZZING_ENGINE}) + target_link_libraries(fuzz inkscape_base -lFuzzingEngine) + else() + target_link_libraries(fuzz inkscape_base -lFuzzer) + endif() endif() diff --git a/testfiles/fuzz-dict b/testfiles/fuzz-dict deleted file mode 100644 index 7eee0d0a0..000000000 --- a/testfiles/fuzz-dict +++ /dev/null @@ -1,521 +0,0 @@ -"100" -"200" -"300" -"400" -"500" -"600" -"700" -"800" -"900" -"a" -"accent-height" -"accumulate" -"additive" -"after-edge" -"alignment-baseline" -"all" -"alphabetic" -"altGlyph" -"altGlyphDef" -"altGlyphItem" -"amplitude" -"animate" -"animateColor" -"animateMotion" -"animateTransform" -"arabic-form" -"ascent" -attr_encoding=" encoding=\"1\"" -attr_generic=" a=\"1\"" -attr_href=" href=\"1\"" -"attributeName" -"attributeType" -attr_standalone=" standalone=\"no\"" -attr_version=" version=\"1\"" -attr_xml_base=" xml:base=\"1\"" -attr_xml_id=" xml:id=\"1\"" -attr_xml_lang=" xml:lang=\"1\"" -attr_xmlns=" xmlns=\"1\"" -attr_xml_space=" xml:space=\"1\"" -"auto" -"azimuth" -"baseFrequency" -"baseline" -"baseline-shift" -"baseProfile" -"bbox" -"before-edge" -"begin" -"bevel" -"bias" -"bidi-override" -"blink" -"block" -"bold" -"bolder" -"butt" -"by" -"calcMode" -"cap-height" -"caption" -"central" -"circle" -"class" -"clip" -"clip-path" -"clipPath" -"clipPathUnits" -"clip-rule" -"collapse" -"color" -"color-interpolation" -"color-interpolation-filters" -"color-profile" -"color-rendering" -"compact" -"condensed" -"contentScriptType" -"contentStyleType" -"crispEdges" -"crosshair" -"currentColor" -"cursor" -"cx" -"cy" -"d" -"default" -"defs" -"desc" -"descent" -"diffuseConstant" -"direction" -"display" -"divisor" -"dominant-baseline" -"dur" -"dx" -"dy" -"edgeMode" -"elevation" -"ellipse" -"embed" -"enable-background" -"end" -entity_builtin="<" -entity_decimal="" -entity_external="&a;" -entity_hex="" -"e-resize" -"evenodd" -"expanded" -"exponent" -"externalResourcesRequired" -"extra-condensed" -"extra-expanded" -"feBlend" -"feColorMatrix" -"feComponentTransfer" -"feComposite" -"feConvolveMatrix" -"feDiffuseLighting" -"feDisplacementMap" -"feDistantLight" -"feFlood" -"feFuncA" -"feFuncB" -"feFuncG" -"feFuncR" -"feGaussianBlur" -"feImage" -"feMerge" -"feMergeNode" -"feMorphology" -"feOffset" -"fePointLight" -"feSpecularLighting" -"feSpotLight" -"feTile" -"feTurbulence" -"fill" -"fill-opacity" -"fill-rule" -"filter" -"filterRes" -"filterUnits" -"flood-color" -"flood-opacity" -"font" -"font-face" -"font-face-format" -"font-face-name" -"font-face-src" -"font-face-uri" -"font-family" -"font-size" -"font-size-adjust" -"font-stretch" -"font-style" -"font-variant" -"font-weight" -"foreignObject" -"format" -"from" -"fx" -"fy" -"g" -"g1" -"g2" -"geometricPrecision" -"glyph" -"glyph-name" -"glyph-orientation-horizontal" -"glyph-orientation-vertical" -"glyphRef" -"gradientTransform" -"gradientUnits" -"hanging" -"height" -"help" -"hidden" -"hkern" -"horiz-adv-x" -"horiz-origin-x" -"horiz-origin-y" -"icon" -"id" -"ideographic" -"image" -"image-rendering" -"in" -"in2" -"individual" -"inherit" -"inline" -"inline-table" -"intercept" -"italic" -"k" -"k1" -"k2" -"k3" -"k4" -"kernelMatrix" -"kernelUnitLength" -"kerning" -"keyPoints" -"keySplines" -"keyTimes" -"lang" -"lengthAdjust" -"letter-spacing" -"lighter" -"lighting-color" -"limitingConeAngle" -"line" -"linearGradient" -"linearRGB" -"'line-height'" -"line-through" -"list-item" -"local" -"lr" -"lr-tb" -"ltr" -"marker" -"marker-end" -"markerHeight" -"marker-mid" -"marker-start" -"markerUnits" -"markerWidth" -"mask" -"maskContentUnits" -"maskUnits" -"mathematical" -"max" -"media" -"menu" -"message-box" -"metadata" -"method" -"middle" -"min" -"missing-glyph" -"miter" -"mode" -"move" -"mpath" -"name" -"narrower" -"ne-resize" -"new" -"no-change" -"none" -"nonzero" -"normal" -"n-resize" -"numOctaves" -"nw-resize" -"oblique" -"offset" -"onabort" -"onactivate" -"onbegin" -"onclick" -"onend" -"onerror" -"onfocusin" -"onfocusout" -"onload" -"onmousedown" -"onmousemove" -"onmouseout" -"onmouseover" -"onmouseup" -"onrepeat" -"onresize" -"onscroll" -"onunload" -"onzoom" -"opacity" -"operator" -"optimizeLegibility" -"optimizeQuality" -"optimizeSpeed" -"order" -"orient" -"orientation" -"origin" -"overflow" -"overline" -"overline-position" -"overline-thickness" -"paint" -"painted" -"panose-1" -"path" -"pathLength" -"pattern" -"patternContentUnits" -"patternTransform" -"patternUnits" -"pointer" -"pointer-events" -"points" -"pointsAtX" -"pointsAtY" -"pointsAtZ" -"polygon" -"polyline" -"preserveAlpha" -"preserveAspectRatio" -"primitiveUnits" -"properties" -"r" -"radialGradient" -"radius" -"rect" -"refX" -"refY" -"rendering-intent" -"repeatCount" -"repeatDur" -"requiredExtensions" -"requiredFeatures" -"reset-size" -"restart" -"result" -"rl" -"rl-tb" -"rotate" -"round" -"rtl" -"run-in" -"rx" -"ry" -"scale" -"script" -"scroll" -"see" -"seed" -"semi-condensed" -"semi-expanded" -"se-resize" -"set" -"shape-rendering" -"slope" -"small-caps" -"small-caption" -"spacing" -"Specifying" -"specularConstant" -"specularExponent" -"spreadMethod" -"square" -"s-resize" -"sRGB" -"start" -"startOffset" -"status-bar" -"stdDeviation" -"stemh" -"stemv" -"stitchTiles" -"stop" -"stop-color" -"stop-opacity" -"strikethrough-position" -"strikethrough-thickness" -"string" -string_any="ANY" -string_brackets="[]" -string_cdata="CDATA" -string_col_fallback=":fallback" -string_col_generic=":a" -string_col_include=":include" -string_dashes="--" -string_empty_dblquotes="\"\"" -string_empty="EMPTY" -string_empty_quotes="''" -string_entities="ENTITIES" -string_entity="ENTITY" -string_fixed="#FIXED" -string_id="ID" -string_idref="IDREF" -string_idrefs="IDREFS" -string_implied="#IMPLIED" -string_nmtoken="NMTOKEN" -string_nmtokens="NMTOKENS" -string_notation="NOTATION" -string_parentheses="()" -string_pcdata="#PCDATA" -string_percent="%a" -string_public="PUBLIC" -string_required="#REQUIRED" -string_schema=":schema" -string_system="SYSTEM" -string_ucs4="UCS-4" -string_utf16="UTF-16" -string_utf8="UTF-8" -string_xmlns="xmlns:" -"stroke" -"stroke-dasharray" -"stroke-dashoffset" -"stroke-linecap" -"stroke-linejoin" -"stroke-miterlimit" -"stroke-opacity" -"stroke-width" -"style" -"sub" -"super" -"surfaceScale" -"svg" -"switch" -"sw-resize" -"symbol" -"systemLanguage" -"table" -"table-caption" -"table-cell" -"table-column" -"table-column-group" -"table-footer-group" -"table-header-group" -"table-row" -"table-row-group" -"tableValues" -tag_attlist="" -tag_doctype="" -tag_open_close="" -tag_open_exclamation="" -tag_xml_q="" -"target" -"targetX" -"targetY" -"tb" -"tb-rl" -"text" -"text-after-edge" -"text-anchor" -"text-before-edge" -"text-decoration" -"textLength" -"textPath" -"text-rendering" -"title" -"to" -"transform" -"tref" -"tspan" -"type" -"u1" -"u2" -"ultra-condensed" -"ultra-expanded" -"underline" -"underline-position" -"underline-thickness" -"unicode" -"unicode-bidi" -"unicode-range" -"units-per-em" -"use" -"use-script" -"v-alphabetic" -"values" -"version" -"vert-adv-y" -"vert-origin-x" -"vert-origin-y" -"v-hanging" -"v-ideographic" -"view" -"viewBox" -"viewTarget" -"visibility" -"visible" -"visibleFill" -"visiblePainted" -"visibleStroke" -"vkern" -"v-mathematical" -"wait" -"wider" -"width" -"widths" -"word-spacing" -"w-resize" -"writing-mode" -"x" -"x1" -"x2" -"xChannelSelector" -"x-height" -"xlink:actuate" -"xlink:arcrole" -"xlink:href" -"xlink:role" -"xlink:show" -"xlink:title" -"xlink:type" -#XML -"xml:base" -"xml:lang" -"xml:space" -"y" -"y1" -"y2" -"yChannelSelector" -"z" -"zoomAndPan" diff --git a/testfiles/fuzzer.dict b/testfiles/fuzzer.dict new file mode 100644 index 000000000..7eee0d0a0 --- /dev/null +++ b/testfiles/fuzzer.dict @@ -0,0 +1,521 @@ +"100" +"200" +"300" +"400" +"500" +"600" +"700" +"800" +"900" +"a" +"accent-height" +"accumulate" +"additive" +"after-edge" +"alignment-baseline" +"all" +"alphabetic" +"altGlyph" +"altGlyphDef" +"altGlyphItem" +"amplitude" +"animate" +"animateColor" +"animateMotion" +"animateTransform" +"arabic-form" +"ascent" +attr_encoding=" encoding=\"1\"" +attr_generic=" a=\"1\"" +attr_href=" href=\"1\"" +"attributeName" +"attributeType" +attr_standalone=" standalone=\"no\"" +attr_version=" version=\"1\"" +attr_xml_base=" xml:base=\"1\"" +attr_xml_id=" xml:id=\"1\"" +attr_xml_lang=" xml:lang=\"1\"" +attr_xmlns=" xmlns=\"1\"" +attr_xml_space=" xml:space=\"1\"" +"auto" +"azimuth" +"baseFrequency" +"baseline" +"baseline-shift" +"baseProfile" +"bbox" +"before-edge" +"begin" +"bevel" +"bias" +"bidi-override" +"blink" +"block" +"bold" +"bolder" +"butt" +"by" +"calcMode" +"cap-height" +"caption" +"central" +"circle" +"class" +"clip" +"clip-path" +"clipPath" +"clipPathUnits" +"clip-rule" +"collapse" +"color" +"color-interpolation" +"color-interpolation-filters" +"color-profile" +"color-rendering" +"compact" +"condensed" +"contentScriptType" +"contentStyleType" +"crispEdges" +"crosshair" +"currentColor" +"cursor" +"cx" +"cy" +"d" +"default" +"defs" +"desc" +"descent" +"diffuseConstant" +"direction" +"display" +"divisor" +"dominant-baseline" +"dur" +"dx" +"dy" +"edgeMode" +"elevation" +"ellipse" +"embed" +"enable-background" +"end" +entity_builtin="<" +entity_decimal="" +entity_external="&a;" +entity_hex="" +"e-resize" +"evenodd" +"expanded" +"exponent" +"externalResourcesRequired" +"extra-condensed" +"extra-expanded" +"feBlend" +"feColorMatrix" +"feComponentTransfer" +"feComposite" +"feConvolveMatrix" +"feDiffuseLighting" +"feDisplacementMap" +"feDistantLight" +"feFlood" +"feFuncA" +"feFuncB" +"feFuncG" +"feFuncR" +"feGaussianBlur" +"feImage" +"feMerge" +"feMergeNode" +"feMorphology" +"feOffset" +"fePointLight" +"feSpecularLighting" +"feSpotLight" +"feTile" +"feTurbulence" +"fill" +"fill-opacity" +"fill-rule" +"filter" +"filterRes" +"filterUnits" +"flood-color" +"flood-opacity" +"font" +"font-face" +"font-face-format" +"font-face-name" +"font-face-src" +"font-face-uri" +"font-family" +"font-size" +"font-size-adjust" +"font-stretch" +"font-style" +"font-variant" +"font-weight" +"foreignObject" +"format" +"from" +"fx" +"fy" +"g" +"g1" +"g2" +"geometricPrecision" +"glyph" +"glyph-name" +"glyph-orientation-horizontal" +"glyph-orientation-vertical" +"glyphRef" +"gradientTransform" +"gradientUnits" +"hanging" +"height" +"help" +"hidden" +"hkern" +"horiz-adv-x" +"horiz-origin-x" +"horiz-origin-y" +"icon" +"id" +"ideographic" +"image" +"image-rendering" +"in" +"in2" +"individual" +"inherit" +"inline" +"inline-table" +"intercept" +"italic" +"k" +"k1" +"k2" +"k3" +"k4" +"kernelMatrix" +"kernelUnitLength" +"kerning" +"keyPoints" +"keySplines" +"keyTimes" +"lang" +"lengthAdjust" +"letter-spacing" +"lighter" +"lighting-color" +"limitingConeAngle" +"line" +"linearGradient" +"linearRGB" +"'line-height'" +"line-through" +"list-item" +"local" +"lr" +"lr-tb" +"ltr" +"marker" +"marker-end" +"markerHeight" +"marker-mid" +"marker-start" +"markerUnits" +"markerWidth" +"mask" +"maskContentUnits" +"maskUnits" +"mathematical" +"max" +"media" +"menu" +"message-box" +"metadata" +"method" +"middle" +"min" +"missing-glyph" +"miter" +"mode" +"move" +"mpath" +"name" +"narrower" +"ne-resize" +"new" +"no-change" +"none" +"nonzero" +"normal" +"n-resize" +"numOctaves" +"nw-resize" +"oblique" +"offset" +"onabort" +"onactivate" +"onbegin" +"onclick" +"onend" +"onerror" +"onfocusin" +"onfocusout" +"onload" +"onmousedown" +"onmousemove" +"onmouseout" +"onmouseover" +"onmouseup" +"onrepeat" +"onresize" +"onscroll" +"onunload" +"onzoom" +"opacity" +"operator" +"optimizeLegibility" +"optimizeQuality" +"optimizeSpeed" +"order" +"orient" +"orientation" +"origin" +"overflow" +"overline" +"overline-position" +"overline-thickness" +"paint" +"painted" +"panose-1" +"path" +"pathLength" +"pattern" +"patternContentUnits" +"patternTransform" +"patternUnits" +"pointer" +"pointer-events" +"points" +"pointsAtX" +"pointsAtY" +"pointsAtZ" +"polygon" +"polyline" +"preserveAlpha" +"preserveAspectRatio" +"primitiveUnits" +"properties" +"r" +"radialGradient" +"radius" +"rect" +"refX" +"refY" +"rendering-intent" +"repeatCount" +"repeatDur" +"requiredExtensions" +"requiredFeatures" +"reset-size" +"restart" +"result" +"rl" +"rl-tb" +"rotate" +"round" +"rtl" +"run-in" +"rx" +"ry" +"scale" +"script" +"scroll" +"see" +"seed" +"semi-condensed" +"semi-expanded" +"se-resize" +"set" +"shape-rendering" +"slope" +"small-caps" +"small-caption" +"spacing" +"Specifying" +"specularConstant" +"specularExponent" +"spreadMethod" +"square" +"s-resize" +"sRGB" +"start" +"startOffset" +"status-bar" +"stdDeviation" +"stemh" +"stemv" +"stitchTiles" +"stop" +"stop-color" +"stop-opacity" +"strikethrough-position" +"strikethrough-thickness" +"string" +string_any="ANY" +string_brackets="[]" +string_cdata="CDATA" +string_col_fallback=":fallback" +string_col_generic=":a" +string_col_include=":include" +string_dashes="--" +string_empty_dblquotes="\"\"" +string_empty="EMPTY" +string_empty_quotes="''" +string_entities="ENTITIES" +string_entity="ENTITY" +string_fixed="#FIXED" +string_id="ID" +string_idref="IDREF" +string_idrefs="IDREFS" +string_implied="#IMPLIED" +string_nmtoken="NMTOKEN" +string_nmtokens="NMTOKENS" +string_notation="NOTATION" +string_parentheses="()" +string_pcdata="#PCDATA" +string_percent="%a" +string_public="PUBLIC" +string_required="#REQUIRED" +string_schema=":schema" +string_system="SYSTEM" +string_ucs4="UCS-4" +string_utf16="UTF-16" +string_utf8="UTF-8" +string_xmlns="xmlns:" +"stroke" +"stroke-dasharray" +"stroke-dashoffset" +"stroke-linecap" +"stroke-linejoin" +"stroke-miterlimit" +"stroke-opacity" +"stroke-width" +"style" +"sub" +"super" +"surfaceScale" +"svg" +"switch" +"sw-resize" +"symbol" +"systemLanguage" +"table" +"table-caption" +"table-cell" +"table-column" +"table-column-group" +"table-footer-group" +"table-header-group" +"table-row" +"table-row-group" +"tableValues" +tag_attlist="" +tag_doctype="" +tag_open_close="" +tag_open_exclamation="" +tag_xml_q="" +"target" +"targetX" +"targetY" +"tb" +"tb-rl" +"text" +"text-after-edge" +"text-anchor" +"text-before-edge" +"text-decoration" +"textLength" +"textPath" +"text-rendering" +"title" +"to" +"transform" +"tref" +"tspan" +"type" +"u1" +"u2" +"ultra-condensed" +"ultra-expanded" +"underline" +"underline-position" +"underline-thickness" +"unicode" +"unicode-bidi" +"unicode-range" +"units-per-em" +"use" +"use-script" +"v-alphabetic" +"values" +"version" +"vert-adv-y" +"vert-origin-x" +"vert-origin-y" +"v-hanging" +"v-ideographic" +"view" +"viewBox" +"viewTarget" +"visibility" +"visible" +"visibleFill" +"visiblePainted" +"visibleStroke" +"vkern" +"v-mathematical" +"wait" +"wider" +"width" +"widths" +"word-spacing" +"w-resize" +"writing-mode" +"x" +"x1" +"x2" +"xChannelSelector" +"x-height" +"xlink:actuate" +"xlink:arcrole" +"xlink:href" +"xlink:role" +"xlink:show" +"xlink:title" +"xlink:type" +#XML +"xml:base" +"xml:lang" +"xml:space" +"y" +"y1" +"y2" +"yChannelSelector" +"z" +"zoomAndPan" -- cgit v1.2.3 From ca7192d984bfe92d295e3bb695d48b4b300e5673 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 28 Oct 2017 18:56:01 +0200 Subject: add some doc --- testfiles/CMakeLists.txt | 5 +++++ testfiles/fuzzer.dict | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'testfiles') diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 923898fc3..62b028729 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -32,7 +32,12 @@ foreach(source ${TEST_SOURCES}) endforeach() add_subdirectory(rendering_tests) + if(WITH_FUZZ) + # to use the fuzzer, make sure you use the right compiler (clang) + # with the right flags -fsanitize=address -fsanitize-coverage=edge,trace-pc-guard,indirect-calls,trace-cmp,trace-div,trace-gep -fno-omit-frame-pointer + # (see libfuzzer doc for info in flags) + # first line is for integration into oss-fuzz https://github.com/google/oss-fuzz add_executable(fuzz fuzzer.cpp) if(EXISTS ${LIB_FUZZING_ENGINE}) target_link_libraries(fuzz inkscape_base -lFuzzingEngine) diff --git a/testfiles/fuzzer.dict b/testfiles/fuzzer.dict index 7eee0d0a0..8fae9bd4e 100644 --- a/testfiles/fuzzer.dict +++ b/testfiles/fuzzer.dict @@ -1,3 +1,7 @@ +# Dictionary for the fuzzer to "guess" faster important words. +# Contains xml keywords and svg element names and attributes. +# It might be useful to remove some of them, maybe. + "100" "200" "300" -- cgit v1.2.3 From 5b7195f3d468c240497565ccf2551da8e0dd7415 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 28 Oct 2017 18:59:06 +0000 Subject: small fix --- testfiles/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testfiles') diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 62b028729..2f721d820 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -39,7 +39,7 @@ if(WITH_FUZZ) # (see libfuzzer doc for info in flags) # first line is for integration into oss-fuzz https://github.com/google/oss-fuzz add_executable(fuzz fuzzer.cpp) - if(EXISTS ${LIB_FUZZING_ENGINE}) + if(LIB_FUZZING_ENGINE) target_link_libraries(fuzz inkscape_base -lFuzzingEngine) else() target_link_libraries(fuzz inkscape_base -lFuzzer) -- cgit v1.2.3