diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-10 12:48:01 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-10 15:31:45 +0200 |
commit | 143c4d3e13a430b951f4f4f8c28db14303f80605 (patch) | |
tree | 2b89637b93fc7d81c674106008566010f986d67c /tests/auto | |
parent | a7ed81b557d593a8ddb43b71bf4bbf3b44ead070 (diff) | |
parent | e5337ad1b1fb02873ce7b5ca8db45f6fd8063352 (diff) |
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts:
configure
src/widgets/styles/qwindowsxpstyle.cpp
tests/auto/gui/kernel/qwindow/qwindow.pro
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
Change-Id: I624b6d26abce9874c610c04954c1c45bc074bef3
Diffstat (limited to 'tests/auto')
64 files changed, 1220 insertions, 242 deletions
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 86e3433c12..81084dbaf4 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -381,7 +381,7 @@ void tst_QtConcurrentRun::exceptions() bool caught = false; try { QtConcurrent::run(throwFunction).waitForFinished(); - } catch (Exception &e) { + } catch (Exception &) { caught = true; } if (!caught) @@ -390,7 +390,7 @@ void tst_QtConcurrentRun::exceptions() caught = false; try { QtConcurrent::run(throwFunctionReturn).waitForFinished(); - } catch (Exception &e) { + } catch (Exception &) { caught = true; } if (!caught) diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index 025bb349d6..07ea4c4545 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 <windows.h> -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/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() diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index ed396d3344..9b1d5c0b68 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -239,18 +239,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/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 87820d2e78..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; }; @@ -1186,7 +1187,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 +1211,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 +1219,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 +1227,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 +1235,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 +1243,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 +1251,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); } } @@ -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" diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 29fa98b8bb..e8f6c29a94 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<char*>("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() diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 9f4944b44b..4eb26928ac 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -450,7 +450,7 @@ template<> struct TestValueFactory<QMetaType::UChar> { static uchar *create() { return new uchar('u'); } }; template<> struct TestValueFactory<QMetaType::Float> { - static float *create() { return new float(3.14); } + static float *create() { return new float(3.14f); } }; template<> struct TestValueFactory<QMetaType::QObjectStar> { static QObject * *create() { return new QObject *(0); } 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 <QtCore/qstring.h> +#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 <QtCore/qobject.h> +#include <QtCore/qplugin.h> +#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 <QtCore/QtGlobal> + +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 <QtCore/qstring.h> +#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 <QtCore/qobject.h> +#include <QtCore/qplugin.h> +#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 <QtCore/QtGlobal> + +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 <QtTest/qtest.h> +#include <QtCore/qdir.h> +#include <QtCore/qfileinfo.h> +#include <private/qfactoryloader_p.h> +#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<PluginInterface1 *>(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<PluginInterface2 *>(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" diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 7afd435e52..1905c9c049 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -780,6 +780,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; @@ -790,6 +795,10 @@ void tst_QString::isNull() QVERIFY(!a.isNull()); } +#ifdef Q_CC_GNU +# pragma GCC diagnostic pop +#endif + void tst_QString::isEmpty() { QString a; 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("<?xml version=\"1.0\" encoding=\"UTF-8\"?><A attribute=\"value%1\"/>\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("<?xml version=\"")); + const QByteArray expected = QByteArrayLiteral("<?xml version=\""); + fb.setCapacity(expected.size()); QXmlStreamWriter writer(&fb); writer.writeStartDocument(); QVERIFY(writer.hasError()); - QCOMPARE(fb.data(), QByteArray("<?xml version=\"")); + QCOMPARE(fb.data(), expected); } { // Failure caused by write(char *) FakeBuffer fb; QVERIFY(fb.open(QBuffer::ReadWrite)); - fb.setCapacity(strlen("<?xml version=\"1.0")); + const QByteArray expected = QByteArrayLiteral("<?xml version=\"1.0"); + fb.setCapacity(expected.size()); QXmlStreamWriter writer(&fb); writer.writeStartDocument(); QVERIFY(writer.hasError()); - QCOMPARE(fb.data(), QByteArray("<?xml version=\"1.0")); + QCOMPARE(fb.data(), expected); } { // Failure caused by write(QStringRef) FakeBuffer fb; QVERIFY(fb.open(QBuffer::ReadWrite)); - fb.setCapacity(strlen("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test xmlns:")); + const QByteArray expected = QByteArrayLiteral("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test xmlns:"); + fb.setCapacity(expected.size()); QXmlStreamWriter writer(&fb); writer.writeStartDocument(); writer.writeStartElement("test"); writer.writeNamespace("http://foo.bar", "foo"); QVERIFY(writer.hasError()); - QCOMPARE(fb.data(), QByteArray("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test xmlns:")); + QCOMPARE(fb.data(), expected); } { diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index 3efb8de499..ed5c03ea64 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -350,8 +350,6 @@ QT_END_NAMESPACE #endif -//bool compare(const QVariantList &l1, const QVariantList &l2); -//bool compare(const QVariantMap &m1, const QVariantMap &m2); template<typename T> bool compare(const T &t1, const T &t2) { return t1 == t2; } diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index 3810546146..cfe26d23e7 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -122,6 +122,8 @@ private slots: void update(); void query(); void inputDirection(); + void inputMethodAccepted(); + private: InputItem m_inputItem; PlatformInputContext m_platformInputContext; @@ -304,5 +306,23 @@ void tst_qinputmethod::inputDirection() QCOMPARE(m_platformInputContext.m_localeCallCount, 1); } +void tst_qinputmethod::inputMethodAccepted() +{ + InputItem disabledItem; + disabledItem.setEnabled(false); + + DummyWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qApp->focusWindow(), &window); + window.setFocusObject(&disabledItem); + + QCOMPARE(m_platformInputContext.inputMethodAccepted(), false); + + window.setFocusObject(&m_inputItem); + QCOMPARE(m_platformInputContext.inputMethodAccepted(), true); +} + QTEST_MAIN(tst_qinputmethod) #include "tst_qinputmethod.moc" diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 861ad3835d..c4db74b6ec 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -422,7 +422,9 @@ void tst_QKeySequence::mnemonic() QFETCH(QString, key); QFETCH(bool, warning); -#ifndef QT_NO_DEBUG +#ifdef QT_NO_DEBUG + Q_UNUSED(warning) +#else if (warning) { QString str = QString::fromLatin1("QKeySequence::mnemonic: \"%1\" contains multiple occurrences of '&'").arg(string); QTest::ignoreMessage(QtWarningMsg, qPrintable(str)); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index df58d8340b..3dc2886b80 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -69,6 +69,7 @@ private slots: void close(); void activateAndClose(); void mouseEventSequence(); + void windowModality(); void initTestCase() { @@ -223,6 +224,9 @@ void tst_QWindow::isExposed() window.hide(); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); +#endif QTRY_VERIFY(window.received(QEvent::Expose) > 1); QTRY_VERIFY(!window.isExposed()); } @@ -804,5 +808,36 @@ void tst_QWindow::mouseEventSequence() QCOMPARE(window.mouseSequenceSignature, QLatin1String("prprprpr")); } +void tst_QWindow::windowModality() +{ + qRegisterMetaType<Qt::WindowModality>("Qt::WindowModality"); + + QWindow window; + QSignalSpy spy(&window, SIGNAL(windowModalityChanged(Qt::WindowModality))); + + QCOMPARE(window.windowModality(), Qt::NonModal); + window.setWindowModality(Qt::NonModal); + QCOMPARE(window.windowModality(), Qt::NonModal); + QCOMPARE(spy.count(), 0); + + window.setWindowModality(Qt::WindowModal); + QCOMPARE(window.windowModality(), Qt::WindowModal); + QCOMPARE(spy.count(), 1); + window.setWindowModality(Qt::WindowModal); + QCOMPARE(window.windowModality(), Qt::WindowModal); + QCOMPARE(spy.count(), 1); + + window.setWindowModality(Qt::ApplicationModal); + QCOMPARE(window.windowModality(), Qt::ApplicationModal); + QCOMPARE(spy.count(), 2); + window.setWindowModality(Qt::ApplicationModal); + QCOMPARE(window.windowModality(), Qt::ApplicationModal); + QCOMPARE(spy.count(), 2); + + window.setWindowModality(Qt::NonModal); + QCOMPARE(window.windowModality(), Qt::NonModal); + QCOMPARE(spy.count(), 3); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp index f4cf586da1..26a68338a6 100644 --- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp +++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp @@ -42,7 +42,7 @@ #include <QtTest/QtTest> #include <qmatrix.h> -#include <math.h> +#include <qmath.h> #include <qpolygon.h> Q_DECLARE_METATYPE(QRect) diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index e8374b0cae..38208d27c8 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -118,6 +118,7 @@ struct SharedResource : public QOpenGLSharedResource void freeResource(QOpenGLContext *context) { Q_ASSERT(context == QOpenGLContext::currentContext()); + Q_UNUSED(context) resource = 0; if (tracker) tracker->freeResourceCalls++; diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp index c609b4a1ed..a33e3cd13b 100644 --- a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp +++ b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp @@ -47,6 +47,7 @@ #include <qabstracttextdocumentlayout.h> #include <qimage.h> #include <qtextobject.h> +#include <qfontmetrics.h> class tst_QAbstractTextDocumentLayout : public QObject { @@ -59,6 +60,7 @@ public: private slots: void getSetCheck(); void maximumBlockCount(); + void anchorAt(); }; tst_QAbstractTextDocumentLayout::tst_QAbstractTextDocumentLayout() @@ -152,5 +154,35 @@ void tst_QAbstractTextDocumentLayout::maximumBlockCount() QCOMPARE(layout.blockCount, 10); } +void tst_QAbstractTextDocumentLayout::anchorAt() +{ + QTextDocument doc; + doc.setHtml("<a href=\"link\">foo</a>"); + QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); + QTextBlock firstBlock = doc.begin(); + QTextLayout *layout = firstBlock.layout(); + layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + + doc.setPageSize(QSizeF(1000, 1000)); + QFontMetrics metrics(layout->font()); + QPointF blockStart = documentLayout->blockBoundingRect(firstBlock).topLeft(); + + // anchorAt on start returns link + QRect linkBr = metrics.boundingRect("foo"); + QPointF linkPoint(linkBr.width() + blockStart.x(), (linkBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->anchorAt(linkPoint), QString("link")); + + // anchorAt() on top of preedit at end should not assert + QRect preeditBr = metrics.boundingRect(doc.toPlainText() + "xx"); + QPointF preeditPoint(preeditBr.width() + blockStart.x(), (preeditBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->anchorAt(preeditPoint), QString()); + + // preedit at start should not return link + layout->setPreeditArea(0, "xxx"); + preeditBr = metrics.boundingRect("xx"); + preeditPoint = QPointF(preeditBr.width() + blockStart.x(), (preeditBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->anchorAt(preeditPoint), QString()); +} + QTEST_MAIN(tst_QAbstractTextDocumentLayout) #include "tst_qabstracttextdocumentlayout.moc" diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 034d08fc8f..c853aaa100 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -11,4 +11,3 @@ wince* { } mac: CONFIG += insignificant_test # QTBUG-23062 -win32:CONFIG += insignificant_test # QTBUG-24193 diff --git a/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro b/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro index bb0d8e3c4a..f5cf957722 100644 --- a/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro +++ b/tests/auto/gui/text/qfontmetrics/qfontmetrics.pro @@ -3,5 +3,3 @@ TARGET = tst_qfontmetrics QT += testlib SOURCES += tst_qfontmetrics.cpp RESOURCES += testfont.qrc - -win32:CONFIG += insignificant_test # QTBUG-24195 diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro index 97b9806c11..acdff0584f 100644 --- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro +++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro @@ -10,5 +10,3 @@ wince* { } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } - -win32:CONFIG += insignificant_test # QTBUG-24196 diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index a88e93c93e..d566f0a20d 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -105,7 +105,7 @@ private slots: void thaiIsolatedSaraAm(); void thaiWithZWJ(); - + void thaiMultipleVowels(); private: bool haveTestFonts; }; @@ -1325,5 +1325,27 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); } +void tst_QTextScriptEngine::thaiMultipleVowels() +{ + QString s(QString::fromUtf8("ส")); + for (int i = 0; i < 100; i++) + s += QChar(0x0E47); // Add lots of "VOWEL SIGN MAI TAI KHU N/S-T" stacked on top of the character + s += QChar(0x200D); // Now add a zero width joiner (which adds a circle which is hidden) + for (int i = 0; i < 100; i++) + s += QChar(0x0E47); //Add lots of "VOWEL SIGN MAI TAI KHU N/S-T" stacked on top of the ZWJ + + for (int i = 0; i < 10; i++) + s += s; //Repeat the string to make it more likely to crash if we have a buffer overflow + QTextLayout layout(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QTextEngine *e = layout.engine(); + e->width(0, s.length()); //force itemize and shape + + // If we haven't crashed at this point, then the test has passed. +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index f2c12bc092..4c36e2d308 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -78,24 +78,12 @@ public: static bool compareReplyIMAP(QByteArray const& actual) { - QList<QByteArray> expected; - - // Mandriva; old test server - expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ) - .append(QtNetworkSettings::serverName().toAscii()) - .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - - // Ubuntu 10.04; new test server - expected << QByteArray( "* OK " ) - .append(QtNetworkSettings::serverLocalName().toAscii()) - .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); - - // Feel free to add more as needed - - Q_FOREACH (QByteArray const& ba, expected) { - if (ba == actual) { - return true; - } + // Server greeting may contain capability, version and server name + // But spec only requires "* OK" and "\r\n" + // Match against a prefix and postfix that covers all Cyrus versions + if (actual.startsWith("* OK ") + && actual.endsWith("server ready\r\n")) { + return true; } return false; @@ -103,27 +91,7 @@ public: static bool compareReplyIMAPSSL(QByteArray const& actual) { - QList<QByteArray> expected; - - // Mandriva; old test server - expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ) - .append(QtNetworkSettings::serverName().toAscii()) - .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - - // Ubuntu 10.04; new test server - expected << QByteArray( "* OK " ) - .append(QtNetworkSettings::serverLocalName().toAscii()) - .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); - - // Feel free to add more as needed - - Q_FOREACH (QByteArray const& ba, expected) { - if (ba == actual) { - return true; - } - } - - return false; + return compareReplyIMAP(actual); } static bool compareReplyFtp(QByteArray const& actual) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 150f5c4616..185c3eedd8 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -399,6 +399,9 @@ private Q_SLOTS: void closeDuringDownload_data(); void closeDuringDownload(); + void ftpAuthentication_data(); + void ftpAuthentication(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); private: @@ -6775,6 +6778,35 @@ void tst_QNetworkReply::closeDuringDownload() QTest::qWait(1000); //cancelling ftp takes some time, this avoids a warning caused by test's cleanup() destroying the connection cache before the abort is finished } + +void tst_QNetworkReply::ftpAuthentication_data() +{ + QTest::addColumn<QString>("referenceName"); + QTest::addColumn<QString>("url"); + QTest::addColumn<int>("error"); + + QTest::newRow("invalidPassword") << (testDataDir + "/rfc3252.txt") << "ftp://ftptest:invalid@" + QtNetworkSettings::serverName() + "/home/qt-test-server/ftp/qtest/rfc3252.txt" << int(QNetworkReply::AuthenticationRequiredError); + QTest::newRow("validPassword") << (testDataDir + "/rfc3252.txt") << "ftp://ftptest:password@" + QtNetworkSettings::serverName() + "/home/qt-test-server/ftp/qtest/rfc3252.txt" << int(QNetworkReply::NoError); +} + +void tst_QNetworkReply::ftpAuthentication() +{ + QFETCH(QString, referenceName); + QFETCH(QString, url); + QFETCH(int, error); + + QFile reference(referenceName); + QVERIFY(reference.open(QIODevice::ReadOnly)); + + QNetworkRequest request(url); + QNetworkReplyPtr reply; + runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply); + + QCOMPARE(reply->url(), request.url()); + QCOMPARE(reply->error(), QNetworkReply::NetworkError(error)); +} + + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { diff --git a/tests/auto/network/socket/qlocalsocket/example/server/main.cpp b/tests/auto/network/socket/qlocalsocket/example/server/main.cpp index d066e4ef51..909bb6856f 100644 --- a/tests/auto/network/socket/qlocalsocket/example/server/main.cpp +++ b/tests/auto/network/socket/qlocalsocket/example/server/main.cpp @@ -72,7 +72,7 @@ public: if (n == 0) break; qDebug() << "Read" << str; - if ("exit" == str) + if (!qstrcmp(str, "exit")) qApp->quit(); if (socket->write(str, 100) < 0) { diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index ac27a621bb..1f68608542 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -115,6 +115,10 @@ private slots: void serverAddress_data(); void serverAddress(); + + void qtbug6305_data() { serverAddress_data(); } + void qtbug6305(); + private: #ifndef QT_NO_BEARERMANAGEMENT QNetworkSession *networkSession; @@ -828,10 +832,28 @@ void tst_QTcpServer::serverAddress() QFETCH(QHostAddress, listenAddress); QFETCH(QHostAddress, serverAddress); QTcpServer server; + + // TODO: why does this QSKIP? if (!server.listen(listenAddress)) QSKIP(qPrintable(server.errorString())); QCOMPARE(server.serverAddress(), serverAddress); } +// on OS X, calling listen() multiple times would succeed each time, which is +// most definitely not wanted. +void tst_QTcpServer::qtbug6305() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QFETCH(QHostAddress, listenAddress); + QTcpServer server; + QVERIFY2(server.listen(listenAddress), qPrintable(server.errorString())); + + QTcpServer server2; + QVERIFY(!server2.listen(listenAddress, server.serverPort())); // second listen should fail +} + QTEST_MAIN(tst_QTcpServer) #include "tst_qtcpserver.moc" diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index c53450eec6..cab3d56d32 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -309,9 +309,10 @@ void tst_QUdpSocket::broadcasting() QByteArray arr; arr.resize(serverSocket.pendingDatagramSize() + 1); QHostAddress host; quint16 port; + const int messageLength = int(strlen(message[i])); QCOMPARE((int) serverSocket.readDatagram(arr.data(), arr.size() - 1, &host, &port), - (int) strlen(message[i])); - arr.resize(strlen(message[i])); + messageLength); + arr.resize(messageLength); QCOMPARE(arr, QByteArray(message[i])); } while (serverSocket.hasPendingDatagrams()); } @@ -1202,6 +1203,7 @@ void tst_QUdpSocket::multicast_data() QHostAddress groupAddress = QHostAddress("239.255.118.62"); QHostAddress any6Address = QHostAddress(QHostAddress::AnyIPv6); QHostAddress group6Address = QHostAddress("FF01::114"); + QHostAddress dualAddress = QHostAddress(QHostAddress::Any); QTest::addColumn<QHostAddress>("bindAddress"); QTest::addColumn<bool>("bindResult"); @@ -1213,6 +1215,8 @@ void tst_QUdpSocket::multicast_data() QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true; QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false; QTest::newRow("same bind, group ipv6 address") << group6Address << true << group6Address << true; + QTest::newRow("dual bind, group ipv4 address") << dualAddress << true << groupAddress << false; + QTest::newRow("dual bind, group ipv6 address") << dualAddress << true << group6Address << true; } void tst_QUdpSocket::multicast() diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 8575b11fca..1935ef0c23 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -864,7 +864,7 @@ static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname static const char connect2a[] = "\5\1\0\3"; // just "Connect to hostname" static const char connected[] = "\5\0\0"; -#define QBA(x) (QByteArray::fromRawData(x, -1 + sizeof(x))) +#define QBA(x) (QByteArray::fromRawData(x, int(sizeof(x)) - 1)) void tst_NetworkSelfTest::socks5Proxy() { @@ -874,42 +874,48 @@ void tst_NetworkSelfTest::socks5Proxy() } ip4Address; ip4Address.data = qToBigEndian(serverIpAddress().toIPv4Address()); + const QByteArray handshakeNoAuthData = QByteArray(handshakeNoAuth, int(sizeof handshakeNoAuth) - 1); + const QByteArray handshakeOkNoAuthData = QByteArray(handshakeOkNoAuth, int(sizeof handshakeOkNoAuth) - 1); + const QByteArray connect1Data = QByteArray(connect1, int(sizeof connect1) - 1); + const QByteArray connectedData = QByteArray(connected, int(sizeof connected) - 1); + const QByteArray connect2Data = QByteArray(connect2, int(sizeof connect2) - 1); + netChat(1080, QList<Chat>() // IP address connection - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) - << Chat::send(QByteArray(connect1, -1 + sizeof connect1)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) + << Chat::send(connect1Data) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() // connect by IP << Chat::Reconnect - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) << Chat::send(QBA(connect1a) + QByteArray::fromRawData(ip4Address.buf, 4) + QBA(connect1b)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() // connect to "localhost" by hostname << Chat::Reconnect - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) - << Chat::send(QByteArray(connect2, -1 + sizeof connect2)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) + << Chat::send(connect2Data) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() // connect to server by its official name << Chat::Reconnect - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeOkNoAuthData) << Chat::send(QBA(connect2a) + char(QtNetworkSettings::serverName().size()) + QtNetworkSettings::serverName().toLatin1() + QBA(connect1b)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() @@ -918,18 +924,25 @@ void tst_NetworkSelfTest::socks5Proxy() void tst_NetworkSelfTest::socks5ProxyAuth() { + const QByteArray handshakeNoAuthData = QByteArray(handshakeNoAuth, int(sizeof handshakeNoAuth) - 1); + const QByteArray connect1Data = QByteArray(connect1, int(sizeof connect1) - 1); + const QByteArray connectedData = QByteArray(connected, int(sizeof connected) - 1); + const QByteArray handshakeAuthNotOkData = QByteArray(handshakeAuthNotOk, int(sizeof(handshakeAuthNotOk)) - 1); + const QByteArray handshakeAuthPasswordData = QByteArray(handshakeAuthPassword, int(sizeof(handshakeAuthPassword)) - 1); + const QByteArray handshakeOkPasswdAuthData = QByteArray(handshakeOkPasswdAuth, int(sizeof(handshakeOkPasswdAuth)) - 1); + netChat(1081, QList<Chat>() // unauthenticated connect -- will get error - << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) - << Chat::expect(QByteArray(handshakeAuthNotOk, -1 + sizeof handshakeAuthNotOk)) + << Chat::send(handshakeNoAuthData) + << Chat::expect(handshakeAuthNotOkData) << Chat::RemoteDisconnect // now try to connect with authentication << Chat::Reconnect - << Chat::send(QByteArray(handshakeAuthPassword, -1 + sizeof handshakeAuthPassword)) - << Chat::expect(QByteArray(handshakeOkPasswdAuth, -1 + sizeof handshakeOkPasswdAuth)) - << Chat::send(QByteArray(connect1, -1 + sizeof connect1)) - << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::send(handshakeAuthPasswordData) + << Chat::expect(handshakeOkPasswdAuthData) + << Chat::send(connect1Data) + << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 0019cc94c8..388e6ab29d 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -13,3 +13,8 @@ wince*: { } mac: CONFIG += insignificant_test # QTBUG-22812 + +win32 { + !*g++: include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri) + LIBS += -loleacc -loleaut32 -lole32 +} diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 262d185bd1..ee49d679f0 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -40,6 +40,18 @@ ****************************************************************************/ +#include <QtCore/qglobal.h> +#ifdef Q_OS_WIN +# include <QtCore/qt_windows.h> +# include <oleacc.h> +# include <servprov.h> +# include <winuser.h> +# ifndef Q_CC_MINGW +# include <Accessible2.h> +# include <AccessibleAction.h> +# include <AccessibleComponent.h> +# endif +#endif #include <QtTest/QtTest> #include <QtGui> #include <QtWidgets> @@ -269,6 +281,7 @@ private slots: void accessibleName(); void labelTest(); void accelerators(); + void bridgeTest(); protected slots: void onClicked(); @@ -2915,5 +2928,100 @@ void tst_QAccessibility::accelerators() QTestAccessibility::clearEvents(); } +void tst_QAccessibility::bridgeTest() +{ + // For now this is a simple test to see if the bridge is working at all. + // Ideally it should be extended to test all aspects of the bridge. +#ifdef Q_OS_WIN + // First, test MSAA part of bridge + QWidget *window = new QWidget; + QVBoxLayout *lay = new QVBoxLayout(window); + QPushButton *button = new QPushButton(tr("Push me"), window); + QLineEdit *le = new QLineEdit(window); + lay->addWidget(button); + lay->addWidget(le); + + window->show(); + QTest::qWaitForWindowShown(window); + + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(button); + QPoint buttonPos = button->mapToGlobal(QPoint(0,0)); + QRect buttonRect = iface->rect(); + QCOMPARE(buttonRect.topLeft(), buttonPos); + + + // All set, now test the bridge. + POINT pt; + pt.x = buttonRect.center().x(); + pt.y = buttonRect.center().y(); + IAccessible *iacc; + + VARIANT varChild; + HRESULT hr = ::AccessibleObjectFromPoint(pt, &iacc, &varChild); + QVERIFY(SUCCEEDED(hr)); + VARIANT varSELF; + varSELF.vt = VT_I4; + varSELF.lVal = 0; + + // **** Test get_accRole **** + VARIANT varRole; + hr = iacc->get_accRole(varSELF, &varRole); + QVERIFY(SUCCEEDED(hr)); + + QCOMPARE(varRole.vt, (VARTYPE)VT_I4); + QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_PUSHBUTTON); + + // **** Test accLocation **** + long x, y, w, h; + hr = iacc->accLocation(&x, &y, &w, &h, varSELF); + QCOMPARE(buttonRect, QRect(x, y, w, h)); + +#ifndef Q_CC_MINGW + // Test IAccessible2 part of bridge + IServiceProvider *pService = 0; + hr = iacc->QueryInterface(IID_IServiceProvider, (void **)&pService); + if (SUCCEEDED(hr)) { + IAccessible2 *pIA2 = 0; + hr = pService->QueryService(IID_IAccessible, IID_IAccessible2, (void**)&pIA2); + if (SUCCEEDED(hr) && pIA2) { + // The control supports IAccessible2. + // pIA2 is the reference to the accessible object's IAccessible2 interface. + + /***** Test IAccessibleComponent *****/ + IAccessibleComponent *ia2Component = 0; + hr = pIA2->QueryInterface(IID_IAccessibleComponent, (void**)&ia2Component); + QVERIFY(SUCCEEDED(hr)); + long x, y; + hr = ia2Component->get_locationInParent(&x, &y); + QVERIFY(SUCCEEDED(hr)); + QCOMPARE(button->pos(), QPoint(x, y)); + ia2Component->Release(); + + /***** Test IAccessibleAction *****/ + IAccessibleAction *ia2Action = 0; + hr = pIA2->QueryInterface(IID_IAccessibleAction, (void**)&ia2Action); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(ia2Action); + long nActions; + ia2Action->nActions(&nActions); + QVERIFY(nActions >= 1); // "Press" and "SetFocus" + BSTR actionName; + ia2Action->get_name(0, &actionName); + QString name((QChar*)actionName); + QCOMPARE(name, QAccessibleActionInterface::pressAction()); + ia2Action->Release(); + + // Done testing + pIA2->Release(); + } + pService->Release(); + } +#endif + iacc->Release(); + + QTestAccessibility::clearEvents(); +#endif +} + QTEST_MAIN(tst_QAccessibility) #include "tst_qaccessibility.moc" diff --git a/tests/auto/printsupport/kernel/qprinter/qprinter.pro b/tests/auto/printsupport/kernel/qprinter/qprinter.pro index 7543e91f8c..ebf8edea32 100644 --- a/tests/auto/printsupport/kernel/qprinter/qprinter.pro +++ b/tests/auto/printsupport/kernel/qprinter/qprinter.pro @@ -4,4 +4,3 @@ QT += printsupport widgets testlib SOURCES += tst_qprinter.cpp mac*:CONFIG+=insignificant_test -win32:CONFIG += insignificant_test # QTBUG-24191 diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 48d38a8146..404aa06399 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -199,7 +199,8 @@ QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command) return QString(array); } #else - return QString(); + Q_UNUSED(command) + return QString(); #endif } diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h index cddeca3945..2049ec7d61 100644 --- a/tests/auto/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -55,13 +55,26 @@ public: m_lastQueries(Qt::ImhNone), m_action(QInputMethod::Click), m_cursorPosition(0), - m_lastEventType(QEvent::None) + m_lastEventType(QEvent::None), + m_setFocusObjectCallCount(0) {} virtual QRectF keyboardRect() const { return m_keyboardRect; } virtual bool isAnimating() const { return m_animating; } virtual void reset() { m_resetCallCount++; } - virtual void commit() { m_commitCallCount++; } + virtual void commit() { + m_commitCallCount++; + QInputMethodEvent commitEvent; + commitEvent.setCommitString(m_commitString); + if (qGuiApp->focusObject()) + qGuiApp->sendEvent(qGuiApp->focusObject(), &commitEvent); + else + qWarning("Test input context to commit without focused object"); + } + void setCommitString(const QString &commitString) + { + m_commitString = commitString; + } virtual void update(Qt::InputMethodQueries queries) { @@ -99,12 +112,18 @@ public: m_inputDirectionCallCount++; return Qt::LeftToRight; } + virtual void setFocusObject(QObject *object) + { + Q_UNUSED(object); + m_setFocusObjectCallCount++; + } bool m_animating; bool m_visible; int m_updateCallCount; int m_resetCallCount; int m_commitCallCount; + QString m_commitString; mutable int m_localeCallCount; mutable int m_inputDirectionCallCount; Qt::InputMethodQueries m_lastQueries; @@ -112,4 +131,5 @@ public: int m_cursorPosition; int m_lastEventType; QRectF m_keyboardRect; + int m_setFocusObjectCallCount; }; diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 7acbf816f1..626c5049f0 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -54,6 +54,8 @@ #include "tst_databases.h" +Q_DECLARE_METATYPE(QSqlDriver::NotificationSource) + QT_FORWARD_DECLARE_CLASS(QSqlDatabase) struct FieldDef; @@ -385,6 +387,7 @@ void tst_QSqlDatabase::populateTestTables(QSqlDatabase db) void tst_QSqlDatabase::initTestCase() { + qRegisterMetaType<QSqlDriver::NotificationSource>("QSqlDriver::NotificationSource"); dbs.open(); for (QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it) { @@ -2064,21 +2067,19 @@ void tst_QSqlDatabase::eventNotificationPSQL() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); -#if defined(Q_OS_LINUX) - QSKIP( "Event support doesn't work on linux"); -#endif - QSqlQuery query(db); QString procedureName = qTableName("posteventProc", __FILE__); - + QString payload = "payload"; QSqlDriver &driver=*(db.driver()); QVERIFY_SQL(driver, subscribeToNotification(procedureName)); - QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&))); - query.exec(QString("NOTIFY \"%1\"").arg(procedureName)); + QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&,QSqlDriver::NotificationSource,const QVariant&))); + query.exec(QString("NOTIFY \"%1\", '%2'").arg(procedureName).arg(payload)); QCoreApplication::processEvents(); QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toString() == procedureName); + QCOMPARE(arguments.at(0).toString(), procedureName); + QCOMPARE(qVariantValue<QSqlDriver::NotificationSource>(arguments.at(1)), QSqlDriver::SelfSource); + QCOMPARE(qvariant_cast<QVariant>(arguments.at(2)).toString(), payload); QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 584fcb045a..559afc4ef4 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -215,6 +215,8 @@ private slots: void QTBUG_21884(); void QTBUG_16967_data() { generic_data("QSQLITE"); } void QTBUG_16967(); //clean close + void QTBUG_23895_data() { generic_data("QSQLITE"); } + void QTBUG_23895(); //sqlite boolean type void sqlite_constraint_data() { generic_data("QSQLITE"); } void sqlite_constraint(); @@ -331,6 +333,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("bug5765", __FILE__) << qTableName("bug6852", __FILE__) << qTableName("bug21884", __FILE__) + << qTableName("bug23895", __FILE__) << qTableName( "qtest_lockedtable", __FILE__ ) << qTableName( "Planet", __FILE__ ) << qTableName( "task_250026", __FILE__ ) @@ -1651,6 +1654,24 @@ void tst_QSqlQuery::synonyms() QCOMPARE( rec.field( 2 ).name().toLower(), QString( "t_varchar" ) ); } +// This class is used to test protected QSqlResult methods +class ResultHelper: public QSqlResult +{ + +public: + ResultHelper(): QSqlResult( 0 ) {} // don't call, it's only for stupid compilers + + bool execBatch( bool bindArray = false ) + { + return QSqlResult::execBatch( bindArray ); + } + + QString boundValueName( int pos ) const + { + return QSqlResult::boundValueName( pos ); + } +}; + // It doesn't make sense to split this into several tests void tst_QSqlQuery::prepare_bind_exec() { @@ -1683,11 +1704,11 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null)"; + createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null, name2 nvarchar(200) null)"; else if ( tst_Databases::isMySQL(db) && useUnicode ) - createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8)"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8, name2 varchar(200) character set utf8)"; else - createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200))"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200), name2 varchar(200))"; QVERIFY_SQL( q, exec( createQuery ) ); @@ -1756,7 +1777,7 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE( q.value( 0 ).toInt(), i ); QCOMPARE( q.value( 1 ).toString().trimmed(), values[ i ] ); QSqlRecord rInf = q.record(); - QCOMPARE(( int )rInf.count(), 2 ); + QCOMPARE(( int )rInf.count(), 3 ); QCOMPARE( rInf.field( 0 ).name().toUpper(), QString( "ID" ) ); QCOMPARE( rInf.field( 1 ).name().toUpper(), QString( "NAME" ) ); QVERIFY( !q.next() ); @@ -1764,33 +1785,90 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec( "DELETE FROM " + qtest_prepare ) ); + /*** Below we test QSqlQuery::boundValues() with position arguments. + * Due to the fact that the name of a positional argument is not + * specified by the Qt docs, we only test that the QMap contains + * the correct values and that QSqlResult::boundValueName returns + * the key that corrosponds to the correct value. ***/ QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) ); q.bindValue( 0, 0 ); q.bindValue( 1, values[ 0 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 0 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[0] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 0 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[0] ); + q.addBindValue( 1 ); q.addBindValue( values[ 1 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 1 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[1] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 1 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[1] ); + q.addBindValue( 2 ); q.addBindValue( values[ 2 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[2] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[2] ); + q.addBindValue( 3 ); q.addBindValue( values[ 3 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 3 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[3] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 3 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[3] ); + q.addBindValue( 4 ); q.addBindValue( values[ 4 ] ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 4 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[4] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 4 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[4] ); + q.bindValue( 1, values[ 5 ] ); q.bindValue( 0, 5 ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 5 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[5] ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 5 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[5] ); + q.bindValue( 0, 6 ); q.bindValue( 1, QString() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 6 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), QString() ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues().size(), 2 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 6 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), QString() ); if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { q.bindValue( 0, 7 ); q.bindValue( 1, utf8str ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 7 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), utf8str ); QVERIFY_SQL( q, exec() ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 7 ); + QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), utf8str ); } QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); @@ -1839,6 +1917,20 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY( !q.isActive() ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name, name2) values (:id, :name, :name)" ) ); + for ( i = 101; i < 103; ++i ) { + q.bindValue( ":id", i ); + q.bindValue( ":name", "name" ); + QVERIFY( q.exec() ); + } + + // Test for QTBUG-6420 + QVERIFY( q.exec( "select * from " + qtest_prepare + " where id > 100 order by id" ) ); + QVERIFY( q.next() ); + QCOMPARE( q.value(0).toInt(), 101 ); + QCOMPARE( q.value(1).toString(), QString("name") ); + QCOMPARE( q.value(2).toString(), QString("name") ); + } // end of SQLite scope } @@ -1947,18 +2039,6 @@ void tst_QSqlQuery::invalidQuery() QVERIFY( !q.next() ); } -class ResultHelper: public QSqlResult -{ - -public: - ResultHelper(): QSqlResult( 0 ) {} // don't call, it's only for stupid compilers - - bool execBatch( bool bindArray = false ) - { - return QSqlResult::execBatch( bindArray ); - } -}; - void tst_QSqlQuery::batchExec() { QFETCH( QString, dbName ); @@ -3187,6 +3267,64 @@ void tst_QSqlQuery::QTBUG_16967() } } +/** + * In SQLite when a boolean value is bound to a placeholder, it should be converted + * into integer 0/1 rather than text "false"/"true". According to documentation, + * SQLite does not have separate Boolean storage class. Instead, Boolean values are + * stored as integers. + */ +void tst_QSqlQuery::QTBUG_23895() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + + QString tableName(qTableName("bug23895", __FILE__ )); + q.prepare("create table " + tableName + "(id integer primary key, val1 bool, val2 boolean)"); + QVERIFY_SQL(q, exec()); + q.prepare("insert into " + tableName + "(id, val1, val2) values(?, ?, ?);"); + q.addBindValue(1); + q.addBindValue(true); + q.addBindValue(false); + QVERIFY_SQL(q, exec()); + + QString sql="select * from " + tableName; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + + QCOMPARE(q.record().field(0).type(), QVariant::Int); + QCOMPARE(q.value(0).type(), QVariant::LongLong); + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.record().field(1).type(), QVariant::Bool); + QCOMPARE(q.value(1).type(), QVariant::LongLong); + QCOMPARE(q.value(1).toBool(), true); + QCOMPARE(q.record().field(2).type(), QVariant::Bool); + QCOMPARE(q.value(2).type(), QVariant::LongLong); + QCOMPARE(q.value(2).toBool(), false); + + q.prepare("insert into " + tableName + "(id, val1, val2) values(?, ?, ?);"); + q.addBindValue(2); + q.addBindValue(false); + q.addBindValue(false); + QVERIFY_SQL(q, exec()); + + sql="select * from " + tableName + " where val1"; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QVERIFY(!q.next()); + + sql="select * from " + tableName + " where not val2"; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 2); + QVERIFY(!q.next()); +} + void tst_QSqlQuery::oraOCINumber() { QFETCH( QString, dbName ); diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index afe2c59144..2cea8b3546 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -133,6 +133,9 @@ private slots: void insertBeforeDelete_data() { generic_data(); } void insertBeforeDelete(); + + void invalidFilterAndHeaderData_data() { generic_data(); } + void invalidFilterAndHeaderData(); //QTBUG-23879 private: void generic_data(const QString& engine=QString()); void generic_data_with_strategies(const QString& engine=QString()); @@ -1681,5 +1684,25 @@ void tst_QSqlTableModel::insertBeforeDelete() QCOMPARE(model.rowCount(), 5); } +void tst_QSqlTableModel::invalidFilterAndHeaderData() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlTableModel model(0, db); + model.setTable(test); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); + QVERIFY_SQL(model, select()); + QVERIFY_SQL(model, setHeaderData(0, Qt::Horizontal, "id")); + QVERIFY_SQL(model, setHeaderData(1, Qt::Horizontal, "name")); + QVERIFY_SQL(model, setHeaderData(2, Qt::Horizontal, "title")); + + model.setFilter("some nonsense"); + + QVariant v = model.headerData(0, Qt::Horizontal, Qt::SizeHintRole); + QVERIFY(!v.isValid()); +} + QTEST_MAIN(tst_QSqlTableModel) #include "tst_qsqltablemodel.moc" diff --git a/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp b/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp index 91b14e5051..f32a5e7cd5 100644 --- a/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp +++ b/tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp @@ -76,7 +76,7 @@ private slots: int main() { - char *argv[] = {"appName", "slotName"}; + char *argv[] = { const_cast<char *>("appName"), const_cast<char *>("slotName") }; int argc = 2; tst_TestA testA; diff --git a/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp b/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp index 20bfc2228a..73de6df5f3 100644 --- a/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp +++ b/tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp @@ -65,7 +65,7 @@ void tst_StrCmp::compareCharStars() const QCOMPARE(str1, "foo"); QCOMPARE(str1, str1); - char *str2 = "foo"; + char *str2 = const_cast<char *>("foo"); QCOMPARE("foo", str2); QCOMPARE(str2, "foo"); QCOMPARE(str2, str2); @@ -88,8 +88,8 @@ void tst_StrCmp::compareByteArray() const QCOMPARE(ba.constData(), "bar"); QCOMPARE(ba.constData(), "foo"); - char *bar = "bar"; - char *foo = "foo"; + char *bar = const_cast<char *>("bar"); + char *foo = const_cast<char *>("foo"); QEXPECT_FAIL("", "Next test should fail", Continue); QCOMPARE(ba.data(), bar); diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 97458abfbf..26ccd826ca 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -135,7 +135,7 @@ static QList<QByteArray> splitLines(QByteArray ba) if (index == -1) { continue; } - int end = line.indexOf('"', index + strlen(markers[j][0])); + const int end = line.indexOf('"', index + int(strlen(markers[j][0]))); if (end == -1) { continue; } @@ -686,11 +686,12 @@ QString extractXmlAttribute(const QString &line, const char *attribute) int index = line.indexOf(attribute); if (index == -1) return QString(); - int end = line.indexOf('"', index + strlen(attribute)); + const int attributeLength = int(strlen(attribute)); + const int end = line.indexOf('"', index + attributeLength); if (end == -1) return QString(); - QString result = line.mid(index + strlen(attribute), end - index - strlen(attribute)); + const QString result = line.mid(index + attributeLength, end - index - attributeLength); if (result.isEmpty()) return ""; // ensure empty but not null return result; diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index 4e5dc26eac..3b77b1ec63 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -128,7 +128,7 @@ TestCompiler::~TestCompiler() bool TestCompiler::errorOut() { - qDebug(qPrintable(testOutput_.join("\n"))); + qDebug("%s", qPrintable(testOutput_.join(QStringLiteral("\n")))); return false; } diff --git a/tests/auto/tools/uic/baseline/tabbedbrowser.ui b/tests/auto/tools/uic/baseline/tabbedbrowser.ui index 7164fb7271..382f49fe5e 100644 --- a/tests/auto/tools/uic/baseline/tabbedbrowser.ui +++ b/tests/auto/tools/uic/baseline/tabbedbrowser.ui @@ -99,7 +99,7 @@ <string/> </property> <property name="icon" > - <iconset resource="assistant.qrc" >:/trolltech/assistant/images/close.png</iconset> + <iconset resource="assistant.qrc" >:/qt-project.org/assistant/images/close.png</iconset> </property> <property name="autoRaise" > <bool>true</bool> @@ -130,7 +130,7 @@ <string>Previous</string> </property> <property name="icon" > - <iconset resource="assistant.qrc" >:/trolltech/assistant/images/win/previous.png</iconset> + <iconset resource="assistant.qrc" >:/qt-project.org/assistant/images/win/previous.png</iconset> </property> <property name="toolButtonStyle" > <enum>Qt::ToolButtonTextBesideIcon</enum> @@ -152,7 +152,7 @@ <string>Next</string> </property> <property name="icon" > - <iconset resource="assistant.qrc" >:/trolltech/assistant/images/win/next.png</iconset> + <iconset resource="assistant.qrc" >:/qt-project.org/assistant/images/win/next.png</iconset> </property> <property name="toolButtonStyle" > <enum>Qt::ToolButtonTextBesideIcon</enum> @@ -194,7 +194,7 @@ </size> </property> <property name="text" > - <string><img src=":/trolltech/assistant/images/wrap.png">&nbsp;Search wrapped</string> + <string><img src=":/qt-project.org/assistant/images/wrap.png">&nbsp;Search wrapped</string> </property> <property name="textFormat" > <enum>Qt::RichText</enum> diff --git a/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h b/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h index 1e99c41312..f2c1f1e3e5 100644 --- a/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h +++ b/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h @@ -125,7 +125,7 @@ public: hboxLayout->setObjectName(QStringLiteral("hboxLayout")); toolClose = new QToolButton(frameFind); toolClose->setObjectName(QStringLiteral("toolClose")); - const QIcon icon = QIcon(QString::fromUtf8(":/trolltech/assistant/images/close.png")); + const QIcon icon = QIcon(QString::fromUtf8(":/qt-project.org/assistant/images/close.png")); toolClose->setIcon(icon); toolClose->setAutoRaise(true); @@ -144,7 +144,7 @@ public: toolPrevious = new QToolButton(frameFind); toolPrevious->setObjectName(QStringLiteral("toolPrevious")); - const QIcon icon1 = QIcon(QString::fromUtf8(":/trolltech/assistant/images/win/previous.png")); + const QIcon icon1 = QIcon(QString::fromUtf8(":/qt-project.org/assistant/images/win/previous.png")); toolPrevious->setIcon(icon1); toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolPrevious->setAutoRaise(true); @@ -154,7 +154,7 @@ public: toolNext = new QToolButton(frameFind); toolNext->setObjectName(QStringLiteral("toolNext")); toolNext->setMinimumSize(QSize(0, 0)); - const QIcon icon2 = QIcon(QString::fromUtf8(":/trolltech/assistant/images/win/next.png")); + const QIcon icon2 = QIcon(QString::fromUtf8(":/qt-project.org/assistant/images/win/next.png")); toolNext->setIcon(icon2); toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolNext->setAutoRaise(true); @@ -204,7 +204,7 @@ public: toolNext->setText(QApplication::translate("TabbedBrowser", "Next", 0, QApplication::UnicodeUTF8)); checkCase->setText(QApplication::translate("TabbedBrowser", "Case Sensitive", 0, QApplication::UnicodeUTF8)); checkWholeWords->setText(QApplication::translate("TabbedBrowser", "Whole words", 0, QApplication::UnicodeUTF8)); - labelWrapped->setText(QApplication::translate("TabbedBrowser", "<img src=\":/trolltech/assistant/images/wrap.png\"> Search wrapped", 0, QApplication::UnicodeUTF8)); + labelWrapped->setText(QApplication::translate("TabbedBrowser", "<img src=\":/qt-project.org/assistant/images/wrap.png\"> Search wrapped", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp index acb9155ca8..4f15f96cba 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp @@ -287,17 +287,15 @@ void tst_QGraphicsLayoutItem::setMaximumSize() void tst_QGraphicsLayoutItem::setMinimumSize_data() { QTest::addColumn<QSizeF>("size"); - QTest::addColumn<QSizeF>("outputSize"); - QTest::newRow("-1") << QSizeF(-1, -1) << QSizeF(0, 0); - QTest::newRow("0") << QSizeF(0, 0) << QSizeF(0, 0); - QTest::newRow("10") << QSizeF(10, 10) << QSizeF(10, 10); + QTest::newRow("-1") << QSizeF(-1, -1); + QTest::newRow("0") << QSizeF(0, 0); + QTest::newRow("10") << QSizeF(10, 10); } // void setMinimumSize(QSizeF const& size) public void tst_QGraphicsLayoutItem::setMinimumSize() { QFETCH(QSizeF, size); - QFETCH(QSizeF, outputSize); SubQGraphicsLayoutItem layoutItem; QSizeF oldSize = layoutItem.minimumSize(); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index d7b1ef9199..df529c6095 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3766,6 +3766,7 @@ void tst_QGraphicsScene::inputMethod() QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); inputContext.m_resetCallCount = 0; + inputContext.m_commitCallCount = 0; scene.addItem(item); QInputMethodEvent event; @@ -3784,7 +3785,7 @@ void tst_QGraphicsScene::inputMethod() scene.setFocusItem(0); // the input context is reset twice, once because an item has lost focus and again because // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. - QCOMPARE(inputContext.m_resetCallCount, callFocusItem ? 2 : 0); + QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, callFocusItem ? 2 : 0); QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected item->eventCalls = 0; diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index ee7ec7ba57..1838977749 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -3712,7 +3712,7 @@ void tst_QGraphicsView::render() view.show(); QTest::qWaitForWindowShown(&view); QApplication::processEvents(); - QTRY_VERIFY(view.painted > 0); + QTRY_VERIFY(view.painted); RenderTester *r1 = new RenderTester(QRectF(0, 0, 50, 50)); RenderTester *r2 = new RenderTester(QRectF(50, 50, 50, 50)); @@ -4187,21 +4187,22 @@ void tst_QGraphicsView::inputContextReset() item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); inputContext.m_resetCallCount = 0; + inputContext.m_commitCallCount = 0; scene.addItem(item1); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); - inputContext.m_resetCallCount = 0; scene.setFocusItem(item1); QCOMPARE(scene.focusItem(), (QGraphicsItem *)item1); QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); - inputContext.m_resetCallCount = 0; scene.setFocusItem(0); // the input context is reset twice, once because an item has lost focus and again because // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. // QEXPECT_FAIL("", "QTBUG-22454", Abort); - QCOMPARE(inputContext.m_resetCallCount, 2); + QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, 2); // introduce another item that is focusable but does not accept input methods QGraphicsItem *item2 = new QGraphicsRectItem; @@ -4209,17 +4210,19 @@ void tst_QGraphicsView::inputContextReset() scene.addItem(item2); inputContext.m_resetCallCount = 0; + inputContext.m_commitCallCount = 0; scene.setFocusItem(item2); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); - inputContext.m_resetCallCount = 0; scene.setFocusItem(item1); QCOMPARE(inputContext.m_resetCallCount, 0); + QCOMPARE(inputContext.m_commitCallCount, 0); // test changing between between items that accept input methods. item2->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); scene.setFocusItem(item2); - QCOMPARE(inputContext.m_resetCallCount, 1); + QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, 1); } void tst_QGraphicsView::indirectPainting() diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index be7c58f20b..c6c8131422 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -238,10 +238,9 @@ public: openedEditor = new QWidget(parent); return openedEditor; } - void destroyEditor(QWidget *editor, const QModelIndex &index) const + void destroyEditor(QWidget *editor, const QModelIndex &) const { calledVirtualDtor = true; - // QAbstractItemDelegate::destroyEditor(editor,index); editor->deleteLater(); } diff --git a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp index 4a9ab93921..cca0887a21 100644 --- a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp +++ b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp @@ -374,32 +374,32 @@ void tst_QIcon::detach() void tst_QIcon::addFile() { QIcon icon; - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); #ifndef Q_OS_WINCE QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); QVERIFY(icon.pixmap(128, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); QVERIFY(icon.pixmap(32, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); #else // WinCE only includes the 16x16 images for size reasons QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); + QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); #endif } @@ -436,7 +436,7 @@ void tst_QIcon::availableSizes() { // we try to load an icon from resources - QIcon icon(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + QIcon icon(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); QList<QSize> availableSizes = icon.availableSizes(); QCOMPARE(availableSizes.size(), 1); QCOMPARE(availableSizes.at(0), QSize(16, 16)); @@ -445,7 +445,7 @@ void tst_QIcon::availableSizes() { // load an icon from binary data. QPixmap pix; - QFile file(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + QFile file(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); QVERIFY(file.open(QIODevice::ReadOnly)); uchar *data = file.map(0, file.size()); QVERIFY(data != 0); @@ -617,12 +617,12 @@ void tst_QIcon::fromTheme() void tst_QIcon::task223279_inconsistentAddFile() { QIcon icon1; - icon1.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon1.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); icon1.addFile(QLatin1String("IconThatDoesntExist"), QSize(32, 32)); QPixmap pm1 = icon1.pixmap(32, 32); QIcon icon2; - icon2.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon2.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png")); icon2.addFile(QLatin1String("IconThatDoesntExist")); QPixmap pm2 = icon1.pixmap(32, 32); diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index 83f93f0ba0..74e2333801 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qlineedit -QT += gui-private core-private widgets testlib +QT += gui-private core-private widgets widgets-private testlib SOURCES += tst_qlineedit.cpp # QTBUG-24518 - unstable test diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index a6860006c2..06bf929e4b 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -62,6 +62,8 @@ #endif #include <qlineedit.h> +#include <private/qlineedit_p.h> +#include <private/qwidgetlinecontrol_p.h> #include <qmenu.h> #include <qlayout.h> #include <qspinbox.h> @@ -72,6 +74,10 @@ #include "qplatformdefs.h" +#include "../../../shared/platforminputcontext.h" +#include <private/qinputmethod_p.h> + + QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE @@ -275,7 +281,6 @@ private slots: void selectAndCursorPosition(); void inputMethod(); void inputMethodSelection(); - void inputMethodTentativeCommit(); protected slots: void editingFinished(); @@ -301,6 +306,7 @@ private: int newCursorPos; QLineEdit *testWidget; int m_keyboardScheme; + PlatformInputContext m_platformInputContext; }; typedef QList<int> IntList; @@ -357,21 +363,23 @@ void tst_QLineEdit::initTestCase() testWidget->resize(200,50); testWidget->show(); + QTest::qWaitForWindowShown(testWidget); QApplication::setActiveWindow(testWidget); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(testWidget); -#endif QTRY_VERIFY(testWidget->hasFocus()); changed_count = 0; edited_count = 0; selection_count = 0; + + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &m_platformInputContext; } void tst_QLineEdit::cleanupTestCase() { delete testWidget; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; } void tst_QLineEdit::init() @@ -659,14 +667,14 @@ void tst_QLineEdit::inputMask_data() QTest::newRow("nul 2") << QString() << QString(); // try different masks - QTest::newRow("mask 1") << QString("000.000.000.000") << QString("000.000.000.000; "); + QTest::newRow("mask 1") << QString("000.000.000.000") << QString("000.000.000.000"); QTest::newRow("mask 2") << QString("000.000.000.000;#") << QString("000.000.000.000;#"); - QTest::newRow("mask 3") << QString("AAA.aa.999.###;") << QString("AAA.aa.999.###; "); - QTest::newRow("mask 4") << QString(">abcdef<GHIJK") << QString(">abcdef<GHIJK; "); + QTest::newRow("mask 3") << QString("AAA.aa.999.###;") << QString("AAA.aa.999.###"); + QTest::newRow("mask 4") << QString(">abcdef<GHIJK") << QString(">abcdef<GHIJK"); // set an invalid input mask... // the current behaviour is that this exact (faulty) string is returned. - QTest::newRow("invalid") << QString("ABCDEFGHIKLMNOP;") << QString("ABCDEFGHIKLMNOP; "); + QTest::newRow("invalid") << QString("ABCDEFGHIKLMNOP;") << QString("ABCDEFGHIKLMNOP"); // verify that we can unset the mask again QTest::newRow("unset") << QString("") << QString(); @@ -1664,8 +1672,16 @@ void tst_QLineEdit::passwordEchoOnEdit() void tst_QLineEdit::passwordEchoDelay() { - if (qGuiApp->styleHints()->passwordMaskDelay() <= 0) - QSKIP("No mask delay in use"); + int delay = qGuiApp->styleHints()->passwordMaskDelay(); +#if defined QT_BUILD_INTERNAL + QLineEditPrivate *priv = QLineEditPrivate::get(testWidget); + QWidgetLineControl *control = priv->control; + control->m_passwordMaskDelayOverride = 200; + delay = 200; +#endif + if (delay <= 0) + QSKIP("Platform not defining echo delay and overriding only possible in internal build"); + QStyleOptionFrameV2 opt; QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget); @@ -1685,7 +1701,7 @@ void tst_QLineEdit::passwordEchoDelay() QCOMPARE(testWidget->displayText(), QString(4, fillChar)); QTest::keyPress(testWidget, '4'); QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(qGuiApp->styleHints()->passwordMaskDelay()); + QTest::qWait(delay); QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar)); QTest::keyPress(testWidget, '5'); QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5')); @@ -3828,6 +3844,23 @@ void tst_QLineEdit::inputMethod() testWidget->setEnabled(false); QApplication::sendEvent(testWidget, &queryEvent); QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false); + testWidget->setEnabled(true); + + // removing focus allows input method to commit preedit + testWidget->setText(""); + testWidget->activateWindow(); + QTRY_VERIFY(testWidget->hasFocus()); + QTRY_COMPARE(qApp->focusObject(), testWidget); + + m_platformInputContext.setCommitString("text"); + m_platformInputContext.m_commitCallCount = 0; + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent preeditEvent("preedit text", attributes); + QApplication::sendEvent(testWidget, &preeditEvent); + + testWidget->clearFocus(); + QCOMPARE(m_platformInputContext.m_commitCallCount, 1); + QCOMPARE(testWidget->text(), QString("text")); } void tst_QLineEdit::inputMethodSelection() @@ -3866,37 +3899,6 @@ void tst_QLineEdit::inputMethodSelection() QCOMPARE(selectionSpy.count(), 3); } -void tst_QLineEdit::inputMethodTentativeCommit() -{ - // test that basic tentative commit gets to text property on preedit state - QList<QInputMethodEvent::Attribute> attributes; - QInputMethodEvent event("test", attributes); - event.setTentativeCommitString("test"); - QApplication::sendEvent(testWidget, &event); - QCOMPARE(testWidget->text(), QString("test")); - - // tentative commit not allowed present in surrounding text - QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText); - QApplication::sendEvent(testWidget, &queryEvent); - QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString("")); - - // if text with tentative commit does not validate, not allowed to be part of text property - testWidget->setText(""); // ensure input state is reset - QValidator *validator = new QIntValidator(0, 100); - testWidget->setValidator(validator); - QApplication::sendEvent(testWidget, &event); - QCOMPARE(testWidget->text(), QString("")); - testWidget->setValidator(0); - delete validator; - - // text remains when focus is removed - testWidget->setText(""); // ensure input state is reset - QApplication::sendEvent(testWidget, &event); - QFocusEvent lostFocus(QEvent::FocusOut); - QApplication::sendEvent(testWidget, &lostFocus); - QCOMPARE(testWidget->text(), QString("test")); -} - QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" diff --git a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro index 85658c222e..1c2821b289 100644 --- a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro +++ b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qtextedit -QT += widgets widgets-private gui-private testlib +QT += widgets widgets-private gui-private core-private testlib INCLUDEPATH += ../ HEADERS += diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 249e9d7fbe..9c5a3dbed7 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -62,6 +62,10 @@ #include <qabstracttextdocumentlayout.h> #include <qtextdocumentfragment.h> +#include "../../../shared/platforminputcontext.h" +#include <private/qinputmethod_p.h> + + //Used in copyAvailable typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType; typedef QList<keyPairType> pairListType; @@ -96,6 +100,8 @@ public: tst_QTextEdit(); public slots: + void initTestCase(); + void cleanupTestCase(); void init(); void cleanup(); private slots: @@ -211,6 +217,7 @@ private: QTextEdit *ed; qreal rootFrameMargin; + PlatformInputContext m_platformInputContext; }; bool tst_QTextEdit::nativeClipboardWorking() @@ -372,6 +379,18 @@ public: tst_QTextEdit::tst_QTextEdit() {} +void tst_QTextEdit::initTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &m_platformInputContext; +} + +void tst_QTextEdit::cleanupTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + void tst_QTextEdit::init() { #ifdef Q_OS_WINCE //disable magic for WindowsCE @@ -2360,6 +2379,8 @@ void tst_QTextEdit::bidiLogicalMovement() void tst_QTextEdit::inputMethodEvent() { + ed->show(); + // test that text change with an input method event triggers change signal QSignalSpy spy(ed, SIGNAL(textChanged())); @@ -2367,14 +2388,23 @@ void tst_QTextEdit::inputMethodEvent() event.setCommitString("text"); QApplication::sendEvent(ed, &event); QCOMPARE(spy.count(), 1); - spy.clear(); + QCOMPARE(ed->toPlainText(), QString("text")); + // test that input method gets chance to commit preedit when removing focus + ed->setText(""); + QApplication::setActiveWindow(ed); + QTRY_VERIFY(QApplication::focusWindow()); + QCOMPARE(qApp->focusObject(), ed); + + m_platformInputContext.setCommitString("text"); + m_platformInputContext.m_commitCallCount = 0; QList<QInputMethodEvent::Attribute> attributes; - QInputMethodEvent event2("preedit", attributes); - event2.setTentativeCommitString("string"); - QApplication::sendEvent(ed, &event2); - QCOMPARE(spy.count(), 1); - QCOMPARE(ed->toPlainText(), QString("textstring")); + QInputMethodEvent preeditEvent("preedit text", attributes); + QApplication::sendEvent(ed, &preeditEvent); + + ed->clearFocus(); + QCOMPARE(m_platformInputContext.m_commitCallCount, 1); + QCOMPARE(ed->toPlainText(), QString("text")); } void tst_QTextEdit::inputMethodSelection() diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp index f93d979169..d8b193f5c8 100644 --- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp +++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp @@ -118,9 +118,9 @@ class ServerAndClient : public QObject public: ServerAndClient(QEventLoop &ev) : success(false) , eventLoop(ev) - , isBody(false) , bodyBytesRead(0) , bodyLength(-1) + , isBody(false) { setObjectName("serverAndClient"); tcpServer = new QTcpServer(this); |