Skip to content
Permalink
Browse files
Tidy up to qgis unit tests:
 - install then in same dir as qgis
 - prefix installed tests with qgis_

Added test to make sure theme exists


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7216 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Sep 21, 2007
1 parent afec9ca commit a2319f4669623a430b7ddd16299d106f77317b6e
Showing with 47 additions and 156 deletions.
  1. +18 −30 tests/src/core/CMakeLists.txt
  2. +29 −126 tests/src/core/testqgsapplication.cpp
@@ -55,38 +55,26 @@ ENDIF (APPLE)
#
# QgsApplication test
#
SET(applicationtest_SRCS testqgsapplication.cpp)
SET(applicationtest_MOC_CPPS testqgsapplication.cpp)
QT4_WRAP_CPP(applicationtest_MOC_SRCS ${applicationtest_MOC_CPPS})
ADD_CUSTOM_TARGET(applicationtestmoc ALL DEPENDS ${applicationtest_MOC_SRCS})
ADD_EXECUTABLE(applicationtest ${applicationtest_SRCS})
ADD_DEPENDENCIES(applicationtest applicationtestmoc)
TARGET_LINK_LIBRARIES(applicationtest ${QT_LIBRARIES} qgis_core)
IF (APPLE)
INSTALL(TARGETS applicationtest RUNTIME DESTINATION ${QGIS_BIN_DIR}/../)
ADD_TEST(application ${QGIS_BIN_DIR}/../applicationtest)
ELSE (APPLE)
INSTALL(TARGETS applicationtest RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ADD_TEST(application ${CMAKE_CURRENT_BINARY_DIR}/applicationtest)
ENDIF (APPLE)
SET(qgis_applicationtest_SRCS testqgsapplication.cpp)
SET(qgis_applicationtest_MOC_CPPS testqgsapplication.cpp)
QT4_WRAP_CPP(qgis_applicationtest_MOC_SRCS ${qgis_applicationtest_MOC_CPPS})
ADD_CUSTOM_TARGET(qgis_applicationtestmoc ALL DEPENDS ${qgis_applicationtest_MOC_SRCS})
ADD_EXECUTABLE(qgis_applicationtest ${qgis_applicationtest_SRCS})
ADD_DEPENDENCIES(qgis_applicationtest qgis_applicationtestmoc)
TARGET_LINK_LIBRARIES(qgis_applicationtest ${QT_LIBRARIES} qgis_core)
INSTALL(TARGETS qgis_applicationtest RUNTIME DESTINATION ${QGIS_BIN_DIR})
ADD_TEST(qgis_applicationtest ${QGIS_BIN_DIR}/qgis_applicationtest)
#
# QgsFileWriter test
#
SET(filewritertest_SRCS testqgsvectorfilewriter.cpp)
SET(filewritertest_MOC_CPPS testqgsvectorfilewriter.cpp)
QT4_WRAP_CPP(filewritertest_MOC_SRCS ${filewritertest_MOC_CPPS})
ADD_CUSTOM_TARGET(filewritertestmoc ALL DEPENDS ${filewritertest_MOC_SRCS})
ADD_EXECUTABLE(filewritertest ${filewritertest_SRCS})
ADD_DEPENDENCIES(filewritertest filewritertestmoc)
TARGET_LINK_LIBRARIES(filewritertest ${QT_LIBRARIES} qgis_core)



#
# We need to install to a path
#

INSTALL(TARGETS filewritertest RUNTIME DESTINATION ${QGIS_BIN_DIR}/../)
ADD_TEST(filewriter ${QGIS_BIN_DIR}/../filewritertest)
SET(qgis_filewritertest_SRCS testqgsvectorfilewriter.cpp)
SET(qgis_filewritertest_MOC_CPPS testqgsvectorfilewriter.cpp)
QT4_WRAP_CPP(qgis_filewritertest_MOC_SRCS ${qgis_filewritertest_MOC_CPPS})
ADD_CUSTOM_TARGET(qgis_filewritertestmoc ALL DEPENDS ${qgis_filewritertest_MOC_SRCS})
ADD_EXECUTABLE(qgis_filewritertest ${qgis_filewritertest_SRCS})
ADD_DEPENDENCIES(qgis_filewritertest qgis_filewritertestmoc)
TARGET_LINK_LIBRARIES(qgis_filewritertest ${QT_LIBRARIES} qgis_core)
INSTALL(TARGETS qgis_filewritertest RUNTIME DESTINATION ${QGIS_BIN_DIR})
ADD_TEST(qgis_filewritertest ${QGIS_BIN_DIR}/qgis_filewritertest)


@@ -1,9 +1,9 @@
/***************************************************************************
testqgsapplication.cpp
--------------------------------------
Date : Sun Sep 16 12:22:49 AKDT 2007
Copyright : (C) 2007 by Gary E. Sherman
Email : sherman at mrcc dot com
testqgsapplication.cpp
--------------------------------------
Date : Sun Sep 16 12:22:49 AKDT 2007
Copyright : (C) 2007 by Gary E. Sherman
Email : sherman at mrcc dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@@ -13,21 +13,11 @@
* *
***************************************************************************/
#include <QtTest>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QObject>
#include <iostream>

#include <QApplication>
#include <QImage>
#include <QPainter>
#include <QPixmap>

#include <qgsapplication.h>
#include <qgsmaplayerregistry.h>
#include <qgsmaprender.h>
#include <qgsspatialrefsys.h>
#include <qgsvectorlayer.h>

//header for class being tested
#include <qgsapplication.h>
@@ -36,127 +26,40 @@ class TestQgsApplication: public QObject
{
Q_OBJECT;
private slots:
void QgsApplicationQgsApplication()
{
// init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(qgisPath, TRUE);

std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;

QgsApplication::initQgis();
/* QStringList myLayerList;
myLayerList << "../../../points.shp";
QStringList::Iterator myIterator = myLayerList.begin();
while( myIterator!= myLayerList.end() )
{
QString myLayerName=*myIterator;
QgsVectorLayer* layer = new QgsVectorLayer(myLayerName, myLayerName, "ogr");
if (layer && layer->isValid())
{
std::cout << "Added layer is valid " << std::endl;
}
// something's wrong
else if (layer)
{
//test must be failed here!
delete layer;
}
//Register this layer with the layers registry
QgsMapLayerRegistry::instance()->addMapLayer(layer);
++myIterator;
}
// create image and painter for it
QImage img(QSize(800,600), QImage::Format_ARGB32_Premultiplied);
QColor bgColor(255,255,255);
img.fill(bgColor.rgb());
QPainter p;
p.begin(&img);
p.setRenderHint(QPainter::Antialiasing); // use antialiasing!
QgsMapRender mapRender;
// set layers
mapRender.setLayerSet(myLayerList);
// use projection
mapRender.setProjectionsEnabled(TRUE);
QgsSpatialRefSys srs(32633); // postgis srid: wgs84 / utm zone 33N
mapRender.setDestinationSrs(srs);
// set extent
QgsRect r = mapRender.fullExtent();
r.scale(1.1); // make rectangle a bit bigger
mapRender.setExtent(r);
// set output size
mapRender.setOutputSize(img.size(), img.logicalDpiX());
// render!
mapRender.render(&p);
// painting done
p.end();
// delete layers
QgsMapLayerRegistry::instance()->removeAllMapLayers();
// save image
img.save("render.png","png");*/
QgsApplication::exitQgis();
};
void QgsApplicationselectTheme()
{

};
void QgsApplicationauthorsFilePath()
{

void getPaths();
void checkTheme();
};
void QgsApplicationdeveloperPath()
{

};
void QgsApplicationhelpAppPath()
{

};
void QgsApplicationi18nPath()
void TestQgsApplication::getPaths()
{
// init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath () + "/../";
QgsApplication::setPrefixPath(qgisPath, TRUE);

};
void QgsApplicationqgisMasterDbFilePath()
{
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;

};
void QgsApplicationqgisSettingsDirPath()
{

};
void QgsApplicationqgisUserDbFilePath()
void TestQgsApplication::checkTheme()
{
QString qgisPath = QCoreApplication::applicationDirPath () + "/../";
QgsApplication::setPrefixPath(qgisPath, TRUE);
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;
QString myIconPath = QgsApplication::themePath();
QPixmap myPixmap;
myPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
qDebug("Checking if a theme icon exists:");
qDebug(myIconPath.toLocal8Bit()+"/mIconProjectionDisabled.png");
QVERIFY(!myPixmap.isNull());

};
void QgsApplicationsplashPath()
{

};
void QgsApplicationsrsDbFilePath()
{

};
void QgsApplicationsvgPath()
{

};

};

QTEST_MAIN(TestQgsApplication)
#include "moc_testqgsapplication.cxx"

0 comments on commit a2319f4

Please sign in to comment.