mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Added regression test for ticket #992
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8980 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
bc3da6a776
commit
ca3dd86ed4
@ -127,6 +127,27 @@ ELSE (APPLE)
|
||||
ENDIF (APPLE)
|
||||
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
117
tests/src/core/regression992.cpp
Normal file
117
tests/src/core/regression992.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
/***************************************************************************
|
||||
testqgsvectorfilewriter.cpp
|
||||
--------------------------------------
|
||||
Date : Frida Nov 23 2007
|
||||
Copyright : (C) 2007 by Tim Sutton
|
||||
Email : tim@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"
|
||||
|
BIN
tests/testdata/rgbwcmyk01_YeGeo.jp2
vendored
Normal file
BIN
tests/testdata/rgbwcmyk01_YeGeo.jp2
vendored
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user