Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Dec 18, 2024
2 parents c467950 + 50751cb commit 2dd3645
Show file tree
Hide file tree
Showing 282 changed files with 3,074 additions and 223 deletions.
27 changes: 27 additions & 0 deletions itext.tests/itext.layout.tests/itext/layout/ParagraphTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,32 @@ public virtual void WordWasSplitAndItWillFitOntoNextLineTest02() {
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
, "diff"));
}

[NUnit.Framework.Test]
public virtual void ParagraphUsingSvgRenderingModeTest() {
String outFileName = destinationFolder + "paragraphUsingSvgRenderingMode.pdf";
String cmpFileName = sourceFolder + "cmp_paragraphUsingSvgRenderingMode.pdf";
using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName))) {
using (Document document = new Document(pdfDocument)) {
Paragraph paragraph1 = new Paragraph().SetBorder(new SolidBorder(ColorConstants.YELLOW, 1));
paragraph1.SetWidth(200).SetHorizontalAlignment(HorizontalAlignment.RIGHT);
Paragraph paragraph2 = new Paragraph().SetBorder(new SolidBorder(ColorConstants.PINK, 1));
paragraph2.SetWidth(200).SetHorizontalAlignment(HorizontalAlignment.RIGHT);
paragraph2.SetProperty(Property.RENDERING_MODE, RenderingMode.SVG_MODE);
for (int i = 0; i < 5; i++) {
Text textChunk = new Text("text" + i).SetBorder(new SolidBorder(ColorConstants.GREEN, 1));
textChunk.SetRelativePosition(-70 * i, 0, 0, 0);
paragraph1.Add(textChunk);
paragraph2.Add(textChunk);
}
document.Add(new Paragraph("Default rendering mode:"));
document.Add(paragraph1);
document.Add(new Paragraph("SVG rendering mode:"));
document.Add(paragraph2);
}
}
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
, "diff"));
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ public virtual void BackgroundWithSvgDataTest() {
declaration.Length - 1)));
}

[NUnit.Framework.Test]
public virtual void Base64Test() {
String cssString = "data:image/jpeg;base64,/9j/aGVsbG8gd29ybGQ=";
CssStyleSheet styleSheet = CssStyleSheetParser.Parse(new MemoryStream(cssString.GetBytes()), sourceFolder);
NUnit.Framework.Assert.IsTrue(styleSheet.GetStatements().IsEmpty());
}

private String GetCssFileContents(String filePath) {
byte[] bytes = StreamUtil.InputStreamToArray(FileUtil.GetInputStreamForFile(filePath));
String content = iText.Commons.Utils.JavaUtil.GetStringForBytes(bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;
using iText.Test;

namespace iText.StyledXmlParser.Css.Util {
Expand Down Expand Up @@ -127,5 +128,14 @@ public virtual void TestSpacesAfterUnitTypes() {
NUnit.Framework.Assert.IsTrue(CssTypesValidationUtils.IsMetricValue("10px "));
NUnit.Framework.Assert.IsTrue(CssTypesValidationUtils.IsPercentageValue("10% "));
}

[NUnit.Framework.Test]
public virtual void IsBase64Test() {
String base64String = "data:image/jpeg;base64,/9j/aGVsbG8gd29ybGQ=";
bool isBase64Data = CssTypesValidationUtils.IsBase64Data(base64String);
bool isInlineData = CssTypesValidationUtils.IsInlineData(base64String);
NUnit.Framework.Assert.IsTrue(isBase64Data);
NUnit.Framework.Assert.IsTrue(isInlineData);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,33 @@ public virtual void ParseDoubleValues() {
public virtual void ParsePathWithNewLinesTest() {
ConvertAndCompareSinglePage(sourceFolder, destinationFolder, "pathWithNewLines");
}

[NUnit.Framework.Test]
//TODO DEVSIX-8769: adapt after supporting
[LogMessage(SvgLogMessageConstant.UNMAPPED_TAG)]
public virtual void DescriptionTagsTest() {
IDictionary<String, ISvgNodeRenderer> map = new Dictionary<String, ISvgNodeRenderer>();
RectangleSvgNodeRenderer rect = new RectangleSvgNodeRenderer();
rect.SetAttribute("title", "Blue rectangle title");
rect.SetAttribute("desc", "This is a description of a blue rectangle in a desc tag.");
rect.SetAttribute("aria-describedby", "This description inside the aria-describedby will take precedent over desc tag description."
);
rect.SetAttribute("fill", "blue");
rect.SetAttribute("width", "300");
rect.SetAttribute("height", "200");
ISvgNodeRenderer root = new SvgTagSvgNodeRenderer();
root.SetAttribute("xmlns", "http://www.w3.org/2000/svg");
root.SetAttribute("font-size", "12pt");
root.SetAttribute("width", "800");
root.SetAttribute("height", "500");
ISvgProcessorResult expected = new SvgProcessorResult(map, root, new SvgProcessorContext(new SvgConverterProperties
()));
String name = "descriptions";
using (Stream fis = FileUtil.GetInputStreamForFile(sourceFolder + name + ".svg")) {
ISvgProcessorResult actual = SvgConverter.ParseAndProcess(fis);
NUnit.Framework.Assert.AreEqual(expected.GetRootRenderer().GetAttributeMapCopy(), actual.GetRootRenderer()
.GetAttributeMapCopy());
}
}
}
}
7 changes: 7 additions & 0 deletions itext.tests/itext.svg.tests/itext/svg/css/BaselineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,12 @@ public virtual void DominantBaselineTest() {
//TODO DEVSIX-5890: update cmp file after supporting
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "dominant-baseline");
}

//TODO DEVSIX-2507: Update cmp file after supporting
[NUnit.Framework.Test]
public virtual void DominantBaselineTspanTest() {
//TODO DEVSIX-5890: update cmp file after supporting
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "dominant-baseline-tspan");
}
}
}
12 changes: 12 additions & 0 deletions itext.tests/itext.svg.tests/itext/svg/css/FontAttributesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,23 @@ public virtual void FontSizeAdjustTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "font-size-adjust");
}

//TODO DEVSIX-2507: Update cmp file after supporting
[NUnit.Framework.Test]
public virtual void FontSizeAdjustTspanTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "font-size-adjust-tspan");
}

[NUnit.Framework.Test]
public virtual void FontStretchTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "font-stretch");
}

//TODO DEVSIX-2507: Update cmp file after supporting
[NUnit.Framework.Test]
public virtual void FontStretchTspanTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "font-stretch-tspan");
}

[NUnit.Framework.Test]
public virtual void FontVariantTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "font-variant");
Expand Down
10 changes: 10 additions & 0 deletions itext.tests/itext.svg.tests/itext/svg/css/ImportRuleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ public virtual void MediaQueryTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQuery", properties);
}

[NUnit.Framework.Test]
[LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI
, LogLevel = LogLevelConstants.ERROR)]
public virtual void MediaQueryPrintTest() {
// TODO DEVSIX-2263 SVG: CSS: Media query processing
ISvgConverterProperties properties = new SvgConverterProperties().SetMediaDeviceDescription(new MediaDeviceDescription
(MediaType.SCREEN));
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryPrint", properties);
}

[NUnit.Framework.Test]
[LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI
, LogLevel = LogLevelConstants.ERROR)]
Expand Down
157 changes: 157 additions & 0 deletions itext.tests/itext.svg.tests/itext/svg/css/MediaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;
using iText.Svg.Renderers;
using iText.Test;

namespace iText.Svg.Css {
[NUnit.Framework.Category("IntegrationTest")]
public class MediaTest : SvgIntegrationTest {
// TODO DEVSIX-2263 SVG: Update cmp files
private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
.CurrentContext.TestDirectory) + "/resources/itext/svg/css/MediaTest/";

private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
+ "/test/itext/svg/css/MediaTest/";

[NUnit.Framework.OneTimeSetUp]
public static void BeforeClass() {
ITextTest.CreateDestinationFolder(DESTINATION_FOLDER);
}

[NUnit.Framework.Test]
public virtual void MediaQueryWidthTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryWidth");
}

[NUnit.Framework.Test]
public virtual void MediaQueryMinWidthTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryMinWidth");
}

[NUnit.Framework.Test]
public virtual void MediaQueryBigMinWidthTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryMinWidth2");
}

[NUnit.Framework.Test]
public virtual void MediaQueryBigMaxWidthTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryMaxWidth");
}

[NUnit.Framework.Test]
public virtual void MediaQueryHeightTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryHeight");
}

[NUnit.Framework.Test]
public virtual void MediaQueryMinHeightTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryMinHeight");
}

[NUnit.Framework.Test]
public virtual void MediaQueryMaxHeightTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryMaxHeight");
}

[NUnit.Framework.Test]
public virtual void MediaQueryOrientationLandscapeTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryOrientationLandscape");
}

[NUnit.Framework.Test]
public virtual void MediaQueryOrientationPortraitTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryOrientationPortrait");
}

[NUnit.Framework.Test]
public virtual void MediaQueryAspectRatioTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryRatio");
}

[NUnit.Framework.Test]
public virtual void MediaQueryAspectRatioSingleValTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryRatioSingleVal");
}

[NUnit.Framework.Test]
public virtual void MediaQueryScreenTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryScreen");
}

[NUnit.Framework.Test]
public virtual void MediaQueryPrintTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryPrint");
}

[NUnit.Framework.Test]
public virtual void MediaQueryResolutionTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryResolution");
}

[NUnit.Framework.Test]
public virtual void MediaQueryOverflowBlockTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryOverflowBlock");
}

[NUnit.Framework.Test]
public virtual void MediaQueryOverflowInlineTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryOverflowInline");
}

[NUnit.Framework.Test]
public virtual void MediaQueryNotTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryNot");
}

[NUnit.Framework.Test]
public virtual void MediaQueryOnlyTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryOnly");
}

[NUnit.Framework.Test]
public virtual void MediaQueryOnlyAndTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryOnlyAnd");
}

[NUnit.Framework.Test]
public virtual void MediaQueryColorTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryColor");
}

[NUnit.Framework.Test]
public virtual void MediaQueryMinColorTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryMinColor");
}

[NUnit.Framework.Test]
public virtual void MediaQueryColorGamutTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryColorGamut");
}

[NUnit.Framework.Test]
public virtual void MediaQueryDisplayBrowserTest() {
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "mediaQueryDisplayBrowser");
}
}
}
52 changes: 52 additions & 0 deletions itext.tests/itext.svg.tests/itext/svg/css/OpacityTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;
using iText.Svg.Renderers;
using iText.Test;

namespace iText.Svg.Css {
[NUnit.Framework.Category("IntegrationTest")]
public class OpacityTest : SvgIntegrationTest {
//TODO DEVSIX-8822: update cmp after supporting
public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
.CurrentContext.TestDirectory) + "/resources/itext/svg/css/OpacityTest/";

public static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
+ "/test/itext/svg/css/OpacityTest/";

[NUnit.Framework.OneTimeSetUp]
public static void BeforeClass() {
ITextTest.CreateDestinationFolder(DESTINATION_FOLDER);
}

[NUnit.Framework.Test]
public virtual void OpacityShapesTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "opacityShapes");
}

[NUnit.Framework.Test]
public virtual void OpacityPathsTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "opacityPaths");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ public virtual void SvgWithInternalCSStoSingleDefaultPage() {
ConvertAndCompare(sourceFolder, destinationFolder, "internalCss");
}

[NUnit.Framework.Test]
public virtual void SvgWithInternalCSSWithoutOverlapTest() {
// TODO: update cmp files when DEVSIX-2286 resolved
ConvertAndCompare(sourceFolder, destinationFolder, "internalCssNoOverlap");
}

[NUnit.Framework.Test]
public virtual void SvgWithExternalCSStoCustomPage() {
// TODO: update cmp files when DEVSIX-2286 resolved
Expand Down Expand Up @@ -308,5 +314,11 @@ public virtual void CssStylesResolverOrder16Test() {
public virtual void CssStylesResolverOrder17Test() {
ConvertAndCompare(sourceFolder, destinationFolder, "cssStylesResolverOrder17");
}

[NUnit.Framework.Test]
public virtual void HeightWidthSvgStyleTest() {
//TODO DEVSIX-8823: update after issue is fixed
ConvertAndCompare(sourceFolder, destinationFolder, "height-width-style");
}
}
}
Loading

0 comments on commit 2dd3645

Please sign in to comment.