@@ -41,49 +41,135 @@ source product.
41414242*/
4343using System ;
44+ using System . IO ;
4445using iText . Html2pdf ;
46+ using iText . IO . Util ;
47+ using iText . Kernel . Geom ;
48+ using iText . Kernel . Pdf ;
49+ using iText . Kernel . Utils ;
4550
4651namespace iText . Html2pdf . Css {
4752 public class OverflowTest : ExtendedHtmlConversionITextTest {
48- public static readonly String sourceFolder = iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
53+ public static readonly String SOURCE_FOLDER = iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
4954 . CurrentContext . TestDirectory ) + "/resources/itext/html2pdf/css/OverflowTest/" ;
5055
51- public static readonly String destinationFolder = NUnit . Framework . TestContext . CurrentContext . TestDirectory
56+ public static readonly String DESTINATION_FOLDER = NUnit . Framework . TestContext . CurrentContext . TestDirectory
5257 + "/test/itext/html2pdf/css/OverflowTest/" ;
5358
5459 [ NUnit . Framework . OneTimeSetUp ]
5560 public static void BeforeClass ( ) {
56- CreateDestinationFolder ( destinationFolder ) ;
61+ CreateDestinationFolder ( DESTINATION_FOLDER ) ;
5762 }
5863
5964 [ NUnit . Framework . Test ]
60- public virtual void OverflowTest04 ( ) {
61- ConvertToPdfAndCompare ( "overflowTest04 " , sourceFolder , destinationFolder ) ;
65+ public virtual void DivOverflowXOverflowYHiddenTest ( ) {
66+ ConvertToPdfAndCompare ( "divOverflowXOverflowYHidden " , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
6267 }
6368
6469 [ NUnit . Framework . Test ]
65- public virtual void OverflowTest06 ( ) {
66- ConvertToPdfAndCompare ( "overflowTest06 " , sourceFolder , destinationFolder ) ;
70+ public virtual void ParagraphOverflowVisibleTest ( ) {
71+ ConvertToPdfAndCompare ( "paragraphOverflowVisible " , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
6772 }
6873
6974 [ NUnit . Framework . Test ]
70- public virtual void OverflowTest07 ( ) {
71- ConvertToPdfAndCompare ( "overflowTest07" , sourceFolder , destinationFolder ) ;
75+ public virtual void DivOverflowHiddenParagraphOverflowVisibleTest ( ) {
76+ ConvertToPdfAndCompare ( "divOverflowHiddenParagraphOverflowVisible" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
77+ }
78+
79+ [ NUnit . Framework . Test ]
80+ public virtual void DivOverflowXOverflowYVisibleTest ( ) {
81+ ConvertToPdfAndCompare ( "divOverflowXOverflowYVisible" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
82+ }
83+
84+ [ NUnit . Framework . Test ]
85+ public virtual void TableOverflowXOverflowYVisibleTest ( ) {
86+ ConvertToPdfAndCompare ( "tableOverflowXOverflowYVisible" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
87+ }
88+
89+ [ NUnit . Framework . Test ]
90+ public virtual void ParagraphOverflowXOverflowYVisibleTest ( ) {
91+ //TODO DEVSIX-5208 Overflown content should be placed over the content of backgrounds and borders of other elements
92+ ConvertToPdfAndCompare ( "paragraphOverflowXOverflowYVisible" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
93+ }
94+
95+ [ NUnit . Framework . Test ]
96+ public virtual void UlOverflowXOverflowYVisibleTest ( ) {
97+ //TODO DEVSIX-5208 Overflown content should be placed over the content of backgrounds and borders of other elements
98+ ConvertToPdfAndCompare ( "ulOverflowXOverflowYVisible" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
99+ }
100+
101+ [ NUnit . Framework . Test ]
102+ public virtual void TableOverflowHiddenTest ( ) {
103+ ConvertToPdfAndCompare ( "tableOverflowHidden" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
104+ }
105+
106+ [ NUnit . Framework . Test ]
107+ public virtual void DivOverflowScrollTest ( ) {
108+ ConvertToPdfAndCompare ( "divOverflowScroll" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
109+ }
110+
111+ [ NUnit . Framework . Test ]
112+ public virtual void DivOverflowAutoTest ( ) {
113+ ConvertToPdfAndCompare ( "divOverflowAuto" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
114+ }
115+
116+ [ NUnit . Framework . Test ]
117+ public virtual void OverflowVisibleContentShouldBeSplitBetweenPagesTest ( ) {
118+ //TODO DEVSIX-5211 Overflown due to 'overflow: visible' content should be wrapped to the next page
119+ ConvertToPdfAndCompare ( "overflowVisibleContentShouldBeSplitBetweenPages" , SOURCE_FOLDER , DESTINATION_FOLDER
120+ ) ;
72121 }
73122
74123 [ NUnit . Framework . Test ]
75124 public virtual void OverflowAndAlignment01 ( ) {
76- ConvertToPdfAndCompare ( "overflowAndAlignment01" , sourceFolder , destinationFolder ) ;
125+ ConvertToPdfAndCompare ( "overflowAndAlignment01" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
77126 }
78127
79128 [ NUnit . Framework . Test ]
80129 public virtual void OverflowAndAlignment02 ( ) {
81- ConvertToPdfAndCompare ( "overflowAndAlignment02" , sourceFolder , destinationFolder ) ;
130+ ConvertToPdfAndCompare ( "overflowAndAlignment02" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
82131 }
83132
84133 [ NUnit . Framework . Test ]
85134 public virtual void DisplayOverflowAutoScroll ( ) {
86- ConvertToPdfAndCompare ( "displayOverflowAutoScroll" , sourceFolder , destinationFolder ) ;
135+ ConvertToPdfAndCompare ( "displayOverflowAutoScroll" , SOURCE_FOLDER , DESTINATION_FOLDER ) ;
136+ }
137+
138+ [ NUnit . Framework . Test ]
139+ public virtual void OverflowYVisibleOverflowXAllValuesTest ( ) {
140+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
141+ RunTest ( "overflowYVisibleOverflowXAllValues" , new PageSize ( 1200 , 1400 ) ) ;
142+ }
143+
144+ [ NUnit . Framework . Test ]
145+ public virtual void OverflowYHiddenOverflowXAllValuesTest ( ) {
146+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
147+ RunTest ( "overflowYHiddenOverflowXAllValues" , new PageSize ( 1200 , 1400 ) ) ;
148+ }
149+
150+ [ NUnit . Framework . Test ]
151+ public virtual void OverflowYScrollOverflowXAllValuesTest ( ) {
152+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
153+ RunTest ( "overflowYScrollOverflowXAllValues" , new PageSize ( 1200 , 1400 ) ) ;
154+ }
155+
156+ [ NUnit . Framework . Test ]
157+ public virtual void OverflowYAutoOverflowXAllValues ( ) {
158+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
159+ RunTest ( "overflowYAutoOverflowXAllValues" , new PageSize ( 1200 , 1400 ) ) ;
160+ }
161+
162+ private void RunTest ( String testName , PageSize pageSize ) {
163+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( DESTINATION_FOLDER + testName + ".pdf" ) ) ;
164+ if ( null != pageSize ) {
165+ pdfDocument . SetDefaultPageSize ( pageSize ) ;
166+ }
167+ HtmlConverter . ConvertToPdf ( new FileStream ( SOURCE_FOLDER + testName + ".html" , FileMode . Open , FileAccess . Read
168+ ) , pdfDocument , new ConverterProperties ( ) . SetBaseUri ( SOURCE_FOLDER ) ) ;
169+ System . Console . Out . WriteLine ( "html: " + UrlUtil . GetNormalizedFileUriString ( SOURCE_FOLDER + testName + ".html"
170+ ) + "\n " ) ;
171+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( DESTINATION_FOLDER + testName + ".pdf" , SOURCE_FOLDER
172+ + "cmp_" + testName + ".pdf" , DESTINATION_FOLDER , "diff_" + testName ) ) ;
87173 }
88174 }
89175}
0 commit comments