@@ -802,6 +802,76 @@ public virtual void CollapsingMarginsFlexContainerTest() {
802802 , "diff" ) ) ;
803803 }
804804
805+ [ NUnit . Framework . Test ]
806+ public virtual void FlexItemBoxSizingTest ( ) {
807+ String outFileName = destinationFolder + "flexItemBoxSizingTest" + comparisonPdfId + ".pdf" ;
808+ String cmpFileName = sourceFolder + "cmp_flexItemBoxSizingTest" + comparisonPdfId + ".pdf" ;
809+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
810+ Document document = new Document ( pdfDocument ) ;
811+ Div flexContainer = CreateFlexContainer ( ) ;
812+ flexContainer . SetProperty ( Property . BORDER , new SolidBorder ( ColorConstants . BLUE , 30 ) ) ;
813+ flexContainer . SetProperty ( Property . BACKGROUND , new Background ( ColorConstants . LIGHT_GRAY ) ) ;
814+ flexContainer . SetWidth ( 450 ) ;
815+ flexContainer . SetHeight ( 200 ) ;
816+ Div innerDiv = new Div ( ) ;
817+ innerDiv . SetWidth ( 120 ) ;
818+ innerDiv . SetHeight ( 120 ) ;
819+ innerDiv . SetProperty ( Property . BOX_SIZING , BoxSizingPropertyValue . BORDER_BOX ) ;
820+ innerDiv . SetProperty ( Property . BACKGROUND , new Background ( ColorConstants . GREEN ) ) ;
821+ innerDiv . SetBorder ( new SolidBorder ( ColorConstants . RED , 20 ) ) ;
822+ innerDiv . SetProperty ( Property . FLEX_GROW , 0.3F ) ;
823+ Div innerDiv2 = new Div ( ) ;
824+ innerDiv2 . SetProperty ( Property . FLEX_BASIS , UnitValue . CreatePointValue ( 120 ) ) ;
825+ innerDiv2 . SetProperty ( Property . BOX_SIZING , BoxSizingPropertyValue . BORDER_BOX ) ;
826+ innerDiv2 . SetProperty ( Property . BACKGROUND , new Background ( ColorConstants . GREEN ) ) ;
827+ innerDiv2 . SetBorder ( new SolidBorder ( ColorConstants . RED , 20 ) ) ;
828+ innerDiv2 . SetProperty ( Property . FLEX_GROW , 0.3F ) ;
829+ Div innerDiv3 = new Div ( ) ;
830+ innerDiv3 . SetProperty ( Property . BOX_SIZING , BoxSizingPropertyValue . BORDER_BOX ) ;
831+ innerDiv3 . SetProperty ( Property . BACKGROUND , new Background ( ColorConstants . GREEN ) ) ;
832+ innerDiv3 . SetBorder ( new SolidBorder ( ColorConstants . RED , 20 ) ) ;
833+ Div innerDivChild = new Div ( ) . SetBorder ( new SolidBorder ( ColorConstants . ORANGE , 10 ) ) . SetBackgroundColor ( ColorConstants
834+ . PINK ) . SetWidth ( 50 ) . SetHeight ( 50 ) ;
835+ innerDivChild . SetProperty ( Property . BOX_SIZING , BoxSizingPropertyValue . BORDER_BOX ) ;
836+ innerDiv . Add ( innerDivChild ) ;
837+ innerDiv2 . Add ( innerDivChild ) ;
838+ innerDiv3 . Add ( innerDivChild ) ;
839+ Div divToCompare = new Div ( ) . SetWidth ( 450 ) . SetHeight ( 100 ) . SetBackgroundColor ( ColorConstants . MAGENTA ) . SetMarginTop
840+ ( 50 ) ;
841+ flexContainer . Add ( innerDiv ) . Add ( innerDiv2 ) . Add ( innerDiv3 ) ;
842+ document . Add ( flexContainer ) . Add ( divToCompare ) ;
843+ document . Close ( ) ;
844+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
845+ , "diff" ) ) ;
846+ }
847+
848+ [ NUnit . Framework . Test ]
849+ public virtual void FlexContainerBoxSizingTest ( ) {
850+ String outFileName = destinationFolder + "flexContainerBoxSizingTest" + comparisonPdfId + ".pdf" ;
851+ String cmpFileName = sourceFolder + "cmp_flexContainerBoxSizingTest" + comparisonPdfId + ".pdf" ;
852+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
853+ Document document = new Document ( pdfDocument ) ;
854+ Div flexContainer = CreateFlexContainer ( ) ;
855+ flexContainer . SetProperty ( Property . BORDER , new SolidBorder ( ColorConstants . BLUE , 30 ) ) ;
856+ flexContainer . SetProperty ( Property . BACKGROUND , new Background ( ColorConstants . LIGHT_GRAY ) ) ;
857+ flexContainer . SetWidth ( 450 ) ;
858+ flexContainer . SetProperty ( Property . BOX_SIZING , BoxSizingPropertyValue . BORDER_BOX ) ;
859+ Div innerDiv = new Div ( ) ;
860+ innerDiv . SetWidth ( 120 ) ;
861+ Div innerDivChild = new Div ( ) . SetBorder ( new SolidBorder ( ColorConstants . ORANGE , 10 ) ) . SetBackgroundColor ( ColorConstants
862+ . PINK ) . SetWidth ( 100 ) . SetHeight ( 100 ) ;
863+ innerDiv . Add ( innerDivChild ) ;
864+ innerDiv . SetProperty ( Property . BACKGROUND , new Background ( ColorConstants . GREEN ) ) ;
865+ innerDiv . SetBorder ( new SolidBorder ( ColorConstants . RED , 20 ) ) ;
866+ Div divToCompare = new Div ( ) . SetWidth ( 450 ) . SetHeight ( 100 ) . SetBackgroundColor ( ColorConstants . MAGENTA ) . SetMarginTop
867+ ( 50 ) ;
868+ flexContainer . Add ( innerDiv ) . Add ( CreateNewDiv ( ) ) ;
869+ document . Add ( flexContainer ) . Add ( divToCompare ) ;
870+ document . Close ( ) ;
871+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
872+ , "diff" ) ) ;
873+ }
874+
805875 private Div GetFlexContainer ( OverflowPropertyValue ? overflowX , Style style ) {
806876 FlexContainer flexContainer = CreateFlexContainer ( ) ;
807877 flexContainer . SetBackgroundColor ( ColorConstants . GREEN ) . SetBorderRight ( new SolidBorder ( 60 ) ) ;
0 commit comments