From cdd783822e90632f2586a7e0dc8ccd55b284101e Mon Sep 17 00:00:00 2001 From: Jaewoong Cheon Date: Sun, 16 Jul 2023 00:25:37 +0900 Subject: [PATCH] Refactor various children size test code --- .../kotlin/io/woong/compose/grid/GridTest.kt | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/grid/src/androidAndroidTest/kotlin/io/woong/compose/grid/GridTest.kt b/grid/src/androidAndroidTest/kotlin/io/woong/compose/grid/GridTest.kt index 7621f2c..7ba5d6a 100644 --- a/grid/src/androidAndroidTest/kotlin/io/woong/compose/grid/GridTest.kt +++ b/grid/src/androidAndroidTest/kotlin/io/woong/compose/grid/GridTest.kt @@ -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 @@ -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 @@ -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 @@ -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