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 Jul 3, 2024
2 parents 599d188 + bdedaad commit 647d810
Show file tree
Hide file tree
Showing 28 changed files with 1,069 additions and 213 deletions.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Test.Utils;

namespace iText.Test {
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
// Android-Conversion-Skip-File (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Category("UnitTest")]
public class VeraPdfLoggerValidationTest : ExtendedITextTest {
//\cond DO_NOT_DOCUMENT
Expand All @@ -51,7 +51,6 @@ public virtual void CheckValidatorLogsNoOutputTest() {
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(DESTINATION_FOLDER + target));
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void CheckValidatorLogsWithWarningTest() {
String source = "pdfA2b_checkValidatorLogsTest_with_warnings.pdf";
Expand All @@ -64,7 +63,6 @@ public virtual void CheckValidatorLogsWithWarningTest() {
+ target));
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void CheckValidatorLogsCleanupTest() {
String fileNameWithWarnings = "pdfA2b_checkValidatorLogsTest_with_warnings.pdf";
Expand All @@ -76,23 +74,19 @@ public virtual void CheckValidatorLogsCleanupTest() {
+ "WARNING: The Top DICT does not begin with ROS operator";
NUnit.Framework.Assert.AreEqual(expectedWarningsForFileWithWarnings, new VeraPdfValidator().Validate(DESTINATION_FOLDER
+ fileNameWithWarnings));
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
//We check that the logs are empty after the first check
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(DESTINATION_FOLDER + fileNameWithoutWarnings
));
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void CheckValidatorLogsForFileContainingErrorsTest() {
String source = "pdfA2b_checkValidatorLogsTest_with_errors.pdf";
String target = "checkValidatorLogsForFileContainingErrorsTest.pdf";
FileUtil.Copy(SOURCE_FOLDER + source, DESTINATION_FOLDER + target);
String expectedResponseForErrors = "VeraPDF verification failed. See verification results: file:";
String result = new VeraPdfValidator().Validate(DESTINATION_FOLDER + target);
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android));
NUnit.Framework.Assert.IsTrue(result.StartsWith(expectedResponseForErrors));
}
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
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 System.Collections.Generic;
using iText.Commons.Utils;
using iText.StyledXmlParser.Css;
using iText.StyledXmlParser.Css.Resolve.Shorthand;
using iText.Test;
using iText.Test.Attributes;

namespace iText.StyledXmlParser.Css.Resolve.Shorthand.Impl {
[NUnit.Framework.Category("UnitTest")]
public class GridItemShorthandResolverTest : ExtendedITextTest {
[NUnit.Framework.Test]
public virtual void InitialOrInheritOrUnsetValuesTest() {
IShorthandResolver resolver = new GridRowShorthandResolver();
String initialShorthand = CommonCssConstants.INITIAL;
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(initialShorthand);
NUnit.Framework.Assert.AreEqual(0, resolvedShorthand.Count);
String inheritShorthand = CommonCssConstants.INHERIT;
resolvedShorthand = resolver.ResolveShorthand(inheritShorthand);
NUnit.Framework.Assert.AreEqual(0, resolvedShorthand.Count);
String unsetShorthand = CommonCssConstants.UNSET;
resolvedShorthand = resolver.ResolveShorthand(unsetShorthand);
NUnit.Framework.Assert.AreEqual(0, resolvedShorthand.Count);
}

[NUnit.Framework.Test]
[LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.SHORTHAND_PROPERTY_CANNOT_BE_EMPTY
, Count = 4)]
public virtual void EmptyShorthandTest() {
IShorthandResolver resolver = new GridColumnShorthandResolver();
String emptyShorthand = "";
NUnit.Framework.Assert.AreEqual(JavaCollectionsUtil.EmptyList<CssDeclaration>(), resolver.ResolveShorthand
(emptyShorthand));
String shorthandWithSpaces = " ";
NUnit.Framework.Assert.AreEqual(JavaCollectionsUtil.EmptyList<CssDeclaration>(), resolver.ResolveShorthand
(shorthandWithSpaces));
String shorthandWithTabs = "\t";
NUnit.Framework.Assert.AreEqual(JavaCollectionsUtil.EmptyList<CssDeclaration>(), resolver.ResolveShorthand
(shorthandWithTabs));
String shorthandWithNewLines = "\n";
NUnit.Framework.Assert.AreEqual(JavaCollectionsUtil.EmptyList<CssDeclaration>(), resolver.ResolveShorthand
(shorthandWithNewLines));
}

[NUnit.Framework.Test]
public virtual void BasicRowValuesTest() {
IShorthandResolver resolver = new GridRowShorthandResolver();
String shorthand = "span 2 / 4";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(2, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_ROW_START, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_ROW_END, resolvedShorthand[1].GetProperty());
NUnit.Framework.Assert.AreEqual("span 2", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("4", resolvedShorthand[1].GetExpression());
}

[NUnit.Framework.Test]
public virtual void BasicColumnValuesTest() {
IShorthandResolver resolver = new GridColumnShorthandResolver();
String shorthand = "3 / span 6";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(2, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_COLUMN_END, resolvedShorthand[1].GetProperty());
NUnit.Framework.Assert.AreEqual("3", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("span 6", resolvedShorthand[1].GetExpression());
}

[NUnit.Framework.Test]
public virtual void SingleValueTest() {
IShorthandResolver resolver = new GridColumnShorthandResolver();
String shorthand = "3";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(2, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_COLUMN_END, resolvedShorthand[1].GetProperty());
NUnit.Framework.Assert.AreEqual("3", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("3", resolvedShorthand[1].GetExpression());
}

[NUnit.Framework.Test]
public virtual void SingleValueSpanTest() {
IShorthandResolver resolver = new GridColumnShorthandResolver();
String shorthand = "span 3";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(1, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual("span 3", resolvedShorthand[0].GetExpression());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
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 System.Collections.Generic;
using iText.StyledXmlParser.Css;
using iText.StyledXmlParser.Css.Resolve.Shorthand;
using iText.Test;

namespace iText.StyledXmlParser.Css.Resolve.Shorthand.Impl {
[NUnit.Framework.Category("UnitTest")]
public class GridShorthandResolverTest : ExtendedITextTest {
/// <summary>Creates grid shorthand resolver.</summary>
public GridShorthandResolverTest() {
}

[NUnit.Framework.Test]
public virtual void TemplateAreasTest() {
IShorthandResolver resolver = new GridShorthandResolver();
String shorthand = "[header-top] 'a a a' [header-bottom] [main-top] 'b b b' 1fr [main-bottom] / auto 1fr auto";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(3, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand[1].GetProperty
());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand[2].GetProperty()
);
NUnit.Framework.Assert.AreEqual("[header-top] [header-bottom] [main-top] 1fr [main-bottom]", resolvedShorthand
[0].GetExpression());
NUnit.Framework.Assert.AreEqual("auto 1fr auto", resolvedShorthand[1].GetExpression());
NUnit.Framework.Assert.AreEqual("'a a a' 'b b b'", resolvedShorthand[2].GetExpression());
}

[NUnit.Framework.Test]
public virtual void ColumnFlowTest() {
IShorthandResolver resolver = new GridShorthandResolver();
String shorthand = "20% 100px 1fr / auto-flow dense 50px";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(3, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand[1].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_AUTO_COLUMNS, resolvedShorthand[2].GetProperty());
NUnit.Framework.Assert.AreEqual("20% 100px 1fr", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("column dense", resolvedShorthand[1].GetExpression());
NUnit.Framework.Assert.AreEqual("50px", resolvedShorthand[2].GetExpression());
}

[NUnit.Framework.Test]
public virtual void RowFlowTest() {
IShorthandResolver resolver = new GridShorthandResolver();
String shorthand = "auto-flow dense auto / 1fr auto minmax(100px, 1fr)";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(3, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_AUTO_ROWS, resolvedShorthand[1].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand[2].GetProperty
());
NUnit.Framework.Assert.AreEqual("dense", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("auto", resolvedShorthand[1].GetExpression());
NUnit.Framework.Assert.AreEqual("1fr auto minmax(100px,1fr)", resolvedShorthand[2].GetExpression());
}

[NUnit.Framework.Test]
public virtual void NoRowTemplateTest() {
IShorthandResolver resolver = new GridShorthandResolver();
String shorthand = "auto-flow dense / 1fr auto minmax(100px, 1fr)";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(2, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand[1].GetProperty
());
NUnit.Framework.Assert.AreEqual("dense", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("1fr auto minmax(100px,1fr)", resolvedShorthand[1].GetExpression());
}

[NUnit.Framework.Test]
public virtual void NoColumnTemplateTest() {
IShorthandResolver resolver = new GridShorthandResolver();
String shorthand = "1fr auto minmax(100px, 1fr) / auto-flow dense";
IList<CssDeclaration> resolvedShorthand = resolver.ResolveShorthand(shorthand);
NUnit.Framework.Assert.AreEqual(2, resolvedShorthand.Count);
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand[0].GetProperty());
NUnit.Framework.Assert.AreEqual(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand[1].GetProperty());
NUnit.Framework.Assert.AreEqual("1fr auto minmax(100px,1fr)", resolvedShorthand[0].GetExpression());
NUnit.Framework.Assert.AreEqual("column dense", resolvedShorthand[1].GetExpression());
}
}
}
Loading

0 comments on commit 647d810

Please sign in to comment.