From 9095f77d717e28c280300c859daa0032aaa89d8a Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Thu, 1 Apr 2010 11:56:48 +0200
Subject: [PATCH] Place tst_qmldesigner_core in local directory (again)

Also unify path handling somewhat
---
 .../qml/qmldesigner/coretests/coretests.pro   | 23 ++++++------
 .../qml/qmldesigner/coretests/testcore.cpp    | 36 +++++++++++--------
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/tests/auto/qml/qmldesigner/coretests/coretests.pro b/tests/auto/qml/qmldesigner/coretests/coretests.pro
index 30b4081de5c..ffd725dfc66 100644
--- a/tests/auto/qml/qmldesigner/coretests/coretests.pro
+++ b/tests/auto/qml/qmldesigner/coretests/coretests.pro
@@ -1,22 +1,25 @@
-include(../../../../../src/plugins/qmldesigner/config.pri)
+CREATORDIR=$$PWD/../../../../..
+
+include($$CREATORDIR/src/plugins/qmldesigner/config.pri)
 QT += testlib \
     script \
     declarative
 
-include(../../../../../src/plugins/qmldesigner/core/core.pri)
-include(../../../../../src/libs/qmljs/qmljs-lib.pri)
-HEADERS+=../../../../../src/libs/utils/changeset.h
-SOURCES+=../../../../../src/libs/utils/changeset.cpp
-INCLUDEPATH+=../../../../../src/libs
-DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB QTCREATOR_TEST
-DESTDIR = ../../../../../bin
+include($$CREATORDIR/src/plugins/qmldesigner/core/core.pri)
+include($$CREATORDIR/src/libs/qmljs/qmljs-lib.pri)
+HEADERS+=$$CREATORDIR/src/libs/utils/changeset.h
+SOURCES+=$$CREATORDIR/src/libs/utils/changeset.cpp
 
-DEFINES+=MANUALTEST_PATH=\\\"$$PWD"/../../../../manual/qml/testfiles/"\\\"
+INCLUDEPATH+=$$CREATORDIR/src/libs
+
+DEFINES+=QTCREATOR_UTILS_STATIC_LIB QML_BUILD_STATIC_LIB QTCREATOR_TEST
+DEFINES+=QTCREATORDIR=\\\"$$CREATORDIR\\\"
 
 DEPENDPATH += ..
-DEPENDPATH += ../../../../../src/plugins/qmldesigner/core/include
+DEPENDPATH += $$CREATORDIR/src/plugins/qmldesigner/core/include
 
 TARGET = tst_qmldesigner_core
+
 CONFIG += console
 CONFIG -= app_bundle
 TEMPLATE = app
diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp
index 8ecbeeef3c6..01121ea07fd 100644
--- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp
@@ -94,7 +94,20 @@ void TestCore::initTestCase()
 #endif
     Exception::setShouldAssert(false);
 
-    initializeMetaTypeSystem(QLatin1String("../../../../../share/qtcreator"));
+    initializeMetaTypeSystem(QLatin1String(QTCREATORDIR "/share/qtcreator"));
+
+
+   // Load plugins
+
+#ifdef Q_OS_MAC
+    const QString pluginPath = QTCREATORDIR "/PlugIns/QmlDesigner";
+#else
+    const QString pluginPath = QTCREATORDIR "/lib/qmldesigner";
+#endif
+
+    qDebug() << pluginPath;
+    Q_ASSERT(QFileInfo(pluginPath).exists());
+    MetaInfo::setPluginPaths(QStringList() << pluginPath);
 }
 
 void TestCore::cleanupTestCase()
@@ -525,7 +538,7 @@ void TestCore::testRewriterDynamicProperties()
 
 void TestCore::loadSubItems()
 {
-    QFile file(QCoreApplication::applicationDirPath() + "/../data/fx/topitem.qml");
+    QFile file(QString(QTCREATORDIR) + "/tests/auto/qml/qmldesigner/data/fx/topitem.qml");
     QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
 
     QPlainTextEdit textEdit1;
@@ -3220,15 +3233,6 @@ void TestCore::testMetaInfoEnums()
 
 void TestCore::testMetaInfoDotProperties()
 {
-
-#ifdef Q_OS_MAC
-    const QString pluginPath = QCoreApplication::applicationDirPath() + "/../PlugIns/QmlDesigner";
-#else
-    const QString pluginPath = QCoreApplication::applicationDirPath() + "/../"
-                               + QLatin1String("lib") + "/qmldesigner";
-#endif
-    MetaInfo::setPluginPaths(QStringList() << pluginPath);
-
     QScopedPointer<Model> model(Model::create("Qt/Text"));
     QVERIFY(model.data());
 
@@ -6249,8 +6253,10 @@ void TestCore::loadWelcomeScreen()
 
 void TestCore::loadTestFiles()
 {
+    const QString manualTestPath = QLatin1String(QTCREATORDIR) + "/tests/manual/qml/testfiles";
+    qDebug() << manualTestPath;
     { //empty.qml
-        QFile file(QString(MANUALTEST_PATH) + "/empty.qml");
+        QFile file(manualTestPath + "/empty.qml");
         QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
 
         QPlainTextEdit textEdit;
@@ -6273,7 +6279,7 @@ void TestCore::loadTestFiles()
     }
 
     { //helloworld.qml
-        QFile file(QString(MANUALTEST_PATH) + "/helloworld.qml");
+        QFile file(manualTestPath + "/helloworld.qml");
         QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
 
         QPlainTextEdit textEdit;
@@ -6303,7 +6309,7 @@ void TestCore::loadTestFiles()
         QCOMPARE(textNode.variantProperty("y").value().toInt(), 93);
     }
     { //states.qml
-        QFile file(QString(MANUALTEST_PATH) + "/states.qml");
+        QFile file(manualTestPath + "/states.qml");
         QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
 
         QPlainTextEdit textEdit;
@@ -6352,7 +6358,7 @@ void TestCore::loadTestFiles()
 
     QSKIP("See BAUHAUS-539 (component loading is broken)", SkipAll);
     { //usingbutton.qml
-        QFile file(QString(MANUALTEST_PATH) + "/usingbutton.qml");
+        QFile file(manualTestPath + "/usingbutton.qml");
         QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
 
         QPlainTextEdit textEdit;
-- 
GitLab