summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-08-31 01:46:11 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-08-31 01:46:11 (GMT)
commit1e48d40597bbe12321a5a3e42b3595dc17a7f8e7 (patch)
tree16bc5824f55124f1be742cc5c3f55f94e223fee1 /tests
parentc57195dc899ca732083487ed069ef813c340c0b5 (diff)
parente95de30977291a251660f72baa84b5ff244711fb (diff)
downloadQt-1e48d40597bbe12321a5a3e42b3595dc17a7f8e7.zip
Qt-1e48d40597bbe12321a5a3e42b3595dc17a7f8e7.tar.gz
Qt-1e48d40597bbe12321a5a3e42b3595dc17a7f8e7.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: don't crash when destroying the shortcuts Disable activeqt on win32-g++ (it doesn't build). fix warning remove unused functions Make the DBus timeout configurable in QDBusAbstractInterface. Fix a typo in qt-conf docs. Revert "Fix build with the Clang compiler" Added missing no_include_pwd check Replace 'i < len-1 && func(i+1)' by 'i+1 < len && func(i+1)' Fix build with the Clang compiler Change spacing of title in offline style. Add support for rawFonts loaded from data in FaceId examples: fix compilation with namespaced Qt. Russian translation update Update Japanese translations for Qt 4.8. directfb: Include directfbgl.h directly tests: fix QNetworkProxyFactory test don't detach until the list is going to be modified optimize QList::removeAll()
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp2
-rw-r--r--tests/auto/qrawfont/tst_qrawfont.cpp25
-rw-r--r--tests/auto/qshortcut/tst_qshortcut.cpp3
-rw-r--r--tests/benchmarks/corelib/tools/qlist/main.cpp250
-rw-r--r--tests/benchmarks/corelib/tools/qlist/qlist.pro5
-rw-r--r--tests/benchmarks/corelib/tools/tools.pro1
6 files changed, 283 insertions, 3 deletions
diff --git a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index 839612e..4ffb00b 100644
--- a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -116,7 +116,7 @@ void tst_QNetworkProxyFactory::systemProxyForQuery() const
QNetworkProxy proxy;
QList<QNetworkProxy> nativeProxyList;
- nativeProxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QString("http://test.proxy.com"), 8080) << QNetworkProxy::NoProxy;
+ nativeProxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QString("test.proxy.com"), 8080) << QNetworkProxy::NoProxy;
foreach (proxy, systemProxyList) {
if (!nativeProxyList.contains(proxy)) {
diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp
index e0680c4..eb78057 100644
--- a/tests/auto/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/qrawfont/tst_qrawfont.cpp
@@ -47,7 +47,6 @@
class tst_QRawFont: public QObject
{
Q_OBJECT
-
#if !defined(QT_NO_RAWFONT)
private slots:
void invalidRawFont();
@@ -94,6 +93,11 @@ private slots:
void rawFontSetPixelSize_data();
void rawFontSetPixelSize();
+
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ void multipleRawFontsFromData();
+#endif
+
#endif // QT_NO_RAWFONT
};
@@ -843,6 +847,25 @@ void tst_QRawFont::rawFontSetPixelSize()
QCOMPARE(rawFont.pixelSize(), 24.0);
}
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+void tst_QRawFont::multipleRawFontsFromData()
+{
+ QFile file(QString::fromLatin1(SRCDIR "testfont.ttf"));
+ QRawFont testFont;
+ if (file.open(QIODevice::ReadOnly)) {
+ testFont.loadFromData(file.readAll(), 11, QFont::PreferDefaultHinting);
+ file.close();
+ }
+ file.setFileName(QLatin1String(SRCDIR "testfont_bold_italic.ttf"));
+ QRawFont testFontBoldItalic;
+ if (file.open(QIODevice::ReadOnly))
+ testFontBoldItalic.loadFromData(file.readAll(), 11, QFont::PreferDefaultHinting);
+
+ QVERIFY(testFont.familyName() != (testFontBoldItalic.familyName())
+ || testFont.styleName() != (testFontBoldItalic.styleName()));
+}
+#endif
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QRawFont)
diff --git a/tests/auto/qshortcut/tst_qshortcut.cpp b/tests/auto/qshortcut/tst_qshortcut.cpp
index a78e8cf..d761b19 100644
--- a/tests/auto/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/qshortcut/tst_qshortcut.cpp
@@ -1124,7 +1124,8 @@ void tst_QShortcut::context()
// ------------------------------------------------------------------
void tst_QShortcut::clearAllShortcuts()
{
- qDeleteAll(shortcuts);
+ QList<QShortcut *> shortcutsCpy = shortcuts;
+ qDeleteAll(shortcutsCpy);
shortcuts.clear();
}
diff --git a/tests/benchmarks/corelib/tools/qlist/main.cpp b/tests/benchmarks/corelib/tools/qlist/main.cpp
new file mode 100644
index 0000000..22aaf49
--- /dev/null
+++ b/tests/benchmarks/corelib/tools/qlist/main.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module 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 <QList>
+#include <QTest>
+
+static const int N = 1000;
+
+struct MyBase
+{
+ MyBase(int i_)
+ : isCopy(false)
+ {
+ ++liveCount;
+
+ i = i_;
+ }
+
+ MyBase(const MyBase &other)
+ : isCopy(true)
+ {
+ if (isCopy)
+ ++copyCount;
+ ++liveCount;
+
+ i = other.i;
+ }
+
+ MyBase &operator=(const MyBase &other)
+ {
+ if (!isCopy) {
+ isCopy = true;
+ ++copyCount;
+ } else {
+ ++errorCount;
+ }
+
+ i = other.i;
+ return *this;
+ }
+
+ ~MyBase()
+ {
+ if (isCopy) {
+ if (!copyCount)
+ ++errorCount;
+ else
+ --copyCount;
+ }
+ if (!liveCount)
+ ++errorCount;
+ else
+ --liveCount;
+ }
+
+ bool operator==(const MyBase &other) const
+ { return i == other.i; }
+
+protected:
+ ushort i;
+ bool isCopy;
+
+public:
+ static int errorCount;
+ static int liveCount;
+ static int copyCount;
+};
+
+int MyBase::errorCount = 0;
+int MyBase::liveCount = 0;
+int MyBase::copyCount = 0;
+
+struct MyPrimitive : public MyBase
+{
+ MyPrimitive(int i = -1) : MyBase(i)
+ { ++errorCount; }
+ MyPrimitive(const MyPrimitive &other) : MyBase(other)
+ { ++errorCount; }
+ ~MyPrimitive()
+ { ++errorCount; }
+};
+
+struct MyMovable : public MyBase
+{
+ MyMovable(int i = -1) : MyBase(i) {}
+};
+
+struct MyComplex : public MyBase
+{
+ MyComplex(int i = -1) : MyBase(i) {}
+};
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_TYPEINFO(MyPrimitive, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(MyMovable, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(MyComplex, Q_COMPLEX_TYPE);
+
+QT_END_NAMESPACE
+
+
+class tst_QList: public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void removeAll_primitive_data();
+ void removeAll_primitive();
+ void removeAll_movable_data();
+ void removeAll_movable();
+ void removeAll_complex_data();
+ void removeAll_complex();
+};
+
+template <class T>
+void removeAll_test(const QList<int> &i10, ushort valueToRemove, int itemsToRemove)
+{
+ bool isComplex = QTypeInfo<T>::isComplex;
+
+ MyBase::errorCount = 0;
+ MyBase::liveCount = 0;
+ MyBase::copyCount = 0;
+ {
+ QList<T> list;
+ QCOMPARE(MyBase::liveCount, 0);
+ QCOMPARE(MyBase::copyCount, 0);
+
+ for (int i = 0; i < 10 * N; ++i) {
+ T t(i10.at(i % 10));
+ list.append(t);
+ }
+ QCOMPARE(MyBase::liveCount, isComplex ? list.size() : 0);
+ QCOMPARE(MyBase::copyCount, isComplex ? list.size() : 0);
+
+ T t(valueToRemove);
+ QCOMPARE(MyBase::liveCount, isComplex ? list.size() + 1 : 1);
+ QCOMPARE(MyBase::copyCount, isComplex ? list.size() : 0);
+
+ int removedCount;
+ QList<T> l;
+
+ QBENCHMARK {
+ l = list;
+ removedCount = l.removeAll(t);
+ }
+ QCOMPARE(removedCount, itemsToRemove * N);
+ QCOMPARE(l.size() + removedCount, list.size());
+ QVERIFY(!l.contains(valueToRemove));
+
+ QCOMPARE(MyBase::liveCount, isComplex ? l.isDetached() ? list.size() + l.size() + 1 : list.size() + 1 : 1);
+ QCOMPARE(MyBase::copyCount, isComplex ? l.isDetached() ? list.size() + l.size() : list.size() : 0);
+ }
+ if (isComplex)
+ QCOMPARE(MyBase::errorCount, 0);
+}
+
+Q_DECLARE_METATYPE(QList<int>);
+
+void tst_QList::removeAll_primitive_data()
+{
+ qRegisterMetaType<QList<int> >();
+
+ QTest::addColumn<QList<int> >("i10");
+ QTest::addColumn<int>("valueToRemove");
+ QTest::addColumn<int>("itemsToRemove");
+
+ QTest::newRow("0%") << (QList<int>() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0) << 5 << 0;
+ QTest::newRow("10%") << (QList<int>() << 0 << 0 << 0 << 0 << 5 << 0 << 0 << 0 << 0 << 0) << 5 << 1;
+ QTest::newRow("90%") << (QList<int>() << 5 << 5 << 5 << 5 << 0 << 5 << 5 << 5 << 5 << 5) << 5 << 9;
+ QTest::newRow("100%") << (QList<int>() << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5) << 5 << 10;
+}
+
+void tst_QList::removeAll_primitive()
+{
+ QFETCH(QList<int>, i10);
+ QFETCH(int, valueToRemove);
+ QFETCH(int, itemsToRemove);
+
+ removeAll_test<MyPrimitive>(i10, valueToRemove, itemsToRemove);
+}
+
+void tst_QList::removeAll_movable_data()
+{
+ removeAll_primitive_data();
+}
+
+void tst_QList::removeAll_movable()
+{
+ QFETCH(QList<int>, i10);
+ QFETCH(int, valueToRemove);
+ QFETCH(int, itemsToRemove);
+
+ removeAll_test<MyMovable>(i10, valueToRemove, itemsToRemove);
+}
+
+void tst_QList::removeAll_complex_data()
+{
+ removeAll_primitive_data();
+}
+
+void tst_QList::removeAll_complex()
+{
+ QFETCH(QList<int>, i10);
+ QFETCH(int, valueToRemove);
+ QFETCH(int, itemsToRemove);
+
+ removeAll_test<MyComplex>(i10, valueToRemove, itemsToRemove);
+}
+
+QTEST_APPLESS_MAIN(tst_QList)
+
+#include "main.moc"
diff --git a/tests/benchmarks/corelib/tools/qlist/qlist.pro b/tests/benchmarks/corelib/tools/qlist/qlist.pro
new file mode 100644
index 0000000..902e72e
--- /dev/null
+++ b/tests/benchmarks/corelib/tools/qlist/qlist.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+TARGET = tst_qlist
+QT = core
+
+SOURCES += main.cpp
diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro
index 681a6c6..44e8973 100644
--- a/tests/benchmarks/corelib/tools/tools.pro
+++ b/tests/benchmarks/corelib/tools/tools.pro
@@ -3,6 +3,7 @@ SUBDIRS = \
containers-associative \
containers-sequential \
qbytearray \
+ qlist \
qrect \
qregexp \
qstring \