Improved testdata deployment.
authorRohan McGovern <rohan.mcgovern@nokia.com>
Tue, 27 Sep 2011 05:07:50 +0000 (15:07 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 28 Sep 2011 00:14:48 +0000 (02:14 +0200)
Don't embed the source path into the binary, instead find the testdata
relative to the test's binary at runtime.

Use DEPLOYMENT hints for installing testdata to a device.

Change-Id: I4005422bb76adf214166fe75d66e82fb18ded04e
Reviewed-on: http://codereview.qt-project.org/5578
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp

index aaf94ea..e5dfbe5 100644 (file)
@@ -9,13 +9,9 @@ INCLUDEPATH += ../shared/
 HEADERS += ../shared/testhttpserver.h
 SOURCES += ../shared/testhttpserver.cpp
 
-symbian: {
-    importFiles.files = data
-    importFiles.path = .
-    DEPLOYMENT += importFiles
-} else {
-    DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
 
 # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
 # LIBS += -lgcov
index e810e1e..e0f7a66 100644 (file)
 // These don't let normal people run tests!
 //#include "../network-settings.h"
 
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-#define SRCDIR "."
-#endif
-
 class tst_qdeclarativepixmapcache : public QObject
 {
     Q_OBJECT
 public:
     tst_qdeclarativepixmapcache() :
-        thisfile(QUrl::fromLocalFile(__FILE__)),
+        thisfile(QUrl::fromLocalFile(QCoreApplication::applicationFilePath())),
         server(14452)
     {
-        server.serveDirectory(SRCDIR "/data/http");
+        server.serveDirectory(QCoreApplication::applicationDirPath() + "/data/http");
     }
 
 private slots:
@@ -368,7 +363,7 @@ void createNetworkServer()
 {
    QEventLoop eventLoop;
    TestHTTPServer server(14453);
-   server.serveDirectory(SRCDIR "/data/http");
+   server.serveDirectory(QCoreApplication::applicationDirPath() + "/data/http");
    QTimer::singleShot(100, &eventLoop, SLOT(quit()));
    eventLoop.exec();
 }