summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qflags/qflags.pro1
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp14
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp68
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp42
-rw-r--r--tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp49
-rw-r--r--tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp29
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp106
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp120
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp29
-rw-r--r--tests/auto/corelib/tools/qdatetime/qdatetime.pro5
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp12
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm82
-rw-r--r--tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp20
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp280
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp66
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp12
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp15
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp4
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp76
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp3
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp64
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp65
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp54
-rw-r--r--tests/auto/network/ssl/qsslellipticcurve/.gitignore1
-rw-r--r--tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro8
-rw-r--r--tests/auto/network/ssl/qsslellipticcurve/tst_qsslellipticcurve.cpp120
-rw-r--r--tests/auto/network/ssl/ssl.pro1
-rw-r--r--tests/auto/other/other.pro1
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp8
-rw-r--r--tests/auto/other/toolsupport/toolsupport.pro4
-rw-r--r--tests/auto/other/toolsupport/tst_toolsupport.cpp153
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp40
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp3
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp5
-rw-r--r--tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp9
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp55
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp68
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp34
-rw-r--r--tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp1
-rw-r--r--tests/auto/widgets/widgets/qframe/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_0_0.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_0_1.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_0_2.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_1_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_1_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_1_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_2_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_2_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_2_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_0_0.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_0_1.pngbin0 -> 129 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_0_2.pngbin0 -> 126 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_1_0.pngbin0 -> 135 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_1_1.pngbin0 -> 158 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_1_2.pngbin0 -> 162 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_2_0.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_2_1.pngbin0 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_2_2.pngbin0 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.pngbin0 -> 129 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.pngbin0 -> 126 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.pngbin0 -> 138 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.pngbin0 -> 159 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.pngbin0 -> 163 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.pngbin0 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.pngbin0 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.pngbin0 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.pngbin0 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.pngbin0 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/qframe.pro8
-rw-r--r--tests/auto/widgets/widgets/qframe/tst_qframe.cpp185
-rw-r--r--tests/auto/widgets/widgets/widgets.pro1
-rw-r--r--tests/auto/xml/dom/qdom/tst_qdom.cpp3
116 files changed, 1731 insertions, 194 deletions
diff --git a/tests/auto/corelib/global/qflags/qflags.pro b/tests/auto/corelib/global/qflags/qflags.pro
index 9e80d5634b..3f78bc045b 100644
--- a/tests/auto/corelib/global/qflags/qflags.pro
+++ b/tests/auto/corelib/global/qflags/qflags.pro
@@ -3,3 +3,4 @@ TARGET = tst_qflags
QT = core testlib
SOURCES = tst_qflags.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+contains(QT_CONFIG, c++11): CONFIG += c++11 c++14
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 4c74ac166b..15fe93298d 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -94,6 +94,16 @@ void tst_QFlags::testFlagMultiBits() const
template <unsigned int N, typename T> bool verifyConstExpr(T n) { return n == N; }
+Q_DECL_RELAXED_CONSTEXPR Qt::MouseButtons testRelaxedConstExpr()
+{
+ Qt::MouseButtons value;
+ value = Qt::LeftButton | Qt::RightButton;
+ value |= Qt::MiddleButton;
+ value &= ~Qt::LeftButton;
+ value ^= Qt::RightButton;
+ return value;
+}
+
void tst_QFlags::constExpr()
{
#ifdef Q_COMPILER_CONSTEXPR
@@ -115,6 +125,10 @@ void tst_QFlags::constExpr()
QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) | 0xff>(0xff));
QVERIFY(!verifyConstExpr<Qt::RightButton>(!Qt::MouseButtons(Qt::LeftButton)));
+
+#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
+ QVERIFY(verifyConstExpr<testRelaxedConstExpr()>(Qt::MiddleButton));
+#endif
#endif
}
diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
index c0b4ff654a..3304a09061 100644
--- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
+++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
@@ -41,14 +41,22 @@ class tst_QGetPutEnv : public QObject
Q_OBJECT
private slots:
void getSetCheck();
+ void intValue_data();
+ void intValue();
};
void tst_QGetPutEnv::getSetCheck()
{
const char varName[] = "should_not_exist";
+ bool ok;
+
QVERIFY(!qEnvironmentVariableIsSet(varName));
QVERIFY(qEnvironmentVariableIsEmpty(varName));
+ ok = true;
+ QCOMPARE(qEnvironmentVariableIntValue(varName), 0);
+ QCOMPARE(qEnvironmentVariableIntValue(varName, &ok), 0);
+ QVERIFY(!ok);
QByteArray result = qgetenv(varName);
QCOMPARE(result, QByteArray());
@@ -57,12 +65,20 @@ void tst_QGetPutEnv::getSetCheck()
QVERIFY(qEnvironmentVariableIsSet(varName));
QVERIFY(qEnvironmentVariableIsEmpty(varName));
+ ok = true;
+ QCOMPARE(qEnvironmentVariableIntValue(varName), 0);
+ QCOMPARE(qEnvironmentVariableIntValue(varName, &ok), 0);
+ QVERIFY(!ok);
#endif
QVERIFY(qputenv(varName, QByteArray("supervalue")));
QVERIFY(qEnvironmentVariableIsSet(varName));
QVERIFY(!qEnvironmentVariableIsEmpty(varName));
+ ok = true;
+ QCOMPARE(qEnvironmentVariableIntValue(varName), 0);
+ QCOMPARE(qEnvironmentVariableIntValue(varName, &ok), 0);
+ QVERIFY(!ok);
result = qgetenv(varName);
QVERIFY(result == "supervalue");
@@ -72,9 +88,61 @@ void tst_QGetPutEnv::getSetCheck()
QVERIFY(qunsetenv(varName));
QVERIFY(!qEnvironmentVariableIsSet(varName));
QVERIFY(qEnvironmentVariableIsEmpty(varName));
+ ok = true;
+ QCOMPARE(qEnvironmentVariableIntValue(varName), 0);
+ QCOMPARE(qEnvironmentVariableIntValue(varName, &ok), 0);
+ QVERIFY(!ok);
result = qgetenv(varName);
QCOMPARE(result, QByteArray());
}
+void tst_QGetPutEnv::intValue_data()
+{
+ QTest::addColumn<QByteArray>("value");
+ QTest::addColumn<int>("expected");
+ QTest::addColumn<bool>("ok");
+
+ // most non-success cases already tested in getSetCheck()
+
+#define ROW(x, i, b) \
+ QTest::newRow(#x) << QByteArray(#x) << (i) << (b)
+ ROW(auto, 0, false);
+ ROW(0, 0, true);
+ ROW(1, 1, true);
+ ROW(010, 8, true);
+ ROW(0x10, 16, true);
+ ROW(-1, -1, true);
+ ROW(-010, -8, true);
+ // ROW(0xffffffff, -1, true); // could be expected, but not how QByteArray::toInt() works
+ ROW(0xffffffff, 0, false);
+ const int bases[] = {10, 8, 16};
+ for (size_t i = 0; i < sizeof bases / sizeof *bases; ++i) {
+ QTest::newRow(qPrintable(QString().sprintf("INT_MAX, base %d", bases[i])))
+ << QByteArray::number(INT_MAX) << INT_MAX << true;
+ QTest::newRow(qPrintable(QString().sprintf("INT_MAX+1, base %d", bases[i])))
+ << QByteArray::number(qlonglong(INT_MAX) + 1) << 0 << false;
+ QTest::newRow(qPrintable(QString().sprintf("INT_MIN, base %d", bases[i])))
+ << QByteArray::number(INT_MIN) << INT_MIN << true;
+ QTest::newRow(qPrintable(QString().sprintf("INT_MIN-1, base %d", bases[i])))
+ << QByteArray::number(qlonglong(INT_MIN) - 1) << 0 << false;
+ };
+}
+
+void tst_QGetPutEnv::intValue()
+{
+ const char varName[] = "should_not_exist";
+
+ QFETCH(QByteArray, value);
+ QFETCH(int, expected);
+ QFETCH(bool, ok);
+
+ bool actualOk = !ok;
+
+ QVERIFY(qputenv(varName, value));
+ QCOMPARE(qEnvironmentVariableIntValue(varName), expected);
+ QCOMPARE(qEnvironmentVariableIntValue(varName, &actualOk), expected);
+ QCOMPARE(actualOk, ok);
+}
+
QTEST_MAIN(tst_QGetPutEnv)
#include "tst_qgetputenv.moc"
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 56a5a28c50..997ceaf7b9 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -90,7 +90,9 @@ private Q_SLOTS:
void fromVariant();
void fromVariantMap();
+ void fromVariantHash();
void toVariantMap();
+ void toVariantHash();
void toVariantList();
void toJson();
@@ -1165,6 +1167,17 @@ void tst_QtJson::fromVariantMap()
QCOMPARE(array.at(3).toString(), QLatin1String("foo"));
}
+void tst_QtJson::fromVariantHash()
+{
+ QVariantHash map;
+ map.insert(QLatin1String("key1"), QLatin1String("value1"));
+ map.insert(QLatin1String("key2"), QLatin1String("value2"));
+ QJsonObject object = QJsonObject::fromVariantHash(map);
+ QCOMPARE(object.size(), 2);
+ QCOMPARE(object.value(QLatin1String("key1")), QJsonValue(QLatin1String("value1")));
+ QCOMPARE(object.value(QLatin1String("key2")), QJsonValue(QLatin1String("value2")));
+}
+
void tst_QtJson::toVariantMap()
{
QCOMPARE(QMetaType::Type(QJsonValue(QJsonObject()).toVariant().type()), QMetaType::QVariantMap); // QTBUG-32524
@@ -1196,6 +1209,35 @@ void tst_QtJson::toVariantMap()
QCOMPARE(list.at(3), QVariant());
}
+void tst_QtJson::toVariantHash()
+{
+ QJsonObject object;
+ QVariantHash hash = object.toVariantHash();
+ QVERIFY(hash.isEmpty());
+
+ object.insert("Key", QString("Value"));
+ object.insert("null", QJsonValue());
+ QJsonArray array;
+ array.append(true);
+ array.append(999.);
+ array.append(QLatin1String("string"));
+ array.append(QJsonValue());
+ object.insert("Array", array);
+
+ hash = object.toVariantHash();
+
+ QCOMPARE(hash.size(), 3);
+ QCOMPARE(hash.value("Key"), QVariant(QString("Value")));
+ QCOMPARE(hash.value("null"), QVariant());
+ QCOMPARE(hash.value("Array").type(), QVariant::List);
+ QVariantList list = hash.value("Array").toList();
+ QCOMPARE(list.size(), 4);
+ QCOMPARE(list.at(0), QVariant(true));
+ QCOMPARE(list.at(1), QVariant(999.));
+ QCOMPARE(list.at(2), QVariant(QLatin1String("string")));
+ QCOMPARE(list.at(3), QVariant());
+}
+
void tst_QtJson::toVariantList()
{
QCOMPARE(QMetaType::Type(QJsonValue(QJsonArray()).toVariant().type()), QMetaType::QVariantList); // QTBUG-32524
diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
index 1d39280afb..18de761e2a 100644
--- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
+++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -50,6 +51,8 @@ private slots:
void comparisonOperators();
void fromSignal();
+
+ void gadget();
};
struct CustomType { };
@@ -727,5 +730,51 @@ void tst_QMetaMethod::fromSignal()
#undef FROMSIGNAL_HELPER
}
+class MyGadget {
+ Q_GADGET
+public:
+ QString m_value;
+ Q_INVOKABLE void setValue(const QString &value) { m_value = value; }
+ Q_INVOKABLE QString getValue() { return m_value; }
+};
+
+void tst_QMetaMethod::gadget()
+{
+ int idx;
+
+ idx = MyGadget::staticMetaObject.indexOfMethod("setValue(QString)");
+ QVERIFY(idx >= 0);
+ QMetaMethod setValueMethod = MyGadget::staticMetaObject.method(idx);
+ QVERIFY(setValueMethod.isValid());
+
+ idx = MyGadget::staticMetaObject.indexOfMethod("getValue()");
+ QVERIFY(idx >= 0);
+ QMetaMethod getValueMethod = MyGadget::staticMetaObject.method(idx);
+ QVERIFY(getValueMethod.isValid());
+
+ {
+ MyGadget gadget;
+ QString string;
+
+ QVERIFY(getValueMethod.invokeOnGadget(&gadget, Q_RETURN_ARG(QString, string)));
+ QCOMPARE(string, gadget.m_value);
+
+ QVERIFY(setValueMethod.invokeOnGadget(&gadget, Q_ARG(QString, QLatin1String("hello"))));
+ QCOMPARE(gadget.m_value, QLatin1String("hello"));
+
+ QVERIFY(getValueMethod.invokeOnGadget(&gadget, Q_RETURN_ARG(QString, string)));
+ QCOMPARE(string, gadget.m_value);
+ }
+
+ {
+ // Call with null should not crash
+ MyGadget *gadget = Q_NULLPTR;
+ QString string;
+ QVERIFY(!setValueMethod.invokeOnGadget(gadget, Q_ARG(QString, QLatin1String("hi"))));
+ QVERIFY(!getValueMethod.invokeOnGadget(gadget, Q_RETURN_ARG(QString, string)));
+ }
+}
+
+
QTEST_MAIN(tst_QMetaMethod)
#include "tst_qmetamethod.moc"
diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
index 5cac80191c..941abf9039 100644
--- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
+++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -50,6 +51,7 @@ private slots:
void hasStdCppSet();
void isConstant();
void isFinal();
+ void gadget();
public:
enum EnumType { EnumType1 };
@@ -103,5 +105,32 @@ void tst_QMetaProperty::isFinal()
QVERIFY(!prop.isFinal());
}
+class MyGadget {
+ Q_GADGET
+ Q_PROPERTY(QString value READ getValue WRITE setValue RESET resetValue)
+public:
+ QString m_value;
+ void setValue(const QString &value) { m_value = value; }
+ QString getValue() { return m_value; }
+ void resetValue() { m_value = QLatin1Literal("reset"); }
+};
+
+void tst_QMetaProperty::gadget()
+{
+ const QMetaObject *mo = &MyGadget::staticMetaObject;
+ QMetaProperty valueProp = mo->property(mo->indexOfProperty("value"));
+ QVERIFY(valueProp.isValid());
+ {
+ MyGadget g;
+ QString hello = QLatin1Literal("hello");
+ QVERIFY(valueProp.writeOnGadget(&g, hello));
+ QCOMPARE(g.m_value, QLatin1String("hello"));
+ QCOMPARE(valueProp.readOnGadget(&g), QVariant(hello));
+ QVERIFY(valueProp.resetOnGadget(&g));
+ QCOMPARE(valueProp.readOnGadget(&g), QVariant(QLatin1String("reset")));
+ }
+}
+
+
QTEST_MAIN(tst_QMetaProperty)
#include "tst_qmetaproperty.moc"
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index a35896283a..e3ef2b6714 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -79,6 +79,10 @@ private slots:
void normalizedTypes();
void typeName_data();
void typeName();
+ void type_data();
+ void type();
+ void type_fromSubString_data();
+ void type_fromSubString();
void create_data();
void create();
void createCopy_data();
@@ -109,6 +113,7 @@ private slots:
void saveAndLoadBuiltin_data();
void saveAndLoadBuiltin();
void saveAndLoadCustom();
+ void metaObject_data();
void metaObject();
void constexprMetaTypeIds();
void constRefs();
@@ -385,6 +390,61 @@ void tst_QMetaType::typeName()
QCOMPARE(name.toLatin1(), QMetaObject::normalizedType(name.toLatin1().constData()));
}
+void tst_QMetaType::type_data()
+{
+ QTest::addColumn<QMetaType::Type>("aType");
+ QTest::addColumn<QByteArray>("aTypeName");
+
+#define TST_QMETATYPE_TYPE_DATA(MetaTypeName, MetaTypeId, RealType)\
+ QTest::newRow(#RealType) << QMetaType::MetaTypeName << QByteArray( #RealType );
+#define TST_QMETATYPE_TYPE_DATA_ALIAS(MetaTypeName, MetaTypeId, AliasType, RealTypeString)\
+ QTest::newRow(RealTypeString) << QMetaType::MetaTypeName << QByteArray( #AliasType );
+
+ QTest::newRow("empty") << QMetaType::UnknownType << QByteArray();
+
+ QT_FOR_EACH_STATIC_TYPE(TST_QMETATYPE_TYPE_DATA)
+ QT_FOR_EACH_STATIC_ALIAS_TYPE(TST_QMETATYPE_TYPE_DATA_ALIAS)
+
+#undef TST_QMETATYPE_TYPE_DATA
+#undef TST_METATYPE_TYPE_DATA_ALIAS
+}
+
+void tst_QMetaType::type()
+{
+ QFETCH(QMetaType::Type, aType);
+ QFETCH(QByteArray, aTypeName);
+
+ // QMetaType::type(QByteArray)
+ QCOMPARE(QMetaType::type(aTypeName), int(aType));
+ // QMetaType::type(const char *)
+ QCOMPARE(QMetaType::type(aTypeName.constData()), int(aType));
+}
+
+void tst_QMetaType::type_fromSubString_data()
+{
+ QTest::addColumn<int>("offset");
+ QTest::addColumn<int>("size");
+ QTest::addColumn<int>("expectedType");
+
+ // The test string is defined in the test function below
+ QTest::newRow("int") << 0 << 3 << int(QMetaType::Int);
+ QTest::newRow("boo") << 3 << 3 << 0;
+ QTest::newRow("bool") << 3 << 4 << int(QMetaType::Bool);
+ QTest::newRow("intbool") << 0 << 7 << 0;
+ QTest::newRow("QMetaType::Type") << 7 << 15 << ::qMetaTypeId<QMetaType::Type>();
+ QTest::newRow("double") << 22 << 6 << int(QMetaType::Double);
+}
+
+void tst_QMetaType::type_fromSubString()
+{
+ static const char *types = "intboolQMetaType::Typedoublexxx";
+ QFETCH(int, offset);
+ QFETCH(int, size);
+ QFETCH(int, expectedType);
+ QByteArray ba = QByteArray::fromRawData(types + offset, size);
+ QCOMPARE(QMetaType::type(ba), expectedType);
+}
+
#define FOR_EACH_PRIMITIVE_METATYPE(F) \
QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \
QT_FOR_EACH_STATIC_CORE_POINTER(F) \
@@ -968,7 +1028,9 @@ void tst_QMetaType::flagsBinaryCompatibility5_0()
QFETCH(quint32, id);
QFETCH(quint32, flags);
- QCOMPARE(quint32(QMetaType::typeFlags(id)), flags);
+ quint32 mask_5_0 = 0x1ff; // Only compare the values that were already defined in 5.0
+
+ QCOMPARE(quint32(QMetaType::typeFlags(id)) & mask_5_0, flags);
}
void tst_QMetaType::construct_data()
@@ -1772,17 +1834,41 @@ void tst_QMetaType::saveAndLoadCustom()
QCOMPARE(stream.status(), QDataStream::ReadPastEnd);
}
-void tst_QMetaType::metaObject()
+struct MyGadget {
+ Q_GADGET;
+};
+
+Q_DECLARE_METATYPE(MyGadget);
+Q_DECLARE_METATYPE(const QMetaObject *);
+
+void tst_QMetaType::metaObject_data()
{
- QCOMPARE(QMetaType::metaObjectForType(QMetaType::QObjectStar), &QObject::staticMetaObject);
- QCOMPARE(QMetaType::metaObjectForType(::qMetaTypeId<QFile*>()), &QFile::staticMetaObject);
- QCOMPARE(QMetaType::metaObjectForType(::qMetaTypeId<MyObject*>()), &MyObject::staticMetaObject);
- QCOMPARE(QMetaType::metaObjectForType(QMetaType::Int), static_cast<const QMetaObject *>(0));
+ QTest::addColumn<int>("type");
+ QTest::addColumn<const QMetaObject*>("result");
+ QTest::addColumn<bool>("isGadget");
+ QTest::addColumn<bool>("isQObjectPtr");
+
+ QTest::newRow("QObject") << int(QMetaType::QObjectStar) << &QObject::staticMetaObject << false << true;
+ QTest::newRow("QFile*") << ::qMetaTypeId<QFile*>() << &QFile::staticMetaObject << false << true;
+ QTest::newRow("MyObject*") << ::qMetaTypeId<MyObject*>() << &MyObject::staticMetaObject << false << true;
+ QTest::newRow("int") << int(QMetaType::Int) << static_cast<const QMetaObject *>(0) << false << false;
+ QTest::newRow("QEasingCurve") << ::qMetaTypeId<QEasingCurve>() << &QEasingCurve::staticMetaObject << true << false;
+ QTest::newRow("MyGadget") << ::qMetaTypeId<MyGadget>() << &MyGadget::staticMetaObject << true << false;
+}
- QCOMPARE(QMetaType(QMetaType::QObjectStar).metaObject(), &QObject::staticMetaObject);
- QCOMPARE(QMetaType(::qMetaTypeId<QFile*>()).metaObject(), &QFile::staticMetaObject);
- QCOMPARE(QMetaType(::qMetaTypeId<MyObject*>()).metaObject(), &MyObject::staticMetaObject);
- QCOMPARE(QMetaType(QMetaType::Int).metaObject(), static_cast<const QMetaObject *>(0));
+
+void tst_QMetaType::metaObject()
+{
+ QFETCH(int, type);
+ QFETCH(const QMetaObject *, result);
+ QFETCH(bool, isGadget);
+ QFETCH(bool, isQObjectPtr);
+
+ QCOMPARE(QMetaType::metaObjectForType(type), result);
+ QMetaType mt(type);
+ QCOMPARE(mt.metaObject(), result);
+ QCOMPARE(!!(mt.flags() & QMetaType::IsGadget), isGadget);
+ QCOMPARE(!!(mt.flags() & QMetaType::PointerToQObject), isQObjectPtr);
}
#define METATYPE_ID_FUNCTION(Type, MetaTypeId, Name) \
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 41a6de214a..301db37233 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -43,9 +43,10 @@
#include <qlocale.h>
#include <qdebug.h>
#include <qjsondocument.h>
-
+#include <quuid.h>
#include <limits.h>
+#include <float.h>
#include <QLinkedList>
#include <QRegularExpression>
@@ -213,7 +214,10 @@ private slots:
void toIntFromQString() const;
void toIntFromDouble() const;
void setValue();
+ void fpStringRoundtrip_data() const;
+ void fpStringRoundtrip() const;
+ void numericalConvert_data();
void numericalConvert();
void moreCustomTypes();
void movabilityTest();
@@ -985,7 +989,7 @@ void tst_QVariant::toByteArray_data()
QTest::newRow( "int" ) << QVariant( -123 ) << QByteArray( "-123" );
QTest::newRow( "uint" ) << QVariant( (uint)123 ) << QByteArray( "123" );
QTest::newRow( "double" ) << QVariant( 123.456 ) << QByteArray( "123.456" );
- QTest::newRow( "float" ) << QVariant( 123.456f ) << QByteArray( "123.456" );
+ QTest::newRow( "float" ) << QVariant( 123.456f ) << QByteArray( "123.456001" );
QTest::newRow( "longlong" ) << QVariant( (qlonglong)34 ) << QByteArray( "34" );
QTest::newRow( "ulonglong" ) << QVariant( (qulonglong)34 ) << QByteArray( "34" );
}
@@ -1011,7 +1015,7 @@ void tst_QVariant::toString_data()
QTest::newRow( "int" ) << QVariant( -123 ) << QString( "-123" );
QTest::newRow( "uint" ) << QVariant( (uint)123 ) << QString( "123" );
QTest::newRow( "double" ) << QVariant( 123.456 ) << QString( "123.456" );
- QTest::newRow( "float" ) << QVariant( 123.456f ) << QString( "123.456" );
+ QTest::newRow( "float" ) << QVariant( 123.456f ) << QString( "123.456001" );
QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" );
QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" );
@@ -1367,12 +1371,12 @@ void tst_QVariant::operator_eq_eq_data()
QVariant mUIntQString(QString("42"));
QVariant mDouble(42.11);
- QVariant mDoubleString(QByteArray("42.11"));
- QVariant mDoubleQString(QString("42.11"));
+ QVariant mDoubleString(QByteArray("42.109999999999999"));
+ QVariant mDoubleQString(QString("42.109999999999999"));
QVariant mFloat(42.11f);
- QVariant mFloatString(QByteArray("42.11"));
- QVariant mFloatQString(QString("42.11"));
+ QVariant mFloatString(QByteArray("42.1100006"));
+ QVariant mFloatQString(QString("42.1100006"));
QVariant mLongLong((qlonglong)-42);
QVariant mLongLongString(QByteArray("-42"));
@@ -1433,6 +1437,13 @@ void tst_QVariant::operator_eq_eq_data()
// ### many other combinations missing
{
+ // QUuid can convert to QString, but not the opposite
+ QUuid uuid(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ QTest::newRow("uuidstring") << QVariant(uuid) << QVariant(uuid.toString()) << true;
+ QTest::newRow("stringuuid") << QVariant(uuid.toString()) << QVariant(uuid) << true;
+ }
+
+ {
QMap<QString, QVariant> map1;
map1.insert( "X", 1 );
@@ -2945,41 +2956,72 @@ void tst_QVariant::setValue()
QVERIFY( v2.isDetached() );
}
+void tst_QVariant::fpStringRoundtrip_data() const
+{
+ QTest::addColumn<QVariant>("number");
+
+ QTest::newRow("float") << QVariant(1 + FLT_EPSILON);
+ QTest::newRow("double") << QVariant(1 + DBL_EPSILON);
+}
+
+void tst_QVariant::fpStringRoundtrip() const
+{
+ QFETCH(QVariant, number);
+
+ QVariant converted = number;
+ QVERIFY(converted.convert(QVariant::String));
+ QVERIFY(converted.convert(number.type()));
+ QCOMPARE(converted, number);
+
+ converted = number;
+ QVERIFY(converted.convert(QVariant::ByteArray));
+ QVERIFY(converted.convert(number.type()));
+ QCOMPARE(converted, number);
+}
+
+void tst_QVariant::numericalConvert_data()
+{
+ QTest::addColumn<QVariant>("v");
+ QTest::addColumn<bool>("isInteger");
+ QTest::newRow("float") << QVariant(float(5.3)) << false;
+ QTest::newRow("double") << QVariant(double(5.3)) << false;
+ QTest::newRow("qreal") << QVariant(qreal(5.3)) << false;
+ QTest::newRow("int") << QVariant(int(5)) << true;
+ QTest::newRow("uint") << QVariant(uint(5)) << true;
+ QTest::newRow("short") << QVariant(short(5)) << true;
+ QTest::newRow("longlong") << QVariant(quint64(5)) << true;
+ QTest::newRow("long") << QVariant::fromValue(long(5)) << true;
+ QTest::newRow("stringint") << QVariant(QString::fromLatin1("5")) << true;
+ QTest::newRow("string") << QVariant(QString::fromLatin1("5.30000019")) << false;
+}
+
void tst_QVariant::numericalConvert()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
QSKIP("Known to fail due to a GCC bug on at least Ubuntu 10.04 32-bit - check QTBUG-8959");
#endif
- QVariant vfloat(float(5.3));
- QVariant vdouble(double(5.3));
- QVariant vreal(qreal(5.3));
- QVariant vint(int(5));
- QVariant vuint(uint(5));
- QVariant vshort(short(5));
- QVariant vlonglong(quint64(5));
- QVariant vlong = QVariant::fromValue(long(5));
- QVariant vstringint(QString::fromLatin1("5"));
- QVariant vstring(QString::fromLatin1("5.3"));
-
- QVector<QVariant *> vect;
- vect << &vfloat << &vdouble << &vreal << &vint << &vuint << &vshort<< &vlonglong << &vlong << &vstringint << &vstring;
-
- for(int i = 0; i < vect.size(); i++) {
- double num = 5.3;
- if (i >= 3 && i <= 8)
- num = 5;
- QVariant *v = vect.at(i);
- QCOMPARE(v->toFloat() , float(num));
- QCOMPARE(float(v->toReal()) , float(num));
- QCOMPARE(float(v->toDouble()) , float(num));
- if (i != 9) {
- QCOMPARE(v->toInt() , int(num));
- QCOMPARE(v->toUInt() , uint(num));
- QCOMPARE(v->toULongLong() , quint64(num));
- QCOMPARE(v->value<ulong>() , ulong(num));
- QCOMPARE(v->value<ushort>() , ushort(num));
- }
- QCOMPARE(v->toString() , QString::number(num));
+ QFETCH(QVariant, v);
+ QFETCH(bool, isInteger);
+ double num = isInteger ? 5 : 5.3;
+
+ QCOMPARE(v.toFloat() , float(num));
+ QCOMPARE(float(v.toReal()) , float(num));
+ QCOMPARE(float(v.toDouble()) , float(num));
+ if (isInteger) {
+ QCOMPARE(v.toInt() , int(num));
+ QCOMPARE(v.toUInt() , uint(num));
+ QCOMPARE(v.toULongLong() , quint64(num));
+ QCOMPARE(v.value<ulong>() , ulong(num));
+ QCOMPARE(v.value<ushort>() , ushort(num));
+ }
+ switch (v.userType())
+ {
+ case QVariant::Double:
+ QCOMPARE(v.toString() , QString::number(num, 'g', DBL_MANT_DIG * log10(2.) + 2));
+ break;
+ case QMetaType::Float:
+ QCOMPARE(v.toString() , QString::number(float(num), 'g', FLT_MANT_DIG * log10(2.) + 2));
+ break;
}
}
@@ -3214,8 +3256,8 @@ void tst_QVariant::moreCustomTypes()
QCOMPARE(MyNotMovable::count, 0);
{
- PLAY_WITH_VARIANT(12.12, false, "12.12", 12.12, true);
- PLAY_WITH_VARIANT(12.12f, false, "12.12", 12.12f, true);
+ PLAY_WITH_VARIANT(12.12, false, "12.119999999999999", 12.12, true);
+ PLAY_WITH_VARIANT(12.12f, false, "12.1199999", 12.12f, true);
PLAY_WITH_VARIANT('a', false, "a", 'a', true);
PLAY_WITH_VARIANT((unsigned char)('a'), false, "a", 'a', true);
PLAY_WITH_VARIANT( quint8(12), false, "\xc", 12, true);
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 18739cb4e1..d010ff807d 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -2000,6 +2000,9 @@ void tst_QByteArray::toUpperLower_data()
QTest::addColumn<QByteArray>("lower");
QTest::newRow("empty") << QByteArray() << QByteArray() << QByteArray();
+ QTest::newRow("literal") << QByteArrayLiteral("Hello World")
+ << QByteArrayLiteral("HELLO WORLD")
+ << QByteArrayLiteral("hello world");
QTest::newRow("ascii") << QByteArray("Hello World, this is a STRING")
<< QByteArray("HELLO WORLD, THIS IS A STRING")
<< QByteArray("hello world, this is a string");
@@ -2014,8 +2017,34 @@ void tst_QByteArray::toUpperLower()
QFETCH(QByteArray, input);
QFETCH(QByteArray, upper);
QFETCH(QByteArray, lower);
+ QCOMPARE(lower.toLower(), lower);
+ QCOMPARE(upper.toUpper(), upper);
QCOMPARE(input.toUpper(), upper);
QCOMPARE(input.toLower(), lower);
+
+ QByteArray copy = input;
+ QCOMPARE(qMove(copy).toUpper(), upper);
+ copy = input;
+ copy.detach();
+ QCOMPARE(qMove(copy).toUpper(), upper);
+
+ copy = input;
+ QCOMPARE(qMove(copy).toLower(), lower);
+ copy = input;
+ copy.detach();
+ QCOMPARE(qMove(copy).toLower(), lower);
+
+ copy = lower;
+ QCOMPARE(qMove(copy).toLower(), lower);
+ copy = lower;
+ copy.detach();
+ QCOMPARE(qMove(copy).toLower(), lower);
+
+ copy = upper;
+ QCOMPARE(qMove(copy).toUpper(), upper);
+ copy = upper;
+ copy.detach();
+ QCOMPARE(qMove(copy).toUpper(), upper);
}
void tst_QByteArray::macTypes()
diff --git a/tests/auto/corelib/tools/qdatetime/qdatetime.pro b/tests/auto/corelib/tools/qdatetime/qdatetime.pro
index 0a89fe7645..25d11443e4 100644
--- a/tests/auto/corelib/tools/qdatetime/qdatetime.pro
+++ b/tests/auto/corelib/tools/qdatetime/qdatetime.pro
@@ -11,3 +11,8 @@ win32-msvc|win32-msvc9x {
QMAKE_CXXFLAGS_RELEASE -= -O1
}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+mac {
+ OBJECTIVE_SOURCES += tst_qdatetime_mac.mm
+ LIBS += -framework Foundation
+}
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 51c3a19d63..8876bb3d34 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -145,6 +145,8 @@ private slots:
void invalid() const;
+ void macTypes();
+
private:
enum { LocalTimeIsUtc = 0, LocalTimeAheadOfUtc = 1, LocalTimeBehindUtc = -1} localTimeType;
bool europeanTimeZone;
@@ -2981,5 +2983,15 @@ void tst_QDateTime::invalid() const
QCOMPARE(tzDate.timeSpec(), Qt::TimeZone);
}
+void tst_QDateTime::macTypes()
+{
+#ifndef Q_OS_MAC
+ QSKIP("This is a Apple-only test");
+#else
+ extern void tst_QDateTime_macTypes(); // in qdatetime_mac.mm
+ tst_QDateTime_macTypes();
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_QDateTime)
#include "tst_qdatetime.moc"
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm b/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm
new file mode 100644
index 0000000000..d03ae3faeb
--- /dev/null
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Petroules Corporation.
+** 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/QDateTime>
+#include <QtTest/QtTest>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <Foundation/Foundation.h>
+
+void tst_QDateTime_macTypes()
+{
+ // QDateTime <-> CFDate
+ {
+ QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
+ const CFDateRef cfDate = qtDateTime.toCFDate();
+ QCOMPARE(QDateTime::fromCFDate(cfDate), qtDateTime);
+ CFRelease(cfDate);
+ }
+ {
+ QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
+ const CFDateRef cfDate = qtDateTime.toCFDate();
+ QDateTime qtDateTimeCopy(qtDateTime);
+ qtDateTime.setTime_t(10000); // modify
+ QCOMPARE(QDateTime::fromCFDate(cfDate), qtDateTimeCopy);
+ }
+ // QDateTime <-> NSDate
+ {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
+ const NSDate *nsDate = qtDateTime.toNSDate();
+ QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTime);
+ [autoreleasepool release];
+ }
+ {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
+ const NSDate *nsDate = qtDateTime.toNSDate();
+ QDateTime qtDateTimeCopy(qtDateTime);
+ qtDateTime.setTime_t(10000); // modify
+ QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTimeCopy);
+ [autoreleasepool release];
+ }
+}
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
index d1152419c0..c1d6184072 100644
--- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
@@ -51,6 +51,7 @@ private slots:
void operators();
void properties();
void metaTypes();
+ void propertyOrderIsNotImportant();
void bezierSpline_data();
void bezierSpline();
void tcbSpline_data();
@@ -552,6 +553,25 @@ void tst_QEasingCurve::metaTypes()
QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve);
}
+/*
+ Test to ensure that regardless of what order properties are set, they should produce the same
+ behavior.
+ */
+void tst_QEasingCurve::propertyOrderIsNotImportant()
+{
+
+ QEasingCurve c1;
+ c1.setPeriod(1);
+ c1.setType(QEasingCurve::OutSine);
+ QVERIFY(c1.valueForProgress(0.75) > 0.9);
+
+ QEasingCurve c2;
+ c2.setType(QEasingCurve::OutSine);
+ c2.setPeriod(1);
+
+ QCOMPARE(c1.valueForProgress(0.75), c2.valueForProgress(0.75));
+}
+
void tst_QEasingCurve::bezierSpline_data()
{
QTest::addColumn<QString>("definition");
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index db22f99cb8..1b6fe2aefe 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -237,6 +237,95 @@ void consistencyCheck(const QRegularExpressionMatchIterator &iterator)
}
+template<typename Result>
+static void prepareResultForNoMatchType(Result *r, const Result &orig)
+{
+ Q_UNUSED(r);
+ Q_UNUSED(orig);
+}
+
+static void prepareResultForNoMatchType(Match *m, const Match &orig)
+{
+ m->isValid = orig.isValid;
+}
+
+template<typename QREMatch, typename QREMatchFunc, typename Subject, typename Result>
+static void testMatchImpl(const QRegularExpression &regexp,
+ QREMatchFunc matchingMethod,
+ const Subject &subject,
+ int offset,
+ QRegularExpression::MatchType matchType,
+ QRegularExpression::MatchOptions matchOptions,
+ const Result &result)
+{
+ {
+ const QREMatch m = (regexp.*matchingMethod)(subject, offset, matchType, matchOptions);
+ consistencyCheck(m);
+ QVERIFY(m == result);
+ QCOMPARE(m.regularExpression(), regexp);
+ QCOMPARE(m.matchType(), matchType);
+ QCOMPARE(m.matchOptions(), matchOptions);
+ }
+ {
+ // ignore the expected results provided by the match object --
+ // we'll never get any result when testing the NoMatch type.
+ // Just check the validity of the match here.
+ Result realMatch;
+ prepareResultForNoMatchType(&realMatch, result);
+
+ const QREMatch m = (regexp.*matchingMethod)(subject, offset, QRegularExpression::NoMatch, matchOptions);
+ consistencyCheck(m);
+ QVERIFY(m == realMatch);
+ QCOMPARE(m.regularExpression(), regexp);
+ QCOMPARE(m.matchType(), QRegularExpression::NoMatch);
+ QCOMPARE(m.matchOptions(), matchOptions);
+ }
+}
+
+template<typename QREMatch, typename QREMatchFuncForString, typename QREMatchFuncForStringRef, typename Result>
+static void testMatch(const QRegularExpression &regexp,
+ QREMatchFuncForString matchingMethodForString,
+ QREMatchFuncForStringRef matchingMethodForStringRef,
+ const QString &subject,
+ int offset,
+ QRegularExpression::MatchType matchType,
+ QRegularExpression::MatchOptions matchOptions,
+ const Result &result)
+{
+ if (forceOptimize)
+ regexp.optimize();
+
+ // test with QString as subject type
+ testMatchImpl<QREMatch>(regexp, matchingMethodForString, subject, offset, matchType, matchOptions, result);
+
+ // test with QStringRef as subject type
+ testMatchImpl<QREMatch>(regexp,
+ matchingMethodForStringRef,
+ QStringRef(&subject, 0, subject.length()),
+ offset,
+ matchType,
+ matchOptions,
+ result);
+
+ // offset <= 0 tested above; now also test stringrefs not spanning over
+ // the entire subject. Note that the offset can be negative, hence the above
+ // tests can't be merged into this one
+ for (int i = 1; i <= offset; ++i) {
+ testMatchImpl<QREMatch>(regexp,
+ matchingMethodForStringRef,
+ QStringRef(&subject, i, subject.length() - i),
+ offset - i,
+ matchType,
+ matchOptions,
+ result);
+ }
+}
+
+typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringPMF)(const QString &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
+typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringRefPMF)(const QStringRef &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
+typedef QRegularExpressionMatchIterator (QRegularExpression::*QREGlobalMatchStringPMF)(const QString &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
+typedef QRegularExpressionMatchIterator (QRegularExpression::*QREGlobalMatchStringRefPMF)(const QStringRef &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
+
void tst_QRegularExpression::provideRegularExpressions()
{
QTest::addColumn<QString>("pattern");
@@ -526,6 +615,7 @@ void tst_QRegularExpression::normalMatch_data()
QTest::addColumn<Match>("match");
Match m;
+ int offset = 0;
m.clear();
m.isValid = true; m.hasMatch = true;
@@ -577,20 +667,28 @@ void tst_QRegularExpression::normalMatch_data()
m.clear();
m.isValid = true; m.hasMatch = true;
m.captured << "c123def" << "c12" << "3" << "def";
- QTest::newRow("match06") << QRegularExpression("(\\w*)(\\d+)(\\w*)")
- << "abc123def"
- << 2
- << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
- << m;
+ offset = 2;
+ for (int i = 0; i <= offset; ++i) {
+ QTest::newRow(QStringLiteral("match06-offset%1").arg(i).toUtf8().constData())
+ << QRegularExpression("(\\w*)(\\d+)(\\w*)")
+ << QStringLiteral("abc123def").mid(offset - i)
+ << i
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+ }
m.clear();
m.isValid = true; m.hasMatch = true;
m.captured << QString("");
- QTest::newRow("match07") << QRegularExpression("\\w*")
- << "abc123def"
- << 9
- << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
- << m;
+ offset = 9;
+ for (int i = 0; i <= offset; ++i) {
+ QTest::newRow(QStringLiteral("match07-offset%1").arg(i).toUtf8().constData())
+ << QRegularExpression("\\w*")
+ << QStringLiteral("abc123def").mid(offset - i)
+ << i
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+ }
m.clear();
m.isValid = true; m.hasMatch = true;
@@ -648,19 +746,27 @@ void tst_QRegularExpression::normalMatch_data()
m.clear();
m.isValid = true;
- QTest::newRow("nomatch02") << QRegularExpression("(\\w+) (\\w+)")
- << "a string"
- << 1
- << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
- << m;
+ offset = 1;
+ for (int i = 0; i <= offset; ++i) {
+ QTest::newRow(QStringLiteral("nomatch02-offset%1").arg(i).toUtf8().constData())
+ << QRegularExpression("(\\w+) (\\w+)")
+ << QStringLiteral("a string").mid(offset - i)
+ << i
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+ }
m.clear();
m.isValid = true;
- QTest::newRow("nomatch03") << QRegularExpression("\\w+")
- << "abc123def"
- << 9
- << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
- << m;
+ offset = 9;
+ for (int i = 0; i <= offset; ++i) {
+ QTest::newRow(QStringLiteral("nomatch03-offset%1").arg(i).toUtf8().constData())
+ << QRegularExpression("\\w+")
+ << QStringLiteral("abc123def").mid(offset - i)
+ << i
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+ }
// ***
@@ -728,32 +834,14 @@ void tst_QRegularExpression::normalMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
- if (forceOptimize)
- regexp.optimize();
-
- {
- QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NormalMatch, matchOptions);
- consistencyCheck(m);
- QVERIFY(m == match);
- QCOMPARE(m.regularExpression(), regexp);
- QCOMPARE(m.matchType(), QRegularExpression::NormalMatch);
- QCOMPARE(m.matchOptions(), matchOptions);
- }
- {
- // ignore the expected results provided by the match object --
- // we'll never get any result when testing the NoMatch type.
- // Just check the validity of the match here.
- Match realMatch;
- realMatch.clear();
- realMatch.isValid = match.isValid;
-
- QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NoMatch, matchOptions);
- consistencyCheck(m);
- QVERIFY(m == realMatch);
- QCOMPARE(m.regularExpression(), regexp);
- QCOMPARE(m.matchType(), QRegularExpression::NoMatch);
- QCOMPARE(m.matchOptions(), matchOptions);
- }
+ testMatch<QRegularExpressionMatch>(regexp,
+ static_cast<QREMatchStringPMF>(&QRegularExpression::match),
+ static_cast<QREMatchStringRefPMF>(&QRegularExpression::match),
+ subject,
+ offset,
+ QRegularExpression::NormalMatch,
+ matchOptions,
+ match);
}
void tst_QRegularExpression::partialMatch_data()
@@ -766,6 +854,7 @@ void tst_QRegularExpression::partialMatch_data()
QTest::addColumn<Match>("match");
Match m;
+ int offset = 0;
m.clear();
m.isValid = true; m.hasPartialMatch = true;
@@ -840,12 +929,16 @@ void tst_QRegularExpression::partialMatch_data()
m.clear();
m.isValid = true; m.hasPartialMatch = true;
m.captured << "def";
- QTest::newRow("softmatch08") << QRegularExpression("abc\\w+X|defY")
- << "abcdef"
- << 1
- << QRegularExpression::PartialPreferCompleteMatch
- << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
- << m;
+ offset = 1;
+ for (int i = 0; i <= offset; ++i) {
+ QTest::newRow(QStringLiteral("softmatch08-offset%1").arg(i).toUtf8().constData())
+ << QRegularExpression("abc\\w+X|defY")
+ << QStringLiteral("abcdef").mid(offset - i)
+ << i
+ << QRegularExpression::PartialPreferCompleteMatch
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+ }
// ***
@@ -922,12 +1015,16 @@ void tst_QRegularExpression::partialMatch_data()
m.clear();
m.isValid = true; m.hasPartialMatch = true;
m.captured << "def";
- QTest::newRow("hardmatch08") << QRegularExpression("abc\\w+X|defY")
- << "abcdef"
- << 1
- << QRegularExpression::PartialPreferFirstMatch
- << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
- << m;
+ offset = 1;
+ for (int i = 0; i <= offset; ++i) {
+ QTest::newRow(QStringLiteral("hardmatch08-offset%1").arg(i).toUtf8().constData())
+ << QRegularExpression("abc\\w+X|defY")
+ << QStringLiteral("abcdef").mid(offset - i)
+ << i
+ << QRegularExpression::PartialPreferFirstMatch
+ << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
+ << m;
+ }
m.clear();
m.isValid = true; m.hasPartialMatch = true;
@@ -1009,32 +1106,14 @@ void tst_QRegularExpression::partialMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
- if (forceOptimize)
- regexp.optimize();
-
- {
- QRegularExpressionMatch m = regexp.match(subject, offset, matchType, matchOptions);
- consistencyCheck(m);
- QVERIFY(m == match);
- QCOMPARE(m.regularExpression(), regexp);
- QCOMPARE(m.matchType(), matchType);
- QCOMPARE(m.matchOptions(), matchOptions);
- }
- {
- // ignore the expected results provided by the match object --
- // we'll never get any result when testing the NoMatch type.
- // Just check the validity of the match here.
- Match realMatch;
- realMatch.clear();
- realMatch.isValid = match.isValid;
-
- QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NoMatch, matchOptions);
- consistencyCheck(m);
- QVERIFY(m == realMatch);
- QCOMPARE(m.regularExpression(), regexp);
- QCOMPARE(m.matchType(), QRegularExpression::NoMatch);
- QCOMPARE(m.matchOptions(), matchOptions);
- }
+ testMatch<QRegularExpressionMatch>(regexp,
+ static_cast<QREMatchStringPMF>(&QRegularExpression::match),
+ static_cast<QREMatchStringRefPMF>(&QRegularExpression::match),
+ subject,
+ offset,
+ matchType,
+ matchOptions,
+ match);
}
void tst_QRegularExpression::globalMatch_data()
@@ -1304,31 +1383,14 @@ void tst_QRegularExpression::globalMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(QList<Match>, matchList);
- if (forceOptimize)
- regexp.optimize();
-
- {
- QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, matchType, matchOptions);
- consistencyCheck(iterator);
- QVERIFY(iterator == matchList);
- QCOMPARE(iterator.regularExpression(), regexp);
- QCOMPARE(iterator.matchType(), matchType);
- QCOMPARE(iterator.matchOptions(), matchOptions);
- }
- {
- // ignore the expected results provided by the match object --
- // we'll never get any result when testing the NoMatch type.
- // Just check the validity of the match here.
- QList<Match> realMatchList;
-
- QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, QRegularExpression::NoMatch, matchOptions);
- consistencyCheck(iterator);
- QVERIFY(iterator == realMatchList);
- QCOMPARE(iterator.regularExpression(), regexp);
- QCOMPARE(iterator.matchType(), QRegularExpression::NoMatch);
- QCOMPARE(iterator.matchOptions(), matchOptions);
- }
-
+ testMatch<QRegularExpressionMatchIterator>(regexp,
+ static_cast<QREGlobalMatchStringPMF>(&QRegularExpression::globalMatch),
+ static_cast<QREGlobalMatchStringRefPMF>(&QRegularExpression::globalMatch),
+ subject,
+ offset,
+ matchType,
+ matchOptions,
+ matchList);
}
void tst_QRegularExpression::serialize_data()
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index ea40c64c89..e001440045 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -155,6 +155,7 @@ private slots:
void lastIndexOfInvalidRegex();
void indexOf_data();
void indexOf();
+ void indexOfInvalidRegex();
void indexOf2_data();
void indexOf2();
void indexOf3_data();
@@ -1182,6 +1183,18 @@ void tst_QString::indexOf()
QRegularExpression re(QRegularExpression::escape(needle), options);
QCOMPARE( haystack.indexOf(re, startpos), resultpos );
+ QCOMPARE(haystack.indexOf(re, startpos, Q_NULLPTR), resultpos);
+
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QCOMPARE(haystack.indexOf(re, startpos, &match), resultpos);
+ QCOMPARE(match.hasMatch(), resultpos != -1);
+ if (resultpos > -1 && needleIsLatin) {
+ if (bcs)
+ QVERIFY(match.captured() == needle);
+ else
+ QVERIFY(match.captured().toLower() == needle.toLower());
+ }
}
if (cs == Qt::CaseSensitive) {
@@ -1290,6 +1303,20 @@ void tst_QString::indexOf2()
}
}
+void tst_QString::indexOfInvalidRegex()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\")), -1);
+ QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, Q_NULLPTR), -1);
+
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, &match), -1);
+ QVERIFY(!match.hasMatch());
+}
+
void tst_QString::lastIndexOf_data()
{
QTest::addColumn<QString>("haystack" );
@@ -1379,6 +1406,17 @@ void tst_QString::lastIndexOf()
QRegularExpression re(QRegularExpression::escape(needle), options);
QCOMPARE(haystack.lastIndexOf(re, from), expected);
+ QCOMPARE(haystack.lastIndexOf(re, from, Q_NULLPTR), expected);
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QCOMPARE(haystack.lastIndexOf(re, from, &match), expected);
+ QCOMPARE(match.hasMatch(), expected > -1);
+ if (expected > -1) {
+ if (caseSensitive)
+ QCOMPARE(match.captured(), needle);
+ else
+ QCOMPARE(match.captured().toLower(), needle.toLower());
+ }
}
}
@@ -1403,7 +1441,15 @@ void tst_QString::lastIndexOf()
void tst_QString::lastIndexOfInvalidRegex()
{
QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object");
- QCOMPARE(QString("").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1);
+ QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1);
+ QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, Q_NULLPTR), -1);
+
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, &match), -1);
+ QVERIFY(!match.hasMatch());
}
void tst_QString::count()
@@ -1838,6 +1884,7 @@ void tst_QString::toUpper()
{
QCOMPARE( QString().toUpper(), QString() );
QCOMPARE( QString("").toUpper(), QString("") );
+ QCOMPARE( QStringLiteral("text").toUpper(), QString("TEXT") );
QCOMPARE( QString("text").toUpper(), QString("TEXT") );
QCOMPARE( QString("Text").toUpper(), QString("TEXT") );
QCOMPARE( QString("tExt").toUpper(), QString("TEXT") );
@@ -1898,6 +1945,7 @@ void tst_QString::toLower()
QCOMPARE( QString().toLower(), QString() );
QCOMPARE( QString("").toLower(), QString("") );
QCOMPARE( QString("text").toLower(), QString("text") );
+ QCOMPARE( QStringLiteral("Text").toLower(), QString("text") );
QCOMPARE( QString("Text").toLower(), QString("text") );
QCOMPARE( QString("tExt").toLower(), QString("text") );
QCOMPARE( QString("teXt").toLower(), QString("text") );
@@ -2019,6 +2067,13 @@ void tst_QString::trimmed()
QCOMPARE(a,(QString)" ");
a=" a ";
QCOMPARE(a.trimmed(),(QString)"a");
+
+ a="Text";
+ QCOMPARE(qMove(a).trimmed(),(QString)"Text");
+ a=" ";
+ QCOMPARE(qMove(a).trimmed(),(QString)"");
+ a=" a ";
+ QCOMPARE(qMove(a).trimmed(),(QString)"a");
}
void tst_QString::simplified_data()
@@ -2063,9 +2118,12 @@ void tst_QString::simplified()
QVERIFY2(result.isEmpty() && !result.isNull(), qPrintable("'" + full + "' did not yield empty: " + result));
} else {
QCOMPARE(result, simple);
- if (full == simple)
- QVERIFY(result.isSharedWith(full));
}
+
+ // force a detach
+ if (!full.isEmpty())
+ full[0] = full[0];
+ QCOMPARE(qMove(full).simplified(), simple);
}
void tst_QString::insert()
@@ -4454,6 +4512,8 @@ void tst_QString::section()
QCOMPARE( wholeString.section( QRegExp(sep), start, end, QString::SectionFlag(flags) ), sectionString );
QCOMPARE( wholeString.section( QRegularExpression(sep), start, end, QString::SectionFlag(flags) ), sectionString );
} else {
+ if (sep.size() == 1)
+ QCOMPARE( wholeString.section( sep[0], start, end, QString::SectionFlag(flags) ), sectionString );
QCOMPARE( wholeString.section( sep, start, end, QString::SectionFlag(flags) ), sectionString );
QCOMPARE( wholeString.section( QRegExp(QRegExp::escape(sep)), start, end, QString::SectionFlag(flags) ), sectionString );
QCOMPARE( wholeString.section( QRegularExpression(QRegularExpression::escape(sep)), start, end, QString::SectionFlag(flags) ), sectionString );
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 9a79d48472..c9e8a5f657 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -575,6 +575,18 @@ void tst_QVector::append() const
QCOMPARE(v.last(), SimpleValue<T>::at(0));
}
#endif
+ {
+ QVector<int> v;
+ v << 1 << 2 << 3;
+ QVector<int> x;
+ x << 4 << 5 << 6;
+ v.append(x);
+
+ QVector<int> combined;
+ combined << 1 << 2 << 3 << 4 << 5 << 6;
+
+ QCOMPARE(v, combined);
+ }
}
void tst_QVector::appendInt() const
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index fcee2884d9..676f8084a1 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -775,6 +775,13 @@ void tst_QImage::convertToFormat_data()
<< int(QImage::Format_ARGB32) << 0xff00ff00;
QTest::newRow("blue rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xff0000ff
<< int(QImage::Format_ARGB32) << 0xff0000ff;
+
+ QTest::newRow("white gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xfffffeffu
+ << int(QImage::Format_ARGB32_Premultiplied) << 0xfffefefeu;
+ QTest::newRow("gray gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xff565557u
+ << int(QImage::Format_ARGB32_Premultiplied) << 0xff555555u;
+ QTest::newRow("black gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xff000100u
+ << int(QImage::Format_ARGB32_Premultiplied) << 0xff000000u;
}
@@ -1004,6 +1011,10 @@ void tst_QImage::rotate_data()
<< QImage::Format_RGBX8888 << d;
QTest::newRow(qPrintable(title.arg("Format_RGBA8888_Premultiplied")))
<< QImage::Format_RGBA8888_Premultiplied << d;
+ QTest::newRow(qPrintable(title.arg("Format_Alpha8")))
+ << QImage::Format_Alpha8 << d;
+ QTest::newRow(qPrintable(title.arg("Format_Grayscale8")))
+ << QImage::Format_Grayscale8 << d;
}
}
@@ -2092,16 +2103,20 @@ void tst_QImage::fillPixel_data()
QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u;
QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u;
QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u;
+ QTest::newRow("Alpha8, transparent") << QImage::Format_Alpha8 << 0x0u << 0x00000000u;
QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u;
QTest::newRow("RGB32, red") << QImage::Format_RGB32 << 0xffff0000u << 0xffff0000u;
QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u;
QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u;
+ QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0xff808080u << 0xff808080u;
+
QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u;
QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u;
QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u;
QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u;
+ QTest::newRow("Alpha8, semi-red") << QImage::Format_Alpha8 << 0x80000080u << 0x80000000u;
}
void tst_QImage::fillPixel()
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index 184cc872a1..e0eaba9896 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -487,13 +487,13 @@ void tst_QImageReader::imageFormat_data()
QTest::addColumn<QImage::Format>("imageFormat");
QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm") << QImage::Format_Mono;
- QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Indexed8;
+ QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Grayscale8;
QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-3") << QString("runners.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-4") << QString("test.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
- QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Indexed8;
+ QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Grayscale8;
QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index fac16ff8a3..7a0683c3bf 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -63,6 +63,7 @@ private slots:
void positioning_data();
void positioning();
void positioningDuringMinimized();
+ void platformSurface();
void isExposed();
void isActive();
void testInputEvents();
@@ -160,8 +161,18 @@ public:
{
m_received[event->type()]++;
m_order << event->type();
- if (event->type() == QEvent::Expose)
+ switch (event->type()) {
+ case QEvent::Expose:
m_exposeRegion = static_cast<QExposeEvent *>(event)->region();
+ break;
+
+ case QEvent::PlatformSurface:
+ m_surfaceventType = static_cast<QPlatformSurfaceEvent *>(event)->surfaceEventType();
+ break;
+
+ default:
+ break;
+ }
return QWindow::event(event);
}
@@ -181,10 +192,16 @@ public:
return m_exposeRegion;
}
+ QPlatformSurfaceEvent::SurfaceEventType surfaceEventType() const
+ {
+ return m_surfaceventType;
+ }
+
private:
QHash<QEvent::Type, int> m_received;
QVector<QEvent::Type> m_order;
QRegion m_exposeRegion;
+ QPlatformSurfaceEvent::SurfaceEventType m_surfaceventType;
};
void tst_QWindow::eventOrderOnShow()
@@ -352,6 +369,63 @@ void tst_QWindow::positioningDuringMinimized()
QTRY_COMPARE(window.geometry(), newGeometry);
}
+class PlatformWindowFilter : public QObject
+{
+ Q_OBJECT
+public:
+ PlatformWindowFilter(QObject *parent = 0)
+ : QObject(parent)
+ , m_window(Q_NULLPTR)
+ , m_alwaysExisted(true)
+ {}
+
+ void setWindow(Window *window) { m_window = window; }
+
+ bool eventFilter(QObject *o, QEvent *e)
+ {
+ // Check that the platform surface events are delivered synchronously.
+ // If they are, the native platform surface should always exist when we
+ // receive a QPlatformSurfaceEvent
+ if (e->type() == QEvent::PlatformSurface && o == m_window) {
+ m_alwaysExisted &= (m_window->handle() != Q_NULLPTR);
+ }
+ return false;
+ }
+
+ bool surfaceExisted() const { return m_alwaysExisted; }
+
+private:
+ Window *m_window;
+ bool m_alwaysExisted;
+};
+
+void tst_QWindow::platformSurface()
+{
+ QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
+
+ Window window;
+ PlatformWindowFilter filter;
+ filter.setWindow(&window);
+ window.installEventFilter(&filter);
+
+ window.setGeometry(geometry);
+ QCOMPARE(window.geometry(), geometry);
+ window.create();
+
+ QTRY_VERIFY(window.received(QEvent::PlatformSurface) == 1);
+ QTRY_VERIFY(window.surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated);
+ QTRY_VERIFY(window.handle() != Q_NULLPTR);
+
+ window.destroy();
+ QTRY_VERIFY(window.received(QEvent::PlatformSurface) == 2);
+ QTRY_VERIFY(window.surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);
+ QTRY_VERIFY(window.handle() == Q_NULLPTR);
+
+ // Check for synchronous delivery of platform surface events and that the platform
+ // surface always existed upon event delivery
+ QTRY_VERIFY(filter.surfaceExisted());
+}
+
void tst_QWindow::isExposed()
{
QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index c5755dcdad..5072aa96c3 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -3442,7 +3442,8 @@ void tst_QPainter::drawImage_data()
for (int srcFormat = QImage::Format_Mono; srcFormat < QImage::NImageFormats; ++srcFormat) {
for (int dstFormat = QImage::Format_Mono; dstFormat < QImage::NImageFormats; ++dstFormat) {
- if (dstFormat == QImage::Format_Indexed8)
+ // Indexed8 can't be painted to, and Alpha8 can't hold a color.
+ if (dstFormat == QImage::Format_Indexed8 || dstFormat == QImage::Format_Alpha8)
continue;
for (int odd_x = 0; odd_x <= 1; ++odd_x) {
for (int odd_width = 0; odd_width <= 1; ++odd_width) {
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 89ad66c1e8..a8834563a1 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -98,6 +98,8 @@ private slots:
void textureblitterPartTargetRectTransform();
void defaultSurfaceFormat();
+ void imageFormatPainting();
+
#ifdef USE_GLX
void glxContextWrap();
#endif
@@ -718,6 +720,68 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
QCOMPARE(fbo->handle(), 0U);
}
+void tst_QOpenGL::imageFormatPainting()
+{
+ QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
+
+ QOpenGLContext ctx;
+ QVERIFY(ctx.create());
+
+ QVERIFY(ctx.makeCurrent(surface.data()));
+
+ if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QOpenGLFramebufferObject not supported on this platform");
+
+ QOpenGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+
+ const QSize size(128, 128);
+ QOpenGLFramebufferObject fbo(size, fboFormat);
+
+ if (fbo.attachment() != QOpenGLFramebufferObject::CombinedDepthStencil)
+ QSKIP("FBOs missing combined depth~stencil support");
+
+ QVERIFY(fbo.bind());
+
+ QImage alpha(128, 128, QImage::Format_Alpha8);
+ alpha.fill(127);
+
+ QPainter fboPainter;
+ QOpenGLPaintDevice device(fbo.width(), fbo.height());
+
+ QVERIFY(fboPainter.begin(&device));
+ fboPainter.fillRect(0, 0, 128, 128, qRgb(255, 0, 255));
+ fboPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ fboPainter.drawImage(0, 0, alpha);
+ fboPainter.end();
+
+ QImage fb = fbo.toImage();
+ QCOMPARE(fb.pixel(0, 0), qRgba(127, 0, 127, 127));
+
+ QImage grayscale(128, 128, QImage::Format_Grayscale8);
+ grayscale.fill(128);
+
+ QVERIFY(fboPainter.begin(&device));
+ fboPainter.setCompositionMode(QPainter::CompositionMode_Plus);
+ fboPainter.drawImage(0, 0, grayscale);
+ fboPainter.end();
+
+ fb = fbo.toImage();
+ QCOMPARE(fb.pixel(0, 0), qRgb(255, 128, 255));
+
+ QImage argb(128, 128, QImage::Format_ARGB32);
+ argb.fill(qRgba(255, 255, 255, 128));
+
+ QVERIFY(fboPainter.begin(&device));
+ fboPainter.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ fboPainter.drawImage(0, 0, argb);
+ fboPainter.end();
+
+ fb = fbo.toImage();
+ QCOMPARE(fb.pixel(0, 0), qRgb(255, 192, 255));
+
+}
+
void tst_QOpenGL::openGLPaintDevice_data()
{
QTest::addColumn<int>("surfaceClass");
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 4cab2b8a51..139cafa1fa 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -78,6 +78,8 @@ private slots:
void find2();
void findWithRegExp_data();
void findWithRegExp();
+ void findWithRegularExpression_data();
+ void findWithRegularExpression();
void findMultiple();
void basicIsModifiedChecks();
void moreIsModified();
@@ -188,6 +190,7 @@ private slots:
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
+ void buildRegExpData();
QTextDocument *doc;
QTextCursor cursor;
@@ -344,21 +347,7 @@ void tst_QTextDocument::find()
void tst_QTextDocument::findWithRegExp_data()
{
- QTest::addColumn<QString>("haystack");
- QTest::addColumn<QString>("needle");
- QTest::addColumn<int>("flags");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("anchor");
- QTest::addColumn<int>("position");
-
- // match integers 0 to 99
- QTest::newRow("1") << "23" << "^\\d\\d?$" << int(QTextDocument::FindCaseSensitively) << 0 << 0 << 2;
- // match ampersands but not &amp;
- QTest::newRow("2") << "His &amp; hers & theirs" << "&(?!amp;)"<< int(QTextDocument::FindCaseSensitively) << 0 << 15 << 16;
- //backward search
- QTest::newRow("3") << QString::fromLatin1("HelloBlahWorld Blah Hah")
- << "h" << int(QTextDocument::FindBackward) << 18 << 8 << 9;
-
+ buildRegExpData();
}
void tst_QTextDocument::findWithRegExp()
@@ -385,6 +374,34 @@ void tst_QTextDocument::findWithRegExp()
}
}
+void tst_QTextDocument::findWithRegularExpression_data()
+{
+ buildRegExpData();
+}
+
+void tst_QTextDocument::findWithRegularExpression()
+{
+ QFETCH(QString, haystack);
+ QFETCH(QString, needle);
+ QFETCH(int, flags);
+ QFETCH(int, from);
+ QFETCH(int, anchor);
+ QFETCH(int, position);
+
+ cursor.insertText(haystack);
+ //search using a regular expression
+ QRegularExpression expr(needle);
+ QTextDocument::FindFlags flg(flags);
+ cursor = doc->find(expr, from, flg);
+
+ if (anchor != -1) {
+ QCOMPARE(cursor.anchor(), anchor);
+ QCOMPARE(cursor.position(), position);
+ } else {
+ QVERIFY(cursor.isNull());
+ }
+}
+
void tst_QTextDocument::find2()
{
doc->setPlainText("aaa");
@@ -2594,6 +2611,24 @@ void tst_QTextDocument::backgroundImage_checkExpectedHtml(const QTextDocument &d
QCOMPARE(doc.toHtml(), expectedHtml);
}
+void tst_QTextDocument::buildRegExpData()
+{
+ QTest::addColumn<QString>("haystack");
+ QTest::addColumn<QString>("needle");
+ QTest::addColumn<int>("flags");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("anchor");
+ QTest::addColumn<int>("position");
+
+ // match integers 0 to 99
+ QTest::newRow("1") << "23" << "^\\d\\d?$" << int(QTextDocument::FindCaseSensitively) << 0 << 0 << 2;
+ // match ampersands but not &amp;
+ QTest::newRow("2") << "His &amp; hers & theirs" << "&(?!amp;)"<< int(QTextDocument::FindCaseSensitively) << 0 << 15 << 16;
+ //backward search
+ QTest::newRow("3") << QString::fromLatin1("HelloBlahWorld Blah Hah")
+ << "h" << int(QTextDocument::FindBackward) << 18 << 8 << 9;
+}
+
void tst_QTextDocument::backgroundImage_toHtml()
{
CREATE_DOC_AND_CURSOR();
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 49cdeb71cf..533f7a7289 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -315,6 +315,7 @@ private Q_SLOTS:
void ioPostToHttpFromMiddleOfQBufferFiveBytes();
void ioPostToHttpNoBufferFlag();
void ioPostToHttpUploadProgress();
+ void emitAllUploadProgressSignals();
void ioPostToHttpEmptyUploadProgress();
void lastModifiedHeaderForFile();
@@ -4979,6 +4980,59 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress()
server.close();
}
+void tst_QNetworkReply::emitAllUploadProgressSignals()
+{
+ QFile sourceFile(testDataDir + "/image1.jpg");
+ QVERIFY(sourceFile.open(QIODevice::ReadOnly));
+
+ // emulate a minimal http server
+ QTcpServer server;
+ server.listen(QHostAddress(QHostAddress::LocalHost), 0);
+ connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QUrl url = QUrl(QString("http://127.0.0.1:%1/").arg(server.serverPort()));
+ QNetworkRequest normalRequest(url);
+ normalRequest.setRawHeader("Content-Type", "application/octet-stream");
+
+ QNetworkRequest catchAllSignalsRequest(normalRequest);
+ catchAllSignalsRequest.setAttribute(QNetworkRequest::EmitAllUploadProgressSignalsAttribute, true);
+
+ QList<QNetworkRequest> requests;
+ requests << normalRequest << catchAllSignalsRequest;
+
+ QList<int> signalCount;
+
+ foreach (const QNetworkRequest &request, requests) {
+
+ sourceFile.seek(0);
+ QNetworkReplyPtr reply(manager.post(request, &sourceFile));
+ QSignalSpy spy(reply.data(), SIGNAL(uploadProgress(qint64,qint64)));
+
+ // get the request started and the incoming socket connected
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QTcpSocket *incomingSocket = server.nextPendingConnection();
+ QVERIFY(incomingSocket);
+ QTestEventLoop::instance().enterLoop(10);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ incomingSocket->write("HTTP/1.0 200 OK\r\n");
+ incomingSocket->write("Content-Length: 0\r\n");
+ incomingSocket->write("\r\n");
+ QTestEventLoop::instance().enterLoop(10);
+ // not timeouted -> finished() was emitted
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ incomingSocket->close();
+ signalCount.append(spy.count());
+ reply->deleteLater();
+ }
+ server.close();
+
+ // verify that the normal request emitted less signals than the one emitting all signals
+ QVERIFY2(signalCount.at(0) < signalCount.at(1), "no upload signal was suppressed");
+}
+
void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
{
QByteArray ba;
diff --git a/tests/auto/network/ssl/qsslellipticcurve/.gitignore b/tests/auto/network/ssl/qsslellipticcurve/.gitignore
new file mode 100644
index 0000000000..27f97e770a
--- /dev/null
+++ b/tests/auto/network/ssl/qsslellipticcurve/.gitignore
@@ -0,0 +1 @@
+tst_qsslellipticcurves
diff --git a/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro b/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro
new file mode 100644
index 0000000000..d9a771a080
--- /dev/null
+++ b/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+CONFIG += parallel_test
+
+SOURCES += tst_qsslellipticcurve.cpp
+!wince*:win32:LIBS += -lws2_32
+QT = core network testlib
+
+TARGET = tst_qsslellipticcurve
diff --git a/tests/auto/network/ssl/qsslellipticcurve/tst_qsslellipticcurve.cpp b/tests/auto/network/ssl/qsslellipticcurve/tst_qsslellipticcurve.cpp
new file mode 100644
index 0000000000..a5b1d14a92
--- /dev/null
+++ b/tests/auto/network/ssl/qsslellipticcurve/tst_qsslellipticcurve.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Governikus GmbH & Co. KG.
+** 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 <QtTest/QtTest>
+#include <QSslEllipticCurve>
+#include <QSslSocket>
+
+class tst_QSslEllipticCurve : public QObject
+{
+ Q_OBJECT
+
+#ifndef QT_NO_SSL
+private Q_SLOTS:
+ void constExpr();
+ void construction();
+ void fromShortName_data();
+ void fromShortName();
+#endif
+};
+
+#ifndef QT_NO_SSL
+
+void tst_QSslEllipticCurve::constExpr()
+{
+#ifdef Q_COMPILER_CONSTEXPR
+ // check that default ctor and op ==/!= are constexpr:
+ char array1[QSslEllipticCurve() == QSslEllipticCurve() ? 1 : -1];
+ char array2[QSslEllipticCurve() != QSslEllipticCurve() ? -1 : 1];
+ Q_UNUSED(array1);
+ Q_UNUSED(array2);
+#else
+ QSKIP("This test requires C++11 generalized constant expression support enabled in the compiler.");
+#endif
+}
+
+void tst_QSslEllipticCurve::construction()
+{
+ QSslEllipticCurve curve;
+ QCOMPARE(curve.isValid(), false);
+ QCOMPARE(curve.shortName(), QString());
+ QCOMPARE(curve.longName(), QString());
+ QCOMPARE(curve.isTlsNamedCurve(), false);
+}
+
+void tst_QSslEllipticCurve::fromShortName_data()
+{
+ QTest::addColumn<QString>("shortName");
+ QTest::addColumn<QSslEllipticCurve>("curve");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("QString()") << QString() << QSslEllipticCurve() << false;
+ QTest::newRow("\"\"") << QString("") << QSslEllipticCurve() << false;
+ QTest::newRow("does-not-exist") << QStringLiteral("does-not-exist") << QSslEllipticCurve() << false;
+ Q_FOREACH (QSslEllipticCurve ec, QSslSocket::supportedEllipticCurves()) {
+ const QString sN = ec.shortName();
+ QTest::newRow(qPrintable("supported EC \"" + sN + '"')) << sN << ec << true;
+ // At least in the OpenSSL impl, the short name is case-sensitive. That feels odd.
+ //const QString SN = sN.toUpper();
+ //QTest::newRow(qPrintable("supported EC \"" + SN + '"')) << SN << ec << true;
+ //const QString sn = sN.toLower();
+ //QTest::newRow(qPrintable("supported EC \"" + sn + '"')) << sn << ec << true;
+ }
+}
+
+void tst_QSslEllipticCurve::fromShortName()
+{
+ QFETCH(QString, shortName);
+ QFETCH(QSslEllipticCurve, curve);
+ QFETCH(bool, valid);
+
+ const QSslEllipticCurve result = QSslEllipticCurve::fromShortName(shortName);
+ QCOMPARE(result, curve);
+ QCOMPARE(result.isValid(), valid);
+ QCOMPARE(result.shortName(), curve.shortName());
+ QCOMPARE(result.shortName(), valid ? shortName : QString());
+}
+
+#endif // QT_NO_SSL
+
+QTEST_MAIN(tst_QSslEllipticCurve)
+#include "tst_qsslellipticcurve.moc"
diff --git a/tests/auto/network/ssl/ssl.pro b/tests/auto/network/ssl/ssl.pro
index 4e30a9cded..3418a3ae65 100644
--- a/tests/auto/network/ssl/ssl.pro
+++ b/tests/auto/network/ssl/ssl.pro
@@ -2,6 +2,7 @@ TEMPLATE=subdirs
SUBDIRS=\
qsslcertificate \
qsslcipher \
+ qsslellipticcurve \
qsslerror \
qsslkey \
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index bd3997f8c9..9f7d45e562 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -24,6 +24,7 @@ SUBDIRS=\
qprocess_and_guieventloop \
qtokenautomaton \
windowsmobile \
+ toolsupport \
!qtHaveModule(widgets): SUBDIRS -= \
baselineexample \
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index ef70509541..af0a0b446e 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -41,13 +41,7 @@
# include <servprov.h>
# include <winuser.h>
# ifdef QT_SUPPORTS_IACCESSIBLE2
-# include <Accessible2.h>
-# include <AccessibleAction.h>
-# include <AccessibleComponent.h>
-# include <AccessibleEditableText.h>
-# include <AccessibleText.h>
-# include <AccessibleTable2.h>
-# include <AccessibleTableCell.h>
+# include <ia2_api_all.h>
# endif
#endif
#include <QtTest/QtTest>
diff --git a/tests/auto/other/toolsupport/toolsupport.pro b/tests/auto/other/toolsupport/toolsupport.pro
new file mode 100644
index 0000000000..274ead2c35
--- /dev/null
+++ b/tests/auto/other/toolsupport/toolsupport.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase parallel_test
+TARGET = tst_toolsupport
+QT = testlib core-private
+SOURCES = $$PWD/tst_toolsupport.cpp
diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp
new file mode 100644
index 0000000000..d4ee3f4c50
--- /dev/null
+++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** 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.
+**
+****************************************************************************/
+
+#include <QtTest>
+
+// Don't do this at home. This is test code, not production.
+#define protected public
+#define private public
+
+#include <private/qdatetime_p.h>
+#include <private/qfile_p.h>
+#include <private/qfileinfo_p.h>
+#include <private/qobject_p.h>
+#include <qobject.h>
+
+#if defined(Q_CC_GNU) || defined(Q_CC_MSVC)
+#define RUN_MEMBER_OFFSET_TEST 1
+#else
+#define RUN_MEMBER_OFFSET_TEST 0
+#endif
+
+#if RUN_MEMBER_OFFSET_TEST
+template <typename T, typename K>
+size_t pmm_to_offsetof(T K:: *pmm)
+{
+#ifdef Q_CC_MSVC
+ // Even on 64 bit MSVC uses 4 byte offsets.
+ quint32 ret;
+#else
+ size_t ret;
+#endif
+ Q_STATIC_ASSERT(sizeof(ret) == sizeof(pmm));
+ memcpy(&ret, &pmm, sizeof(ret));
+ return ret;
+}
+#endif
+
+class tst_toolsupport : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void offsets();
+ void offsets_data();
+};
+
+void tst_toolsupport::offsets()
+{
+ QFETCH(size_t, actual);
+ QFETCH(int, expected32);
+ QFETCH(int, expected64);
+ size_t expect = sizeof(void *) == 4 ? expected32 : expected64;
+ QCOMPARE(actual, expect);
+}
+
+void tst_toolsupport::offsets_data()
+{
+ QTest::addColumn<size_t>("actual");
+ QTest::addColumn<int>("expected32");
+ QTest::addColumn<int>("expected64");
+
+ {
+ QTestData &data = QTest::newRow("sizeof(QObjectData)")
+ << sizeof(QObjectData);
+ data << 28 << 48; // vptr + 3 ptr + 2 int + ptr
+ }
+
+#if RUN_MEMBER_OFFSET_TEST
+ {
+ QTestData &data = QTest::newRow("QObjectPrivate::extraData")
+ << pmm_to_offsetof(&QObjectPrivate::extraData);
+ data << 28 << 48; // sizeof(QObjectData)
+ }
+
+ {
+ QTestData &data = QTest::newRow("QFileInfoPrivate::fileEntry")
+ << pmm_to_offsetof(&QFileInfoPrivate::fileEntry);
+ data << 4 << 8;
+ }
+
+ {
+ QTestData &data = QTest::newRow("QFileSystemEntry::filePath")
+ << pmm_to_offsetof(&QFileSystemEntry::m_filePath);
+ data << 0 << 0;
+ }
+
+#ifdef Q_OS_LINUX
+ if (sizeof(void *) == 8) {
+ QTestData &data = QTest::newRow("QFilePrivate::fileName")
+ << pmm_to_offsetof(&QFilePrivate::fileName);
+ data << -1 << 272;
+ }
+#endif
+
+ {
+#ifdef Q_OS_WIN
+ QTest::newRow("QDateTimePrivate::m_msecs")
+ << pmm_to_offsetof(&QDateTimePrivate::m_msecs) << 8 << 8;
+ QTest::newRow("QDateTimePrivate::m_spec")
+ << pmm_to_offsetof(&QDateTimePrivate::m_spec) << 16 << 16;
+ QTest::newRow("QDateTimePrivate::m_offsetFromUtc")
+ << pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 20 << 20;
+ QTest::newRow("QDateTimePrivate::m_timeZone")
+ << pmm_to_offsetof(&QDateTimePrivate::m_timeZone) << 24 << 24;
+ QTest::newRow("QDateTimePrivate::m_status")
+ << pmm_to_offsetof(&QDateTimePrivate::m_status) << 28 << 32;
+#else
+ QTest::newRow("QDateTimePrivate::m_msecs")
+ << pmm_to_offsetof(&QDateTimePrivate::m_msecs) << 4 << 8;
+ QTest::newRow("QDateTimePrivate::m_spec")
+ << pmm_to_offsetof(&QDateTimePrivate::m_spec) << 12 << 16;
+ QTest::newRow("QDateTimePrivate::m_offsetFromUtc")
+ << pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 16 << 20;
+ QTest::newRow("QDateTimePrivate::m_timeZone")
+ << pmm_to_offsetof(&QDateTimePrivate::m_timeZone) << 20 << 24;
+ QTest::newRow("QDateTimePrivate::m_status")
+ << pmm_to_offsetof(&QDateTimePrivate::m_status) << 24 << 32;
+#endif
+ }
+#endif // RUN_MEMBER_OFFSET_TEST
+}
+
+
+QTEST_APPLESS_MAIN(tst_toolsupport);
+
+#include "tst_toolsupport.moc"
+
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index edb6488eaa..fe6ad6637a 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -572,6 +572,7 @@ private slots:
void relatedMetaObjectsInGadget();
void relatedMetaObjectsNameConflict_data();
void relatedMetaObjectsNameConflict();
+ void strignLiteralsInMacroExtension();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -3269,6 +3270,45 @@ void tst_Moc::relatedMetaObjectsNameConflict()
QCOMPARE(dependency.size(), relatedMetaObjects.size());
}
+class StringLiteralsInMacroExtension: public QObject
+{
+ Q_OBJECT
+#define Macro(F) F " " F
+ Q_CLASSINFO(Macro("String"), Macro("Literal"))
+#undef Macro
+
+#define Macro(F) F
+ Q_CLASSINFO("String" Macro("!"), "Literal" Macro("!"))
+ Q_CLASSINFO(Macro("!") "String", Macro("!") "Literal")
+#undef Macro
+
+#define Macro "foo"
+ Q_CLASSINFO("String" Macro, "Literal" Macro)
+ Q_CLASSINFO(Macro "String", Macro "Literal")
+#undef Macro
+};
+
+void tst_Moc::strignLiteralsInMacroExtension()
+{
+ const QMetaObject *mobj = &StringLiteralsInMacroExtension::staticMetaObject;
+ QCOMPARE(mobj->classInfoCount(), 5);
+
+ QCOMPARE(mobj->classInfo(0).name(), "String String");
+ QCOMPARE(mobj->classInfo(0).value(), "Literal Literal");
+
+ QCOMPARE(mobj->classInfo(1).name(), "String!");
+ QCOMPARE(mobj->classInfo(1).value(), "Literal!");
+
+ QCOMPARE(mobj->classInfo(2).name(), "!String");
+ QCOMPARE(mobj->classInfo(2).value(), "!Literal");
+
+ QCOMPARE(mobj->classInfo(3).name(), "Stringfoo");
+ QCOMPARE(mobj->classInfo(3).value(), "Literalfoo");
+
+ QCOMPARE(mobj->classInfo(4).name(), "fooString");
+ QCOMPARE(mobj->classInfo(4).value(), "fooLiteral");
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 250790d9fa..04852721db 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -2110,8 +2110,7 @@ void tst_QGraphicsView::sendEvent()
QCOMPARE(item->events.at(item->events.size() - 2), QEvent::GraphicsSceneMouseRelease);
QCOMPARE(item->events.at(item->events.size() - 1), QEvent::UngrabMouse);
- QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Space, 0);
- QApplication::sendEvent(view.viewport(), &keyPress);
+ QTest::keyPress(view.viewport(), Qt::Key_Space);
QCOMPARE(item->events.size(), 9);
QCOMPARE(item->events.at(item->events.size() - 2), QEvent::ShortcutOverride);
QCOMPARE(item->events.last(), QEvent::KeyPress);
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 3f8b8ec067..f2a40576f6 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -518,11 +518,16 @@ void tst_QAbstractItemView::basic_tests(TestView *view)
// setIconSize
view->setIconSize(QSize(16, 16));
QCOMPARE(view->iconSize(), QSize(16, 16));
+ QSignalSpy spy(view, &QAbstractItemView::iconSizeChanged);
+ QVERIFY(spy.isValid());
view->setIconSize(QSize(32, 32));
QCOMPARE(view->iconSize(), QSize(32, 32));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).value<QSize>(), QSize(32, 32));
// Should this happen?
view->setIconSize(QSize(-1, -1));
QCOMPARE(view->iconSize(), QSize(-1, -1));
+ QCOMPARE(spy.count(), 2);
QCOMPARE(view->currentIndex(), QModelIndex());
QCOMPARE(view->rootIndex(), QModelIndex());
diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index 2c3fdb1baa..1616b08fb2 100644
--- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -30,9 +30,12 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QtGui/QtGui>
-#include <QtWidgets/QtWidgets>
-#include <QtTest/QtTest>
+#include <QDataWidgetMapper>
+#include <QStandardItemModel>
+#include <QLineEdit>
+#include <QComboBox>
+#include <QTest>
+#include <QSignalSpy>
class tst_QDataWidgetMapper: public QObject
{
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index 6428bbba10..428b2f0c42 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -123,7 +123,7 @@ private slots:
void task258949_keypressHangup();
void QTBUG8086_currentItemChangedOnClick();
void QTBUG14363_completerWithAnyKeyPressedEditTriggers();
-
+ void mimeData();
protected slots:
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
@@ -1082,6 +1082,9 @@ public:
Q_UNUSED(item);
return QListWidget::state() == QListWidget::EditingState;
}
+
+ using QListWidget::mimeData;
+ using QListWidget::indexFromItem;
};
void tst_QListWidget::closeEditor()
@@ -1662,7 +1665,57 @@ void tst_QListWidget::QTBUG14363_completerWithAnyKeyPressedEditTriggers()
QCOMPARE(le->completer()->currentCompletion(), QString("completer"));
}
+void tst_QListWidget::mimeData()
+{
+ TestListWidget list;
+
+ for (int x = 0; x < 10; ++x) {
+ QListWidgetItem *item = new QListWidgetItem(QStringLiteral("123"));
+ list.addItem(item);
+ }
+
+ QList<QListWidgetItem *> tableWidgetItemList;
+ QModelIndexList modelIndexList;
+
+ // do these checks more than once to ensure that the "cached indexes" work as expected
+ QVERIFY(!list.mimeData(tableWidgetItemList));
+ QVERIFY(!list.model()->mimeData(modelIndexList));
+ QVERIFY(!list.model()->mimeData(modelIndexList));
+ QVERIFY(!list.mimeData(tableWidgetItemList));
+
+ tableWidgetItemList << list.item(1);
+ modelIndexList << list.indexFromItem(list.item(1));
+
+ QMimeData *data;
+
+ QVERIFY(data = list.mimeData(tableWidgetItemList));
+ delete data;
+ QVERIFY(data = list.model()->mimeData(modelIndexList));
+ delete data;
+
+ QVERIFY(data = list.model()->mimeData(modelIndexList));
+ delete data;
+
+ QVERIFY(data = list.mimeData(tableWidgetItemList));
+ delete data;
+
+ // check the saved data is actually the same
+
+ QMimeData *data2;
+
+ data = list.mimeData(tableWidgetItemList);
+ data2 = list.model()->mimeData(modelIndexList);
+
+ const QString format = QStringLiteral("application/x-qabstractitemmodeldatalist");
+
+ QVERIFY(data->hasFormat(format));
+ QVERIFY(data2->hasFormat(format));
+ QVERIFY(data->data(format) == data2->data(format));
+
+ delete data;
+ delete data2;
+}
QTEST_MAIN(tst_QListWidget)
#include "tst_qlistwidget.moc"
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 8335497c6c..de88e832aa 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -93,6 +93,7 @@ private slots:
void task219380_removeLastRow();
void task262056_sortDuplicate();
void itemWithHeaderItems();
+ void mimeData();
private:
QTableWidget *testWidget;
@@ -1497,5 +1498,72 @@ void tst_QTableWidget::itemWithHeaderItems()
QCOMPARE(table.item(0, 1), static_cast<QTableWidgetItem *>(0));
}
+class TestTableWidget : public QTableWidget
+{
+ Q_OBJECT
+public:
+ TestTableWidget(int rows, int columns, QWidget *parent = 0)
+ : QTableWidget(rows, columns, parent)
+ {
+ }
+
+ using QTableWidget::mimeData;
+ using QTableWidget::indexFromItem;
+};
+
+void tst_QTableWidget::mimeData()
+{
+ TestTableWidget table(10, 10);
+
+ for (int x = 0; x < 10; ++x) {
+ for (int y = 0; y < 10; ++y) {
+ QTableWidgetItem *item = new QTableWidgetItem(QStringLiteral("123"));
+ table.setItem(y, x, item);
+ }
+ }
+
+ QList<QTableWidgetItem *> tableWidgetItemList;
+ QModelIndexList modelIndexList;
+
+ // do these checks more than once to ensure that the "cached indexes" work as expected
+ QVERIFY(!table.mimeData(tableWidgetItemList));
+ QVERIFY(!table.model()->mimeData(modelIndexList));
+ QVERIFY(!table.model()->mimeData(modelIndexList));
+ QVERIFY(!table.mimeData(tableWidgetItemList));
+
+ tableWidgetItemList << table.item(1, 1);
+ modelIndexList << table.indexFromItem(table.item(1, 1));
+
+ QMimeData *data;
+
+ QVERIFY(data = table.mimeData(tableWidgetItemList));
+ delete data;
+
+ QVERIFY(data = table.model()->mimeData(modelIndexList));
+ delete data;
+
+ QVERIFY(data = table.model()->mimeData(modelIndexList));
+ delete data;
+
+ QVERIFY(data = table.mimeData(tableWidgetItemList));
+ delete data;
+
+ // check the saved data is actually the same
+
+ QMimeData *data2;
+
+ data = table.mimeData(tableWidgetItemList);
+ data2 = table.model()->mimeData(modelIndexList);
+
+ const QString format = QStringLiteral("application/x-qabstractitemmodeldatalist");
+
+ QVERIFY(data->hasFormat(format));
+ QVERIFY(data2->hasFormat(format));
+ QVERIFY(data->data(format) == data2->data(format));
+
+ delete data;
+ delete data2;
+}
+
QTEST_MAIN(tst_QTableWidget)
#include "tst_qtablewidget.moc"
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 1d6f577192..0691801553 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -42,6 +42,7 @@
#include <qdebug.h>
#include <qstring.h>
#include <qshortcut.h>
+#include <qscreen.h>
class AccelForm;
QT_BEGIN_NAMESPACE
@@ -119,6 +120,7 @@ private slots:
void keypressConsumption();
void unicodeCompare();
void context();
+ void duplicatedShortcutOverride();
protected:
static Qt::KeyboardModifiers toButtons( int key );
@@ -1082,6 +1084,36 @@ void tst_QShortcut::context()
clearAllShortcuts();
}
+// QTBUG-38986, do not generate duplicated QEvent::ShortcutOverride in event processing.
+class OverrideCountingWidget : public QWidget
+{
+public:
+ OverrideCountingWidget(QWidget *parent = 0) : QWidget(parent), overrideCount(0) {}
+
+ int overrideCount;
+
+ bool event(QEvent *e) Q_DECL_OVERRIDE
+ {
+ if (e->type() == QEvent::ShortcutOverride)
+ overrideCount++;
+ return QWidget::event(e);
+ }
+};
+
+void tst_QShortcut::duplicatedShortcutOverride()
+{
+ OverrideCountingWidget w;
+ w.setWindowTitle(Q_FUNC_INFO);
+ w.resize(200, 200);
+ w.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(100, 100));
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+ QTest::keyPress(w.windowHandle(), Qt::Key_A);
+ QCoreApplication::processEvents();
+ QCOMPARE(w.overrideCount, 1);
+}
+
// ------------------------------------------------------------------
// Element Testing helper functions ---------------------------------
// ------------------------------------------------------------------
@@ -1226,7 +1258,7 @@ void tst_QShortcut::testElement()
setupShortcut(testWidget, txt, k1, k2, k3, k4);
} else {
sendKeyEvents(k1, c1, k2, c2, k3, c3, k4, c4);
- QCOMPARE(currentResult, result);
+ QCOMPARE((int)currentResult, (int)result);
}
}
diff --git a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp
index 917a00e6db..30b0b2b896 100644
--- a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp
+++ b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp
@@ -70,6 +70,7 @@ void tst_QWidgetMetaType::metaObject()
QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QWidget*>()), &QWidget::staticMetaObject);
QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QLabel*>()), &QLabel::staticMetaObject);
QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<CustomWidget*>()), &CustomWidget::staticMetaObject);
+ QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QSizePolicy>()), &QSizePolicy::staticMetaObject);
}
QTEST_MAIN(tst_QWidgetMetaType)
diff --git a/tests/auto/widgets/widgets/qframe/.gitignore b/tests/auto/widgets/widgets/qframe/.gitignore
new file mode 100644
index 0000000000..d01744a6bd
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/.gitignore
@@ -0,0 +1 @@
+tst_qframe
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png
new file mode 100644
index 0000000000..0cc9090e3b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png
new file mode 100644
index 0000000000..0cc9090e3b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png
new file mode 100644
index 0000000000..0cc9090e3b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png
new file mode 100644
index 0000000000..0cc9090e3b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png
new file mode 100644
index 0000000000..0cc9090e3b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png
new file mode 100644
index 0000000000..0cc9090e3b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png
new file mode 100644
index 0000000000..b2ab941d30
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png
new file mode 100644
index 0000000000..21ebe53eff
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png
new file mode 100644
index 0000000000..4f097cee48
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png
new file mode 100644
index 0000000000..86f9ed6186
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png
new file mode 100644
index 0000000000..51a7899d05
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png
new file mode 100644
index 0000000000..8c3769c32d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png
new file mode 100644
index 0000000000..81e0c2a152
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png
new file mode 100644
index 0000000000..107272d0b9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png
new file mode 100644
index 0000000000..f1d6392779
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png
new file mode 100644
index 0000000000..b2ab941d30
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png
new file mode 100644
index 0000000000..21ebe53eff
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png
new file mode 100644
index 0000000000..6905baa1fd
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png
new file mode 100644
index 0000000000..9d5440b3aa
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png
new file mode 100644
index 0000000000..17eb7f59c0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png
new file mode 100644
index 0000000000..a6ccd54a39
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png
new file mode 100644
index 0000000000..3736bf6c99
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png
new file mode 100644
index 0000000000..5750751c58
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png
new file mode 100644
index 0000000000..61f683df52
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
new file mode 100644
index 0000000000..a75833c89c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
new file mode 100644
index 0000000000..d656ac56f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/qframe.pro b/tests/auto/widgets/widgets/qframe/qframe.pro
new file mode 100644
index 0000000000..1da7eb1d11
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/qframe.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qframe
+
+QT += testlib widgets
+
+SOURCES += tst_qframe.cpp
+
+TESTDATA += images/*
diff --git a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp
new file mode 100644
index 0000000000..ee6b3313a6
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTest>
+#include <QFrame>
+#include <QStyleOptionFrame>
+#include <QPixmap>
+#include <QStyle>
+#include <QStyleFactory>
+
+class tst_QFrame : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testDefaults();
+ void testInitStyleOption_data();
+ void testInitStyleOption();
+ void testPainting_data();
+ void testPainting();
+};
+
+Q_DECLARE_METATYPE(QFrame::Shape)
+Q_DECLARE_METATYPE(QFrame::Shadow)
+
+void tst_QFrame::testDefaults()
+{
+ QFrame frame;
+ QCOMPARE(frame.frameStyle(), int(QFrame::NoFrame | QFrame::Plain));
+ frame.setFrameShape(QFrame::Box);
+ QCOMPARE(frame.frameStyle(), int(QFrame::Box | QFrame::Plain));
+ frame.setFrameStyle(QFrame::Box); // no shadow specified!
+ QCOMPARE(frame.frameStyle(), int(QFrame::Box));
+}
+
+static void provideFrameData()
+{
+ QTest::addColumn<QString>("basename");
+ QTest::addColumn<int>("lineWidth");
+ QTest::addColumn<int>("midLineWidth");
+ QTest::addColumn<QFrame::Shape>("shape");
+ QTest::addColumn<QFrame::Shadow>("shadow");
+
+ for (int lineWidth = 0; lineWidth < 3; ++lineWidth) {
+ for (int midLineWidth = 0; midLineWidth < 3; ++midLineWidth) {
+ QTest::newRow(qPrintable(QStringLiteral("box_noshadow_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "box_noshadow" << lineWidth << midLineWidth << QFrame::Box << (QFrame::Shadow)0;
+ QTest::newRow(qPrintable(QStringLiteral("box_plain_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "box_plain" << lineWidth << midLineWidth << QFrame::Box << QFrame::Plain;
+ QTest::newRow(qPrintable(QStringLiteral("box_raised_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "box_raised" << lineWidth << midLineWidth << QFrame::Box << QFrame::Raised;
+ QTest::newRow(qPrintable(QStringLiteral("box_sunken_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "box_sunken" << lineWidth << midLineWidth << QFrame::Box << QFrame::Sunken;
+
+ QTest::newRow(qPrintable(QStringLiteral("winpanel_noshadow_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "winpanel_noshadow" << lineWidth << midLineWidth << QFrame::WinPanel << (QFrame::Shadow)0;
+ QTest::newRow(qPrintable(QStringLiteral("winpanel_plain_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "winpanel_plain" << lineWidth << midLineWidth << QFrame::WinPanel << QFrame::Plain;
+ QTest::newRow(qPrintable(QStringLiteral("winpanel_raised_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "winpanel_raised" << lineWidth << midLineWidth << QFrame::WinPanel << QFrame::Raised;
+ QTest::newRow(qPrintable(QStringLiteral("winpanel_sunken_%1_%2").arg(lineWidth).arg(midLineWidth)))
+ << "winpanel_sunken" << lineWidth << midLineWidth << QFrame::WinPanel << QFrame::Sunken;
+ }
+ }
+}
+
+class Frame : public QFrame
+{
+public:
+ using QFrame::initStyleOption;
+};
+
+void tst_QFrame::testInitStyleOption_data()
+{
+ provideFrameData();
+}
+
+void tst_QFrame::testInitStyleOption()
+{
+ QFETCH(QString, basename);
+ QFETCH(int, lineWidth);
+ QFETCH(int, midLineWidth);
+ QFETCH(QFrame::Shape, shape);
+ QFETCH(QFrame::Shadow, shadow);
+
+ Frame frame;
+ frame.setFrameStyle(shape | shadow);
+ frame.setLineWidth(lineWidth);
+ frame.setMidLineWidth(midLineWidth);
+ frame.resize(16, 16);
+
+ QStyleOptionFrame styleOption;
+ frame.initStyleOption(&styleOption);
+
+ switch (shape) {
+ case QFrame::Box:
+ case QFrame::Panel:
+ case QFrame::StyledPanel:
+ case QFrame::HLine:
+ case QFrame::VLine:
+ QCOMPARE(styleOption.lineWidth, lineWidth);
+ QCOMPARE(styleOption.midLineWidth, midLineWidth);
+ break;
+
+ case QFrame::NoFrame:
+ case QFrame::WinPanel:
+ QCOMPARE(styleOption.lineWidth, frame.frameWidth());
+ QCOMPARE(styleOption.midLineWidth, 0);
+ break;
+ }
+
+ QCOMPARE(styleOption.features, QStyleOptionFrame::None);
+ QCOMPARE(styleOption.frameShape, shape);
+ if (shadow == QFrame::Sunken)
+ QVERIFY(styleOption.state & QStyle::State_Sunken);
+ else if (shadow == QFrame::Raised)
+ QVERIFY(styleOption.state & QStyle::State_Raised);
+}
+
+QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT QPalette qt_fusionPalette();
+QT_END_NAMESPACE
+
+void tst_QFrame::testPainting_data()
+{
+ provideFrameData();
+}
+
+void tst_QFrame::testPainting()
+{
+ QFETCH(QString, basename);
+ QFETCH(int, lineWidth);
+ QFETCH(int, midLineWidth);
+ QFETCH(QFrame::Shape, shape);
+ QFETCH(QFrame::Shadow, shadow);
+
+ QFrame frame;
+ frame.setStyle(QStyleFactory::create(QStringLiteral("fusion")));
+ frame.setPalette(qt_fusionPalette());
+ frame.setFrameStyle(shape | shadow);
+ frame.setLineWidth(lineWidth);
+ frame.setMidLineWidth(midLineWidth);
+ frame.resize(16, 16);
+
+ const QPixmap pixmap = frame.grab();
+
+ const QString referenceFilePath = QFINDTESTDATA(QStringLiteral("images/%1_%2_%3.png").arg(basename).arg(lineWidth).arg(midLineWidth));
+ const QPixmap referencePixmap(referenceFilePath);
+ QVERIFY2(!referencePixmap.isNull(), qPrintable(QStringLiteral("Could not load reference pixmap %1").arg(referenceFilePath)));
+ QCOMPARE(pixmap, referencePixmap);
+}
+
+QTEST_MAIN(tst_QFrame)
+
+#include "tst_qframe.moc"
diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro
index 423b3952d4..0651583867 100644
--- a/tests/auto/widgets/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets/widgets.pro
@@ -16,6 +16,7 @@ SUBDIRS=\
qdoublespinbox \
qfocusframe \
qfontcombobox \
+ qframe \
qgroupbox \
qkeysequenceedit \
qlabel \
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp
index 20143b4ee1..80cf69b7fc 100644
--- a/tests/auto/xml/dom/qdom/tst_qdom.cpp
+++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp
@@ -718,6 +718,9 @@ void tst_QDom::ownerDocument()
OWNERDOCUMENT_IMPORTNODE_TEST( QDomEntityReference, doc2.createEntityReference( "foo" ) );
OWNERDOCUMENT_IMPORTNODE_TEST( QDomProcessingInstruction, doc2.createProcessingInstruction( "foo", "bar" ) );
OWNERDOCUMENT_IMPORTNODE_TEST( QDomText, doc2.createTextNode( "foo" ) );
+
+ // QTBUG-12927
+ QVERIFY(doc2.importNode(QDomNode(), deep).isNull());
}
}