File indexing completed on 2024-06-09 04:20:56
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2007, 2009 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "TestShapeReorderCommand.h" 0008 #include <MockShapes.h> 0009 #include <KoShapeReorderCommand.h> 0010 #include <KoShapeManager.h> 0011 0012 #include <simpletest.h> 0013 0014 TestShapeReorderCommand::TestShapeReorderCommand() 0015 { 0016 } 0017 0018 TestShapeReorderCommand::~TestShapeReorderCommand() 0019 { 0020 } 0021 0022 void TestShapeReorderCommand::testZIndexSorting() 0023 { 0024 MockShape shape1; 0025 MockShape shape2; 0026 MockShape shape3; 0027 MockShape shape4; 0028 MockShape shape5; 0029 0030 shape1.setZIndex(-2); 0031 shape2.setZIndex(5); 0032 shape3.setZIndex(0); 0033 shape4.setZIndex(9999); 0034 shape5.setZIndex(-9999); 0035 0036 QList<KoShape*> shapes; 0037 shapes.append(&shape1); 0038 shapes.append(&shape2); 0039 shapes.append(&shape3); 0040 shapes.append(&shape4); 0041 shapes.append(&shape5); 0042 0043 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0044 0045 QCOMPARE(shapes.indexOf(&shape1), 1); 0046 QCOMPARE(shapes.indexOf(&shape2), 3); 0047 QCOMPARE(shapes.indexOf(&shape3), 2); 0048 QCOMPARE(shapes.indexOf(&shape4), 4); 0049 QCOMPARE(shapes.indexOf(&shape5), 0); 0050 } 0051 0052 void TestShapeReorderCommand::testRunThroughSorting() 0053 { 0054 MockShape shape1; 0055 MockShape shape2; 0056 MockShape shape3; 0057 MockShape shape4; 0058 MockShape shape5; 0059 0060 shape1.setZIndex(-2); 0061 shape2.setZIndex(5); 0062 shape3.setZIndex(0); 0063 shape4.setZIndex(9999); 0064 shape5.setZIndex(-9999); 0065 0066 shape2.setTextRunAroundSide(KoShape::RunThrough, KoShape::Background); 0067 shape3.setTextRunAroundSide(KoShape::RunThrough, KoShape::Foreground); 0068 0069 QList<KoShape*> shapes; 0070 shapes.append(&shape1); 0071 shapes.append(&shape2); 0072 shapes.append(&shape3); 0073 shapes.append(&shape4); 0074 shapes.append(&shape5); 0075 0076 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0077 0078 QCOMPARE(shapes.indexOf(&shape1), 2); 0079 QCOMPARE(shapes.indexOf(&shape2), 0); 0080 QCOMPARE(shapes.indexOf(&shape3), 4); 0081 QCOMPARE(shapes.indexOf(&shape4), 3); 0082 QCOMPARE(shapes.indexOf(&shape5), 1); 0083 } 0084 0085 void TestShapeReorderCommand::testParentChildSorting() 0086 { 0087 MockShape *shape1 = new MockShape(); 0088 MockShape *shape2 = new MockShape(); 0089 MockShape *shape3 = new MockShape(); 0090 MockShape *shape4 = new MockShape(); 0091 MockShape *shape5 = new MockShape(); 0092 MockShape *shape6 = new MockShape(); 0093 MockShape *shape7 = new MockShape(); 0094 MockContainer *container1 = new MockContainer(); 0095 MockContainer *container2 = new MockContainer(); 0096 MockContainer *container3 = new MockContainer(); 0097 0098 shape1->setZIndex(-2); 0099 shape2->setZIndex(5); 0100 shape3->setZIndex(0); 0101 shape4->setZIndex(9999); 0102 shape5->setZIndex(-9999); 0103 shape6->setZIndex(3); 0104 shape7->setZIndex(7); 0105 container1->setZIndex(-55); 0106 container2->setZIndex(57); 0107 0108 shape2->setTextRunAroundSide(KoShape::RunThrough, KoShape::Background); 0109 shape3->setTextRunAroundSide(KoShape::RunThrough, KoShape::Foreground); 0110 container1->setTextRunAroundSide(KoShape::RunThrough, KoShape::Foreground); 0111 0112 container1->addShape(shape1); 0113 //container1.addShape(&shape2); //we shouldn't parent combine fg and bg 0114 container2->addShape(shape4); 0115 container2->addShape(shape5); 0116 container1->addShape(container2); 0117 container1->addShape(container3); 0118 0119 QList<KoShape*> shapes; 0120 shapes.append(shape1); 0121 shapes.append(shape2); 0122 shapes.append(shape3); 0123 shapes.append(shape4); 0124 shapes.append(shape5); 0125 shapes.append(shape6); 0126 shapes.append(shape7); 0127 shapes.append(container1); 0128 shapes.append(container2); 0129 shapes.append(container3); 0130 0131 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0132 0133 /* This is the expected result 0134 s3 0 fg 0135 s4 9999 0136 s5 -9999 0137 c2 57 0138 c3 0 0139 s1 -2 0140 c1 -55 fg 0141 0142 s7 7 0143 s6 3 0144 0145 s2 5 bg 0146 */ 0147 0148 QCOMPARE(shapes.indexOf(shape1), 4); 0149 QCOMPARE(shapes.indexOf(shape2), 0); 0150 QCOMPARE(shapes.indexOf(shape3), 9); 0151 QCOMPARE(shapes.indexOf(shape4), 8); 0152 QCOMPARE(shapes.indexOf(shape5), 7); 0153 QCOMPARE(shapes.indexOf(shape6), 1); 0154 QCOMPARE(shapes.indexOf(shape7), 2); 0155 QCOMPARE(shapes.indexOf(container1), 3); 0156 QCOMPARE(shapes.indexOf(container2), 6); 0157 QCOMPARE(shapes.indexOf(container3), 5); 0158 0159 delete container1; 0160 delete shape2; 0161 delete shape3; 0162 delete shape6; 0163 delete shape7; 0164 } 0165 0166 void TestShapeReorderCommand::testBringToFront() 0167 { 0168 MockShape shape1, shape2, shape3; 0169 0170 shape1.setSize(QSizeF(100, 100)); 0171 shape1.setZIndex(1); 0172 shape2.setSize(QSizeF(100, 100)); 0173 shape2.setZIndex(2); 0174 shape3.setSize(QSizeF(100, 100)); 0175 shape3.setZIndex(3); 0176 QList<KoShape*> shapes; 0177 shapes.append(&shape1); 0178 shapes.append(&shape2); 0179 shapes.append(&shape3); 0180 0181 MockCanvas canvas; 0182 KoShapeManager manager(&canvas, shapes); 0183 0184 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0185 QCOMPARE(shapes.indexOf(&shape1), 0); 0186 QCOMPARE(shapes.indexOf(&shape2), 1); 0187 QCOMPARE(shapes.indexOf(&shape3), 2); 0188 0189 QList<KoShape*> selectedShapes; 0190 selectedShapes.append(&shape1); 0191 0192 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::BringToFront); 0193 cmd->redo(); 0194 0195 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0196 QCOMPARE(shapes.indexOf(&shape2), 0); 0197 QCOMPARE(shapes.indexOf(&shape3), 1); 0198 QCOMPARE(shapes.indexOf(&shape1), 2); 0199 0200 delete cmd; 0201 } 0202 0203 void TestShapeReorderCommand::testSendToBack() 0204 { 0205 MockShape shape1, shape2, shape3; 0206 0207 shape1.setSize(QSizeF(100, 100)); 0208 shape1.setZIndex(1); 0209 shape2.setSize(QSizeF(100, 100)); 0210 shape2.setZIndex(2); 0211 shape3.setSize(QSizeF(100, 100)); 0212 shape3.setZIndex(3); 0213 QList<KoShape*> shapes; 0214 shapes.append(&shape1); 0215 shapes.append(&shape2); 0216 shapes.append(&shape3); 0217 0218 MockCanvas canvas; 0219 KoShapeManager manager(&canvas, shapes); 0220 0221 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0222 QCOMPARE(shapes.indexOf(&shape1), 0); 0223 QCOMPARE(shapes.indexOf(&shape2), 1); 0224 QCOMPARE(shapes.indexOf(&shape3), 2); 0225 0226 QList<KoShape*> selectedShapes; 0227 selectedShapes.append(&shape3); 0228 0229 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::SendToBack); 0230 cmd->redo(); 0231 0232 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0233 QCOMPARE(shapes.indexOf(&shape3), 0); 0234 QCOMPARE(shapes.indexOf(&shape1), 1); 0235 QCOMPARE(shapes.indexOf(&shape2), 2); 0236 0237 delete cmd; 0238 } 0239 0240 void TestShapeReorderCommand::testMoveUp() 0241 { 0242 MockShape shape1, shape2, shape3; 0243 0244 shape1.setSize(QSizeF(100, 100)); 0245 shape1.setZIndex(1); 0246 shape2.setSize(QSizeF(100, 100)); 0247 shape2.setZIndex(2); 0248 shape3.setSize(QSizeF(100, 100)); 0249 shape3.setZIndex(3); 0250 QList<KoShape*> shapes; 0251 shapes.append(&shape1); 0252 shapes.append(&shape2); 0253 shapes.append(&shape3); 0254 0255 MockCanvas canvas; 0256 KoShapeManager manager(&canvas, shapes); 0257 0258 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0259 QCOMPARE(shapes.indexOf(&shape1), 0); 0260 QCOMPARE(shapes.indexOf(&shape2), 1); 0261 QCOMPARE(shapes.indexOf(&shape3), 2); 0262 0263 QList<KoShape*> selectedShapes; 0264 selectedShapes.append(&shape1); 0265 0266 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::RaiseShape); 0267 cmd->redo(); 0268 0269 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0270 QCOMPARE(shapes.indexOf(&shape2), 0); 0271 QCOMPARE(shapes.indexOf(&shape1), 1); 0272 QCOMPARE(shapes.indexOf(&shape3), 2); 0273 0274 delete cmd; 0275 } 0276 0277 void TestShapeReorderCommand::testMoveDown() 0278 { 0279 MockShape shape1, shape2, shape3; 0280 0281 shape1.setSize(QSizeF(100, 100)); 0282 shape1.setZIndex(1); 0283 shape2.setSize(QSizeF(100, 100)); 0284 shape2.setZIndex(2); 0285 shape3.setSize(QSizeF(100, 100)); 0286 shape3.setZIndex(3); 0287 QList<KoShape*> shapes; 0288 shapes.append(&shape1); 0289 shapes.append(&shape2); 0290 shapes.append(&shape3); 0291 0292 MockCanvas canvas; 0293 KoShapeManager manager(&canvas, shapes); 0294 0295 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0296 QCOMPARE(shapes.indexOf(&shape1), 0); 0297 QCOMPARE(shapes.indexOf(&shape2), 1); 0298 QCOMPARE(shapes.indexOf(&shape3), 2); 0299 0300 QList<KoShape*> selectedShapes; 0301 selectedShapes.append(&shape2); 0302 0303 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::LowerShape); 0304 cmd->redo(); 0305 0306 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0307 QCOMPARE(shapes.indexOf(&shape2), 0); 0308 QCOMPARE(shapes.indexOf(&shape1), 1); 0309 QCOMPARE(shapes.indexOf(&shape3), 2); 0310 0311 delete cmd; 0312 } 0313 0314 void TestShapeReorderCommand::testMoveUpOverlapping() 0315 { 0316 MockShape shape1, shape2, shape3, shape4, shape5; 0317 0318 shape1.setSize(QSizeF(100, 100)); 0319 shape1.setZIndex(1); 0320 shape2.setSize(QSizeF(100, 100)); 0321 shape2.setZIndex(2); 0322 0323 shape3.setSize(QSizeF(300, 300)); 0324 shape3.setZIndex(3); 0325 0326 shape4.setSize(QSizeF(100, 100)); 0327 shape4.setPosition(QPointF(200,200)); 0328 shape4.setZIndex(4); 0329 shape5.setSize(QSizeF(100, 100)); 0330 shape5.setPosition(QPointF(200,200)); 0331 shape5.setZIndex(5); 0332 0333 QList<KoShape*> shapes; 0334 shapes.append(&shape1); 0335 shapes.append(&shape2); 0336 shapes.append(&shape3); 0337 shapes.append(&shape4); 0338 shapes.append(&shape5); 0339 0340 MockCanvas canvas; 0341 KoShapeManager manager(&canvas, shapes); 0342 0343 QVERIFY(shape1.zIndex() < shape2.zIndex()); 0344 QVERIFY(shape2.zIndex() < shape3.zIndex()); 0345 QVERIFY(shape3.zIndex() < shape4.zIndex()); 0346 QVERIFY(shape4.zIndex() < shape5.zIndex()); 0347 0348 QList<KoShape*> selectedShapes; 0349 selectedShapes.append(&shape1); 0350 0351 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::RaiseShape); 0352 cmd->redo(); 0353 delete cmd; 0354 0355 QVERIFY(shape1.zIndex() > shape2.zIndex()); 0356 QVERIFY(shape2.zIndex() < shape3.zIndex()); 0357 QVERIFY(shape1.zIndex() < shape3.zIndex()); 0358 QVERIFY(shape3.zIndex() < shape4.zIndex()); 0359 QVERIFY(shape4.zIndex() < shape5.zIndex()); 0360 } 0361 0362 void TestShapeReorderCommand::testMoveDownOverlapping() 0363 { 0364 #if 0 // disable a current algorithm does not yet support this 0365 MockShape shape1, shape2, shape3, shape4, shape5; 0366 0367 shape1.setSize(QSizeF(100, 100)); 0368 shape1.setZIndex(1); 0369 shape2.setSize(QSizeF(100, 100)); 0370 shape2.setZIndex(2); 0371 0372 shape3.setSize(QSizeF(300, 300)); 0373 shape3.setZIndex(3); 0374 0375 shape4.setSize(QSizeF(100, 100)); 0376 shape4.setPosition(QPointF(200,200)); 0377 shape4.setZIndex(4); 0378 shape5.setSize(QSizeF(100, 100)); 0379 shape5.setPosition(QPointF(200,200)); 0380 shape5.setZIndex(5); 0381 0382 QList<KoShape*> shapes; 0383 shapes.append(&shape1); 0384 shapes.append(&shape2); 0385 shapes.append(&shape3); 0386 shapes.append(&shape4); 0387 shapes.append(&shape5); 0388 0389 MockCanvas canvas; 0390 KoShapeManager manager(&canvas, shapes); 0391 0392 QVERIFY(shape1.zIndex() < shape2.zIndex()); 0393 QVERIFY(shape2.zIndex() < shape3.zIndex()); 0394 QVERIFY(shape3.zIndex() < shape4.zIndex()); 0395 QVERIFY(shape4.zIndex() < shape5.zIndex()); 0396 0397 QList<KoShape*> selectedShapes; 0398 selectedShapes.append(&shape5); 0399 0400 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::LowerShape); 0401 cmd->redo(); 0402 delete cmd; 0403 0404 QVERIFY(shape1.zIndex() < shape2.zIndex()); 0405 QVERIFY(shape2.zIndex() < shape3.zIndex()); 0406 QVERIFY(shape3.zIndex() < shape4.zIndex()); 0407 QVERIFY(shape4.zIndex() > shape5.zIndex()); 0408 QVERIFY(shape3.zIndex() > shape5.zIndex()); 0409 #endif 0410 } 0411 0412 void TestShapeReorderCommand::testSendToBackChildren() 0413 { 0414 MockShape *shape1 = new MockShape(); 0415 MockShape *shape2 = new MockShape(); 0416 MockShape *shape3 = new MockShape(); 0417 0418 shape1->setSize(QSizeF(100, 100)); 0419 shape1->setZIndex(1); 0420 shape2->setSize(QSizeF(100, 100)); 0421 shape2->setZIndex(2); 0422 shape3->setSize(QSizeF(100, 100)); 0423 shape3->setZIndex(3); 0424 0425 QScopedPointer<MockContainer> container(new MockContainer()); 0426 container->addShape(shape1); 0427 container->addShape(shape2); 0428 container->addShape(shape3); 0429 0430 QList<KoShape*> shapes; 0431 shapes.append(shape1); 0432 shapes.append(shape2); 0433 shapes.append(shape3); 0434 shapes.append(container.data()); 0435 0436 MockCanvas canvas; 0437 KoShapeManager manager(&canvas, shapes); 0438 0439 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0440 QCOMPARE(shapes.indexOf(container.data()), 0); // atm the parent is always lower than its children 0441 QCOMPARE(shapes.indexOf(shape1), 1); 0442 QCOMPARE(shapes.indexOf(shape2), 2); 0443 QCOMPARE(shapes.indexOf(shape3), 3); 0444 0445 QList<KoShape*> selectedShapes; 0446 selectedShapes.append(shape3); 0447 0448 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::SendToBack); 0449 cmd->redo(); 0450 delete cmd; 0451 0452 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0453 QCOMPARE(shapes.indexOf(container.data()), 0); // atm the parent is always lower than its children 0454 QCOMPARE(shapes.indexOf(shape3), 1); 0455 QVERIFY(shape3->zIndex() < shape1->zIndex()); 0456 QCOMPARE(shapes.indexOf(shape1), 2); 0457 QVERIFY(shape1->zIndex() < shape2->zIndex()); 0458 QCOMPARE(shapes.indexOf(shape2), 3); 0459 0460 selectedShapes.clear(); 0461 selectedShapes.append(shape2); 0462 0463 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::SendToBack); 0464 cmd->redo(); 0465 delete cmd; 0466 0467 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0468 QCOMPARE(shapes.indexOf(container.data()), 0); // atm the parent is always lower than its children 0469 QCOMPARE(shapes.indexOf(shape2), 1); 0470 QVERIFY(shape2->zIndex() < shape3->zIndex()); 0471 QCOMPARE(shapes.indexOf(shape3), 2); 0472 QVERIFY(shape3->zIndex() < shape1->zIndex()); 0473 QCOMPARE(shapes.indexOf(shape1), 3); 0474 0475 selectedShapes.clear(); 0476 selectedShapes.append(shape1); 0477 0478 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::SendToBack); 0479 cmd->redo(); 0480 delete cmd; 0481 0482 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0483 QCOMPARE(shapes.indexOf(container.data()), 0); // atm the parent is always lower than its children 0484 QCOMPARE(shapes.indexOf(shape1), 1); 0485 QVERIFY(shape1->zIndex() < shape2->zIndex()); 0486 QCOMPARE(shapes.indexOf(shape2), 2); 0487 QVERIFY(shape2->zIndex() < shape3->zIndex()); 0488 QCOMPARE(shapes.indexOf(shape3), 3); 0489 } 0490 0491 void TestShapeReorderCommand::testNoCommand() 0492 { 0493 MockShape shape1, shape2, shape3; 0494 0495 shape1.setSize(QSizeF(100, 100)); 0496 shape1.setZIndex(1); 0497 shape2.setSize(QSizeF(100, 100)); 0498 shape2.setZIndex(2); 0499 shape3.setSize(QSizeF(100, 100)); 0500 shape3.setZIndex(3); 0501 QList<KoShape*> shapes; 0502 shapes.append(&shape1); 0503 shapes.append(&shape2); 0504 shapes.append(&shape3); 0505 0506 MockCanvas canvas; 0507 KoShapeManager manager(&canvas, shapes); 0508 0509 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0510 QCOMPARE(shapes.indexOf(&shape1), 0); 0511 QCOMPARE(shapes.indexOf(&shape2), 1); 0512 QCOMPARE(shapes.indexOf(&shape3), 2); 0513 0514 QList<KoShape*> selectedShapes; 0515 selectedShapes.append(&shape3); 0516 0517 KUndo2Command * cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::BringToFront); 0518 QVERIFY(cmd == 0); 0519 0520 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::RaiseShape); 0521 QVERIFY(cmd == 0); 0522 0523 selectedShapes.append(&shape1); 0524 selectedShapes.append(&shape2); 0525 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::BringToFront); 0526 QVERIFY(cmd == 0); 0527 0528 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::RaiseShape); 0529 QVERIFY(cmd == 0); 0530 0531 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::LowerShape); 0532 QVERIFY(cmd == 0); 0533 0534 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::SendToBack); 0535 QVERIFY(cmd == 0); 0536 0537 selectedShapes.clear(); 0538 selectedShapes.append(&shape1); 0539 0540 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::SendToBack); 0541 QVERIFY(cmd == 0); 0542 0543 cmd = KoShapeReorderCommand::createCommand(selectedShapes, &manager, KoShapeReorderCommand::LowerShape); 0544 QVERIFY(cmd == 0); 0545 } 0546 #include <kis_assert.h> 0547 #include <kis_debug.h> 0548 void testMergeInShapeImpl(const QVector<int> indexesProfile, 0549 int newShapeIndex, 0550 const QVector<qint16> expectedIndexes) 0551 { 0552 KIS_ASSERT(indexesProfile.size() == expectedIndexes.size()); 0553 0554 QVector<MockShape> shapesStore(indexesProfile.size()); 0555 0556 QList<KoShape*> managedShapes; 0557 0558 for (int i = 0; i < shapesStore.size(); i++) { 0559 shapesStore[i].setSize(QSizeF(100,100)); 0560 shapesStore[i].setZIndex(indexesProfile[i]); 0561 0562 managedShapes << &shapesStore[i]; 0563 } 0564 0565 QScopedPointer<KUndo2Command> cmd( 0566 KoShapeReorderCommand::mergeInShape(managedShapes, &shapesStore[newShapeIndex])); 0567 cmd->redo(); 0568 0569 for (int i = 0; i < shapesStore.size(); i++) { 0570 //qDebug() << ppVar(i) << ppVar(shapesStore[i].zIndex()); 0571 QCOMPARE(shapesStore[i].zIndex(), expectedIndexes[i]); 0572 } 0573 } 0574 0575 void TestShapeReorderCommand::testMergeInShape() 0576 { 0577 QVector<int> indexesProfile({1,1,2,2,2,3,3,4,5,6}); 0578 int newShapeIndex = 3; 0579 QVector<qint16> expectedIndexes({1,1,2,3,2,4,4,5,6,7}); 0580 0581 testMergeInShapeImpl(indexesProfile, newShapeIndex, expectedIndexes); 0582 } 0583 0584 void TestShapeReorderCommand::testMergeInShapeDistant() 0585 { 0586 QVector<int> indexesProfile({1,1,2,2,2,4,4,5,6,7}); 0587 int newShapeIndex = 3; 0588 QVector<qint16> expectedIndexes({1,1,2,3,2,4,4,5,6,7}); 0589 0590 testMergeInShapeImpl(indexesProfile, newShapeIndex, expectedIndexes); 0591 } 0592 0593 SIMPLE_TEST_MAIN(TestShapeReorderCommand)