Skip to content

Commit

Permalink
Refactor various children size test code
Browse files Browse the repository at this point in the history
  • Loading branch information
cheonjaeung committed Jul 15, 2023
1 parent 7c447c8 commit cdd7838
Showing 1 changed file with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,7 @@ class GridTest {
}

var i = 0
var expectedGridWidth = 0.dp
var expectedGridHeight = 0.dp
for (column in 0 until columnCount) {
var lineWidthMax = 0.dp
var lineHeightSum = 0.dp
for (row in 0 until rowCount) {
if (i < testTags.size) {
composeRule
Expand All @@ -477,19 +473,14 @@ class GridTest {
expectedLeft = 50.dp * column,
expectedTop = 50.dp * row
)

lineWidthMax = max(lineWidthMax, childrenSize[i])
lineHeightSum += childrenSize[i]
i++
}
}
expectedGridWidth += lineWidthMax
expectedGridHeight = max(expectedGridHeight, lineHeightSum)
}
composeRule
.onNode(hasTestTag("grid"))
.assertWidthIsEqualTo(expectedGridWidth)
.assertHeightIsEqualTo(expectedGridHeight)
.assertWidthIsEqualTo(150.dp)
.assertHeightIsEqualTo(150.dp)
}

@Test
Expand Down Expand Up @@ -519,11 +510,7 @@ class GridTest {
}

var i = 0
var expectedGridWidth = 0.dp
var expectedGridHeight = 0.dp
for (row in 0 until rowCount) {
var lineWidthSum = 0.dp
var lineHeightMax = 0.dp
for (column in 0 until columnCount) {
if (i < testTags.size) {
composeRule
Expand All @@ -534,20 +521,15 @@ class GridTest {
expectedLeft = 50.dp * column,
expectedTop = 50.dp * row
)

lineWidthSum += childrenSize[i]
lineHeightMax = max(lineHeightMax, childrenSize[i])
i++
}
}
expectedGridWidth = max(expectedGridWidth, lineWidthSum)
expectedGridHeight += lineHeightMax
}

composeRule
.onNode(hasTestTag("grid"))
.assertWidthIsEqualTo(expectedGridWidth)
.assertHeightIsEqualTo(expectedGridHeight)
.assertWidthIsEqualTo(150.dp)
.assertHeightIsEqualTo(150.dp)
}

@Test
Expand Down

0 comments on commit cdd7838

Please sign in to comment.