File indexing completed on 2024-06-09 04:20:54
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2009 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "TestSegmentTypeCommand.h" 0008 #include "KoPathSegmentTypeCommand.h" 0009 #include <KoPathSegment.h> 0010 #include <simpletest.h> 0011 0012 void TestSegmentTypeCommand::changeToCurve() 0013 { 0014 KoPathShape path; 0015 path.moveTo( QPointF(0,0) ); 0016 path.lineTo( QPointF(100,0) ); 0017 0018 KoPathPointData segment(&path, KoPathPointIndex(0,0)); 0019 QList<KoPathPointData> segments; 0020 segments.append(segment); 0021 0022 // get first segment 0023 KoPathSegment s = path.segmentByIndex(KoPathPointIndex(0,0)); 0024 0025 KoPathSegmentTypeCommand cmd(segments, KoPathSegmentTypeCommand::Curve); 0026 0027 QVERIFY(!s.first()->activeControlPoint2()); 0028 QVERIFY(!s.second()->activeControlPoint1()); 0029 0030 cmd.redo(); 0031 0032 QVERIFY(s.first()->activeControlPoint2()); 0033 QVERIFY(s.second()->activeControlPoint1()); 0034 0035 cmd.undo(); 0036 0037 QVERIFY(!s.first()->activeControlPoint2()); 0038 QVERIFY(!s.second()->activeControlPoint1()); 0039 } 0040 0041 void TestSegmentTypeCommand::changeToLine() 0042 { 0043 KoPathShape path; 0044 path.moveTo( QPointF(0,0) ); 0045 path.curveTo( QPointF(25,25), QPointF(75,25), QPointF(100,0) ); 0046 0047 KoPathPointData segment(&path, KoPathPointIndex(0,0)); 0048 QList<KoPathPointData> segments; 0049 segments.append(segment); 0050 0051 // get first segment 0052 KoPathSegment s = path.segmentByIndex(KoPathPointIndex(0,0)); 0053 0054 KoPathSegmentTypeCommand cmd(segments, KoPathSegmentTypeCommand::Line); 0055 0056 QVERIFY(s.first()->activeControlPoint2()); 0057 QVERIFY(s.second()->activeControlPoint1()); 0058 0059 cmd.redo(); 0060 0061 QVERIFY(!s.first()->activeControlPoint2()); 0062 QVERIFY(!s.second()->activeControlPoint1()); 0063 0064 cmd.undo(); 0065 0066 QVERIFY(s.first()->activeControlPoint2()); 0067 QVERIFY(s.second()->activeControlPoint1()); 0068 } 0069 0070 SIMPLE_TEST_MAIN(TestSegmentTypeCommand)