Updates so that paths are correctly set based on changes in

qgisapplication



git-svn-id: http://svn.osgeo.org/qgis/trunk@8715 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2008-07-06 22:04:28 +00:00
parent ada4534450
commit 0888e99a8c
3 changed files with 17 additions and 56 deletions

View File

@ -26,42 +26,27 @@ class TestQgsApplication: public QObject
{ {
Q_OBJECT; Q_OBJECT;
private slots: private slots:
void getPaths();
void checkTheme(); void checkTheme();
void initTestCase();
private: private:
QString getQgisPath(); QString getQgisPath();
}; };
QString TestQgsApplication::getQgisPath()
{
#ifdef Q_OS_LINUX
QString qgisPath = QCoreApplication::applicationDirPath () + "/../";
#else //mac and win
QString qgisPath = QCoreApplication::applicationDirPath () ;
#endif
return qgisPath;
}
void TestQgsApplication::getPaths() void TestQgsGeometry::initTestCase()
{ {
//
// Runs once before any tests are run
//
// init QGIS's paths - true means that all path will be inited from prefix // init QGIS's paths - true means that all path will be inited from prefix
QgsApplication::setPrefixPath(getQgisPath(), TRUE); QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl; QgsApplication::showSettings();
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 TestQgsApplication::checkTheme() void TestQgsApplication::checkTheme()
{ {
QgsApplication::setPrefixPath(getQgisPath(), TRUE); QgsApplication::setPrefixPath(getQgisPath(), 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(); QString myIconPath = QgsApplication::themePath();
QPixmap myPixmap; QPixmap myPixmap;
myPixmap.load(myIconPath+"/mIconProjectionDisabled.png"); myPixmap.load(myIconPath+"/mIconProjectionDisabled.png");

View File

@ -35,7 +35,6 @@ class TestQgsGeometry: public QObject
{ {
Q_OBJECT; Q_OBJECT;
private slots: private slots:
QString getQgisPath(); // Gets the path to QGIS installation
void initTestCase();// will be called before the first testfunction is executed. void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase();// will be called after the last testfunction was executed. void cleanupTestCase();// will be called after the last testfunction was executed.
void init();// will be called before each testfunction is executed. void init();// will be called before each testfunction is executed.
@ -64,15 +63,6 @@ class TestQgsGeometry: public QObject
QString mTestDataDir; QString mTestDataDir;
}; };
QString TestQgsGeometry::getQgisPath()
{
#ifdef Q_OS_LINUX
QString qgisPath = QCoreApplication::applicationDirPath () + "/../";
#else //mac and win
QString qgisPath = QCoreApplication::applicationDirPath () ;
#endif
return qgisPath;
}
void TestQgsGeometry::init() void TestQgsGeometry::init()
{ {
@ -118,19 +108,11 @@ void TestQgsGeometry::initTestCase()
// Runs once before any tests are run // Runs once before any tests are run
// //
// init QGIS's paths - true means that all path will be inited from prefix // init QGIS's paths - true means that all path will be inited from prefix
//QString qgisPath = QCoreApplication::applicationDirPath (); QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(getQgisPath(), TRUE); QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
#ifdef Q_OS_LINUX QgsApplication::showSettings();
// QgsApplication::setPkgDataPath(qgisPath + "/../share/qgis");
// QgsApplication::setPluginPath(qgisPath + "/../lib/qgis");
#endif
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 TestQgsGeometry::cleanupTestCase() void TestQgsGeometry::cleanupTestCase()
{ {
// //

View File

@ -47,23 +47,17 @@ class TestQgsMapLayer: public QObject
void TestQgsMapLayer::initTestCase() void TestQgsMapLayer::initTestCase()
{ {
//
// Runs once before any tests are run
//
// init QGIS's paths - true means that all path will be inited from prefix // init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath (); QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(qgisPath, TRUE); QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
#ifdef Q_OS_LINUX QgsApplication::showSettings();
QgsApplication::setPkgDataPath(qgisPath + "/../share/qgis");
QgsApplication::setPluginPath(qgisPath + "/../lib/qgis");
#endif
// Instantiate the plugin directory so that providers are loaded // Instantiate the plugin directory so that providers are loaded
QgsProviderRegistry::instance(QgsApplication::pluginPath()); QgsProviderRegistry::instance(QgsApplication::pluginPath());
//create some objects that will be used in all tests... //create some objects that will be used in all tests...
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;
//create a map layer that will be used in all tests... //create a map layer that will be used in all tests...
QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
myFileName = myFileName + QDir::separator() + "points.shp"; myFileName = myFileName + QDir::separator() + "points.shp";