• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

rocs/RocsCore

  • sources
  • kde-4.12
  • kdeedu
  • rocs
  • RocsCore
  • LoadSave
  • Plugins
  • gmlFileFormat
  • Tests
GmlFileFormatTest.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2010 Wagner Reck <wagner.reck@gmail.com>
4  Copyright 2012 Andreas Cord-Landwehr <cola@uni-paderborn.de>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "GmlFileFormatTest.h"
21 #include "../GmlGrammar.h"
22 #include "../GmlFileFormatPlugin.h"
23 #include <QTest>
24 #include "Document.h"
25 #include "Pointer.h"
26 #include "DataStructure.h"
27 #include "DocumentManager.h"
28 #include <KDebug>
29 #include <KUrl>
30 
31 void GmlFileFormatTest::parseTest()
32 {
33  // create importer plugin
34  GmlFileFormatPlugin importer(this, QList<QVariant>());
35  importer.setFile(KUrl::fromLocalFile("example.gml"));
36  importer.readFile();
37  QVERIFY(importer.hasError() == false);
38 }
39 
40 void GmlFileFormatTest::serializeTest()
41 {
42  DocumentManager::self().addDocument(new Document("testSerialization"));
43  Document* document = DocumentManager::self().activeDocument();
44  QMap<QString, DataPtr> dataList;
45 
46  // Creates a simple Graph with 5 data elements and connect them with pointers.
47  DataStructurePtr ds = document->activeDataStructure();
48  ds->setProperty("name", "Graph1");
49  dataList.insert("a", ds->createData("first node", 0));
50  dataList.insert("b", ds->createData("b", 0));
51  dataList.insert("c", ds->createData("c", 0));
52  dataList.insert("d", ds->createData("d", 0));
53  dataList.insert("e", ds->createData("e", 0));
54 
55  ds->createPointer(dataList["a"], dataList["b"], 0)->setProperty("value", "test value");
56  ds->createPointer(dataList["b"], dataList["c"], 0);
57  ds->createPointer(dataList["c"], dataList["d"], 0);
58  ds->createPointer(dataList["d"], dataList["e"], 0);
59  ds->createPointer(dataList["e"], dataList["a"], 0);
60 
61  // create exporter plugin
62  GmlFileFormatPlugin serializer(this, QList<QVariant>());
63  serializer.setFile(KUrl::fromLocalFile("test.gml"));
64  serializer.writeFile(*document);
65  QVERIFY(serializer.hasError() == false);
66 }
67 
68 QTEST_MAIN(GmlFileFormatTest)
DocumentManager.h
DocumentManager::self
static DocumentManager & self()
Definition: DocumentManager.cpp:57
DataStructurePtr
boost::shared_ptr< DataStructure > DataStructurePtr
Definition: CoreTypes.h:38
GmlParser::document
Document * document
Definition: GmlGrammar.cpp:40
DocumentManager::activeDocument
Document * activeDocument() const
Returns the currently active document, or 0 if there document list is empty.
Definition: DocumentManager.cpp:96
GmlFileFormatTest.h
Document.h
DataStructure.h
QTEST_MAIN
QTEST_MAIN(TestTgfFileFormatPlugin)
Document::activeDataStructure
DataStructurePtr activeDataStructure() const
Definition: Document.cpp:431
Document
Definition: Document.h:41
GmlFileFormatPlugin
Definition: GmlFileFormatPlugin.h:31
Pointer.h
GmlFileFormatTest
Definition: GmlFileFormatTest.h:25
DocumentManager::addDocument
void addDocument(Document *document)
Add document to document list and set this document as active document.
Definition: DocumentManager.cpp:106
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

rocs/RocsCore

Skip menu "rocs/RocsCore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal