Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Add subpath removal unit test

Luna Lovecraftd3430f32c2a9
diff --git a/libs/flake/tests/TestPointRemoveCommand.cpp b/libs/flake/tests/TestPointRemoveCommand.cpp
index a65cea5351..9c5a8ea20f 100644
--- a/libs/flake/tests/TestPointRemoveCommand.cpp
+++ b/libs/flake/tests/TestPointRemoveCommand.cpp
@@ -134,6 +134,35 @@ void TestPointRemoveCommand::redoUndoSubpathRemove()
delete cmd1;
}
+void TestPointRemoveCommand::subpathRemoval()
+{
+ KoPathShape path;
+
+ path.moveTo(QPointF(-1,-1));
+
+ auto p0 = path.moveTo(QPointF(0,0));
+ auto p1 = path.lineTo(QPointF(1,0));
+
+ auto p2 = path.moveTo(QPointF(0,1));
+ auto p3 = path.lineTo(QPointF(1,1));
+
+ QList<KoPathPointData> pd;
+ pd
+ << KoPathPointData(&path, path.pathPointIndex(p0))
+ << KoPathPointData(&path, path.pathPointIndex(p1))
+ << KoPathPointData(&path, path.pathPointIndex(p2))
+ << KoPathPointData(&path, path.pathPointIndex(p3));
+
+ MockShapeController mockController;
+ KoShapeController shapeController(0, &mockController);
+
+ KUndo2Command *cmd = KoPathPointRemoveCommand::createCommand(pd, &shapeController);
+ cmd->redo();
+
+ //Have to have one subpath left, so that it doesn't delete the whole shape
+ QCOMPARE(path.subpathCount(), 1);
+}
+
void TestPointRemoveCommand::redoUndoShapeRemove()
{
KoPathShape *path1 = new KoPathShape();
diff --git a/libs/flake/tests/TestPointRemoveCommand.h b/libs/flake/tests/TestPointRemoveCommand.h
index 5d1c6a7b4e..72de8213eb 100644
--- a/libs/flake/tests/TestPointRemoveCommand.h
+++ b/libs/flake/tests/TestPointRemoveCommand.h
@@ -16,6 +16,7 @@ private Q_SLOTS:
void redoUndoSubpathRemove();
void redoUndoShapeRemove();
void redoUndo();
+ void subpathRemoval();
};
#endif // TESTPOINTREMOVECOMMAND_H