@@ -43,6 +43,7 @@ source product.
4343using System ;
4444using System . IO ;
4545using iText . Html2pdf ;
46+ using iText . IO . Util ;
4647using iText . Kernel . Utils ;
4748using iText . Test ;
4849
@@ -59,137 +60,164 @@ public static void BeforeClass() {
5960 CreateDestinationFolder ( destinationFolder ) ;
6061 }
6162
63+ /// <exception cref="System.IO.IOException"/>
64+ /// <exception cref="System.Exception"/>
65+ private void TestWithSuffix ( String testIndex ) {
66+ String htmlFile = sourceFolder + MessageFormatUtil . Format ( "spanTest{0}.html" , testIndex ) ;
67+ String pdfFile = destinationFolder + MessageFormatUtil . Format ( "spanTest{0}.pdf" , testIndex ) ;
68+ String cmpFile = sourceFolder + MessageFormatUtil . Format ( "cmp_spanTest{0}.pdf" , testIndex ) ;
69+ String diff = MessageFormatUtil . Format ( "diff{0}_" , testIndex ) ;
70+ HtmlConverter . ConvertToPdf ( new FileInfo ( htmlFile ) , new FileInfo ( pdfFile ) ) ;
71+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( pdfFile , cmpFile , destinationFolder , diff
72+ ) ) ;
73+ }
74+
75+ /// <exception cref="System.IO.IOException"/>
76+ /// <exception cref="System.Exception"/>
77+ private void Test ( String testName ) {
78+ String htmlFile = sourceFolder + testName + ".html" ;
79+ String pdfFile = destinationFolder + testName + ".pdf" ;
80+ String cmpFile = sourceFolder + MessageFormatUtil . Format ( "cmp_{0}.pdf" , testName ) ;
81+ String diff = MessageFormatUtil . Format ( "diff_{0}_" , testName ) ;
82+ HtmlConverter . ConvertToPdf ( new FileInfo ( htmlFile ) , new FileInfo ( pdfFile ) ) ;
83+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( pdfFile , cmpFile , destinationFolder , diff
84+ ) ) ;
85+ }
86+
6287 /// <exception cref="System.IO.IOException"/>
6388 /// <exception cref="System.Exception"/>
6489 [ NUnit . Framework . Test ]
6590 public virtual void SpanTest01 ( ) {
66- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest01.html" ) , new FileInfo ( destinationFolder
67- + "spanTest01.pdf" ) ) ;
68- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest01.pdf" , sourceFolder
69- + "cmp_spanTest01.pdf" , destinationFolder , "diff01_" ) ) ;
91+ TestWithSuffix ( "01" ) ;
7092 }
7193
7294 /// <exception cref="System.IO.IOException"/>
7395 /// <exception cref="System.Exception"/>
7496 [ NUnit . Framework . Test ]
7597 public virtual void SpanTest02 ( ) {
76- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest02.html" ) , new FileInfo ( destinationFolder
77- + "spanTest02.pdf" ) ) ;
78- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest02.pdf" , sourceFolder
79- + "cmp_spanTest02.pdf" , destinationFolder , "diff02_" ) ) ;
98+ TestWithSuffix ( "02" ) ;
8099 }
81100
82101 /// <exception cref="System.IO.IOException"/>
83102 /// <exception cref="System.Exception"/>
84103 [ NUnit . Framework . Test ]
85104 public virtual void SpanTest03 ( ) {
86- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest03.html" ) , new FileInfo ( destinationFolder
87- + "spanTest03.pdf" ) ) ;
88- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest03.pdf" , sourceFolder
89- + "cmp_spanTest03.pdf" , destinationFolder , "diff03_" ) ) ;
105+ TestWithSuffix ( "03" ) ;
90106 }
91107
92108 /// <exception cref="System.IO.IOException"/>
93109 /// <exception cref="System.Exception"/>
94110 [ NUnit . Framework . Test ]
95111 public virtual void SpanTest04 ( ) {
96- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest04.html" ) , new FileInfo ( destinationFolder
97- + "spanTest04.pdf" ) ) ;
98- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest04.pdf" , sourceFolder
99- + "cmp_spanTest04.pdf" , destinationFolder , "diff04_" ) ) ;
112+ TestWithSuffix ( "04" ) ;
100113 }
101114
102115 /// <exception cref="System.IO.IOException"/>
103116 /// <exception cref="System.Exception"/>
104117 [ NUnit . Framework . Test ]
105118 public virtual void SpanTest05 ( ) {
106- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest05.html" ) , new FileInfo ( destinationFolder
107- + "spanTest05.pdf" ) ) ;
108- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest05.pdf" , sourceFolder
109- + "cmp_spanTest05.pdf" , destinationFolder , "diff05_" ) ) ;
119+ TestWithSuffix ( "05" ) ;
110120 }
111121
112122 /// <exception cref="System.IO.IOException"/>
113123 /// <exception cref="System.Exception"/>
114124 [ NUnit . Framework . Test ]
115125 public virtual void SpanTest06 ( ) {
116- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest06.html" ) , new FileInfo ( destinationFolder
117- + "spanTest06.pdf" ) ) ;
118- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest06.pdf" , sourceFolder
119- + "cmp_spanTest06.pdf" , destinationFolder , "diff06_" ) ) ;
126+ TestWithSuffix ( "06" ) ;
120127 }
121128
122129 /// <exception cref="System.IO.IOException"/>
123130 /// <exception cref="System.Exception"/>
124131 [ NUnit . Framework . Test ]
125132 public virtual void SpanTest07 ( ) {
126- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest07.html" ) , new FileInfo ( destinationFolder
127- + "spanTest07.pdf" ) ) ;
128- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest07.pdf" , sourceFolder
129- + "cmp_spanTest07.pdf" , destinationFolder , "diff07_" ) ) ;
133+ TestWithSuffix ( "07" ) ;
130134 }
131135
132136 /// <exception cref="System.IO.IOException"/>
133137 /// <exception cref="System.Exception"/>
134138 [ NUnit . Framework . Test ]
135139 public virtual void SpanTest08 ( ) {
136140 // TODO DEVSIX-1438
137- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest08.html" ) , new FileInfo ( destinationFolder
138- + "spanTest08.pdf" ) ) ;
139- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest08.pdf" , sourceFolder
140- + "cmp_spanTest08.pdf" , destinationFolder , "diff08_" ) ) ;
141+ TestWithSuffix ( "08" ) ;
141142 }
142143
143144 /// <exception cref="System.IO.IOException"/>
144145 /// <exception cref="System.Exception"/>
145146 [ NUnit . Framework . Test ]
146147 public virtual void SpanTest09 ( ) {
147- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest09.html" ) , new FileInfo ( destinationFolder
148- + "spanTest09.pdf" ) ) ;
149- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest09.pdf" , sourceFolder
150- + "cmp_spanTest09.pdf" , destinationFolder , "diff09_" ) ) ;
148+ TestWithSuffix ( "09" ) ;
151149 }
152150
153151 /// <exception cref="System.IO.IOException"/>
154152 /// <exception cref="System.Exception"/>
155153 [ NUnit . Framework . Test ]
156154 public virtual void SpanTest10 ( ) {
157- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest10.html" ) , new FileInfo ( destinationFolder
158- + "spanTest10.pdf" ) ) ;
159- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest10.pdf" , sourceFolder
160- + "cmp_spanTest10.pdf" , destinationFolder , "diff10_" ) ) ;
155+ TestWithSuffix ( "10" ) ;
161156 }
162157
163158 /// <exception cref="System.IO.IOException"/>
164159 /// <exception cref="System.Exception"/>
165160 [ NUnit . Framework . Test ]
166161 public virtual void SpanTest11 ( ) {
167- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest11.html" ) , new FileInfo ( destinationFolder
168- + "spanTest11.pdf" ) ) ;
169- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest11.pdf" , sourceFolder
170- + "cmp_spanTest11.pdf" , destinationFolder , "diff11_" ) ) ;
162+ TestWithSuffix ( "11" ) ;
171163 }
172164
173165 /// <exception cref="System.IO.IOException"/>
174166 /// <exception cref="System.Exception"/>
175167 [ NUnit . Framework . Test ]
176- [ NUnit . Framework . Ignore ( "DEVSIX-2118" ) ]
177168 public virtual void SpanTest12 ( ) {
178- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest12.html" ) , new FileInfo ( destinationFolder
179- + "spanTest12.pdf" ) ) ;
180- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest12.pdf" , sourceFolder
181- + "cmp_spanTest12.pdf" , destinationFolder , "diff12_" ) ) ;
169+ TestWithSuffix ( "12" ) ;
182170 }
183171
184172 /// <exception cref="System.IO.IOException"/>
185173 /// <exception cref="System.Exception"/>
186174 [ NUnit . Framework . Test ]
187- [ NUnit . Framework . Ignore ( "DEVSIX-2118" ) ]
188175 public virtual void SpanTest13 ( ) {
189- HtmlConverter . ConvertToPdf ( new FileInfo ( sourceFolder + "spanTest13.html" ) , new FileInfo ( destinationFolder
190- + "spanTest13.pdf" ) ) ;
191- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "spanTest13.pdf" , sourceFolder
192- + "cmp_spanTest13.pdf" , destinationFolder , "diff13_" ) ) ;
176+ TestWithSuffix ( "13" ) ;
177+ }
178+
179+ /// <exception cref="System.IO.IOException"/>
180+ /// <exception cref="System.Exception"/>
181+ [ NUnit . Framework . Test ]
182+ public virtual void SpanInsideSpanWithBackgroundTest ( ) {
183+ Test ( "spanInsideSpanWithBackground" ) ;
184+ }
185+
186+ /// <exception cref="System.IO.IOException"/>
187+ /// <exception cref="System.Exception"/>
188+ [ NUnit . Framework . Test ]
189+ public virtual void SpanWithLeftFloatInsideSpanWithBackgroundTest ( ) {
190+ Test ( "spanWithLeftFloatInsideSpanWithBackground" ) ;
191+ }
192+
193+ /// <exception cref="System.IO.IOException"/>
194+ /// <exception cref="System.Exception"/>
195+ [ NUnit . Framework . Test ]
196+ public virtual void SpanWithFloatsInsideSpanWithBackgroundAndFloatTest ( ) {
197+ Test ( "spanWithFloatsInsideSpanWithBackgroundAndFloat" ) ;
198+ }
199+
200+ /// <exception cref="System.IO.IOException"/>
201+ /// <exception cref="System.Exception"/>
202+ [ NUnit . Framework . Test ]
203+ public virtual void CommonNestedSpanTest ( ) {
204+ Test ( "commonNestedSpanTest" ) ;
205+ }
206+
207+ // TODO: update cmp files during DEVSIX-2510
208+ /// <exception cref="System.IO.IOException"/>
209+ /// <exception cref="System.Exception"/>
210+ [ NUnit . Framework . Test ]
211+ public virtual void SpanTestNestedBlock ( ) {
212+ Test ( "spanTestNestedBlock" ) ;
213+ }
214+
215+ // TODO: update cmp files during DEVSIX-2510
216+ /// <exception cref="System.IO.IOException"/>
217+ /// <exception cref="System.Exception"/>
218+ [ NUnit . Framework . Test ]
219+ public virtual void SpanTestNestedInlineBlock ( ) {
220+ Test ( "spanTestNestedInlineBlock" ) ;
193221 }
194222 }
195223}
0 commit comments