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 14, 2024
2 parents 264d72f + f908981 commit cdbad68
Show file tree
Hide file tree
Showing 133 changed files with 223 additions and 363 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public virtual void SignWithTempFileTest() {
).SetFieldName("Signature1");
signer.SetSignerProperties(signerProperties);
// Creating the appearance
CreateAppearance(signer, "Signature1", "Test 1", "TestCity", false, rect, 12f);
CreateAppearance(signer, "Test 1", "TestCity", false, rect, 12f);
// Creating the signature
IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256);
signer.SignDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES
Expand All @@ -143,7 +143,7 @@ protected internal virtual void Sign(String src, String name, String dest, IX509
(name);
signer.SetSignerProperties(signerProperties);
// Creating the appearance
CreateAppearance(signer, name, reason, location, setReuseAppearance, rectangleForNewField, fontSize);
CreateAppearance(signer, reason, location, setReuseAppearance, rectangleForNewField, fontSize);
// Creating the signature
IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm);
signer.SignDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, subfilter);
Expand All @@ -155,8 +155,8 @@ private static IDictionary<int, IList<Rectangle>> GetTestMap(Rectangle ignoredAr
return result;
}

private static void CreateAppearance(PdfSigner signer, String signatureName, String reason, String location
, bool setReuseAppearance, Rectangle rectangleForNewField, float? fontSize) {
private static void CreateAppearance(PdfSigner signer, String reason, String location, bool setReuseAppearance
, Rectangle rectangleForNewField, float? fontSize) {
SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID).SetContent
(new SignedAppearanceText());
signer.GetSignerProperties().SetReason(reason).SetLocation(location).SetSignatureAppearance(appearance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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.Logs;
using iText.Svg.Renderers;
using iText.Test;
using iText.Test.Attributes;
Expand Down Expand Up @@ -138,38 +139,44 @@ public virtual void ViewBoxTranslationTestMultipleViewBoxes() {

[NUnit.Framework.Test]
public virtual void SvgTranslationYMinMeetTest() {
//TODO (DEVSIX-3537) change cmp files after the ticket will be fixed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgTranslationYMinMeet");
}

[NUnit.Framework.Test]
public virtual void SvgTranslationYMidMeetTest() {
//TODO (DEVSIX-3537) change cmp files after the ticket will be fixed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgTranslationYMidMeet");
}

[NUnit.Framework.Test]
public virtual void SvgTranslationYMaxMeetTest() {
//TODO (DEVSIX-3537) change cmp files after the ticket will be fixed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgTranslationYMaxMeet");
}

[NUnit.Framework.Test]
public virtual void SvgTranslationXMinMeetTest() {
//TODO (DEVSIX-3537) change cmp files after the ticket will be fixed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgTranslationXMinMeet");
}

[NUnit.Framework.Test]
public virtual void SvgTranslationXMidMeetTest() {
//TODO (DEVSIX-3537) change cmp files after the ticket will be fixed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgTranslationXMidMeet");
}

[NUnit.Framework.Test]
public virtual void SvgTranslationXMaxMeetTest() {
//TODO (DEVSIX-3537) change cmp files after the ticket will be fixed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgTranslationXMaxMeet");
}

[NUnit.Framework.Test]
[LogMessage(SvgLogMessageConstant.VIEWBOX_WIDTH_OR_HEIGHT_IS_ZERO, LogLevel = LogLevelConstants.INFO)]
public virtual void SvgZeroWidthRatioTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgZeroWidthRatio");
}

[NUnit.Framework.Test]
[LogMessage(SvgLogMessageConstant.VIEWBOX_WIDTH_OR_HEIGHT_IS_ZERO, LogLevel = LogLevelConstants.INFO)]
public virtual void SvgZeroHeightRatioTest() {
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "svgZeroHeightRatio");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,96 +25,14 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Utils;
using iText.Kernel.Geom;
using iText.Svg;
using iText.Svg.Renderers;
using iText.Test;

namespace iText.Svg.Renderers.Impl {
[NUnit.Framework.Category("UnitTest")]
public class PreserveAspectRatioSvgNodeRendererUnitTest : ExtendedITextTest {
private static readonly Rectangle VIEWPORT_VALUE = PageSize.DEFAULT;

private static readonly float[] VIEWBOX_VALUES = new float[] { 0, 0, 300, 400 };

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionDefault() {
//default aspect ration is xMidYMid
String alignValue = SvgConstants.Values.DEFAULT_ASPECT_RATIO;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(147.5, 221);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionNone() {
String alignValue = SvgConstants.Values.NONE;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(0, 0);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMinYMin() {
String alignValue = SvgConstants.Values.XMIN_YMIN;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(0, 0);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMinYMid() {
String alignValue = SvgConstants.Values.XMIN_YMID;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(0, 221);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMinYMax() {
String alignValue = SvgConstants.Values.XMIN_YMAX;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(0, 442);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMidYMin() {
String alignValue = SvgConstants.Values.XMID_YMIN;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(147.5, 0);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMidYMax() {
String alignValue = SvgConstants.Values.XMID_YMAX;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(147.5, 442);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMaxYMin() {
String alignValue = SvgConstants.Values.XMAX_YMIN;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(295, 0);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMaxYMid() {
String alignValue = SvgConstants.Values.XMAX_YMID;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(295, 221);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}

[NUnit.Framework.Test]
public virtual void ProcessAspectRatioPositionXMaxYMax() {
String alignValue = SvgConstants.Values.XMAX_YMAX;
AffineTransform cmpTransform = new AffineTransform();
cmpTransform.Translate(295, 442);
ProcessAspectRatioPositionAndCompare(alignValue, cmpTransform);
}
private static readonly Rectangle VIEWBOX_VALUE = new Rectangle(0, 0, 300, 400);

[NUnit.Framework.Test]
public virtual void RetrieveAlignAndMeetXMinYMinMeet() {
Expand Down Expand Up @@ -190,21 +108,6 @@ public virtual void RetrieveAlignAndMeetAllDefault() {
NUnit.Framework.Assert.AreEqual(cmpAlignAndMeet, outAlignAndMeet);
}

private void ProcessAspectRatioPositionAndCompare(String alignValue, AffineTransform cmpTransform) {
SvgDrawContext context = new SvgDrawContext(null, null);
// topmost viewport has default page size values for bounding rectangle
context.AddViewPort(VIEWPORT_VALUE);
float[] viewboxValues = VIEWBOX_VALUES;
float scaleWidth = 1.0f;
float scaleHeight = 1.0f;
AbstractBranchSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer();
IDictionary<String, String> attributesAndStyles = new Dictionary<String, String>();
renderer.SetAttributesAndStyles(attributesAndStyles);
AffineTransform outTransform = renderer.ProcessAspectRatioPosition(context, viewboxValues, alignValue, scaleWidth
, scaleHeight);
NUnit.Framework.Assert.IsTrue(cmpTransform.Equals(outTransform));
}

private String[] RetrieveAlignAndMeet(String align, String meet) {
AbstractBranchSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer();
IDictionary<String, String> attributesAndStyles = new Dictionary<String, String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public virtual void WidthHeightAttrPercentsPxTest() {

[NUnit.Framework.Test]
public virtual void PreserveAspectRatioViewBoxTest() {
// TODO DEVSIX-3537 Processing of preserveAspectRatio attribute with offsets x and y is not currently supported
ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "preserveAspectRatioViewBoxTest");
}

Expand Down Expand Up @@ -181,7 +180,7 @@ public virtual void UseSymbolHeightWidthAllUnitsTest() {

[NUnit.Framework.Test]
[LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED
, Count = 3)]
, Count = 2)]
public virtual void UseSymbolXYContrudictionAllUnitsTest() {
// TODO DEVSIX-4388 The handling of x and y attributes with percentages is not currently supported
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "useSymbolXYContrudictionAllUnitsTest", properties
Expand All @@ -190,7 +189,7 @@ public virtual void UseSymbolXYContrudictionAllUnitsTest() {

[NUnit.Framework.Test]
[LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED
, Count = 6)]
, Count = 4)]
public virtual void UseSymbolCoordinatesContrudictionTest() {
// TODO DEVSIX-2654 Percent values are not correctly processed
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "useSymbolCoordinatesContrudiction", properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,18 @@ public virtual void ViewBoxXYValuesPreserveAspectRatioNoneValues() {

[NUnit.Framework.Test]
public virtual void ViewBoxXYValuesPreserveAspectRatioXMaxYMaxMeetValues() {
//TODO (DEVSIX-3493) change cmp files after fix
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "viewBoxXYValuesPreserveAspectRatioXMaxYMaxMeetValues"
);
}

[NUnit.Framework.Test]
public virtual void ViewBoxXYValuesPreserveAspectRatioXMaxYMaxSliceValues() {
//TODO (DEVSIX-3493) change cmp files after fix
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "viewBoxXYValuesPreserveAspectRatioXMaxYMaxSliceValues"
);
}

[NUnit.Framework.Test]
public virtual void PreserveAspectRationAllOptionsTest() {
//TODO DEVSIX-4861 change cmp after fix
ConvertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "preserveAspectRationAllOptions");
}
}
Expand Down
Loading

0 comments on commit cdbad68

Please sign in to comment.