|
21 | 21 | import org.springframework.shell.component.view.screen.DefaultScreen;
|
22 | 22 |
|
23 | 23 | import static org.assertj.core.api.Assertions.assertThat;
|
| 24 | +import static org.mockito.Mockito.never; |
24 | 25 | import static org.mockito.Mockito.spy;
|
25 | 26 | import static org.mockito.Mockito.verify;
|
26 | 27 |
|
@@ -88,6 +89,182 @@ void positionsWith1x2() {
|
88 | 89 | verify(sbox2).setRect(0, 12, 80, 12);
|
89 | 90 | }
|
90 | 91 |
|
| 92 | + @Test |
| 93 | + void positionsWith3x3() { |
| 94 | + BoxView box1 = new BoxView(); |
| 95 | + BoxView box2 = new BoxView(); |
| 96 | + BoxView box3 = new BoxView(); |
| 97 | + BoxView box4 = new BoxView(); |
| 98 | + BoxView box5 = new BoxView(); |
| 99 | + BoxView box6 = new BoxView(); |
| 100 | + BoxView box7 = new BoxView(); |
| 101 | + BoxView box8 = new BoxView(); |
| 102 | + BoxView box9 = new BoxView(); |
| 103 | + BoxView sbox1 = spy(box1); |
| 104 | + BoxView sbox2 = spy(box2); |
| 105 | + BoxView sbox3 = spy(box3); |
| 106 | + BoxView sbox4 = spy(box4); |
| 107 | + BoxView sbox5 = spy(box5); |
| 108 | + BoxView sbox6 = spy(box6); |
| 109 | + BoxView sbox7 = spy(box7); |
| 110 | + BoxView sbox8 = spy(box8); |
| 111 | + BoxView sbox9 = spy(box9); |
| 112 | + GridView grid = new GridView(); |
| 113 | + |
| 114 | + grid.setShowBorders(false); |
| 115 | + grid.setRowSize(0, 0, 0); |
| 116 | + grid.setColumnSize(0, 0, 0); |
| 117 | + grid.setShowBorder(false); |
| 118 | + |
| 119 | + grid.addItem(sbox1, 0, 0, 1, 1, 0, 0); |
| 120 | + grid.addItem(sbox2, 0, 1, 1, 1, 0, 0); |
| 121 | + grid.addItem(sbox3, 0, 2, 1, 1, 0, 0); |
| 122 | + |
| 123 | + grid.addItem(sbox4, 1, 0, 1, 1, 0, 0); |
| 124 | + grid.addItem(sbox5, 1, 1, 1, 1, 0, 0); |
| 125 | + grid.addItem(sbox6, 1, 2, 1, 1, 0, 0); |
| 126 | + |
| 127 | + grid.addItem(sbox7, 2, 0, 1, 1, 0, 0); |
| 128 | + grid.addItem(sbox8, 2, 1, 1, 1, 0, 0); |
| 129 | + grid.addItem(sbox9, 2, 2, 1, 1, 0, 0); |
| 130 | + |
| 131 | + grid.setRect(0, 0, 80, 24); |
| 132 | + grid.draw(screen24x80); |
| 133 | + |
| 134 | + verify(sbox1).setRect(0, 0, 26, 8); |
| 135 | + verify(sbox2).setRect(26, 0, 27, 8); |
| 136 | + verify(sbox3).setRect(53, 0, 27, 8); |
| 137 | + verify(sbox4).setRect(0, 8, 26, 8); |
| 138 | + verify(sbox5).setRect(26, 8, 27, 8); |
| 139 | + verify(sbox6).setRect(53, 8, 27, 8); |
| 140 | + verify(sbox7).setRect(0, 16, 26, 8); |
| 141 | + verify(sbox8).setRect(26, 16, 27, 8); |
| 142 | + verify(sbox9).setRect(53, 16, 27, 8); |
| 143 | + } |
| 144 | + |
| 145 | + @Test |
| 146 | + void minimumWidthWith3x3_1() { |
| 147 | + BoxView box1 = new BoxView(); |
| 148 | + BoxView box2 = new BoxView(); |
| 149 | + BoxView box3 = new BoxView(); |
| 150 | + BoxView box4 = new BoxView(); |
| 151 | + BoxView box5 = new BoxView(); |
| 152 | + BoxView sbox1 = spy(box1); |
| 153 | + BoxView sbox2 = spy(box2); |
| 154 | + BoxView sbox3 = spy(box3); |
| 155 | + BoxView sbox4 = spy(box4); |
| 156 | + BoxView sbox5 = spy(box5); |
| 157 | + GridView grid = new GridView(); |
| 158 | + |
| 159 | + grid.setShowBorders(false); |
| 160 | + grid.setRowSize(0); |
| 161 | + grid.setColumnSize(30, 10, -1, -1, -2); |
| 162 | + grid.setShowBorder(false); |
| 163 | + |
| 164 | + grid.addItem(sbox1, 0, 0, 1, 1, 0, 0); |
| 165 | + grid.addItem(sbox2, 0, 1, 1, 1, 0, 0); |
| 166 | + grid.addItem(sbox3, 0, 2, 1, 1, 0, 0); |
| 167 | + grid.addItem(sbox4, 0, 3, 1, 1, 0, 0); |
| 168 | + grid.addItem(sbox5, 0, 4, 1, 1, 0, 0); |
| 169 | + |
| 170 | + grid.setRect(0, 0, 100, 100); |
| 171 | + grid.draw(screen24x80); |
| 172 | + |
| 173 | + verify(sbox1).setRect(0, 0, 30, 100); |
| 174 | + verify(sbox2).setRect(30, 0, 10, 100); |
| 175 | + verify(sbox3).setRect(40, 0, 15, 100); |
| 176 | + verify(sbox4).setRect(55, 0, 15, 100); |
| 177 | + verify(sbox5).setRect(70, 0, 30, 100); |
| 178 | + } |
| 179 | + |
| 180 | + @Test |
| 181 | + void minimumWidthWith3x3_2() { |
| 182 | + BoxView box1 = new BoxView(); |
| 183 | + BoxView box2 = new BoxView(); |
| 184 | + BoxView box3 = new BoxView(); |
| 185 | + BoxView box4 = new BoxView(); |
| 186 | + BoxView box5 = new BoxView(); |
| 187 | + BoxView box6 = new BoxView(); |
| 188 | + BoxView box7 = new BoxView(); |
| 189 | + BoxView sbox1 = spy(box1); |
| 190 | + BoxView sbox2 = spy(box2); |
| 191 | + BoxView sbox3 = spy(box3); |
| 192 | + BoxView sbox4 = spy(box4); |
| 193 | + BoxView sbox5 = spy(box5); |
| 194 | + BoxView sbox6 = spy(box6); |
| 195 | + BoxView sbox7 = spy(box7); |
| 196 | + GridView grid = new GridView(); |
| 197 | + |
| 198 | + grid.setShowBorders(false); |
| 199 | + grid.setRowSize(0); |
| 200 | + grid.setColumnSize(30, 10, -1, -1, -2); |
| 201 | + grid.setShowBorder(false); |
| 202 | + |
| 203 | + grid.addItem(sbox1, 0, 0, 1, 1, 0, 0); |
| 204 | + grid.addItem(sbox2, 0, 1, 1, 1, 0, 0); |
| 205 | + grid.addItem(sbox3, 0, 2, 1, 1, 0, 0); |
| 206 | + grid.addItem(sbox4, 0, 3, 1, 1, 0, 0); |
| 207 | + grid.addItem(sbox5, 0, 4, 1, 1, 0, 0); |
| 208 | + grid.addItem(sbox6, 0, 5, 1, 1, 0, 0); |
| 209 | + grid.addItem(sbox7, 0, 6, 1, 1, 0, 0); |
| 210 | + |
| 211 | + grid.setRect(0, 0, 100, 100); |
| 212 | + grid.draw(screen24x80); |
| 213 | + |
| 214 | + verify(sbox1).setRect(0, 0, 30, 100); |
| 215 | + verify(sbox2).setRect(30, 0, 10, 100); |
| 216 | + verify(sbox3).setRect(40, 0, 10, 100); |
| 217 | + verify(sbox4).setRect(50, 0, 10, 100); |
| 218 | + verify(sbox5).setRect(60, 0, 20, 100); |
| 219 | + verify(sbox6).setRect(80, 0, 10, 100); |
| 220 | + verify(sbox7).setRect(90, 0, 10, 100); |
| 221 | + } |
| 222 | + |
| 223 | + @Test |
| 224 | + void minimumWidthWith3x3_3() { |
| 225 | + BoxView box1 = new BoxView(); |
| 226 | + BoxView box2 = new BoxView(); |
| 227 | + BoxView box3 = new BoxView(); |
| 228 | + BoxView box4 = new BoxView(); |
| 229 | + BoxView box5 = new BoxView(); |
| 230 | + BoxView box6 = new BoxView(); |
| 231 | + BoxView box7 = new BoxView(); |
| 232 | + BoxView sbox1 = spy(box1); |
| 233 | + BoxView sbox2 = spy(box2); |
| 234 | + BoxView sbox3 = spy(box3); |
| 235 | + BoxView sbox4 = spy(box4); |
| 236 | + BoxView sbox5 = spy(box5); |
| 237 | + BoxView sbox6 = spy(box6); |
| 238 | + BoxView sbox7 = spy(box7); |
| 239 | + GridView grid = new GridView(); |
| 240 | + |
| 241 | + grid.setShowBorders(false); |
| 242 | + grid.setRowSize(0); |
| 243 | + grid.setColumnSize(30, 10, -1, -1, -2); |
| 244 | + grid.setShowBorder(false); |
| 245 | + |
| 246 | + grid.addItem(sbox1, 0, 0, 1, 1, 0, 0); |
| 247 | + grid.addItem(sbox2, 0, 1, 1, 1, 0, 0); |
| 248 | + grid.addItem(sbox3, 0, 2, 1, 1, 0, 0); |
| 249 | + grid.addItem(sbox4, 0, 3, 1, 1, 0, 0); |
| 250 | + grid.addItem(sbox5, 0, 4, 1, 1, 0, 0); |
| 251 | + grid.addItem(sbox6, 0, 5, 1, 1, 0, 0); |
| 252 | + grid.addItem(sbox7, 0, 6, 1, 1, 0, 0); |
| 253 | + |
| 254 | + grid.setRect(0, 0, 100, 100); |
| 255 | + grid.setMinSize(15, 20); |
| 256 | + grid.draw(screen24x80); |
| 257 | + |
| 258 | + verify(sbox1).setRect(0, 0, 30, 100); |
| 259 | + verify(sbox2).setRect(30, 0, 15, 100); |
| 260 | + verify(sbox3).setRect(45, 0, 15, 100); |
| 261 | + verify(sbox4).setRect(60, 0, 15, 100); |
| 262 | + verify(sbox5).setRect(75, 0, 18, 100); |
| 263 | + verify(sbox6).setRect(93, 0, 7, 100); |
| 264 | + // last one outside should not get called |
| 265 | + verify(sbox7, never()).setRect(0, 0, 0, 0); |
| 266 | + } |
| 267 | + |
91 | 268 | }
|
92 | 269 |
|
93 | 270 | @Nested
|
|
0 commit comments