diff --git a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/DynamicLineToolIntegrationTest.kt b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/DynamicLineToolIntegrationTest.kt index 9f5a75cf92..d3a33a7dd8 100644 --- a/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/DynamicLineToolIntegrationTest.kt +++ b/Paintroid/src/androidTest/java/org/catrobat/paintroid/test/espresso/tools/DynamicLineToolIntegrationTest.kt @@ -68,6 +68,7 @@ class DynamicLineToolIntegrationTest { private val IMAGE_NAME = "fileName" private val colorStringIndex0 = "#FF0074CD" + private val colorStringIndex1 = "#FF00B4F1" private val colorStringIndex2 = "#FF078707" private val colorStringBlack = "#FF000000" private val colorStringTransparent = "#00000000" @@ -389,7 +390,7 @@ class DynamicLineToolIntegrationTest { } @Test - fun testColorChangesAndQuittingConnectedLineMode() { + fun testColorChangesChangeLineColor() { ToolPropertiesInteraction.onToolProperties().setColor(Color.BLACK) touchAt(DrawingSurfaceLocationProvider.HALFWAY_LEFT_MIDDLE) touchAt(DrawingSurfaceLocationProvider.HALFWAY_RIGHT_MIDDLE) @@ -399,26 +400,24 @@ class DynamicLineToolIntegrationTest { touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT) TestUtils.selectColorInDialog(0) - checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT) TestUtils.selectColorInDialog(1) - TestUtils.selectColorInDialog(2) + checkPixelColor(colorStringIndex1, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT) + TestUtils.selectColorInDialog(2) checkPixelColor(colorStringIndex2, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT) - TopBarViewInteraction.onTopBarView().performUndo() TopBarViewInteraction.onTopBarView().performUndo() - checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT) - - touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_LEFT) - checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_LEFT) + TestUtils.selectColorInDialog(0) + checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_RIGHT_MIDDLE) - touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT) - checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT) + TestUtils.selectColorInDialog(1) + checkPixelColor(colorStringIndex1, BitmapLocationProvider.HALFWAY_RIGHT_MIDDLE) - TopBarViewInteraction.onTopBarView().performClickCheckmark() + TestUtils.selectColorInDialog(2) + checkPixelColor(colorStringIndex2, BitmapLocationProvider.HALFWAY_RIGHT_MIDDLE) } @Test diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/tools/implementation/DynamicLineTool.kt b/Paintroid/src/main/java/org/catrobat/paintroid/tools/implementation/DynamicLineTool.kt index ee31d292c0..ae30fdea29 100644 --- a/Paintroid/src/main/java/org/catrobat/paintroid/tools/implementation/DynamicLineTool.kt +++ b/Paintroid/src/main/java/org/catrobat/paintroid/tools/implementation/DynamicLineTool.kt @@ -187,7 +187,6 @@ class DynamicLineTool( addNewPath = false return true } - clearRedoIfPathWasAdjusted() return true } @@ -204,19 +203,19 @@ class DynamicLineTool( override fun handleMove(coordinate: PointF?): Boolean { coordinate ?: return false - updateMovingGhostVertices(coordinate) - clearRedoIfPathWasAdjusted() hideToolOptions() super.handleMove(coordinate) + updateMovingGhostVertices(coordinate) + clearRedoIfPathWasAdjusted() return true } override fun handleUp(coordinate: PointF?): Boolean { coordinate ?: return false - super.handleUp(coordinate) showToolOptions() + super.handleUp(coordinate) updateMovingVertices(coordinate) - commandManager.executeAllCommands() + clearRedoIfPathWasAdjusted() resetGhostPathCoordinates() showPlusButton() return true @@ -318,6 +317,7 @@ class DynamicLineTool( var endPoint = successorVertex?.vertexCenter?.let { center -> copyPointF(center) } updatePathCommand(startPoint, endPoint, movingVertex?.outgoingPathCommand) } + commandManager.executeAllCommands() } } @@ -368,7 +368,7 @@ class DynamicLineTool( } } - fun hideToolOptions() { + private fun hideToolOptions() { if (toolOptionsViewController.isVisible) { if (brushToolOptionsView.getTopToolOptions().visibility == View.VISIBLE) { toolOptionsViewController.slideUp( @@ -388,7 +388,7 @@ class DynamicLineTool( } } - fun showToolOptions() { + private fun showToolOptions() { if (!toolOptionsViewController.isVisible) { if (brushToolOptionsView.getBottomToolOptions().visibility == View.INVISIBLE) { toolOptionsViewController.slideDown(