From b72fd8482e9bfbf924fe05e6efdb58a6bb25b887 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 13 Mar 2012 15:18:48 +1000 Subject: Uncomment disabled code in QSettings autotest. The code in question was already commented out before the test was added to the Qt repository in 2006. After changing the code to use QFile::rename() for portability, the test appears to pass. Change-Id: I52a8578a47da419cabf5826b633cc4f2ac2c5218 Reviewed-by: Rohan McGovern --- tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index d294eec248..dbb844d204 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -1486,11 +1486,9 @@ void tst_QSettings::sync() settings1.sync(); QCOMPARE(settings1.allKeys().count(), 0); -/* - // Now "some other app" will change software.org.conf - unlink((userConfDir + "software.org.ini").toLatin1()); - rename((userConfDir + "other.software.org.ini").toLatin1(), - (userConfDir + "software.org.ini").toLatin1()); + // Now "some other app" will change software.org.ini + QVERIFY(QFile::rename((userConfDir + "other.software.org.ini").toLatin1(), + (userConfDir + "software.org.ini").toLatin1())); settings1.sync(); QCOMPARE(settings1.value("alpha/beta/geometry").toInt(), -7); @@ -1505,7 +1503,6 @@ void tst_QSettings::sync() QCOMPARE(settings1.value("moo/beta/geometry/height").toInt(), 4); QCOMPARE(settings1.value("moo/gamma/splitter").toInt(), 5); QCOMPARE(settings1.allKeys().count(), 11); -*/ } void tst_QSettings::setFallbacksEnabled_data() -- cgit v1.2.3 From 7ecbc49c55c531875d98103609e025dd1ad5c44f Mon Sep 17 00:00:00 2001 From: Alexei Rousskikh Date: Tue, 13 Mar 2012 10:10:12 -0400 Subject: QJsonParseError improvements - added human-readable error message - improved enum value names Change-Id: I86d4bb419f9581f85d61b6e090048f1943017f9e Reviewed-by: Lars Knoll --- tests/auto/corelib/json/tst_qtjson.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 87820d2e78..8a206dd6f9 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1186,7 +1186,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n 11111"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::EndOfNumber); + QCOMPARE(error.error, QJsonParseError::TerminationByNumber); QCOMPARE(error.offset, 11); } { @@ -1210,7 +1210,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); + QCOMPARE(error.error, QJsonParseError::IllegalEscapeSequence); QCOMPARE(error.offset, 11); } { @@ -1218,7 +1218,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"foo" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); + QCOMPARE(error.error, QJsonParseError::IllegalUTF8String); QCOMPARE(error.offset, 13); } { @@ -1226,7 +1226,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \""; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::EndOfString); + QCOMPARE(error.error, QJsonParseError::UnterminatedString); QCOMPARE(error.offset, 8); } { @@ -1234,7 +1234,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"c" UNICODE_DJE "a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); + QCOMPARE(error.error, QJsonParseError::IllegalEscapeSequence); QCOMPARE(error.offset, 15); } { @@ -1242,7 +1242,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"c" UNICODE_DJE "a" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); + QCOMPARE(error.error, QJsonParseError::IllegalUTF8String); QCOMPARE(error.offset, 14); } { @@ -1250,7 +1250,7 @@ void TestQtJson::fromJsonErrors() QByteArray json = "[\n \"c" UNICODE_DJE "a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); - QCOMPARE(error.error, QJsonParseError::EndOfString); + QCOMPARE(error.error, QJsonParseError::UnterminatedString); QCOMPARE(error.offset, 14); } } -- cgit v1.2.3 From 2c4845ce331e5dfaf5e106f74871ce16721a1358 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Mar 2012 11:44:19 +0100 Subject: Fix some compiler warnings in tests. - Unused variables - Deprecated conversion from const char * to char *. Change-Id: Iea0b9c4613ea74cead6d95ba12ad1028f531cbff Reviewed-by: Jason McDonald --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index f007d44262..4eabd61025 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -718,6 +718,11 @@ void tst_QString::acc_01() } } +#ifdef Q_CC_GNU +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-security" +#endif + void tst_QString::isNull() { QString a; @@ -728,6 +733,10 @@ void tst_QString::isNull() QVERIFY(!a.isNull()); } +#ifdef Q_CC_GNU +# pragma GCC diagnostic pop +#endif + void tst_QString::isEmpty() { QString a; -- cgit v1.2.3 From e5d549552614f89dd73b29fc3ee4710f65bb1e57 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 20 Mar 2012 18:01:20 +0100 Subject: Make QCoreApplication::applicationName() default to argv[0] This makes it more useful in all the Qt apps that don't set it, given that it's used internally by QTemporaryFile, QTemporaryDir, QStandardPaths, QDBus, QAccessibleApplication, etc. Qt4 compatibility in the deprecated QDesktopServices is preserved, no fallback there. Change-Id: I584463507cf917a3720793c6bd45d07c60f8356c Reviewed-by: Thiago Macieira --- .../auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp | 14 ++++---------- .../kernel/qcoreapplication/tst_qcoreapplication.cpp | 3 ++- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index a6eabbbed6..e9af29494b 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -186,18 +186,12 @@ void tst_qstandardpaths::testDataLocation() { // On all platforms, DataLocation should be GenericDataLocation / organization name / app name // This allows one app to access the data of another app. - { - const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - const QString app = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - QCOMPARE(base, app); - } + const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths"); QCoreApplication::instance()->setOrganizationName("Qt"); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/tst_qstandardpaths"); QCoreApplication::instance()->setApplicationName("QtTest"); - { - const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - const QString app = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - QCOMPARE(app, base + "/Qt/QtTest"); - } + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/QtTest"); #ifdef Q_XDG_PLATFORM setDefaultLocations(); diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 84d723ca61..f4aefb2726 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -121,7 +121,8 @@ void tst_QCoreApplication::qAppName() int argc = 1; char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); - QVERIFY(!::qAppName().isEmpty()); + QCOMPARE(::qAppName(), QString::fromLatin1("tst_qcoreapplication")); + QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1("tst_qcoreapplication")); } void tst_QCoreApplication::argc() -- cgit v1.2.3 From 5185a28139800a9fef49dabc6c110e017f83cdd6 Mon Sep 17 00:00:00 2001 From: Jonas Rabbe Date: Wed, 28 Mar 2012 12:07:19 +1000 Subject: Fix a crash in QFactoryLoader The change in plugin loading has meant that different plugins in the same plugin folder will not be handled properly when loaded with different instances of QFactoryLoader. A solution is to only unload compatability plugins from QFactoryLoader::update() since they are the only plugins that are actually loaded in that method. This auto test shows the error on the current version of QFactoryLoader and passes with the fix described above. Change-Id: I12001525d51bb631d6742c5965357598322f247c Reviewed-by: Lars Knoll --- tests/auto/corelib/plugin/plugin.pro | 1 + .../plugin/qfactoryloader/plugin1/plugin1.cpp | 47 +++++++++++ .../plugin/qfactoryloader/plugin1/plugin1.h | 58 ++++++++++++++ .../plugin/qfactoryloader/plugin1/plugin1.pro | 10 +++ .../qfactoryloader/plugin1/plugininterface1.h | 59 ++++++++++++++ .../plugin/qfactoryloader/plugin2/plugin2.cpp | 47 +++++++++++ .../plugin/qfactoryloader/plugin2/plugin2.h | 58 ++++++++++++++ .../plugin/qfactoryloader/plugin2/plugin2.pro | 10 +++ .../qfactoryloader/plugin2/plugininterface2.h | 59 ++++++++++++++ .../plugin/qfactoryloader/qfactoryloader.pro | 15 ++++ .../corelib/plugin/qfactoryloader/test/test.pro | 21 +++++ .../plugin/qfactoryloader/tst_qfactoryloader.cpp | 91 ++++++++++++++++++++++ 12 files changed, 476 insertions(+) create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h create mode 100644 tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/test/test.pro create mode 100644 tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/plugin/plugin.pro b/tests/auto/corelib/plugin/plugin.pro index 24de36e4ec..506f6abaeb 100644 --- a/tests/auto/corelib/plugin/plugin.pro +++ b/tests/auto/corelib/plugin/plugin.pro @@ -1,5 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ + qfactoryloader \ qlibrary \ qplugin \ qpluginloader \ diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp new file mode 100644 index 0000000000..542b58a5bf --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "plugin1.h" + +QString Plugin1::pluginName() const +{ + return QLatin1String("Plugin1 ok"); +} diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h new file mode 100644 index 0000000000..02d814e1fa --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef THEPLUGIN_H +#define THEPLUGIN_H + +#include +#include +#include "plugininterface1.h" + +class Plugin1 : public QObject, public PluginInterface1 +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface1") + Q_INTERFACES(PluginInterface1) + +public: + virtual QString pluginName() const; +}; + +#endif // THEPLUGIN_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro new file mode 100644 index 0000000000..1d578c0b2e --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +CONFIG += plugin +HEADERS = plugin1.h +SOURCES = plugin1.cpp +TARGET = $$qtLibraryTarget(plugin1) +DESTDIR = ../bin + +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qfactoryloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h new file mode 100644 index 0000000000..37f53c9c89 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugininterface1.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PLUGININTERFACE1_H +#define PLUGININTERFACE1_H + +#include + +struct PluginInterface1 { + virtual ~PluginInterface1() {} + virtual QString pluginName() const = 0; +}; + +QT_BEGIN_NAMESPACE + +#define PluginInterface1_iid "org.qt-project.Qt.autotests.plugininterface1" + +Q_DECLARE_INTERFACE(PluginInterface1, PluginInterface1_iid) + +QT_END_NAMESPACE + +#endif // PLUGININTERFACE1_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp new file mode 100644 index 0000000000..b0a8f08495 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "plugin2.h" + +QString Plugin2::pluginName() const +{ + return QLatin1String("Plugin2 ok"); +} diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h new file mode 100644 index 0000000000..f5741246ab --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef THEPLUGIN_H +#define THEPLUGIN_H + +#include +#include +#include "plugininterface2.h" + +class Plugin2 : public QObject, public PluginInterface2 +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface2") + Q_INTERFACES(PluginInterface2) + +public: + virtual QString pluginName() const; +}; + +#endif // THEPLUGIN_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro new file mode 100644 index 0000000000..1a8bd3a721 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +CONFIG += plugin +HEADERS = plugin2.h +SOURCES = plugin2.cpp +TARGET = $$qtLibraryTarget(plugin2) +DESTDIR = ../bin + +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qfactoryloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h new file mode 100644 index 0000000000..3fc57f1df2 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugininterface2.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PLUGININTERFACE2_H +#define PLUGININTERFACE2_H + +#include + +struct PluginInterface2 { + virtual ~PluginInterface2() {} + virtual QString pluginName() const = 0; +}; + +QT_BEGIN_NAMESPACE + +#define PluginInterface2_iid "org.qt-project.Qt.autotests.plugininterface2" + +Q_DECLARE_INTERFACE(PluginInterface2, PluginInterface2_iid) + +QT_END_NAMESPACE + +#endif // PLUGININTERFACE2_H diff --git a/tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro b/tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro new file mode 100644 index 0000000000..42bc01e2ed --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/qfactoryloader.pro @@ -0,0 +1,15 @@ +QT = core-private +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = \ + plugin1 \ + plugin2 \ + test + +TARGET = tst_qpluginloader + +# no special install rule for subdir +INSTALLS = + + +CONFIG += parallel_test diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro new file mode 100644 index 0000000000..d03af231aa --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro @@ -0,0 +1,21 @@ +CONFIG += testcase +TARGET = ../tst_qfactoryloader +QT = core-private testlib + +SOURCES = \ + ../tst_qfactoryloader.cpp + +HEADERS = \ + ../plugin1/plugininterface1.h \ + ../plugin2/plugininterface2.h + +win32 { + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qfactoryloader + } else { + TARGET = ../../release/tst_qfactoryloader + } +} + +mac: CONFIG -= app_bundle +mac: CONFIG += insignificant_test # QTBUG-22765 diff --git a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp new file mode 100644 index 0000000000..d4ed63dc37 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include "plugin1/plugininterface1.h" +#include "plugin2/plugininterface2.h" + +class tst_QFactoryLoader : public QObject +{ + Q_OBJECT +public slots: + void initTestCase(); + +private slots: + void usingTwoFactoriesFromSameDir(); +}; + +static const char binFolderC[] = "bin"; + +void tst_QFactoryLoader::initTestCase() +{ + const QString binFolder = QFINDTESTDATA(binFolderC); + QVERIFY2(!binFolder.isEmpty(), "Unable to locate 'bin' folder"); + + QCoreApplication::setLibraryPaths(QStringList(QFileInfo(binFolder).absolutePath())); +} + +void tst_QFactoryLoader::usingTwoFactoriesFromSameDir() +{ + const QString suffix = QLatin1Char('/') + QLatin1String(binFolderC); + QFactoryLoader loader1(PluginInterface1_iid, suffix); + + PluginInterface1 *plugin1 = qobject_cast(loader1.instance(0)); + QVERIFY2(plugin1, + qPrintable(QString::fromLatin1("Cannot load plugin '%1'") + .arg(QLatin1String(PluginInterface1_iid)))); + + QFactoryLoader loader2(PluginInterface2_iid, suffix); + + PluginInterface2 *plugin2 = qobject_cast(loader2.instance(0)); + QVERIFY2(plugin2, + qPrintable(QString::fromLatin1("Cannot load plugin '%1'") + .arg(QLatin1String(PluginInterface2_iid)))); + + QCOMPARE(plugin1->pluginName(), QLatin1String("Plugin1 ok")); + QCOMPARE(plugin2->pluginName(), QLatin1String("Plugin2 ok")); +} + +QTEST_MAIN(tst_QFactoryLoader) +#include "tst_qfactoryloader.moc" -- cgit v1.2.3 From 698b33fccebbd1cb4094fdf8dc681108824530f5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 29 Mar 2012 12:25:09 +0200 Subject: Properly detach when the modified object is a sub object The clone() method didn't detach if we had enough memory allocated, but didn't consider that the object being modified is not the root object of the binary blob. Change-Id: I9a479ae1c873b7fe9cff7e13c539e7a41961bf68 Reviewed-by: Cristiano di Flora Reviewed-by: abcd Reviewed-by: Jamey Hicks --- tests/auto/corelib/json/tst_qtjson.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 8a206dd6f9..4ab4b78da1 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -122,6 +122,7 @@ private Q_SLOTS: void assignArrays(); void testTrailingComma(); + void testDetachBug(); private: QString testDataDir; }; @@ -1820,5 +1821,29 @@ void TestQtJson::testTrailingComma() } } +void TestQtJson::testDetachBug() +{ + QJsonObject dynamic; + QJsonObject embedded; + + QJsonObject local; + + embedded.insert("Key1", QString("Value1")); + embedded.insert("Key2", QString("Value2")); + dynamic.insert(QStringLiteral("Bogus"), QString("bogusValue")); + dynamic.insert("embedded", embedded); + local = dynamic.value("embedded").toObject(); + + dynamic.remove("embedded"); + + QCOMPARE(local.keys().size(),2); + local.remove("Key1"); + local.remove("Key2"); + QCOMPARE(local.keys().size(), 0); + + local.insert("Key1", QString("anotherValue")); + QCOMPARE(local.keys().size(), 1); +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" -- cgit v1.2.3 From 8f2a088028cf074a08e5252509c60e0f1021c43f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 2 Apr 2012 14:22:04 +0200 Subject: Fix MSVC warnings in tests. - Unused variables - conversion truncations - Overflow in expressions like '-1 + sizeof()' Change-Id: Ibbd18497951e9e7e9dccaf596cb4e864b69ec02c Reviewed-by: Jason McDonald --- tests/auto/corelib/codecs/utf8/tst_utf8.cpp | 2 +- tests/auto/corelib/io/qdir/tst_qdir.cpp | 2 +- .../corelib/io/qprocess/testProcessEchoGui/main_win.cpp | 10 +++++----- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 2 +- tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp | 17 ++++++++++------- 5 files changed, 18 insertions(+), 15 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index dd6774e101..b80ba8e665 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -185,7 +185,7 @@ void tst_Utf8::charByChar() } if (encoded.startsWith(utf8bom)) - encoded = encoded.mid(strlen(utf8bom)); + encoded = encoded.mid(int(strlen(utf8bom))); QCOMPARE(encoded, utf8); } { diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index b7fc366a39..250575bea0 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -53,7 +53,7 @@ #include "../../../network-settings.h" #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(_WIN32_WINNT) #define _WIN32_WINNT 0x500 #endif diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp index a8a17b6951..3bae41e83e 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp @@ -42,10 +42,10 @@ #include -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) +int APIENTRY WinMain(HINSTANCE /* hInstance */, + HINSTANCE /* hPrevInstance */, + LPSTR /* lpCmdLine */, + int /* nCmdShow */) { HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); @@ -64,4 +64,4 @@ int APIENTRY WinMain(HINSTANCE hInstance, WriteFile(hStderr, &c, 1, &wrote, 0); } return 0; -} \ No newline at end of file +} diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index d93e00eed8..09bd9fe445 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -429,7 +429,7 @@ template<> struct TestValueFactory { static uchar *create() { return new uchar('u'); } }; template<> struct TestValueFactory { - static float *create() { return new float(3.14); } + static float *create() { return new float(3.14f); } }; template<> struct TestValueFactory { static QObject * *create() { return new QObject *(0); } diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index bd9fa2a8db..8a60bb1876 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -984,7 +984,7 @@ void tst_QXmlStream::writeAttributesWithSpace() const QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeEmptyElement("A"); - writer.writeAttribute("attribute", QString("value")+QChar::Nbsp); + writer.writeAttribute("attribute", QStringLiteral("value") + QChar(QChar::Nbsp)); writer.writeEndDocument(); QString s = QString("\n").arg(QChar(QChar::Nbsp)); QCOMPARE(buffer.buffer().data(), s.toUtf8().data()); @@ -1512,35 +1512,38 @@ void tst_QXmlStream::hasError() const // Failure caused by write(QString) FakeBuffer fb; QVERIFY(fb.open(QBuffer::ReadWrite)); - fb.setCapacity(strlen("