Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
The size() test was testing a special case of a round rect being
exactly an oval. The test was technically correct and passing but
somehwat misleading.
  • Loading branch information
romainguy committed Sep 6, 2022
1 parent b550425 commit a67b5de
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,11 @@ class PathIteratorTest {
@Test
fun convertedConics() {
val path1 = Path().apply {
addRoundRect(12.0f, 12.0f, 64.0f, 64.0f, 12.0f, 12.0f, Path.Direction.CW)
addRoundRect(RectF(12.0f, 12.0f, 64.0f, 64.0f), 12.0f, 12.0f, Path.Direction.CW)
}

val path2 = Path()
for (segment in path1) {
android.util.Log.d("Test", "$segment")
when (segment.type) {
PathSegment.Type.Move -> path2.moveTo(segment.points[0].x, segment.points[0].y)
PathSegment.Type.Line -> path2.lineTo(segment.points[1].x, segment.points[1].y)
Expand Down Expand Up @@ -430,18 +429,18 @@ class PathIteratorTest {
@Test
fun sizes() {
val path = Path().apply {
addRoundRect(12.0f, 12.0f, 24.0f, 24.0f, 8.0f, 8.0f, Path.Direction.CW)
addRoundRect(RectF(12.0f, 12.0f, 64.0f, 64.0f), 8.0f, 8.0f, Path.Direction.CW)
}

// Preserve conics and count
var iterator = path.iterator(PathIterator.ConicEvaluation.AsConic)
assertEquals(6, iterator.rawSize())
assertEquals(10, iterator.rawSize())
assertEquals(iterator.rawSize(), iterator.size())

// Convert conics and count
iterator = path.iterator(PathIterator.ConicEvaluation.AsQuadratics)
assertEquals(6, iterator.rawSize())
assertEquals(10, iterator.size())
assertEquals(10, iterator.rawSize())
assertEquals(14, iterator.size())
}
}

Expand Down

0 comments on commit a67b5de

Please sign in to comment.