[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [rocs] src: Added rooted tree convert test and set first node as tree root (in conversion)
From: Wagner de Melo Reck <wagner.reck () gmail ! com>
Date: 2012-04-30 19:45:06
Message-ID: 20120430194506.AB071A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit ffdacce2c6db3b62fc204be0a3c14c96d931eed5 by Wagner de Melo Reck.
Committed on 30/04/2012 at 21:44.
Pushed by reck into branch 'master'.
Added rooted tree convert test and set first node as tree root (in conversion)
M +5 -1 src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp
M +36 -2 src/Tests/TestPlugins.cpp
M +2 -0 src/Tests/TestPlugins.h
http://commits.kde.org/rocs/ffdacce2c6db3b62fc204be0a3c14c96d931eed5
diff --git a/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp \
b/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp index 406c04c..d7de37f \
100644
--- a/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp
+++ b/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp
@@ -77,6 +77,8 @@ void RootedTreeStructure::importStructure(DataStructurePtr other)
newdata->setX(p->x());
newdata->setY(p->y());
newdata->setWidth(p->width());
+ if (!rootNode().get())
+ set_root_node(qobject_cast< RootedTreeNode* >(newdata.get()));
fromOtherToNew.insert(p.get(), newdata);
while(!queue.isEmpty()){
DataPtr n = queue.dequeue();
@@ -172,7 +174,9 @@ void RootedTreeStructure::set_root_node(RootedTreeNode* node)
DataPtr RootedTreeStructure::rootNode() const
{
- return m_rootNode->getData();
+ if (m_rootNode)
+ return m_rootNode->getData();
+ return DataPtr();
}
void RootedTreeStructure::setEngine(QScriptEngine* engine)
diff --git a/src/Tests/TestPlugins.cpp b/src/Tests/TestPlugins.cpp
index c7af424..a2720dd 100644
--- a/src/Tests/TestPlugins.cpp
+++ b/src/Tests/TestPlugins.cpp
@@ -19,7 +19,7 @@
#include "TestPlugins.h"
#include <QtTest/QSignalSpy>
-#include <QtTest/QTest>
+#include <qtest_kde.h>
#include "DataStructurePluginManager.h"
#include "Document.h"
#include "DataStructure.h"
@@ -108,4 +108,38 @@ void TestPlugins::convertGraphToLinkedList()
QCOMPARE(list->pointers().count(), 1);
}
-QTEST_MAIN(TestPlugins)
+void TestPlugins::convertGraphToRootedTree()
+{
+
+ DataStructurePluginInterface * plGraph = \
DataStructurePluginManager::self()->plugin("Graph"); +
+ QVERIFY2(plGraph,"Graph plugin not found");
+
+ DataStructurePluginInterface * plTree = \
DataStructurePluginManager::self()->plugin("RootedTree"); +
+ QVERIFY2(plTree,"Rooted plugin not found");
+
+ DataStructurePluginManager::self()->setDataStructurePlugin(plGraph->name());
+ Document doc("TestDocument");
+ // connect(DSPluginManager::instance(), SIGNAL(changingDS(QString)), &doc, \
SLOT(convertToDS(QString))); + //Create a simple graph
+ DataStructurePtr tree = doc.addDataStructure("Graph1");
+ tree->addData("node1");
+ tree->addData("node2");
+ tree->addData("node3");
+ tree->addPointer("node1", "node2");
+ tree->addPointer("node1", "node3");
+
+ //Change plugin.
+ DataStructurePluginManager::self()->setDataStructurePlugin(plTree->name());
+
+ DataStructurePtr list = plTree->convertToDataStructure(tree, &doc);
+
+ QCOMPARE(list->dataList().count(), 3);
+ QCOMPARE(list->pointers().count(), 4);
+// QVERIFY(list->)
+
+}
+
+
+QTEST_KDEMAIN_CORE(TestPlugins)
diff --git a/src/Tests/TestPlugins.h b/src/Tests/TestPlugins.h
index 6361e66..e384d25 100644
--- a/src/Tests/TestPlugins.h
+++ b/src/Tests/TestPlugins.h
@@ -33,6 +33,8 @@ private slots:
void createRootedTree();
void convertGraphToLinkedList();
+
+ void convertGraphToRootedTree();
};
#endif // TESTPLUGINS_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic