[Marble-commits] KDE/kdeedu/marble
Andrew Manson
g.real.ate at gmail.com
Thu Aug 6 18:49:39 CEST 2009
SVN commit 1007995 by mansona:
extensive work on the GeoWriter unit test. Now ready for Test Driven Development
to get the writer to work. Also setting the Tests to Build by default
M +1 -1 CMakeLists.txt
M +15 -1 src/lib/geodata/writer/GeoWriter.cpp
M +10 -0 src/lib/geodata/writer/GeoWriter.h
M +9 -0 tests/CMakeLists.txt
M +3 -0 tests/TestGeoDataParser.cpp
A tests/TestGeoDataWriter.cpp [License: UNKNOWN]
A tests/data (directory)
A tests/data/NewYork.kml
A tests/data/NewYorkDocument.kml
--- trunk/KDE/kdeedu/marble/CMakeLists.txt #1007994:1007995
@@ -29,7 +29,7 @@
####################################################
# build unit tests
if( QTONLY )
- option( BUILD_MARBLE_TESTS "build marble tests if building QTONLY " OFF )
+ option( BUILD_MARBLE_TESTS "build marble tests if building QTONLY " ON )
if( BUILD_MARBLE_TESTS )
enable_testing()
endif( BUILD_MARBLE_TESTS )
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoWriter.cpp #1007994:1007995
@@ -36,11 +36,25 @@
const GeoTagWriter* writer = GeoTagWriter::recognizes( name );
if( writer ) {
- writer->write( f, (*this) );
+ if(!writer->write( f, (*this) ) ) {
+ //something went wrong while writing
+ return false;
+ }
+ } else {
+ //do not have a handler for this element
+ return false;
}
}
+ return true;
}
+bool GeoWriter::write( QIODevice *device, const GeoDataFeature &feature)
+{
+ QList<GeoDataFeature> list;
+ list.append(feature);
+ return write(device, list);
+}
+
void GeoWriter::setDocumentType( const QString &documentType )
{
m_documentType = documentType;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoWriter.h #1007994:1007995
@@ -39,7 +39,17 @@
bool write( QIODevice* device,
const QList<GeoDataFeature>& features);
+
/**
+ * @brief Overloaded convienience method to write a single feature or tree
+ * This convenience method allows you to call the GeoWriter using just a
+ * single @see GeoDataFeature. This accounts for the case where a KML
+ * document is contained in one single root element.
+ * See @see write(QIODevice*, const QList<GeoDataFeature>&) for more details
+ */
+ bool write( QIODevice* device, const GeoDataFeature& feature );
+
+ /**
* @brief Set the current document type.
* The current Document Type defines which set of hadlers are to be used
* when writing the GeoDocument. This string should corrispond with the
--- trunk/KDE/kdeedu/marble/tests/CMakeLists.txt #1007994:1007995
@@ -21,7 +21,14 @@
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
#############################################################
+# Make the current test source directory avaiable in #define TESTSRCDIR
+# use this for accessing TESTSRCDIR/data
+#############################################################
+add_definitions( -DTESTSRCDIR=\\"${CMAKE_CURRENT_SOURCE_DIR}\\" )
+
+#############################################################
+
# MarbleWidget test
marble_add_test( MarbleWidgetSpeedTest )
@@ -51,6 +58,7 @@
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata/data )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata/parser )
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata/writer )
marble_add_test( GeoPolygonTest )
############################
@@ -58,6 +66,7 @@
############################
marble_add_test( TestGeoDataParser )
+marble_add_test( TestGeoDataWriter )
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
--- trunk/KDE/kdeedu/marble/tests/TestGeoDataParser.cpp #1007994:1007995
@@ -1,6 +1,9 @@
#include <QObject>
#include <QtTest/QtTest>
+/**
+ * This class is intended to test the GeoDataParser. Should it replace KMLTest?
+ */
class TestGeoDataParser : public QObject
{
Q_OBJECT
More information about the Marble-commits
mailing list