Skip to content

Commit d78e970

Browse files
nanouhiText-CI
authored andcommitted
Add tests for grid layout for nesting and em - rem values
DEVSIX-8338 Autoported commit. Original commit hash: [67c625bdd]
1 parent 8f18761 commit d78e970

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1761
-1
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/css/grid/GridAreaTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public virtual void TemplateAreasWithDotsTest() {
6464
RunTest("templateAreasWithDots");
6565
}
6666

67+
[NUnit.Framework.Test]
68+
public virtual void TemplateAreasSwitchedPlacesTest() {
69+
RunTest("grid-area-switched-places");
70+
}
71+
6772
[NUnit.Framework.Test]
6873
[LogMessage(Html2PdfLogMessageConstant.GRID_TEMPLATE_AREAS_IS_INVALID)]
6974
public virtual void InvalidTemplateAreasTest() {
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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.Html2pdf;
25+
using iText.Test.Attributes;
26+
27+
namespace iText.Html2pdf.Css.Grid {
28+
[NUnit.Framework.Category("IntegrationTest")]
29+
public class GridTemplateNestedTest : ExtendedHtmlConversionITextTest {
30+
public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
31+
.CurrentContext.TestDirectory) + "/resources/itext/html2pdf/css/grid" + "/GridTemplateNestedTest/";
32+
33+
public static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
34+
+ "/test/itext/html2pdf/css/grid" + "/GridTemplateNestedTest/";
35+
36+
//TODO DEVSIX-3340 change cmp files when GRID LAYOUT is supported
37+
[NUnit.Framework.OneTimeSetUp]
38+
public static void BeforeClass() {
39+
CreateOrClearDestinationFolder(DESTINATION_FOLDER);
40+
}
41+
42+
[NUnit.Framework.Test]
43+
public virtual void TemplateNestedAreasTest() {
44+
RunTest("grid-nested-areas");
45+
}
46+
47+
[NUnit.Framework.Test]
48+
public virtual void TemplateNestedArticlesTest() {
49+
RunTest("grid-nested-articles");
50+
}
51+
52+
[NUnit.Framework.Test]
53+
public virtual void TemplateNestedFormsTest() {
54+
RunTest("grid-nested-forms");
55+
}
56+
57+
[NUnit.Framework.Test]
58+
public virtual void TemplateNestedGridTest() {
59+
RunTest("grid-nested-grid");
60+
}
61+
62+
[NUnit.Framework.Test]
63+
public virtual void TemplateNestedListsTest() {
64+
RunTest("grid-nested-lists");
65+
}
66+
67+
[NUnit.Framework.Test]
68+
public virtual void TemplateNestedListsOddEvenTest() {
69+
RunTest("grid-nested-lists-odd-even");
70+
}
71+
72+
[NUnit.Framework.Test]
73+
public virtual void TemplateNestedMixedContentTest() {
74+
RunTest("grid-nested-mixed-content");
75+
}
76+
77+
[NUnit.Framework.Test]
78+
public virtual void TemplateNestedParagraphsTest() {
79+
RunTest("grid-nested-paragraphs");
80+
}
81+
82+
[NUnit.Framework.Test]
83+
public virtual void TemplateNestedImagesTest() {
84+
RunTest("grid-nested-images");
85+
}
86+
87+
[NUnit.Framework.Test]
88+
public virtual void TemplateNestedTableTest() {
89+
RunTest("grid-nested-table");
90+
}
91+
92+
[LogMessage(iText.IO.Logs.IoLogMessageConstant.TABLE_WIDTH_IS_MORE_THAN_EXPECTED_DUE_TO_MIN_WIDTH, Count =
93+
2)]
94+
[NUnit.Framework.Test]
95+
public virtual void TemplateNestedTableNestedGridTest() {
96+
RunTest("grid-nested-table-nested-grid");
97+
}
98+
99+
[NUnit.Framework.Test]
100+
public virtual void TemplateNestedTableMixedContentTest() {
101+
RunTest("grid-nested-table-with-mixed-content");
102+
}
103+
104+
[NUnit.Framework.Test]
105+
public virtual void TemplateNested2LevelsWithAreasTest() {
106+
RunTest("grid-nested-2-levels-areas");
107+
}
108+
109+
[LogMessage(iText.IO.Logs.IoLogMessageConstant.CLIP_ELEMENT, Count = 5)]
110+
[NUnit.Framework.Test]
111+
public virtual void TemplateNested3LevelsFormsTest() {
112+
RunTest("grid-nested-3-forms");
113+
}
114+
115+
[NUnit.Framework.Test]
116+
public virtual void TemplateNested3LevelsTest() {
117+
RunTest("grid-nested-3-levels");
118+
}
119+
120+
[NUnit.Framework.Test]
121+
public virtual void TemplateNested3LevelsMultipleTest() {
122+
RunTest("grid-nested-3-levels-multiple");
123+
}
124+
125+
[NUnit.Framework.Test]
126+
public virtual void TemplateNested3LevelsTablesTest() {
127+
RunTest("grid-nested-3-levels-tables");
128+
}
129+
130+
private void RunTest(String testName) {
131+
ConvertToPdfAndCompare(testName, SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().SetBaseUri
132+
(SOURCE_FOLDER).SetCssGridEnabled(true));
133+
}
134+
}
135+
}

itext.tests/itext.html2pdf.tests/itext/html2pdf/css/grid/GridTemplatesTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,16 @@ public virtual void GridWithTableTest() {
329329
RunTest("gridWithTableTest");
330330
}
331331

332+
[NUnit.Framework.Test]
333+
public virtual void BasicGridRemValuesTest() {
334+
RunTest("grid-layout-rem");
335+
}
336+
337+
[NUnit.Framework.Test]
338+
public virtual void BasicGridEmValuesTest() {
339+
RunTest("grid-layout-em");
340+
}
341+
332342
[NUnit.Framework.Test]
333343
public virtual void GridLayoutDisablingTest() {
334344
ConvertToPdfAndCompare("basicColumnFewDivsTest", SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
.container {
6+
display: grid;
7+
grid-template-columns: 300px 300px;
8+
grid-template-rows: auto;
9+
row-gap: 10px;
10+
column-gap: 10px;
11+
padding: 15px;
12+
}
13+
.grid-elem {
14+
color: white;
15+
font-size: 20px;
16+
background-color: darkblue;
17+
padding: 20px;
18+
border-radius: 0.5rem;
19+
}
20+
.third {
21+
grid-area: 1;
22+
background-color: #81b29a;
23+
}
24+
.fourth {
25+
grid-area: 3 / 2;
26+
background-color: #81b29a;
27+
}
28+
29+
</style>
30+
</head>
31+
<body>
32+
<div class="container">
33+
<div class="grid-elem">
34+
<p>1st elem</p>
35+
</div>
36+
<div class="grid-elem">
37+
<p>2nd elem</p>
38+
</div>
39+
<div class="grid-elem third">
40+
<p>3rd elem</p>
41+
</div>
42+
<div class="grid-elem fourth">
43+
<p>4th elem</p>
44+
</div>
45+
<div class="grid-elem">
46+
<p>5th elem</p>
47+
</div>
48+
<div class="grid-elem">
49+
<p>6th elem</p>
50+
</div>
51+
</div>
52+
</body>
53+
</html>

0 commit comments

Comments
 (0)