summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/util
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-03-24 09:23:25 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-24 19:07:22 +0100
commit518a4cb5abdca788c4bb59e570e97c01e44587c8 (patch)
tree96160c719612cd133a0abc2af316a945e12c5289 /tests/auto/gui/util
parentad81f75429f6c5586d667880f90f4a425f1ce968 (diff)
Restore Qt4 compat in QDesktopServices::DataLocation
"/data/" was appended to the base directory. Change-Id: I220f2ce74c36b795bc49c7c84106feb0709d1547 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/gui/util')
-rw-r--r--tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
index 0ad37c21e8..618587356b 100644
--- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
@@ -57,12 +57,11 @@ private slots:
void cleanup();
void openUrl();
void handlers();
+ void testDataLocation();
};
tst_qdesktopservices::tst_qdesktopservices()
{
- QCoreApplication::setOrganizationName("Nokia");
- QCoreApplication::setApplicationName("tst_qdesktopservices");
}
tst_qdesktopservices::~tst_qdesktopservices()
@@ -117,5 +116,37 @@ void tst_qdesktopservices::handlers()
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString());
}
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
+#define Q_XDG_PLATFORM
+#endif
+
+void tst_qdesktopservices::testDataLocation()
+{
+ // This is the one point where QDesktopServices and QStandardPaths differ.
+ // QDesktopServices on unix returns "data"/orgname/appname for DataLocation, for Qt4 compat.
+ // And the appname in qt4 defaulted to empty, not to argv[0].
+ {
+ const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
+ const QString app = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#ifdef Q_XDG_PLATFORM
+ QCOMPARE(app, base + "/data//"); // as ugly as in Qt4
+#else
+ QCOMPARE(app, base);
+#endif
+ }
+ QCoreApplication::instance()->setOrganizationName("Qt");
+ QCoreApplication::instance()->setApplicationName("QtTest");
+ {
+ const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
+ const QString app = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#ifdef Q_XDG_PLATFORM
+ QCOMPARE(app, base + "/data/Qt/QtTest");
+#else
+ QCOMPARE(app, base + "/Qt/QtTest");
+#endif
+ }
+}
+
QTEST_MAIN(tst_qdesktopservices)
+
#include "tst_qdesktopservices.moc"