Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Jun 1, 2024
2 parents 316a3c2 + b15d4e0 commit 6c2acbb
Show file tree
Hide file tree
Showing 21 changed files with 949 additions and 895 deletions.
162 changes: 104 additions & 58 deletions itext.tests/itext.layout.tests/itext/layout/element/GridContainerTest.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ public virtual void EmptyGridContainerTest() {
GridContainer gridcontainer0 = new GridContainer();
gridcontainer0.SetProperty(Property.COLUMN_GAP_BORDER, null);
gridcontainer0.SetBackgroundColor(ColorConstants.RED);
gridcontainer0.SetProperty(Property.GRID_TEMPLATE_COLUMNS, JavaUtil.ArraysAsList(GridValue.CreateUnitValue
(new UnitValue(1, 150.0f)), GridValue.CreateUnitValue(new UnitValue(1, 150.0f)), GridValue.CreateUnitValue
(new UnitValue(1, 150.0f))));
gridcontainer0.SetProperty(Property.GRID_TEMPLATE_COLUMNS, JavaUtil.ArraysAsList(GridValue.CreatePointValue
(150.0f), GridValue.CreatePointValue(150.0f), GridValue.CreatePointValue(150.0f)));
gridcontainer0.SetProperty(Property.COLUMN_GAP, 12.0f);
document.Add(gridcontainer0);
document.Close();
Expand All @@ -166,9 +165,8 @@ public virtual void OverflowGridContainerTest() {
Document document = new Document(pdfDocument);
GridContainer gridcontainer0 = CreateGridBoxWithText();
gridcontainer0.SetBackgroundColor(ColorConstants.MAGENTA);
gridcontainer0.SetProperty(Property.GRID_TEMPLATE_ROWS, JavaUtil.ArraysAsList(GridValue.CreateUnitValue(new
UnitValue(1, 500.0f)), GridValue.CreateUnitValue(new UnitValue(1, 500.0f)), GridValue.CreateUnitValue(
new UnitValue(1, 500.0f))));
gridcontainer0.SetProperty(Property.GRID_TEMPLATE_ROWS, JavaUtil.ArraysAsList(GridValue.CreatePointValue(500.0f
), GridValue.CreatePointValue(500.0f), GridValue.CreatePointValue(500.0f)));
gridcontainer0.Add(new iText.Layout.Element.Image(ImageDataFactory.Create(SOURCE_FOLDER + "rock_texture.jpg"
)).SetHeight(150));
document.Add(gridcontainer0);
Expand All @@ -195,9 +193,8 @@ public virtual void NothingResultTest() {
private GridContainer CreateGridBoxWithText() {
GridContainer gridcontainer0 = new GridContainer();
gridcontainer0.SetProperty(Property.COLUMN_GAP_BORDER, null);
gridcontainer0.SetProperty(Property.GRID_TEMPLATE_COLUMNS, JavaUtil.ArraysAsList(GridValue.CreateUnitValue
(new UnitValue(1, 150.0f)), GridValue.CreateUnitValue(new UnitValue(1, 150.0f)), GridValue.CreateUnitValue
(new UnitValue(1, 150.0f))));
gridcontainer0.SetProperty(Property.GRID_TEMPLATE_COLUMNS, JavaUtil.ArraysAsList(GridValue.CreatePointValue
(150.0f), GridValue.CreatePointValue(150.0f), GridValue.CreatePointValue(150.0f)));
gridcontainer0.SetProperty(Property.COLUMN_GAP, 12.0f);
Div div1 = new Div();
div1.SetBackgroundColor(ColorConstants.YELLOW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,37 @@ namespace iText.Layout.Properties {
[NUnit.Framework.Category("UnitTest")]
public class GridValueTest : ExtendedITextTest {
[NUnit.Framework.Test]
public virtual void SizingValueTest() {
GridValue value = GridValue.CreateSizeValue(SizingValue.CreateUnitValue(UnitValue.CreatePointValue(1.3f)));
NUnit.Framework.Assert.AreEqual(GridValue.GridValueType.SIZING, value.GetType());
NUnit.Framework.Assert.AreEqual(1.3f, (float)value.GetAbsoluteValue(), 0.00001);
value = GridValue.CreateSizeValue(SizingValue.CreateUnitValue(UnitValue.CreatePercentValue(30)));
NUnit.Framework.Assert.AreEqual(GridValue.GridValueType.SIZING, value.GetType());
NUnit.Framework.Assert.IsNull(value.GetAbsoluteValue());
NUnit.Framework.Assert.AreEqual(30, value.GetSizingValue().GetUnitValue().GetValue(), 0.00001);
public virtual void UnitValueTest() {
GridValue value = GridValue.CreatePointValue(3.2f);
NUnit.Framework.Assert.IsTrue(value.IsPointValue());
NUnit.Framework.Assert.AreEqual(3.2f, value.GetValue(), 0.00001);
value = GridValue.CreatePercentValue(30f);
NUnit.Framework.Assert.IsTrue(value.IsPercentValue());
NUnit.Framework.Assert.AreEqual(30, value.GetValue(), 0.00001);
}

[NUnit.Framework.Test]
public virtual void UnitValueTest() {
GridValue value = GridValue.CreateUnitValue(UnitValue.CreatePointValue(1.3f));
NUnit.Framework.Assert.AreEqual(GridValue.GridValueType.SIZING, value.GetType());
NUnit.Framework.Assert.AreEqual(1.3f, (float)value.GetAbsoluteValue(), 0.00001);
value = GridValue.CreateUnitValue(UnitValue.CreatePercentValue(30));
NUnit.Framework.Assert.AreEqual(GridValue.GridValueType.SIZING, value.GetType());
NUnit.Framework.Assert.IsNull(value.GetAbsoluteValue());
NUnit.Framework.Assert.AreEqual(30, value.GetSizingValue().GetUnitValue().GetValue(), 0.00001);
public virtual void MinMaxContentTest() {
GridValue value = GridValue.CreateMinContentValue();
NUnit.Framework.Assert.IsTrue(value.IsMinContentValue());
NUnit.Framework.Assert.IsNull(value.GetValue());
value = GridValue.CreateMaxContentValue();
NUnit.Framework.Assert.IsTrue(value.IsMaxContentValue());
NUnit.Framework.Assert.IsNull(value.GetValue());
}

[NUnit.Framework.Test]
public virtual void AutoTest() {
GridValue value = GridValue.CreateAutoValue();
NUnit.Framework.Assert.IsTrue(value.IsAutoValue());
NUnit.Framework.Assert.IsNull(value.GetValue());
}

[NUnit.Framework.Test]
public virtual void FlexValueTest() {
GridValue value = GridValue.CreateFlexValue(1.5f);
NUnit.Framework.Assert.AreEqual(GridValue.GridValueType.FLEX, value.GetType());
NUnit.Framework.Assert.IsNull(value.GetAbsoluteValue());
NUnit.Framework.Assert.AreEqual(1.5f, (float)value.GetFlexValue(), 0.00001);
NUnit.Framework.Assert.IsTrue(value.IsFlexibleValue());
NUnit.Framework.Assert.AreEqual(1.5f, (float)value.GetValue(), 0.00001);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using iText.Kernel.Geom;
using System;
using iText.Layout.Element;
using iText.Layout.Properties;
using iText.Test;
Expand All @@ -29,32 +29,45 @@ namespace iText.Layout.Renderer {
[NUnit.Framework.Category("UnitTest")]
public class GridUnitTest : ExtendedITextTest {
[NUnit.Framework.Test]
public virtual void GetClosestTopNeighborTest() {
public virtual void GetUniqueCellsTest() {
Grid grid = new Grid(3, 3, GridFlow.ROW);
grid.AddCell(new GridCell(new TextRenderer(new Text("One"))));
grid.AddCell(new GridCell(new TextRenderer(new Text("Three"))));
IRenderer value = new TextRenderer(new Text("Two"));
value.SetProperty(Property.GRID_COLUMN_START, 2);
value.SetProperty(Property.GRID_ROW_START, 2);
GridCell cell = new GridCell(value);
IRenderer twoRenderer = new TextRenderer(new Text("Two"));
twoRenderer.SetProperty(Property.GRID_COLUMN_START, 2);
twoRenderer.SetProperty(Property.GRID_COLUMN_END, 4);
GridCell cell = new GridCell(twoRenderer);
grid.AddCell(cell);
NUnit.Framework.Assert.AreEqual(grid.GetRows()[0][0], grid.GetClosestTopNeighbor(cell));
grid.AddCell(new GridCell(new TextRenderer(new Text("Three"))));
grid.AddCell(new GridCell(new TextRenderer(new Text("Four"))));
NUnit.Framework.Assert.AreEqual(4, grid.GetUniqueGridCells(Grid.GridOrder.ROW).Count);
}

[NUnit.Framework.Test]
public virtual void GetClosestLeftNeighborTest() {
public virtual void GetUniqueCellsInColumnTest() {
Grid grid = new Grid(3, 3, GridFlow.ROW);
grid.AddCell(new GridCell(new TextRenderer(new Text("One"))));
IRenderer value = new TextRenderer(new Text("Two"));
value.SetProperty(Property.GRID_COLUMN_START, 2);
value.SetProperty(Property.GRID_ROW_START, 2);
GridCell cell = new GridCell(value);
IRenderer twoRenderer = new TextRenderer(new Text("Two"));
twoRenderer.SetProperty(Property.GRID_ROW_START, 2);
twoRenderer.SetProperty(Property.GRID_ROW_END, 4);
GridCell cell = new GridCell(twoRenderer);
grid.AddCell(cell);
NUnit.Framework.Assert.AreEqual(grid.GetRows()[0][0], grid.GetClosestLeftNeighbor(cell));
grid.AddCell(new GridCell(new TextRenderer(new Text("Three"))));
grid.AddCell(new GridCell(new TextRenderer(new Text("Four"))));
NUnit.Framework.Assert.AreEqual(1, grid.GetUniqueCellsInTrack(Grid.GridOrder.COLUMN, 1).Count);
}

[NUnit.Framework.Test]
public virtual void GetUniqueCellsTest() {
public virtual void InvalidColumnForGetColCellsTest() {
Grid grid = new Grid(3, 3, GridFlow.ROW);
NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => grid.GetUniqueCellsInTrack(Grid.GridOrder
.COLUMN, 4));
NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => grid.GetUniqueCellsInTrack(Grid.GridOrder
.COLUMN, -1));
NUnit.Framework.Assert.DoesNotThrow(() => grid.GetUniqueCellsInTrack(Grid.GridOrder.COLUMN, 2));
}

[NUnit.Framework.Test]
public virtual void GetUniqueCellsInRowTest() {
Grid grid = new Grid(3, 3, GridFlow.ROW);
grid.AddCell(new GridCell(new TextRenderer(new Text("One"))));
IRenderer twoRenderer = new TextRenderer(new Text("Two"));
Expand All @@ -64,50 +77,17 @@ public virtual void GetUniqueCellsTest() {
grid.AddCell(cell);
grid.AddCell(new GridCell(new TextRenderer(new Text("Three"))));
grid.AddCell(new GridCell(new TextRenderer(new Text("Four"))));
NUnit.Framework.Assert.AreEqual(4, grid.GetUniqueGridCells(Grid.GridOrder.ROW).Count);
NUnit.Framework.Assert.AreEqual(2, grid.GetUniqueCellsInTrack(Grid.GridOrder.ROW, 0).Count);
}

[NUnit.Framework.Test]
public virtual void IncreaseRowHeightTest() {
public virtual void InvalidRowForGetRowCellsTest() {
Grid grid = new Grid(3, 3, GridFlow.ROW);
GridCell cell1 = new GridCell(new TextRenderer(new Text("One")));
cell1.SetLayoutArea(new Rectangle(50.0f, 50.0f));
GridCell cell2 = new GridCell(new TextRenderer(new Text("Two")));
cell2.SetLayoutArea(new Rectangle(50.0f, 50.0f));
GridCell cell3 = new GridCell(new TextRenderer(new Text("Three")));
cell3.SetLayoutArea(new Rectangle(50.0f, 50.0f));
grid.AddCell(cell1);
grid.AddCell(cell2);
grid.AddCell(cell3);
grid.AlignRow(0, 100.0f);
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][0].GetLayoutArea().GetHeight(), 0.00001f);
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][1].GetLayoutArea().GetHeight(), 0.00001f);
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][2].GetLayoutArea().GetHeight(), 0.00001f);
}

[NUnit.Framework.Test]
public virtual void IncreaseColumnWidthTest() {
Grid grid = new Grid(3, 3, GridFlow.ROW);
GridCell cell1 = new GridCell(new TextRenderer(new Text("One")));
cell1.SetLayoutArea(new Rectangle(100.0f, 50.0f));
GridCell cell2 = new GridCell(new TextRenderer(new Text("Two")));
cell2.SetLayoutArea(new Rectangle(30.0f, 50.0f));
GridCell cell3 = new GridCell(new TextRenderer(new Text("Three")));
cell3.SetLayoutArea(new Rectangle(50.0f, 50.0f));
GridCell cell4 = new GridCell(new TextRenderer(new Text("Three")));
cell4.SetLayoutArea(new Rectangle(100.0f, 50.0f));
GridCell cell5 = new GridCell(new TextRenderer(new Text("Three")));
cell5.SetLayoutArea(new Rectangle(50.0f, 50.0f));
grid.AddCell(cell1);
grid.AddCell(cell2);
grid.AddCell(cell3);
grid.AddCell(cell4);
grid.AddCell(cell5);
grid.AlignColumn(1, 150.0f);
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][0].GetLayoutArea().GetWidth(), 0.00001f);
NUnit.Framework.Assert.AreEqual(150.0f, grid.GetRows()[0][1].GetLayoutArea().GetWidth(), 0.00001f);
NUnit.Framework.Assert.AreEqual(150.0f, grid.GetRows()[1][1].GetLayoutArea().GetWidth(), 0.00001f);
NUnit.Framework.Assert.AreEqual(50.0f, grid.GetRows()[0][2].GetLayoutArea().GetWidth(), 0.00001f);
NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => grid.GetUniqueCellsInTrack(Grid.GridOrder
.ROW, 4));
NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => grid.GetUniqueCellsInTrack(Grid.GridOrder
.ROW, -1));
NUnit.Framework.Assert.DoesNotThrow(() => grid.GetUniqueCellsInTrack(Grid.GridOrder.ROW, 2));
}

[NUnit.Framework.Test]
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 6c2acbb

Please sign in to comment.