From cd77272091df53874f1df2384cf061b136063277 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Sat, 22 Jul 2023 07:52:42 +0100 Subject: [PATCH] Add test for GridView row layout - Relates #805 --- .../component/view/control/GridViewTests.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/spring-shell-core/src/test/java/org/springframework/shell/component/view/control/GridViewTests.java b/spring-shell-core/src/test/java/org/springframework/shell/component/view/control/GridViewTests.java index ff2d7294..285d568e 100644 --- a/spring-shell-core/src/test/java/org/springframework/shell/component/view/control/GridViewTests.java +++ b/spring-shell-core/src/test/java/org/springframework/shell/component/view/control/GridViewTests.java @@ -321,6 +321,54 @@ class GridViewTests extends AbstractViewTests { verify(sbox3, never()).setRect(anyInt(), anyInt(), anyInt(), anyInt()); } + @Test + void widthHides_2_base() { + BoxView sbox1 = spy(new BoxView()); + BoxView sbox2 = spy(new BoxView()); + BoxView sbox3 = spy(new BoxView()); + + GridView grid = new GridView(); + grid.setRowSize(0, 0, 0); + grid.setColumnSize(0); + + grid.addItem(sbox1, 0, 0, 1, 1, 0, 0); + grid.addItem(sbox2, 1, 0, 1, 1, 0, 0); + grid.addItem(sbox3, 2, 0, 1, 1, 0, 0); + + grid.setRect(0, 0, 80, 24); + grid.draw(screen24x80); + + verify(sbox1).setRect(0, 0, 80, 8); + verify(sbox2).setRect(0, 8, 80, 8); + verify(sbox3).setRect(0, 16, 80, 8); + } + + @Test + void widthHides_2_shouldHide() { + BoxView sbox1 = spy(new BoxView()); + BoxView sbox2 = spy(new BoxView()); + BoxView sbox3 = spy(new BoxView()); + + GridView grid = new GridView(); + grid.setRowSize(0, 0, 0); + grid.setColumnSize(0); + + grid.addItem(sbox1, 0, 0, 0, 1, 0, 0); + grid.addItem(sbox2, 0, 0, 3, 1, 0, 0); + grid.addItem(sbox3, 2, 0, 0, 1, 0, 0); + + grid.addItem(sbox1, 0, 0, 1, 1, 100, 0); + grid.addItem(sbox2, 1, 0, 1, 1, 100, 0); + grid.addItem(sbox3, 2, 0, 1, 1, 100, 0); + + grid.setRect(0, 0, 80, 24); + grid.draw(screen24x80); + + verify(sbox1, never()).setRect(anyInt(), anyInt(), anyInt(), anyInt()); + verify(sbox2).setRect(0, 0, 80, 24); + verify(sbox3, never()).setRect(anyInt(), anyInt(), anyInt(), anyInt()); + } + } @Nested