@@ -32,23 +32,61 @@ public virtual void BlocksInsideDiv() {
3232 PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
3333 pdfDocument . SetTagged ( ) ;
3434 Document document = new Document ( pdfDocument ) ;
35+ Div div1 = CreateDiv ( ColorConstants . RED , HorizontalAlignment . CENTER , ClearPropertyValue . BOTH , FloatPropertyValue
36+ . NONE ) ;
37+ Div div2 = CreateDiv ( ColorConstants . BLUE , HorizontalAlignment . LEFT , ClearPropertyValue . BOTH , FloatPropertyValue
38+ . NONE ) ;
39+ Div div3 = CreateDiv ( ColorConstants . GREEN , HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH , FloatPropertyValue
40+ . NONE ) ;
41+ Div divParent1 = CreateParentDiv ( HorizontalAlignment . CENTER , ClearPropertyValue . BOTH , 500 ) ;
42+ divParent1 . Add ( div3 ) ;
43+ divParent1 . Add ( div2 ) ;
44+ divParent1 . Add ( div1 ) ;
45+ document . Add ( divParent1 ) ;
46+ Div divParent2 = CreateParentDiv ( HorizontalAlignment . LEFT , ClearPropertyValue . BOTH , 500 ) ;
47+ divParent2 . Add ( div2 ) ;
48+ divParent2 . Add ( div1 ) ;
49+ divParent2 . Add ( div3 ) ;
50+ document . Add ( divParent2 ) ;
51+ Div divParent3 = CreateParentDiv ( HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH , 500 ) ;
52+ divParent3 . Add ( div1 ) ;
53+ divParent3 . Add ( div2 ) ;
54+ divParent3 . Add ( div3 ) ;
55+ document . Add ( divParent3 ) ;
56+ document . Close ( ) ;
57+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
58+ , "diff01_" ) ) ;
59+ }
60+
61+ /// <exception cref="System.IO.IOException"/>
62+ /// <exception cref="System.Exception"/>
63+ [ NUnit . Framework . Test ]
64+ public virtual void BlocksInsideDivFloat ( ) {
65+ /* this test shows different combinations of 3 float values blocks within divParent containers
66+ */
67+ String testName = "blocksInsideDivFloat" ;
68+ String outFileName = destinationFolder + testName + ".pdf" ;
69+ String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf" ;
70+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
71+ pdfDocument . SetTagged ( ) ;
72+ Document document = new Document ( pdfDocument ) ;
3573 Div div1 = CreateDiv ( ColorConstants . RED , HorizontalAlignment . CENTER , ClearPropertyValue . BOTH , FloatPropertyValue
3674 . NONE ) ;
3775 Div div2 = CreateDiv ( ColorConstants . BLUE , HorizontalAlignment . LEFT , ClearPropertyValue . BOTH , FloatPropertyValue
3876 . RIGHT ) ;
3977 Div div3 = CreateDiv ( ColorConstants . GREEN , HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH , FloatPropertyValue
4078 . LEFT ) ;
41- Div divParent1 = CreateParentDiv ( HorizontalAlignment . CENTER , ClearPropertyValue . BOTH ) ;
79+ Div divParent1 = CreateParentDiv ( HorizontalAlignment . CENTER , ClearPropertyValue . BOTH , 400 ) ;
4280 divParent1 . Add ( div3 ) ;
4381 divParent1 . Add ( div2 ) ;
4482 divParent1 . Add ( div1 ) ;
4583 document . Add ( divParent1 ) ;
46- Div divParent2 = CreateParentDiv ( HorizontalAlignment . LEFT , ClearPropertyValue . BOTH ) ;
84+ Div divParent2 = CreateParentDiv ( HorizontalAlignment . LEFT , ClearPropertyValue . BOTH , 400 ) ;
4785 divParent2 . Add ( div2 ) ;
4886 divParent2 . Add ( div1 ) ;
4987 divParent2 . Add ( div3 ) ;
5088 document . Add ( divParent2 ) ;
51- Div divParent3 = CreateParentDiv ( HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH ) ;
89+ Div divParent3 = CreateParentDiv ( HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH , 400 ) ;
5290 divParent3 . Add ( div1 ) ;
5391 divParent3 . Add ( div2 ) ;
5492 divParent3 . Add ( div3 ) ;
@@ -82,39 +120,80 @@ public virtual void BlocksInsideEachOther() {
82120 . RIGHT ) ;
83121 Div div5 = CreateDiv ( ColorConstants . ORANGE , HorizontalAlignment . LEFT , ClearPropertyValue . NONE , FloatPropertyValue
84122 . LEFT ) ;
85- Div divParent1 = CreateParentDiv ( HorizontalAlignment . CENTER , ClearPropertyValue . BOTH ) ;
123+ Div divParent1 = CreateParentDiv ( HorizontalAlignment . CENTER , ClearPropertyValue . BOTH , 500 ) ;
86124 divParent1 . Add ( div1 ) ;
87125 div1 . Add ( div2 ) ;
88126 div2 . Add ( div3 ) ;
89127 document . Add ( divParent1 ) ;
90- Div divParent2 = CreateParentDiv ( HorizontalAlignment . LEFT , ClearPropertyValue . BOTH ) ;
128+ Div divParent2 = CreateParentDiv ( HorizontalAlignment . LEFT , ClearPropertyValue . BOTH , 500 ) ;
91129 divParent2 . Add ( div4 ) ;
92130 div4 . Add ( div1 ) ;
93131 document . Add ( divParent2 ) ;
94- Div divParent3 = CreateParentDiv ( HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH ) ;
132+ Div divParent3 = CreateParentDiv ( HorizontalAlignment . RIGHT , ClearPropertyValue . BOTH , 500 ) ;
95133 divParent3 . Add ( div5 ) ;
96134 div5 . Add ( div4 ) ;
97135 document . Add ( divParent3 ) ;
98136 document . Close ( ) ;
99137 NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
100- , "diff01_" ) ) ;
138+ , "diff02_" ) ) ;
139+ }
140+
141+ /// <exception cref="System.IO.IOException"/>
142+ /// <exception cref="System.Exception"/>
143+ [ NUnit . Framework . Test ]
144+ public virtual void BlocksNotInDivCenter ( ) {
145+ /* this test shows different combinations of 3 float values blocks
146+ * NOTE, that div1 text is partly overlapped
147+ */
148+ String testName = "blocksNotInDivCenter" ;
149+ String outFileName = destinationFolder + testName + ".pdf" ;
150+ String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf" ;
151+ CreateDocumentWithBlocks ( outFileName , HorizontalAlignment . CENTER ) ;
152+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
153+ , "diff03_" ) ) ;
154+ }
155+
156+ /// <exception cref="System.IO.IOException"/>
157+ /// <exception cref="System.Exception"/>
158+ [ NUnit . Framework . Test ]
159+ public virtual void BlocksNotInDivLeft ( ) {
160+ /* this test shows different combinations of 3 float values blocks
161+ * NOTE, that div1 text is partly overlapped
162+ */
163+ String testName = "blocksNotInDivLeft" ;
164+ String outFileName = destinationFolder + testName + ".pdf" ;
165+ String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf" ;
166+ CreateDocumentWithBlocks ( outFileName , HorizontalAlignment . LEFT ) ;
167+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
168+ , "diff04_" ) ) ;
101169 }
102170
103171 /// <exception cref="System.IO.IOException"/>
104172 /// <exception cref="System.Exception"/>
105173 [ NUnit . Framework . Test ]
106- public virtual void BlocksNotInDiv01 ( ) {
174+ public virtual void BlocksNotInDivRight ( ) {
107175 /* this test shows different combinations of 3 float values blocks
108- * TODO: DEVSIX-1731: div1 text is partly overlapped.
176+ * NOTE, that div1 text is partly overlapped
109177 */
110- String testName = "blocksNotInDiv01 " ;
178+ String testName = "blocksNotInDivRight " ;
111179 String outFileName = destinationFolder + testName + ".pdf" ;
112180 String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf" ;
181+ /*
182+ * Please, NOTE: in current example HorizontalAlignment values are ignored, if FloatPropertyValue !=NONE
183+ * So, only FloatPropertyValue defines the position of element in such cases
184+ */
185+ CreateDocumentWithBlocks ( outFileName , HorizontalAlignment . RIGHT ) ;
186+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
187+ , "diff05_" ) ) ;
188+ }
189+
190+ /// <exception cref="System.IO.FileNotFoundException"/>
191+ private void CreateDocumentWithBlocks ( String outFileName , HorizontalAlignment ? horizontalAlignment ) {
113192 PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
114193 pdfDocument . SetTagged ( ) ;
115194 Document document = new Document ( pdfDocument ) ;
116- Div div1 = CreateDiv ( ColorConstants . RED , HorizontalAlignment . CENTER , ClearPropertyValue . NONE , FloatPropertyValue
117- . NONE ) ;
195+ Div div1 = CreateDiv ( ColorConstants . RED , horizontalAlignment , ClearPropertyValue . NONE , FloatPropertyValue .
196+ NONE ) ;
118197 Div div2 = CreateDiv ( ColorConstants . BLUE , HorizontalAlignment . LEFT , ClearPropertyValue . NONE , FloatPropertyValue
119198 . RIGHT ) ;
120199 Div div3 = CreateDiv ( ColorConstants . GREEN , HorizontalAlignment . RIGHT , ClearPropertyValue . NONE , FloatPropertyValue
@@ -136,8 +215,6 @@ public virtual void BlocksNotInDiv01() {
136215 document . Add ( div1 ) ;
137216 document . Add ( div1 ) ;
138217 document . Close ( ) ;
139- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
140- , "diff01_" ) ) ;
141218 }
142219
143220 /// <exception cref="System.IO.IOException"/>
@@ -188,18 +265,19 @@ public virtual void InlineBlocksAndFloatsWithTextAlignmentTest02() {
188265 }
189266
190267 private Div CreateParentDiv ( HorizontalAlignment ? horizontalAlignment , ClearPropertyValue ? clearPropertyValue
191- ) {
192- Div divParent1 = new Div ( ) . SetBorder ( new SolidBorder ( 5 ) ) ;
193- divParent1 . SetHorizontalAlignment ( HorizontalAlignment . CENTER ) ;
194- divParent1 . SetProperty ( Property . CLEAR , ClearPropertyValue . BOTH ) ;
268+ , float width ) {
269+ Div divParent1 = new Div ( ) . SetBorder ( new SolidBorder ( 5 ) ) . SetWidth ( width ) ;
270+ divParent1 . SetHorizontalAlignment ( horizontalAlignment ) ;
271+ divParent1 . SetProperty ( Property . CLEAR , clearPropertyValue ) ;
195272 divParent1 . Add ( new Paragraph ( "Div with HorizontalAlignment." + horizontalAlignment + ", ClearPropertyValue."
196273 + clearPropertyValue ) ) ;
197274 return divParent1 ;
198275 }
199276
200277 private static Div CreateDiv ( Color color , HorizontalAlignment ? horizontalAlignment , ClearPropertyValue ? clearPropertyValue
201278 , FloatPropertyValue ? floatPropertyValue ) {
202- Div div = new Div ( ) . SetBorder ( new SolidBorder ( color , 1 ) ) . SetMargins ( 10 , 10 , 10 , 10 ) . SetWidth ( 300 ) ;
279+ Div div = new Div ( ) . SetBorder ( new SolidBorder ( color , 1 ) ) . SetBackgroundColor ( color , 0.3f ) . SetMargins ( 10 , 10
280+ , 10 , 10 ) . SetWidth ( 300 ) ;
203281 div . SetHorizontalAlignment ( horizontalAlignment ) ;
204282 div . SetProperty ( Property . CLEAR , clearPropertyValue ) ;
205283 div . SetProperty ( Property . FLOAT , floatPropertyValue ) ;
0 commit comments