Skip to content

Commit 60aec96

Browse files
committed
Move and rework unsupportedimagetypetest
DEVSIX-8367
1 parent 989a5d9 commit 60aec96

File tree

5 files changed

+60
-19
lines changed

5 files changed

+60
-19
lines changed

itext.tests/itext.cleanup.tests/itext/pdfcleanup/PdfCleanUpToolTest.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -929,24 +929,6 @@ public virtual void LineArtsDrawingOnCanvasTest() {
929929
CompareByContent(cmp, output, OUTPUT_PATH, "diff_lineArtsDrawingOnCanvasTest_");
930930
}
931931

932-
[NUnit.Framework.Test]
933-
[NUnit.Framework.Ignore("DEVSIX-8367: Rewrite checkUnSupportedImageTypeTest")]
934-
public virtual void CheckUnSupportedImageTypeTest() {
935-
String input = INPUT_PATH + "UnsupportedImageType.pdf";
936-
String output = OUTPUT_PATH + "UnsupportedImageType.pdf";
937-
PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output, new WriterProperties
938-
()));
939-
iText.PdfCleanup.PdfCleanUpTool workingTool = new iText.PdfCleanup.PdfCleanUpTool(pdfDocument);
940-
int pageIndex = 1;
941-
Rectangle area = pdfDocument.GetPage(pageIndex).GetPageSize();
942-
workingTool.AddCleanupLocation(new iText.PdfCleanup.PdfCleanUpLocation(pageIndex, area));
943-
Exception e = NUnit.Framework.Assert.Catch(typeof(Exception), () => workingTool.CleanUp());
944-
NUnit.Framework.Assert.IsTrue(CleanupExceptionMessageConstant.UNSUPPORTED_IMAGE_TYPE.ToLowerInvariant().Equals
945-
(e.Message.ToLowerInvariant()) || "incompatible color conversion".Equals(e.Message.ToLowerInvariant())
946-
);
947-
pdfDocument.Close();
948-
}
949-
950932
[NUnit.Framework.Test]
951933
public virtual void CleanUpFullyFilteredImageTest() {
952934
String input = INPUT_PATH + "fullyFilteredImageDocument.pdf";
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2024 Apryse Group NV
4+
Authors: Apryse Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using System;
24+
using iText.Kernel.Geom;
25+
using iText.Kernel.Pdf;
26+
using iText.PdfCleanup.Exceptions;
27+
using iText.Test;
28+
29+
namespace iText.PdfCleanup {
30+
[NUnit.Framework.Category("IntegrationTest")]
31+
public class UnsupportedImageTypeTest : ExtendedITextTest {
32+
private static readonly String INPUT_PATH = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
33+
.CurrentContext.TestDirectory) + "/resources/itext/pdfcleanup/UnsupportedImageTypeTest/";
34+
35+
private static readonly String OUTPUT_PATH = NUnit.Framework.TestContext.CurrentContext.TestDirectory + "/test/itext/pdfcleanup/UnsupportedImageTypeTest/";
36+
37+
[NUnit.Framework.OneTimeSetUp]
38+
public static void Before() {
39+
CreateOrClearDestinationFolder(OUTPUT_PATH);
40+
}
41+
42+
[NUnit.Framework.Test]
43+
public virtual void CheckUnSupportedImageTypeTest() {
44+
String input = INPUT_PATH + "JpegCmykImage.pdf";
45+
String output = OUTPUT_PATH + "JpegCmykImage.pdf";
46+
PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output, new WriterProperties
47+
()));
48+
iText.PdfCleanup.PdfCleanUpTool workingTool = new iText.PdfCleanup.PdfCleanUpTool(pdfDocument);
49+
int pageIndex = 1;
50+
Rectangle area = pdfDocument.GetPage(pageIndex).GetPageSize();
51+
workingTool.AddCleanupLocation(new iText.PdfCleanup.PdfCleanUpLocation(pageIndex, area));
52+
Exception e = NUnit.Framework.Assert.Catch(typeof(Exception), () => workingTool.CleanUp());
53+
NUnit.Framework.Assert.IsTrue(CleanupExceptionMessageConstant.UNSUPPORTED_IMAGE_TYPE.ToLowerInvariant().Equals
54+
(e.Message.ToLowerInvariant()) || "incompatible color conversion".Equals(e.Message.ToLowerInvariant())
55+
);
56+
pdfDocument.Close();
57+
}
58+
}
59+
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cda44613faf3fe98414b934ddeb5925670a3d7a4
1+
96a14c79d8b8b8aa9251cfce621cc399e7c33e68

0 commit comments

Comments
 (0)