Skip to content

Commit

Permalink
Add test for correct alpha and color values
Browse files Browse the repository at this point in the history
  • Loading branch information
wasky authored and burhanrashid52 committed Jan 29, 2023
1 parent 94235d9 commit 825fab9
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,48 @@ internal class DrawingViewApiTest : BaseDrawingViewTest() {
assertTrue(drawingView.isDrawingEnabled)
}

@Test
fun testCorrectAlphaAndColorValues() {
val drawingView = setupDrawingView()
val currentShapeBuilder = drawingView.currentShapeBuilder

val shapeOpacity = 120
val colorAlpha1 = 11
val colorAlpha2 = 22

currentShapeBuilder.withShapeColor(Color.argb(colorAlpha1, 33, 44, 55))
touchView(drawingView, MotionEvent.ACTION_DOWN)

drawingView.currentShape!!.paint.also { paint ->
assertEquals(colorAlpha1, paint.alpha)
assertEquals(Color.argb(colorAlpha1, 33, 44, 55), paint.color)
}

currentShapeBuilder.withShapeOpacity(shapeOpacity)
touchView(drawingView, MotionEvent.ACTION_DOWN)

drawingView.currentShape!!.paint.also { paint ->
assertEquals(shapeOpacity, paint.alpha)
assertEquals(Color.argb(shapeOpacity, 33, 44, 55), paint.color)
}

currentShapeBuilder.withShapeColor(Color.argb(colorAlpha2, 44, 55, 66))
touchView(drawingView, MotionEvent.ACTION_DOWN)

drawingView.currentShape!!.paint.also { paint ->
assertEquals(shapeOpacity, paint.alpha)
assertEquals(Color.argb(shapeOpacity, 44, 55, 66), paint.color)
}

currentShapeBuilder.withShapeOpacity(null)
touchView(drawingView, MotionEvent.ACTION_DOWN)

drawingView.currentShape!!.paint.also { paint ->
assertEquals(colorAlpha2, paint.alpha)
assertEquals(Color.argb(colorAlpha2, 44, 55, 66), paint.color)
}
}

@Test
fun testDefaultBrushColorValue() {
val drawingView = setupDrawingView()
Expand Down

0 comments on commit 825fab9

Please sign in to comment.