Skip to content

Commit a647b15

Browse files
authored
Merge pull request #29 from ITArray/1.4.2-fix-grid-validation
1.4.2 fix grid validation
2 parents 19bd2b4 + ddbd7ba commit a647b15

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/util/validator/ResponsiveUIValidator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.concurrent.ConcurrentHashMap;
26+
import java.util.concurrent.ConcurrentSkipListMap;
2627
import java.util.concurrent.atomic.AtomicLong;
2728

2829
import static environment.EnvironmentFactory.*;
@@ -312,7 +313,7 @@ void validateElementsAreNotOverlapped(List<WebElement> rootElements) {
312313

313314
void validateGridAlignment(int columns, int rows) {
314315
if (rootElements != null) {
315-
ConcurrentHashMap<Integer, AtomicLong> map = new ConcurrentHashMap<>();
316+
ConcurrentSkipListMap<Integer, AtomicLong> map = new ConcurrentSkipListMap<>();
316317
for (WebElement el : rootElements) {
317318
Integer y = el.getLocation().y;
318319

@@ -328,12 +329,16 @@ void validateGridAlignment(int columns, int rows) {
328329
}
329330

330331
if (columns > 0) {
332+
int errorLastLine = 0;
331333
int rowCount = 1;
332334
for (Map.Entry<Integer, AtomicLong> entry : map.entrySet()) {
333335
if (rowCount <= mapSize) {
334336
int actualInARow = entry.getValue().intValue();
335337
if (actualInARow != columns) {
336-
putJsonDetailsWithoutElement(String.format("Elements in a grid are not aligned properly in row #%d. Expected %d elements in a row. Actually it's %d", rowCount, columns, actualInARow));
338+
errorLastLine ++;
339+
if (errorLastLine > 1) {
340+
putJsonDetailsWithoutElement(String.format("Elements in a grid are not aligned properly in row #%d. Expected %d elements in a row. Actually it's %d", rowCount, columns, actualInARow));
341+
}
337342
}
338343
rowCount++;
339344
}

0 commit comments

Comments
 (0)