diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-03-05 13:42:11 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-03-05 13:42:11 +0100 |
commit | 5e8ae03578ecd0538a774505f2f7e2fc626b0ab7 (patch) | |
tree | 3b6f704df4d55d0ed2a5a706acf785541a74a45e /tests | |
parent | 7a5fea113ec6088135b0b6a0fc4297e0ef362bc5 (diff) | |
parent | be3fb9afe50361e4b35d02d28ef30851335b17b6 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
configure
qmake/generators/mac/pbuilder_pbx.cpp
src/corelib/kernel/qtimerinfo_unix.cpp
src/plugins/platforms/cocoa/qcocoabackingstore.mm
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/windows/qwindowswindow.cpp
src/plugins/platforms/xcb/qglxintegration.cpp
Change-Id: I8d125fe498f5304874e6976b53f588d3e98a66ac
Diffstat (limited to 'tests')
18 files changed, 510 insertions, 105 deletions
diff --git a/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt b/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt index dfac4ca3be..c0fdfd6b9a 100644 --- a/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt +++ b/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt @@ -5,5 +5,9 @@ project(test_multiple_find_package) find_package(Qt5Core REQUIRED) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + add_subdirectory(subdir1) +add_executable(exe1 "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp") +include_directories(${Qt5Core_INCLUDE_DIRS}) diff --git a/tests/auto/cmake/test_multiple_find_package/main.cpp b/tests/auto/cmake/test_multiple_find_package/main.cpp new file mode 100644 index 0000000000..82f1109395 --- /dev/null +++ b/tests/auto/cmake/test_multiple_find_package/main.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QString> + +int main(int,char**) +{ + return 0; +} diff --git a/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt b/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt index 86c05f5de5..0c7a113f50 100644 --- a/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt +++ b/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt @@ -1,2 +1,5 @@ find_package(Qt5Core REQUIRED) + +add_executable(exe2 "${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp") +include_directories(${Qt5Core_INCLUDE_DIRS}) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index ef7c810a90..c0afb83cb1 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -88,6 +88,12 @@ QT_END_NAMESPACE #endif #endif +#ifdef Q_OS_QNX +#ifdef open +#undef open +#endif +#endif + #include <stdio.h> #include <errno.h> diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index c4453fd5f2..f94c8eac4f 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -45,6 +45,7 @@ #include <qstandardpaths.h> #include <qfileinfo.h> #include <qsysinfo.h> +#include <qregexp.h> #ifdef Q_OS_UNIX #include <unistd.h> @@ -72,6 +73,7 @@ private slots: void testCustomRuntimeDirectory(); void testAllWritableLocations_data(); void testAllWritableLocations(); + void testCleanPath(); private: #ifdef Q_XDG_PLATFORM @@ -430,6 +432,18 @@ void tst_qstandardpaths::testAllWritableLocations() QCOMPARE(loc.endsWith(QLatin1Char('/')), false); } +void tst_qstandardpaths::testCleanPath() +{ + const QRegExp filter(QStringLiteral("\\\\")); + QVERIFY(filter.isValid()); + for (int i = 0; i <= QStandardPaths::GenericCacheLocation; ++i) { + const QStringList paths = QStandardPaths::standardLocations(QStandardPaths::StandardLocation(i)); + QVERIFY2(paths.filter(filter).isEmpty(), + qPrintable(QString::fromLatin1("Backslash found in %1 %2") + .arg(i).arg(paths.join(QLatin1Char(','))))); + } +} + QTEST_MAIN(tst_qstandardpaths) #include "tst_qstandardpaths.moc" diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index c7e4664007..f750b7a9d4 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -46,6 +46,20 @@ #include "dynamictreemodel.h" #include "qidentityproxymodel.h" +class DataChangedModel : public QAbstractListModel +{ +public: + int rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : 1; } + QVariant data(const QModelIndex&, int) const { return QVariant(); } + QModelIndex index(int row, int column, const QModelIndex &) const { return createIndex(row, column); } + + void changeData() + { + const QModelIndex idx = index(0, 0, QModelIndex()); + Q_EMIT dataChanged(idx, idx, QVector<int>() << 1); + } +}; + class tst_QIdentityProxyModel : public QObject { Q_OBJECT @@ -63,6 +77,7 @@ private slots: void removeRows(); void moveRows(); void reset(); + void dataChanged(); protected: void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex()); @@ -79,6 +94,7 @@ tst_QIdentityProxyModel::tst_QIdentityProxyModel() void tst_QIdentityProxyModel::initTestCase() { + qRegisterMetaType<QVector<int> >(); m_model = new QStandardItemModel(0, 1); m_proxy = new QIdentityProxyModel(); } @@ -326,5 +342,27 @@ void tst_QIdentityProxyModel::reset() m_proxy->setSourceModel(0); } +void tst_QIdentityProxyModel::dataChanged() +{ + DataChangedModel model; + m_proxy->setSourceModel(&model); + + verifyIdentity(&model); + + QSignalSpy modelSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); + QSignalSpy proxySpy(m_proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); + + QVERIFY(modelSpy.isValid()); + QVERIFY(proxySpy.isValid()); + + model.changeData(); + + QCOMPARE(modelSpy.first().at(2).value<QVector<int> >(), QVector<int>() << 1); + QVERIFY(modelSpy.first().at(2) == proxySpy.first().at(2)); + + verifyIdentity(&model); + m_proxy->setSourceModel(0); +} + QTEST_MAIN(tst_QIdentityProxyModel) #include "tst_qidentityproxymodel.moc" diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 7c1e22689e..7738a2c797 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -40,6 +40,9 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include <QAtomicInt> +#include <QThread> +#include <QSemaphore> #include <qvector.h> struct Movable { @@ -47,21 +50,21 @@ struct Movable { : i(input) , state(Constructed) { - ++counter; + counter.fetchAndAddRelaxed(1); } Movable(const Movable &other) : i(other.i) , state(Constructed) { check(other.state, Constructed); - ++counter; + counter.fetchAndAddRelaxed(1); } ~Movable() { check(state, Constructed); i = 0; - --counter; + counter.fetchAndAddRelaxed(-1); state = Destructed; } @@ -80,7 +83,7 @@ struct Movable { return *this; } char i; - static int counter; + static QAtomicInt counter; private: enum State { Constructed = 106, Destructed = 110 }; State state; @@ -91,7 +94,7 @@ private: } }; -int Movable::counter = 0; +QAtomicInt Movable::counter = 0; QT_BEGIN_NAMESPACE Q_DECLARE_TYPEINFO(Movable, Q_MOVABLE_TYPE); QT_END_NAMESPACE @@ -103,21 +106,21 @@ struct Custom { , that(this) , state(Constructed) { - ++counter; + counter.fetchAndAddRelaxed(1); } Custom(const Custom &other) : that(this) , state(Constructed) { check(&other); - ++counter; + counter.fetchAndAddRelaxed(1); this->i = other.i; } ~Custom() { check(this); i = 0; - --counter; + counter.fetchAndAddRelaxed(-1); state = Destructed; } @@ -135,7 +138,7 @@ struct Custom { i = other.i; return *this; } - static int counter; + static QAtomicInt counter; char i; // used to identify orgin of an instance private: @@ -151,7 +154,7 @@ private: QCOMPARE(c->state, Constructed); } }; -int Custom::counter = 0; +QAtomicInt Custom::counter = 0; Q_DECLARE_METATYPE(Custom); @@ -271,6 +274,9 @@ private slots: void detachInt() const; void detachMovable() const; void detachCustom() const; + void detachThreadSafetyInt() const; + void detachThreadSafetyMovable() const; + void detachThreadSafetyCustom() const; private: template<typename T> void copyConstructor() const; @@ -294,6 +300,7 @@ private: template<typename T> void setSharable_data() const; template<typename T> void setSharable() const; template<typename T> void detach() const; + template<typename T> void detachThreadSafety() const; }; @@ -415,16 +422,16 @@ void tst_QVector::copyConstructorInt() const void tst_QVector::copyConstructorMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); copyConstructor<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::copyConstructorCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); copyConstructor<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -465,16 +472,16 @@ void tst_QVector::addInt() const void tst_QVector::addMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); add<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::addCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); add<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -523,16 +530,16 @@ void tst_QVector::appendInt() const void tst_QVector::appendMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); append<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::appendCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); append<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::at() const @@ -602,16 +609,16 @@ void tst_QVector::capacityInt() const void tst_QVector::capacityMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); capacity<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::capacityCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); capacity<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -633,16 +640,16 @@ void tst_QVector::clearInt() const void tst_QVector::clearMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); clear<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::clearCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); clear<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::constData() const @@ -717,16 +724,16 @@ void tst_QVector::countInt() const void tst_QVector::countMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); count<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::countCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); count<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::data() const @@ -771,16 +778,16 @@ void tst_QVector::emptyInt() const void tst_QVector::emptyMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); empty<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::emptyCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); empty<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::endsWith() const @@ -826,16 +833,16 @@ void tst_QVector::eraseEmptyInt() const void tst_QVector::eraseEmptyMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); eraseEmpty<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::eraseEmptyCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); eraseEmpty<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -863,16 +870,16 @@ void tst_QVector::eraseEmptyReservedInt() const void tst_QVector::eraseEmptyReservedMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); eraseEmptyReserved<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::eraseEmptyReservedCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); eraseEmptyReserved<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -986,30 +993,30 @@ void tst_QVector::eraseIntShared() const void tst_QVector::eraseMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); erase<Movable>(false); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::eraseMovableShared() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); erase<Movable>(true); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::eraseCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); erase<Custom>(false); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::eraseCustomShared() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); erase<Custom>(true); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> void tst_QVector::eraseReserved() const @@ -1062,16 +1069,16 @@ void tst_QVector::eraseReservedInt() const void tst_QVector::eraseReservedMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); eraseReserved<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::eraseReservedCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); eraseReserved<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -1102,16 +1109,16 @@ void tst_QVector::fillInt() const void tst_QVector::fillMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); fill<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::fillCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); fill<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::first() const @@ -1152,16 +1159,16 @@ void tst_QVector::fromListInt() const void tst_QVector::fromListMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); fromList<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::fromListCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); fromList<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::fromStdVector() const @@ -1338,16 +1345,16 @@ void tst_QVector::prependInt() const void tst_QVector::prependMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); prepend<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::prependCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); prepend<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -1374,16 +1381,16 @@ void tst_QVector::removeInt() const void tst_QVector::removeMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); remove<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::removeCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); remove<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::resizePOD_data() const @@ -1510,7 +1517,7 @@ void tst_QVector::resizeComplexMovable_data() const void tst_QVector::resizeComplexMovable() const { - const int items = Movable::counter; + const int items = Movable::counter.loadAcquire(); { QFETCH(QVector<Movable>, vector); QFETCH(int, size); @@ -1529,7 +1536,7 @@ void tst_QVector::resizeComplexMovable() const QCOMPARE(vector.size(), 0); QVERIFY(vector.capacity() <= capacity); } - QCOMPARE(items, Movable::counter); + QCOMPARE(items, Movable::counter.loadAcquire()); } void tst_QVector::resizeComplex_data() const @@ -1585,7 +1592,7 @@ void tst_QVector::resizeComplex_data() const void tst_QVector::resizeComplex() const { - const int items = Custom::counter; + const int items = Custom::counter.loadAcquire(); { QFETCH(QVector<Custom>, vector); QFETCH(int, size); @@ -1604,12 +1611,12 @@ void tst_QVector::resizeComplex() const QVERIFY(vector.isEmpty()); QVERIFY(vector.capacity() <= capacity); } - QCOMPARE(Custom::counter, items); + QCOMPARE(Custom::counter.loadAcquire(), items); } void tst_QVector::resizeCtorAndDtor() const { - const int items = Custom::counter; + const int items = Custom::counter.loadAcquire(); { QVector<Custom> null; QVector<Custom> empty(0, '0'); @@ -1631,7 +1638,7 @@ void tst_QVector::resizeCtorAndDtor() const nonEmpty.resize(0); nonEmptyReserved.resize(2); } - QCOMPARE(Custom::counter, items); + QCOMPARE(Custom::counter.loadAcquire(), items); } template<typename T> @@ -1661,16 +1668,16 @@ void tst_QVector::sizeInt() const void tst_QVector::sizeMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); size<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::sizeCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); size<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } // ::squeeze() is tested in ::capacity(). @@ -1720,16 +1727,16 @@ void tst_QVector::swapInt() const void tst_QVector::swapMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); swap<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::swapCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); swap<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::toList() const @@ -1947,16 +1954,16 @@ void tst_QVector::initializeListInt() void tst_QVector::initializeListMovable() { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); initializeList<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::initializeListCustom() { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); initializeList<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } void tst_QVector::const_shared_null() @@ -2084,16 +2091,16 @@ void tst_QVector::setSharableInt() void tst_QVector::setSharableMovable() { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); setSharable<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::setSharableCustom() { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); setSharable<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } template<typename T> @@ -2200,17 +2207,87 @@ void tst_QVector::detachInt() const void tst_QVector::detachMovable() const { - const int instancesCount = Movable::counter; + const int instancesCount = Movable::counter.loadAcquire(); detach<Movable>(); - QCOMPARE(instancesCount, Movable::counter); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); } void tst_QVector::detachCustom() const { - const int instancesCount = Custom::counter; + const int instancesCount = Custom::counter.loadAcquire(); detach<Custom>(); - QCOMPARE(instancesCount, Custom::counter); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } -QTEST_APPLESS_MAIN(tst_QVector) +static QAtomicPointer<QVector<int> > detachThreadSafetyDataInt; +static QAtomicPointer<QVector<Movable> > detachThreadSafetyDataMovable; +static QAtomicPointer<QVector<Custom> > detachThreadSafetyDataCustom; + +template<typename T> QAtomicPointer<QVector<T> > *detachThreadSafetyData(); +template<> QAtomicPointer<QVector<int> > *detachThreadSafetyData() { return &detachThreadSafetyDataInt; } +template<> QAtomicPointer<QVector<Movable> > *detachThreadSafetyData() { return &detachThreadSafetyDataMovable; } +template<> QAtomicPointer<QVector<Custom> > *detachThreadSafetyData() { return &detachThreadSafetyDataCustom; } + +static QSemaphore detachThreadSafetyLock; + +template<typename T> +void tst_QVector::detachThreadSafety() const +{ + delete detachThreadSafetyData<T>()->fetchAndStoreOrdered(new QVector<T>(SimpleValue<T>::vector(400))); + + static const uint threadsCount = 5; + + struct : QThread { + void run() Q_DECL_OVERRIDE + { + QVector<T> copy(*detachThreadSafetyData<T>()->load()); + QVERIFY(!copy.isDetached()); + detachThreadSafetyLock.release(); + detachThreadSafetyLock.acquire(100); + copy.detach(); + } + } threads[threadsCount]; + + for (uint i = 0; i < threadsCount; ++i) + threads[i].start(); + QThread::yieldCurrentThread(); + detachThreadSafetyLock.acquire(threadsCount); + + // destroy static original data + delete detachThreadSafetyData<T>()->fetchAndStoreOrdered(0); + + QVERIFY(threadsCount < 100); + detachThreadSafetyLock.release(threadsCount * 100); + QThread::yieldCurrentThread(); + + for (uint i = 0; i < threadsCount; ++i) + threads[i].wait(); +} + +void tst_QVector::detachThreadSafetyInt() const +{ + for (uint i = 0; i < 128; ++i) + detachThreadSafety<int>(); +} + +void tst_QVector::detachThreadSafetyMovable() const +{ + const int instancesCount = Movable::counter.loadAcquire(); + for (uint i = 0; i < 128; ++i) { + detachThreadSafety<Movable>(); + QCOMPARE(Movable::counter.loadAcquire(), instancesCount); + } +} + +void tst_QVector::detachThreadSafetyCustom() const +{ + const int instancesCount = Custom::counter.loadAcquire(); + for (uint i = 0; i < 128; ++i) { + detachThreadSafety<Custom>(); + QCOMPARE(Custom::counter.loadAcquire(), instancesCount); + } +} + + +QTEST_MAIN(tst_QVector) #include "tst_qvector.moc" diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index 5fb8df3f59..085dfd0461 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -718,6 +718,8 @@ void tst_QStandardItemModel::checkChildren() QVERIFY(!model.hasChildren()); QCOMPARE(model.rowCount(), 0); QCOMPARE(model.columnCount(), 1); + + QVERIFY(!model.index(0,0).sibling(100,100).isValid()); } void tst_QStandardItemModel::data() diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 6c5c90d737..3bae5d5103 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -78,7 +78,6 @@ private slots: void shareRegister(); void textureCleanup(); #endif - void graphicsViewClipping(); void partialGLWidgetUpdates_data(); void partialGLWidgetUpdates(); void glWidgetWithAlpha(); @@ -98,6 +97,7 @@ private slots: void destroyFBOAfterContext(); void threadImages(); void nullRectCrash(); + void graphicsViewClipping(); }; tst_QGL::tst_QGL() @@ -865,7 +865,11 @@ void tst_QGL::graphicsViewClipping() scene.setSceneRect(view.viewport()->rect()); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + #ifdef Q_OS_MAC + // The black rectangle jumps from the center to the upper left for some reason. + QTest::qWait(100); + #endif QImage image = viewport->grabFrameBuffer(); QImage expected = image; diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index 3e5841835d..f12899e368 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -76,6 +76,9 @@ #endif +#define PD_ADD_SUFFIX(x) PD_DEFINE1(x,_SUFFIX) +#define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF) + PD_BEGIN_NAMESPACE class PD_CLASSNAME : public QObject @@ -128,6 +131,8 @@ public slots: void conditionSlot() {} #endif + void PD_DEFINE_ITSELF(int) {} + }; #undef QString diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 382ee36d37..5fc46d195b 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -2936,7 +2936,6 @@ void tst_Moc::parseDefines() } if (!qstrcmp(mci.name(), "TestString2")) { ++count; - qDebug() << mci.value(); QVERIFY(!qstrcmp(mci.value(), "ParseDefine")); } if (!qstrcmp(mci.name(), "TestString3")) { @@ -2945,6 +2944,9 @@ void tst_Moc::parseDefines() } } QVERIFY(count == 3); + + index = mo->indexOfSlot("PD_DEFINE_ITSELF_SUFFIX(int)"); + QVERIFY(index != -1); } void tst_Moc::preprocessorOnly() diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 4ac0dfca75..e6b1caf694 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5430,7 +5430,7 @@ void tst_QWidget::setToolTip() QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup)); popup->setObjectName(QString::fromLatin1("tst_qwidget setToolTip #%1").arg(pass)); popup->setWindowTitle(popup->objectName()); - popup->resize(150, 50); + popup->setGeometry(50, 50, 150, 50); QFrame *frame = new QFrame(popup.data()); frame->setGeometry(0, 0, 50, 50); frame->setFrameStyle(QFrame::Box | QFrame::Plain); diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 210e52f0aa..3fa669c1fb 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3902,6 +3902,11 @@ void tst_QLineEdit::inputMethod() // removing focus allows input method to commit preedit testWidget->setText(""); testWidget->activateWindow(); + // TODO setFocus should not be necessary here, because activateWindow + // should focus it, and the window is the QLineEdit. But the test can fail + // on Windows if we don't do this. If each test had a unique QLineEdit + // instance, maybe such problems would go away. + testWidget->setFocus(); QTRY_VERIFY(testWidget->hasFocus()); QTRY_COMPARE(qApp->focusObject(), testWidget); diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index 2bbfb48e63..e373e50e0a 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -115,7 +115,9 @@ void tst_QProgressBar::minMaxSameValue() QProgressBar bar; bar.setRange(10, 10); bar.setValue(10); + bar.move(300, 300); bar.show(); + QVERIFY(QTest::qWaitForWindowExposed(&bar)); } void tst_QProgressBar::destroyIndeterminate() @@ -125,7 +127,9 @@ void tst_QProgressBar::destroyIndeterminate() // it's deleted. QPointer<QProgressBar> bar = new QProgressBar; bar->setMaximum(0); + bar->move(300, 300); bar->show(); + QVERIFY(QTest::qWaitForWindowExposed(bar.data())); QEventLoop loop; QTimer::singleShot(500, bar, SLOT(deleteLater())); @@ -168,8 +172,10 @@ void tst_QProgressBar::format() ProgressBar bar; bar.setRange(0, 10); bar.setValue(1); + bar.move(300, 300); bar.show(); QVERIFY(QTest::qWaitForWindowExposed(&bar)); + QVERIFY(QTest::qWaitForWindowExposed(&bar)); QTest::qWait(20); bar.repainted = false; @@ -204,6 +210,7 @@ void tst_QProgressBar::setValueRepaint() pbar.setMinimum(0); pbar.setMaximum(10); pbar.setFormat("%v"); + pbar.move(300, 300); pbar.show(); QVERIFY(QTest::qWaitForWindowExposed(&pbar)); @@ -226,7 +233,9 @@ void tst_QProgressBar::setMinMaxRepaint() pbar.setMinimum(0); pbar.setMaximum(10); pbar.setFormat("%v"); + pbar.move(300, 300); pbar.show(); + qApp->setActiveWindow(&pbar); QVERIFY(QTest::qWaitForWindowActive(&pbar)); // No repaint when setting minimum to the current minimum @@ -355,7 +364,9 @@ void tst_QProgressBar::task245201_testChangeStyleAndDelete() QStyle *style = QStyleFactory::create(style1_str); bar->setStyle(style); + bar->move(300, 300); bar->show(); + QVERIFY(QTest::qWaitForWindowExposed(bar)); QStyle *style2 = QStyleFactory::create(style2_str); bar->setStyle(style2); QTest::qWait(10); diff --git a/tests/manual/transientwindow/main.cpp b/tests/manual/transientwindow/main.cpp new file mode 100644 index 0000000000..aebb051688 --- /dev/null +++ b/tests/manual/transientwindow/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "mainwindow.h" +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/tests/manual/transientwindow/mainwindow.cpp b/tests/manual/transientwindow/mainwindow.cpp new file mode 100644 index 0000000000..25123c4936 --- /dev/null +++ b/tests/manual/transientwindow/mainwindow.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "mainwindow.h" +#include <QDebug> + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), m_showButton("Toggle visible", this), m_window(0) +{ + connect(&m_showButton, SIGNAL(clicked()), this, SLOT(toggleVisible())); + setWindowTitle(QString::fromLatin1("Main Window")); + m_showButton.setVisible(true); + setMinimumSize(300, 200); +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::toggleVisible() +{ + if (!m_window) { + m_window = new QWindow(); + m_window->setTransientParent(windowHandle()); + m_window->setMinimumSize(QSize(200, 100)); + m_window->setTitle("Transient Window"); + } + m_window->setVisible(!m_window->isVisible()); +} diff --git a/tests/manual/transientwindow/mainwindow.h b/tests/manual/transientwindow/mainwindow.h new file mode 100644 index 0000000000..352fc961e1 --- /dev/null +++ b/tests/manual/transientwindow/mainwindow.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QPushButton> +#include <QWindow> + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +public slots: + void toggleVisible(); + +private: + QPushButton m_showButton; + QWindow* m_window; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/transientwindow/transientwindow.pro b/tests/manual/transientwindow/transientwindow.pro new file mode 100644 index 0000000000..a07ee09dbc --- /dev/null +++ b/tests/manual/transientwindow/transientwindow.pro @@ -0,0 +1,6 @@ +QT += core gui widgets +TARGET = transientwindow +TEMPLATE = app +SOURCES += main.cpp\ + mainwindow.cpp +HEADERS += mainwindow.h |