File indexing completed on 2024-04-14 04:29:41

0001 #include "documenttest.h"
0002 
0003 #include <QtTest/QTest>
0004 #include <QDebug>
0005 #include <QUndoStack>
0006 
0007 #include <tikz/core/Document.h>
0008 #include <tikz/core/Node.h>
0009 #include <tikz/core/Path.h>
0010 
0011 QTEST_MAIN(DocumentTest)
0012 
0013 void DocumentTest::initTestCase()
0014 {
0015 }
0016 
0017 void DocumentTest::cleanupTestCase()
0018 {
0019 }
0020 
0021 void DocumentTest::documentTest()
0022 {
0023 #if 0
0024     tikz::core::Document doc;
0025 
0026     QCOMPARE(doc.toJson(), QByteArray("[  ]"));
0027 
0028     tikz::core::Node * node = doc.createNode();
0029     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 1 } ]"));
0030 
0031     node = doc.createNode();
0032     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 1 }, { \"node\" : 2 } ]"));
0033 
0034     doc.undoManager()->undo();
0035     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 1 } ]"));
0036 
0037     doc.undoManager()->redo();
0038     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 1 }, { \"node\" : 2 } ]"));
0039 
0040     tikz::PathType * path = doc.createPath();
0041     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 1 }, { \"node\" : 2 }, { \"edge\" : 3 } ]"));
0042 
0043     edge->setStartNode(doc.nodeFromId(1));
0044     edge->setEndNode(doc.nodeFromId(2));
0045     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 1 }, { \"node\" : 2 }, { \"edge\" : 3 } ]"));
0046 
0047     node = doc.nodeFromId(1);
0048     doc.deleteNode(node);
0049     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 2 }, { \"edge\" : 3 } ]"));
0050 
0051     QVERIFY(edge->startNode() == 0);
0052     QCOMPARE(edge->endNode(), doc.nodeFromId(2));
0053 
0054     doc.undoManager()->undo();
0055     QCOMPARE(QString(doc.toJson()), QString("[ { \"node\" : 2 }, { \"node\" : 1 }, { \"edge\" : 3 } ]"));
0056 
0057     QCOMPARE(edge->startNode(), doc.nodeFromId(1));
0058     QCOMPARE(edge->endNode(), doc.nodeFromId(2));
0059 #endif
0060 }
0061 
0062 // kate: indent-width 4; replace-tabs on;