[QGIS Commit] r8980 - in trunk/qgis/tests: src/core testdata
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Aug 2 07:10:33 EDT 2008
Author: timlinux
Date: 2008-08-02 07:10:33 -0400 (Sat, 02 Aug 2008)
New Revision: 8980
Added:
trunk/qgis/tests/src/core/regression992.cpp
trunk/qgis/tests/testdata/rgbwcmyk01_YeGeo.jp2
Modified:
trunk/qgis/tests/src/core/CMakeLists.txt
Log:
Added regression test for ticket #992
Modified: trunk/qgis/tests/src/core/CMakeLists.txt
===================================================================
--- trunk/qgis/tests/src/core/CMakeLists.txt 2008-08-02 10:00:27 UTC (rev 8979)
+++ trunk/qgis/tests/src/core/CMakeLists.txt 2008-08-02 11:10:33 UTC (rev 8980)
@@ -128,6 +128,27 @@
#
+# Ticket 992 Regression992 test
+#
+SET(regression992_SRCS regression992.cpp ${util_SRCS})
+SET(regression992_MOC_CPPS regression992.cpp)
+QT4_WRAP_CPP(regression992_MOC_SRCS ${regression992_MOC_CPPS})
+ADD_CUSTOM_TARGET(regression992moc ALL DEPENDS ${regression992_MOC_SRCS})
+ADD_EXECUTABLE(regression992 ${regression992_SRCS})
+ADD_DEPENDENCIES(regression992 regression992moc)
+TARGET_LINK_LIBRARIES(regression992 ${QT_LIBRARIES} qgis_core)
+SET_TARGET_PROPERTIES(regression992
+ PROPERTIES INSTALL_RPATH ${QGIS_LIB_DIR}
+ INSTALL_RPATH_USE_LINK_PATH true)
+IF (APPLE)
+# For Mac OS X, the executable must be at the root of the bundle's executable folder
+ INSTALL(TARGETS regression992 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
+ ADD_TEST(regression992 ${CMAKE_INSTALL_PREFIX}/regression992)
+ELSE (APPLE)
+ INSTALL(TARGETS regression992 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ ADD_TEST(regression992 ${CMAKE_INSTALL_PREFIX}/bin/regression992)
+ENDIF (APPLE)
+#
# Ticket 1141 Regression1141 test
#
SET(regression1141_SRCS regression1141.cpp ${util_SRCS})
Added: trunk/qgis/tests/src/core/regression992.cpp
===================================================================
--- trunk/qgis/tests/src/core/regression992.cpp (rev 0)
+++ trunk/qgis/tests/src/core/regression992.cpp 2008-08-02 11:10:33 UTC (rev 8980)
@@ -0,0 +1,117 @@
+/***************************************************************************
+ testqgsvectorfilewriter.cpp
+ --------------------------------------
+ Date : Frida Nov 23 2007
+ Copyright : (C) 2007 by Tim Sutton
+ Email : tim at linfiniti.com
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include <QtTest>
+#include <QObject>
+#include <QString>
+#include <QStringList>
+#include <QObject>
+#include <iostream>
+#include <QApplication>
+#include <QFileInfo>
+#include <QDir>
+#include <QPainter>
+#include <QSettings>
+#include <QTime>
+#include <QDesktopServices>
+
+
+//qgis includes...
+#include <qgsrasterlayer.h>
+#include <qgsrasterbandstats.h>
+#include <qgsmaplayerregistry.h>
+#include <qgsapplication.h>
+#include <qgsmaprender.h>
+
+//qgis unit test includes
+#include <qgsrenderchecker.h>
+
+
+/** \ingroup UnitTests
+ * This is a regression test for ticket #992.
+ */
+class Regression992: public QObject
+{
+ Q_OBJECT;
+ private slots:
+ void initTestCase();// will be called before the first testfunction is executed.
+ void cleanupTestCase();// will be called after the last testfunction was executed.
+ void init(){};// will be called before each testfunction is executed.
+ void cleanup(){};// will be called after every testfunction.
+
+ void regression992();
+ private:
+ bool render(QString theFileName);
+ QString mTestDataDir;
+ QgsRasterLayer * mpRasterLayer;
+ QgsMapRender * mpMapRenderer;
+ QString mReport;
+};
+
+//runs before all tests
+void Regression992::initTestCase()
+{
+ // init QGIS's paths - true means that all path will be inited from prefix
+ QString qgisPath = QCoreApplication::applicationDirPath ();
+ QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
+ QgsApplication::showSettings();
+ //create some objects that will be used in all tests...
+ //create a raster layer that will be used in all tests...
+ mTestDataDir = QString(TEST_DATA_DIR) + QDir::separator(); //defined in CMakeLists.txt
+ QString myFileName = mTestDataDir + "rgbwcmyk01_YeGeo.jp2";
+ QFileInfo myRasterFileInfo ( myFileName );
+ mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath(),
+ myRasterFileInfo.completeBaseName() );
+ // Register the layer with the registry
+ QgsMapLayerRegistry::instance()->addMapLayer(mpRasterLayer);
+ // add the test layer to the maprender
+ mpMapRenderer = new QgsMapRender();
+ QStringList myLayers;
+ myLayers << mpRasterLayer->getLayerID();
+ mpMapRenderer->setLayerSet(myLayers);
+ mReport += "<h1>Regression 992 Test</h1>\n";
+ mReport += "<p>See <a href=\"https://trac.osgeo.org/qgis/ticket/992\">"
+ "trac ticket 992</a> for more details.</p>";
+}
+//runs after all tests
+void Regression992::cleanupTestCase()
+{
+ QString myReportFile = QDir::tempPath() + QDir::separator() + "regression992.html";
+ QFile myFile ( myReportFile);
+ if ( myFile.open ( QIODevice::WriteOnly ) )
+ {
+ QTextStream myQTextStream ( &myFile );
+ myQTextStream << mReport;
+ myFile.close();
+ QDesktopServices::openUrl("file://"+myReportFile);
+ }
+}
+
+void Regression992::regression992()
+{
+ QVERIFY ( mpRasterLayer->isValid() );
+ mpMapRenderer->setExtent(mpRasterLayer->extent());
+ QString myDataDir (TEST_DATA_DIR); //defined in CmakeLists.txt
+ QString myTestDataDir = myDataDir + QDir::separator();
+ QgsRenderChecker myChecker;
+ myChecker.setExpectedImage ( myTestDataDir + "expected_rgbwcmyk01_YeGeo.jp2.png" );
+ myChecker.setMapRenderer ( mpMapRenderer );
+ bool myResultFlag = myChecker.runTest("regression992");
+ mReport += "\n\n\n" + myChecker.report();
+ QVERIFY(myResultFlag);
+}
+
+QTEST_MAIN(Regression992)
+#include "moc_regression992.cxx"
+
Added: trunk/qgis/tests/testdata/rgbwcmyk01_YeGeo.jp2
===================================================================
(Binary files differ)
Property changes on: trunk/qgis/tests/testdata/rgbwcmyk01_YeGeo.jp2
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the QGIS-commit
mailing list