Skip to content

Commit 4eff113

Browse files
author
timlinux
committed
Updates so that paths are correctly set based on changes in
qgisapplication git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8715 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 6acb003 commit 4eff113

File tree

3 files changed

+17
-56
lines changed

3 files changed

+17
-56
lines changed

tests/src/core/testqgsapplication.cpp

+8-23
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,27 @@ class TestQgsApplication: public QObject
2626
{
2727
Q_OBJECT;
2828
private slots:
29-
void getPaths();
3029
void checkTheme();
30+
void initTestCase();
3131
private:
3232
QString getQgisPath();
3333
};
3434

35-
QString TestQgsApplication::getQgisPath()
36-
{
37-
#ifdef Q_OS_LINUX
38-
QString qgisPath = QCoreApplication::applicationDirPath () + "/../";
39-
#else //mac and win
40-
QString qgisPath = QCoreApplication::applicationDirPath () ;
41-
#endif
42-
return qgisPath;
43-
}
4435

45-
void TestQgsApplication::getPaths()
36+
void TestQgsGeometry::initTestCase()
4637
{
38+
//
39+
// Runs once before any tests are run
40+
//
4741
// init QGIS's paths - true means that all path will be inited from prefix
48-
QgsApplication::setPrefixPath(getQgisPath(), TRUE);
49-
50-
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
51-
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
52-
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
53-
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;
54-
42+
QString qgisPath = QCoreApplication::applicationDirPath ();
43+
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
44+
QgsApplication::showSettings();
5545
};
5646

5747
void TestQgsApplication::checkTheme()
5848
{
5949
QgsApplication::setPrefixPath(getQgisPath(), TRUE);
60-
61-
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
62-
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
63-
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
64-
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;
6550
QString myIconPath = QgsApplication::themePath();
6651
QPixmap myPixmap;
6752
myPixmap.load(myIconPath+"/mIconProjectionDisabled.png");

tests/src/core/testqgsgeometry.cpp

+4-22
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class TestQgsGeometry: public QObject
3535
{
3636
Q_OBJECT;
3737
private slots:
38-
QString getQgisPath(); // Gets the path to QGIS installation
3938
void initTestCase();// will be called before the first testfunction is executed.
4039
void cleanupTestCase();// will be called after the last testfunction was executed.
4140
void init();// will be called before each testfunction is executed.
@@ -64,15 +63,6 @@ class TestQgsGeometry: public QObject
6463
QString mTestDataDir;
6564
};
6665

67-
QString TestQgsGeometry::getQgisPath()
68-
{
69-
#ifdef Q_OS_LINUX
70-
QString qgisPath = QCoreApplication::applicationDirPath () + "/../";
71-
#else //mac and win
72-
QString qgisPath = QCoreApplication::applicationDirPath () ;
73-
#endif
74-
return qgisPath;
75-
}
7666

7767
void TestQgsGeometry::init()
7868
{
@@ -118,19 +108,11 @@ void TestQgsGeometry::initTestCase()
118108
// Runs once before any tests are run
119109
//
120110
// init QGIS's paths - true means that all path will be inited from prefix
121-
//QString qgisPath = QCoreApplication::applicationDirPath ();
122-
QgsApplication::setPrefixPath(getQgisPath(), TRUE);
123-
#ifdef Q_OS_LINUX
124-
// QgsApplication::setPkgDataPath(qgisPath + "/../share/qgis");
125-
// QgsApplication::setPluginPath(qgisPath + "/../lib/qgis");
126-
#endif
127-
128-
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
129-
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
130-
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
131-
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;
132-
111+
QString qgisPath = QCoreApplication::applicationDirPath ();
112+
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
113+
QgsApplication::showSettings();
133114
}
115+
134116
void TestQgsGeometry::cleanupTestCase()
135117
{
136118
//

tests/src/core/testqgsmaplayer.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,17 @@ class TestQgsMapLayer: public QObject
4747

4848
void TestQgsMapLayer::initTestCase()
4949
{
50+
//
51+
// Runs once before any tests are run
52+
//
5053
// init QGIS's paths - true means that all path will be inited from prefix
5154
QString qgisPath = QCoreApplication::applicationDirPath ();
52-
QgsApplication::setPrefixPath(qgisPath, TRUE);
53-
#ifdef Q_OS_LINUX
54-
QgsApplication::setPkgDataPath(qgisPath + "/../share/qgis");
55-
QgsApplication::setPluginPath(qgisPath + "/../lib/qgis");
56-
#endif
55+
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
56+
QgsApplication::showSettings();
5757
// Instantiate the plugin directory so that providers are loaded
5858
QgsProviderRegistry::instance(QgsApplication::pluginPath());
5959

6060
//create some objects that will be used in all tests...
61-
62-
std::cout << "Prefix PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;
63-
std::cout << "Plugin PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;
64-
std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;
65-
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;
66-
6761
//create a map layer that will be used in all tests...
6862
QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
6963
myFileName = myFileName + QDir::separator() + "points.shp";

0 commit comments

Comments
 (0)