File indexing completed on 2024-05-12 05:40:52
0001 /*************************************************************************** 0002 * Copyright (C) 2021 by Renaud Guezennec * 0003 * http://www.rolisteam.org/contact * 0004 * * 0005 * This software is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include <QtTest/QtTest> 0021 0022 #include "controller/view_controller/mindmapcontroller.h" 0023 #include "mindmap/controller/selectioncontroller.h" 0024 #include "mindmap/data/linkcontroller.h" 0025 #include "mindmap/data/mindnode.h" 0026 #include "mindmap/geometry/linknode.h" 0027 #include "mindmap/model/minditemmodel.h" 0028 #include "mindmap/model/nodestylemodel.h" 0029 #include "network/networkmessagereader.h" 0030 #include "network/networkmessagewriter.h" 0031 #include "worker/messagehelper.h" 0032 #include <helper.h> 0033 #include <memory> 0034 0035 #include <QSignalSpy> 0036 #include <QAbstractItemModel> 0037 #include <QAbstractListModel> 0038 #include <QTimer> 0039 0040 class MindMapTest : public QObject 0041 { 0042 Q_OBJECT 0043 public: 0044 MindMapTest(); 0045 0046 private slots: 0047 void init(); 0048 0049 void addRemoveImageTest(); 0050 void addItemAndUndoTest(); 0051 void reparentTest(); 0052 void AddLinkTest(); 0053 0054 void selectionCtrl(); 0055 void selectionCtrl_data(); 0056 0057 void removeNodeAndLinkTest(); 0058 void removeNodeAndLinkTest_data(); 0059 0060 void remoteAddTest(); 0061 0062 void linkGeometryTest(); 0063 void getAndSetTest(); 0064 0065 private: 0066 std::unique_ptr<MindMapController> m_ctrl; 0067 }; 0068 0069 void MindMapTest::init() 0070 { 0071 m_ctrl.reset(new MindMapController("test_id")); 0072 } 0073 0074 MindMapTest::MindMapTest() {} 0075 0076 void MindMapTest::addRemoveImageTest() 0077 { 0078 auto node= std::make_unique<mindmap::MindNode>(); 0079 auto id= Helper::randomString(); 0080 node->setId(id); 0081 m_ctrl->addNode({node.get()}, false); 0082 0083 auto imagePath= Helper::imagePath(); 0084 m_ctrl->addImageFor(id, imagePath, {}); 0085 0086 QVERIFY(m_ctrl->imgModel()->hasPixmap(id)); 0087 QVERIFY(m_ctrl->canUndo()); 0088 QVERIFY(!m_ctrl->canRedo()); 0089 0090 m_ctrl->undo(); 0091 0092 QVERIFY(!m_ctrl->imgModel()->hasPixmap(id)); 0093 QVERIFY(!m_ctrl->canUndo()); 0094 QVERIFY(m_ctrl->canRedo()); 0095 0096 m_ctrl->redo(); 0097 0098 QVERIFY(m_ctrl->imgModel()->hasPixmap(id)); 0099 QVERIFY(m_ctrl->canUndo()); 0100 QVERIFY(!m_ctrl->canRedo()); 0101 0102 m_ctrl->removeImageFor(id); 0103 0104 QVERIFY(!m_ctrl->imgModel()->hasPixmap(id)); 0105 QVERIFY(m_ctrl->canUndo()); 0106 QVERIFY(!m_ctrl->canRedo()); 0107 0108 m_ctrl->undo(); 0109 0110 QVERIFY(m_ctrl->imgModel()->hasPixmap(id)); 0111 QVERIFY(m_ctrl->canUndo()); 0112 QVERIFY(m_ctrl->canRedo()); 0113 0114 m_ctrl->redo(); 0115 QVERIFY(!m_ctrl->imgModel()->hasPixmap(id)); 0116 } 0117 0118 void MindMapTest::AddLinkTest() 0119 { 0120 auto node= std::make_unique<mindmap::MindNode>(); 0121 auto id= Helper::randomString(); 0122 node->setId(id); 0123 0124 auto node2= std::make_unique<mindmap::MindNode>(); 0125 auto id2= Helper::randomString(); 0126 node2->setId(id2); 0127 0128 m_ctrl->addNode({node.get(), node2.get()}, false); 0129 0130 m_ctrl->addLink(id, id2); 0131 0132 auto items= m_ctrl->itemModel()->items(mindmap::MindItem::LinkType); 0133 QCOMPARE(items.size(), 1); 0134 QVERIFY(m_ctrl->canUndo()); 0135 0136 m_ctrl->undo(); 0137 0138 items= m_ctrl->itemModel()->items(mindmap::MindItem::LinkType); 0139 QCOMPARE(items.size(), 0); 0140 QVERIFY(m_ctrl->canRedo()); 0141 0142 m_ctrl->redo(); 0143 items= m_ctrl->itemModel()->items(mindmap::MindItem::LinkType); 0144 QCOMPARE(items.size(), 1); 0145 } 0146 0147 void MindMapTest::addItemAndUndoTest() 0148 { 0149 m_ctrl->addNode(QString{}); 0150 QVERIFY(m_ctrl->canUndo()); 0151 QCOMPARE(m_ctrl->itemModel()->rowCount(), 1); 0152 0153 m_ctrl->undo(); 0154 0155 QVERIFY(m_ctrl->canRedo()); 0156 QCOMPARE(m_ctrl->itemModel()->rowCount(), 0); 0157 0158 m_ctrl->redo(); 0159 QVERIFY(m_ctrl->canUndo()); 0160 QCOMPARE(m_ctrl->itemModel()->rowCount(), 1); 0161 } 0162 0163 void MindMapTest::reparentTest() 0164 { 0165 /*auto node = std::make_unique<mindmap::MindNode>(); 0166 auto fatherId = Helper::randomString(); 0167 node->setId(fatherId); 0168 0169 auto node1 = std::make_unique<mindmap::MindNode>(); 0170 auto child1Id = Helper::randomString(); 0171 node1->setId(child1Id); 0172 0173 auto node2 = std::make_unique<mindmap::MindNode>(); 0174 auto child2Id = Helper::randomString(); 0175 node2->setId(child2Id);*/ 0176 0177 m_ctrl->addNode(QString()); 0178 auto items= m_ctrl->itemModel()->items(mindmap::MindItem::NodeType); 0179 QCOMPARE(items.size(), 1); 0180 0181 auto main= dynamic_cast<mindmap::MindNode*>(items[0]); 0182 auto mainId= main->id(); 0183 0184 m_ctrl->addNode(mainId); 0185 items= m_ctrl->itemModel()->items(mindmap::MindItem::NodeType); 0186 QCOMPARE(items.size(), 2); 0187 0188 auto second= dynamic_cast<mindmap::MindNode*>(items[1]); 0189 // auto secondId = second->id(); 0190 0191 m_ctrl->addNode(mainId); 0192 items= m_ctrl->itemModel()->items(mindmap::MindItem::NodeType); 0193 QCOMPARE(items.size(), 3); 0194 0195 auto third= dynamic_cast<mindmap::MindNode*>(items[2]); 0196 auto thirdId= third->id(); 0197 0198 QSet<mindmap::LinkController*> a; 0199 QCOMPARE(main->subNodeCount(a), 2); 0200 0201 QSet<mindmap::LinkController*> a1; 0202 QCOMPARE(second->subNodeCount(a1), 0); 0203 0204 QSet<mindmap::LinkController*> a2; 0205 QCOMPARE(third->subNodeCount(a2), 0); 0206 QCOMPARE(third->parentNode(), main); 0207 QCOMPARE(second->parentNode(), main); 0208 0209 m_ctrl->reparenting(second, thirdId); 0210 0211 QSet<mindmap::LinkController*> b; 0212 QCOMPARE(main->subNodeCount(b), 2); 0213 0214 QSet<mindmap::LinkController*> b1; 0215 QCOMPARE(second->subNodeCount(b1), 1); 0216 0217 QSet<mindmap::LinkController*> b2; 0218 QCOMPARE(third->subNodeCount(b2), 0); 0219 QCOMPARE(third->parentNode(), main); 0220 QCOMPARE(second->parentNode(), main); 0221 0222 m_ctrl->undo(); 0223 0224 QSet<mindmap::LinkController*> c; 0225 QCOMPARE(main->subNodeCount(c), 2); 0226 0227 QSet<mindmap::LinkController*> c1; 0228 QCOMPARE(second->subNodeCount(c1), 0); 0229 0230 QSet<mindmap::LinkController*> c2; 0231 QCOMPARE(third->subNodeCount(c2), 0); 0232 QCOMPARE(third->parentNode(), main); 0233 QCOMPARE(second->parentNode(), main); 0234 } 0235 0236 void MindMapTest::selectionCtrl() 0237 { 0238 QFETCH(int, nodeCount); 0239 auto ctrl= new mindmap::SelectionController(); 0240 auto undo= new QUndoStack(); 0241 ctrl->setUndoStack(undo); 0242 0243 QVERIFY(!ctrl->enabled()); 0244 QVERIFY(!ctrl->hasSelection()); 0245 0246 QList<QPointF> positions; 0247 positions.reserve(nodeCount); 0248 QList<mindmap::MindNode*> nodes; 0249 for(int i= 0; i < nodeCount; ++i) 0250 { 0251 auto node= new mindmap::MindNode(); 0252 node->setText(Helper::randomString()); 0253 QPointF pos(Helper::generate(0, 1000), Helper::generate(0, 1000)); 0254 positions.append(pos); 0255 node->setPosition(pos); 0256 0257 ctrl->addToSelection(node); 0258 nodes.append(node); 0259 } 0260 if(nodeCount > 0) 0261 QVERIFY(ctrl->hasSelection()); 0262 QCOMPARE(ctrl->selectedNodes().size(), nodes.size()); 0263 0264 QPointF move{0, 0}; 0265 for(int i= 0; i < nodeCount; ++i) 0266 { 0267 QPointF pos(Helper::generate(0, 100), Helper::generate(0, 100)); 0268 ctrl->movingNode(pos); 0269 move+= pos; 0270 } 0271 0272 auto selection= ctrl->selectedNodes(); 0273 int i= 0; 0274 for(auto item : selection) 0275 { 0276 auto pos= positions[i]; 0277 auto pItem= dynamic_cast<mindmap::PositionedItem*>(item); 0278 QCOMPARE(pItem->position(), pos + move); 0279 ++i; 0280 } 0281 0282 for(auto item : selection) 0283 { 0284 ctrl->removeFromSelection(item); 0285 } 0286 QVERIFY(!ctrl->hasSelection()); 0287 0288 for(int i= 0; i < nodeCount; ++i) 0289 { 0290 auto node= new mindmap::MindNode(); 0291 node->setText(Helper::randomString()); 0292 QPointF pos(Helper::generate(0, 1000), Helper::generate(0, 1000)); 0293 node->setPosition(pos); 0294 ctrl->addToSelection(node); 0295 } 0296 if(nodeCount > 0) 0297 QVERIFY(ctrl->hasSelection()); 0298 ctrl->clearSelection(); 0299 QVERIFY(!ctrl->hasSelection()); 0300 0301 while(undo->canUndo()) 0302 { 0303 undo->undo(); 0304 } 0305 0306 delete ctrl; 0307 delete undo; 0308 } 0309 0310 void MindMapTest::selectionCtrl_data() 0311 { 0312 QTest::addColumn<int>("nodeCount"); 0313 0314 for(int i= 0; i < 100; ++i) 0315 { 0316 QTest::addRow("cmd %d", i) << i; 0317 } 0318 } 0319 0320 void MindMapTest::remoteAddTest() 0321 { 0322 // auto ctrl= new MindMapController("test_id_tmp"); 0323 // auto spacerCtrl= m_ctrl->spacingController(); 0324 auto itemModel= dynamic_cast<mindmap::MindItemModel*>(m_ctrl->itemModel()); 0325 0326 QSignalSpy itemAdded(itemModel, &mindmap::MindItemModel::rowsInserted); 0327 0328 auto node1= new mindmap::MindNode(); 0329 node1->setText("Node1"); 0330 node1->setPosition(QPointF(0, 0)); 0331 0332 auto node2= new mindmap::MindNode(); 0333 node2->setText("Node2"); 0334 node2->setPosition(QPointF(0, 0)); 0335 0336 auto link= new mindmap::LinkController(); 0337 link->setStart(node1); 0338 link->setEnd(node2); 0339 0340 NetworkMessageWriter msg(NetMsg::MindMapCategory, NetMsg::AddMessage); 0341 MessageHelper::buildAddItemMessage(msg, {node1, node2}, {link}); 0342 0343 auto dataMsg= msg.data(); 0344 NetworkMessageReader readMsg; 0345 readMsg.setData(dataMsg); 0346 MessageHelper::readMindMapAddItem(m_ctrl.get(), &readMsg); 0347 0348 /* auto dataMsg1= msg1.getData(); 0349 NetworkMessageReader readMsg1; 0350 readMsg1.setData(dataMsg1); 0351 MessageHelper::readAddMindMapNode(m_ctrl.get(), &readMsg1); 0352 0353 auto dataMsgLink= msgLink.getData(); 0354 NetworkMessageReader readMsgLink; 0355 readMsgLink.setData(dataMsgLink); 0356 MessageHelper::readMindMapLink(m_ctrl.get(), &readMsgLink);*/ 0357 0358 QCOMPARE(itemModel->rowCount(), 2); 0359 QCOMPARE(itemAdded.count(), 2); 0360 0361 auto links= itemModel->items(mindmap::MindItem::LinkType); 0362 QCOMPARE(links.size(), 0); 0363 0364 QTimer timer; 0365 QSignalSpy spacer(&timer, &QTimer::timeout); 0366 timer.start(5000); 0367 0368 spacer.wait(5001); 0369 0370 auto realNode1= dynamic_cast<mindmap::MindNode*>(itemModel->item(node1->id())); 0371 auto realNode2= dynamic_cast<mindmap::MindNode*>(itemModel->item(node2->id())); 0372 auto realLink= dynamic_cast<mindmap::LinkController*>(itemModel->item(link->id())); 0373 0374 QCOMPARE(qIsNaN(realNode1->position().x()), false); 0375 QCOMPARE(qIsNaN(realNode1->position().y()), false); 0376 QCOMPARE(qIsNaN(realNode2->position().x()), false); 0377 QCOMPARE(qIsNaN(realNode2->position().y()), false); 0378 0379 // QCOMPARE(node1->position(), realNode1->position()); 0380 // QCOMPARE(node1->boundingRect(), realNode1->boundingRect()); 0381 // QCOMPARE(realLink->startPoint(), link->startPoint()); 0382 // QCOMPARE(realLink->endPoint(), link->endPoint()); 0383 if(realLink) 0384 { 0385 QVERIFY(realLink->startPoint() != QPointF()); 0386 QVERIFY(realLink->endPoint() != QPointF()); 0387 } 0388 } 0389 void MindMapTest::removeNodeAndLinkTest() 0390 { 0391 QFETCH(QList<QList<int>>, nodetree); 0392 QFETCH(int, nodeCount); 0393 QFETCH(int, linkCount); 0394 QFETCH(int, indexToRemove); 0395 QFETCH(int, restingNodes); 0396 QFETCH(int, restingLinks); 0397 0398 auto itemModel= dynamic_cast<mindmap::MindItemModel*>(m_ctrl->itemModel()); 0399 0400 auto& nodes= itemModel->items(mindmap::MindItem::NodeType); 0401 0402 QCOMPARE(itemModel->rowCount(), 0); 0403 0404 int d= 0; 0405 QList<QStringList> idLevels; 0406 for(const auto& level : nodetree) 0407 { 0408 QStringList currentLevelIds; 0409 int index= 0; 0410 for(auto c : level) 0411 { 0412 for(int i= 0; i < c; ++i) 0413 { 0414 if(d == 0) 0415 { 0416 m_ctrl->addNode(QString()); 0417 auto last= nodes[nodes.size() - 1]; 0418 0419 currentLevelIds << last->id(); 0420 } 0421 else 0422 { 0423 // qDebug() << "parentId: "<< c-1 << index; 0424 auto parentId= idLevels[idLevels.size() - 1].at(index); 0425 m_ctrl->addNode(parentId); 0426 auto last= nodes[nodes.size() - 1]; 0427 currentLevelIds << last->id(); 0428 } 0429 } 0430 index++; 0431 } 0432 idLevels << currentLevelIds; 0433 ++d; 0434 } 0435 0436 QCOMPARE(itemModel->rowCount(), linkCount + nodeCount); 0437 0438 m_ctrl->undo(); 0439 0440 QCOMPARE(itemModel->rowCount(), std::max(nodeCount - 1, 0) + std::max(linkCount - 1, 0)); 0441 0442 m_ctrl->redo(); 0443 0444 QCOMPARE(itemModel->rowCount(), nodeCount + linkCount); 0445 0446 if(indexToRemove < 0) 0447 return; 0448 // Remove 0449 0450 QSignalSpy nodeSpy(itemModel, &mindmap::MindItemModel::rowsAboutToBeRemoved); 0451 0452 auto selectionCtrl= m_ctrl->selectionController(); 0453 0454 auto last= nodes[indexToRemove]; 0455 selectionCtrl->addToSelection(last); 0456 m_ctrl->removeSelection(); 0457 0458 QCOMPARE(itemModel->rowCount(), restingNodes + restingLinks); 0459 0460 QCOMPARE(nodeSpy.count(), nodeCount - restingNodes + linkCount - restingLinks); 0461 0462 m_ctrl->undo(); 0463 0464 QCOMPARE(itemModel->rowCount(), nodeCount + linkCount); 0465 nodeSpy.clear(); 0466 0467 m_ctrl->redo(); 0468 0469 QCOMPARE(itemModel->rowCount(), restingNodes + restingLinks); 0470 0471 QCOMPARE(nodeSpy.count(), nodeCount - restingNodes + linkCount - restingLinks); 0472 } 0473 0474 void MindMapTest::removeNodeAndLinkTest_data() 0475 { 0476 QTest::addColumn<QList<QList<int>>>("nodetree"); 0477 QTest::addColumn<int>("nodeCount"); 0478 QTest::addColumn<int>("linkCount"); 0479 QTest::addColumn<int>("indexToRemove"); 0480 QTest::addColumn<int>("restingNodes"); 0481 QTest::addColumn<int>("restingLinks"); 0482 0483 QTest::addRow("cmd 1") << QList<QList<int>>() << 0 << 0 << -1 << 0 << 0; 0484 QTest::addRow("cmd 2") << QList<QList<int>>({{1}}) << 1 << 0 << 0 << 0 << 0; 0485 QTest::addRow("cmd 3") << QList<QList<int>>({{1}, {1}}) << 2 << 1 << 0 << 1 << 0; 0486 QTest::addRow("cmd 4") << QList<QList<int>>({{1}, {1}}) << 2 << 1 << 1 << 1 << 0; 0487 0488 QTest::addRow("cmd 5") << QList<QList<int>>({{1}, {2}}) << 3 << 2 << 0 << 0 << 2; // last was 0 0489 QTest::addRow("cmd 6") << QList<QList<int>>({{1}, {2}}) << 3 << 2 << 1 << 2 << 1; 0490 QTest::addRow("cmd 7") << QList<QList<int>>({{1}, {2}}) << 3 << 2 << 2 << 2 << 1; 0491 0492 QTest::addRow("cmd 8") << QList<QList<int>>({{1}, {1}, {1}}) << 3 << 2 << 0 << 0 << 3; // last was 0 0493 QTest::addRow("cmd 9") << QList<QList<int>>({{1}, {1}, {1}}) << 3 << 2 << 1 << 1 << 1; // last was 0 0494 QTest::addRow("cmd 10") << QList<QList<int>>({{1}, {1}, {1}}) << 3 << 2 << 2 << 2 << 1; 0495 0496 QTest::addRow("cmd 11") << QList<QList<int>>({{1}, {2}, {2, 1}}) << 6 << 5 << 0 << 0 << 8; // last was 0 0497 QTest::addRow("cmd 12") << QList<QList<int>>({{1}, {2}, {2, 1}}) << 6 << 5 << 1 << 3 << 4; // last was 2 0498 QTest::addRow("cmd 13") << QList<QList<int>>({{1}, {2}, {2, 1}}) << 6 << 5 << 2 << 4 << 4; // last was 3 0499 QTest::addRow("cmd 14") << QList<QList<int>>({{1}, {2}, {2, 1}}) << 6 << 5 << 3 << 5 << 4; 0500 QTest::addRow("cmd 15") << QList<QList<int>>({{1}, {2}, {2, 1}}) << 6 << 5 << 4 << 5 << 4; 0501 QTest::addRow("cmd 16") << QList<QList<int>>({{1}, {2}, {2, 1}}) << 6 << 5 << 5 << 5 << 4; 0502 } 0503 0504 void MindMapTest::linkGeometryTest() 0505 { 0506 mindmap::LinkNode linkNode; 0507 0508 linkNode.setColor(Helper::randomColor()); 0509 linkNode.update(Helper::randomRect(), mindmap::LinkController::RightBottom, Helper::randomRect(), 0510 Helper::randomRect()); 0511 linkNode.update(Helper::randomRect(), mindmap::LinkController::LeftBottom, Helper::randomRect(), 0512 Helper::randomRect()); 0513 linkNode.update(Helper::randomRect(), mindmap::LinkController::RightTop, Helper::randomRect(), 0514 Helper::randomRect()); 0515 linkNode.update(Helper::randomRect(), mindmap::LinkController::LeftTop, Helper::randomRect(), Helper::randomRect()); 0516 } 0517 0518 void MindMapTest::getAndSetTest() 0519 { 0520 auto space = m_ctrl->spacingCtrl(); 0521 space->setRunning(false); 0522 space->setRunning(true); 0523 0524 0525 auto styleModel = dynamic_cast<mindmap::NodeStyleModel*>(m_ctrl->styleModel()); 0526 new QAbstractItemModelTester(styleModel); 0527 0528 for(int i = 0; i < styleModel->rowCount(); ++i) 0529 { 0530 qDebug() << i; 0531 QVERIFY(styleModel->getStyle(i) != nullptr); 0532 QVERIFY(m_ctrl->style(i) != nullptr); 0533 QCOMPARE(styleModel->getStyle(i), m_ctrl->style(i)); 0534 } 0535 0536 QCOMPARE(m_ctrl->errorMsg(), QString()); 0537 QCOMPARE(m_ctrl->contentRect(), QRectF(0,0,100,20)); 0538 0539 QSignalSpy spy(m_ctrl.get(), &MindMapController::errorMsgChanged); 0540 auto msg = Helper::randomString(); 0541 m_ctrl->setErrorMsg(msg); 0542 m_ctrl->setErrorMsg(msg); 0543 0544 QCOMPARE(m_ctrl->errorMsg(),msg); 0545 QCOMPARE(spy.count(), 1); 0546 0547 QSignalSpy spy2(m_ctrl.get(), &MindMapController::defaultStyleIndexChanged); 0548 m_ctrl->setDefaultStyleIndex(8000); 0549 auto indexStyle = Helper::generate<int>(0, styleModel->rowCount()); 0550 m_ctrl->setDefaultStyleIndex(indexStyle); 0551 QCOMPARE(spy.count(), 1); 0552 QCOMPARE(indexStyle, m_ctrl->defaultStyleIndex()); 0553 0554 m_ctrl->setSpacing(false); 0555 QVERIFY(!m_ctrl->spacing()); 0556 m_ctrl->setSpacing(true); 0557 QVERIFY(m_ctrl->spacing()); 0558 0559 m_ctrl->centerItems(200, 300); 0560 m_ctrl->refresh(); 0561 0562 auto imgModel = m_ctrl->imgModel(); 0563 new QAbstractItemModelTester(imgModel); 0564 0565 auto id = Helper::randomString(); 0566 auto path = QUrl::fromLocalFile(Helper::imagePath()); 0567 m_ctrl->openImage(id, path); 0568 0569 m_ctrl->removeImage(id); 0570 m_ctrl->removeImage(Helper::randomString()); 0571 0572 m_ctrl->openImage(id, path); 0573 m_ctrl->removeImageFor(id); 0574 0575 0576 m_ctrl->removeLink({Helper::randomString()}); 0577 m_ctrl->removeNode({Helper::randomString()}); 0578 0579 m_ctrl->updatePackage(Helper::randomPoint()); 0580 m_ctrl->addPackage(Helper::randomPoint()); 0581 0582 m_ctrl->updatePackage(Helper::randomPoint()); 0583 m_ctrl->updatePackage(Helper::randomPoint()); 0584 m_ctrl->updatePackage(Helper::randomPoint()); 0585 0586 QVERIFY(!m_ctrl->pasteData(QMimeData())); 0587 0588 m_ctrl->addLink(Helper::randomString(), Helper::randomString()); 0589 m_ctrl->addLink({}, {}); 0590 0591 m_ctrl->setCurrentPackage(nullptr); 0592 0593 QVERIFY(!m_ctrl->hasSelection()); 0594 0595 m_ctrl->setLinkLabelVisibility(false); 0596 QSignalSpy spy3(m_ctrl.get(), &MindMapController::linkLabelVisibilityChanged); 0597 0598 m_ctrl->setLinkLabelVisibility(true); 0599 m_ctrl->setLinkLabelVisibility(true); 0600 m_ctrl->setLinkLabelVisibility(false); 0601 QVERIFY(!m_ctrl->linkLabelVisibility()); 0602 QCOMPARE(spy3.count(), 2); 0603 0604 m_ctrl->setLinkLabelVisibility(true); 0605 QVERIFY(m_ctrl->linkLabelVisibility()); 0606 QCOMPARE(spy3.count(), 3); 0607 0608 0609 m_ctrl->addItemIntoPackage(Helper::randomString(), Helper::randomString()); 0610 m_ctrl->subItem(Helper::randomString(), mindmap::MindItem::LinkType); 0611 0612 QSignalSpy spyZoom(m_ctrl.get(), &MindMapController::zoomLevelChanged); 0613 m_ctrl->setZoomLevel(0.2); 0614 m_ctrl->setZoomLevel(0.2); 0615 spyZoom.wait(10); 0616 QCOMPARE(spyZoom.count(), 1); 0617 QCOMPARE(m_ctrl->zoomLevel(), 0.2); 0618 0619 0620 m_ctrl->hasNetwork(); 0621 } 0622 0623 QTEST_MAIN(MindMapTest); 0624 0625 #include "tst_mindmap.moc"