Skip to content

Commit

Permalink
Updates so that paths are correctly set based on changes in
Browse files Browse the repository at this point in the history
qgisapplication



git-svn-id: http://svn.osgeo.org/qgis/trunk@8715 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jul 6, 2008
1 parent ada4534 commit 0888e99
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 56 deletions.
31 changes: 8 additions & 23 deletions tests/src/core/testqgsapplication.cpp
Expand Up @@ -26,42 +26,27 @@ class TestQgsApplication: public QObject
{
Q_OBJECT;
private slots:
void getPaths();
void checkTheme();
void initTestCase();
private:
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
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 qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
QgsApplication::showSettings();
};

void TestQgsApplication::checkTheme()
{
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();
QPixmap myPixmap;
myPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
Expand Down
26 changes: 4 additions & 22 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -35,7 +35,6 @@ class TestQgsGeometry: public QObject
{
Q_OBJECT;
private slots:
QString getQgisPath(); // Gets the path to QGIS installation
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.
Expand Down Expand Up @@ -64,15 +63,6 @@ class TestQgsGeometry: public QObject
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()
{
Expand Down Expand Up @@ -118,19 +108,11 @@ void TestQgsGeometry::initTestCase()
// Runs once before any tests are run
//
// init QGIS's paths - true means that all path will be inited from prefix
//QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(getQgisPath(), TRUE);
#ifdef Q_OS_LINUX
// 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;

QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
QgsApplication::showSettings();
}

void TestQgsGeometry::cleanupTestCase()
{
//
Expand Down
16 changes: 5 additions & 11 deletions tests/src/core/testqgsmaplayer.cpp
Expand Up @@ -47,23 +47,17 @@ class TestQgsMapLayer: public QObject

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

//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...
QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
myFileName = myFileName + QDir::separator() + "points.shp";
Expand Down

0 comments on commit 0888e99

Please sign in to comment.