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/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp32
-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.cpp80
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp106
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp443
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp10
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp29
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.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.cpp76
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp12
-rw-r--r--tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp53
-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.cpp79
-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/qsslsocket/tst_qsslsocket.cpp121
-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.cpp126
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp17
-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/qheaderview/tst_qheaderview.cpp36
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp84
-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/qabstractscrollarea/tst_qabstractscrollarea.cpp19
-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
125 files changed, 2451 insertions, 348 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/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 53ed1bc9a0..122427a021 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -96,6 +96,7 @@ private slots:
void changeSourceData_data();
void changeSourceData();
void changeSourceDataKeepsStableSorting_qtbug1548();
+ void changeSourceDataForwardsRoles_qtbug35440();
void sortFilterRole();
void selectionFilteredOut();
void match_data();
@@ -2084,6 +2085,37 @@ void tst_QSortFilterProxyModel::changeSourceDataKeepsStableSorting_qtbug1548()
checkSortedTableModel(&model, rows);
}
+void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440()
+{
+ QStringList strings;
+ for (int i = 0; i < 100; ++i)
+ strings << QString::number(i);
+
+ QStringListModel model(strings);
+
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ proxy.sort(0, Qt::AscendingOrder);
+
+ QSignalSpy spy(&proxy, &QAbstractItemModel::dataChanged);
+ QVERIFY(spy.isValid());
+ QCOMPARE(spy.length(), 0);
+
+ QModelIndex index;
+
+ index = model.index(0, 0);
+ QVERIFY(index.isValid());
+ model.setData(index, QStringLiteral("teststring"), Qt::DisplayRole);
+ QCOMPARE(spy.length(), 1);
+ QCOMPARE(spy.at(0).at(2).value<QVector<int> >(), QVector<int>() << Qt::DisplayRole);
+
+ index = model.index(1, 0);
+ QVERIFY(index.isValid());
+ model.setData(index, QStringLiteral("teststring2"), Qt::EditRole);
+ QCOMPARE(spy.length(), 2);
+ QCOMPARE(spy.at(1).at(2).value<QVector<int> >(), QVector<int>() << Qt::EditRole);
+}
+
void tst_QSortFilterProxyModel::sortFilterRole()
{
QStandardItemModel model;
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..df76dfc47f 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,8 @@ private slots:
void hasStdCppSet();
void isConstant();
void isFinal();
+ void gadget();
+ void readAndWriteWithLazyRegistration();
public:
enum EnumType { EnumType1 };
@@ -103,5 +106,82 @@ 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")));
+ }
+}
+
+struct CustomReadObject : QObject
+{
+ Q_OBJECT
+};
+
+struct CustomWriteObject : QObject
+{
+ Q_OBJECT
+};
+
+struct CustomWriteObjectChild : CustomWriteObject
+{
+ Q_OBJECT
+};
+
+struct TypeLazyRegistration : QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(CustomReadObject *read MEMBER _read)
+ Q_PROPERTY(CustomWriteObject *write MEMBER _write)
+
+ CustomReadObject *_read;
+ CustomWriteObject *_write;
+
+public:
+ TypeLazyRegistration()
+ : _read()
+ , _write()
+ {}
+};
+
+void tst_QMetaProperty::readAndWriteWithLazyRegistration()
+{
+ QCOMPARE(QMetaType::type("CustomReadObject*"), int(QMetaType::UnknownType));
+ QCOMPARE(QMetaType::type("CustomWriteObject*"), int(QMetaType::UnknownType));
+
+ TypeLazyRegistration o;
+ QVERIFY(o.property("read").isValid());
+ QVERIFY(QMetaType::type("CustomReadObject*") != QMetaType::UnknownType);
+ QCOMPARE(QMetaType::type("CustomWriteObject*"), int(QMetaType::UnknownType));
+
+ CustomWriteObjectChild data;
+ QVariant value = QVariant::fromValue(&data); // this register CustomWriteObjectChild
+ // check if base classes are not registered automatically, otherwise this test would be meaningless
+ QCOMPARE(QMetaType::type("CustomWriteObject*"), int(QMetaType::UnknownType));
+ QVERIFY(o.setProperty("write", value));
+ QVERIFY(QMetaType::type("CustomWriteObject*") != QMetaType::UnknownType);
+ QCOMPARE(o.property("write").value<CustomWriteObjectChild*>(), &data);
+}
+
+
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..757576c6da 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>
@@ -169,8 +170,9 @@ private slots:
void operator_eq_eq_data();
void operator_eq_eq();
-
void operator_eq_eq_rhs();
+ void compareNumbers_data() const;
+ void compareNumbers() const;
void typeName_data();
void typeName();
@@ -213,7 +215,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 +990,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 +1016,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 +1372,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 +1438,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 );
@@ -1580,6 +1592,326 @@ void tst_QVariant::operator_eq_eq_rhs()
#endif
}
+void tst_QVariant::compareNumbers_data() const
+{
+ typedef signed char schar;
+ QTest::addColumn<QVariant>("v1");
+ QTest::addColumn<QVariant>("v2");
+ QTest::addColumn<int>("expected");
+
+ // sanity checking: same types
+ QTest::newRow("bool1") << QVariant(false) << QVariant(false) << 0;
+ QTest::newRow("bool2") << QVariant(true) << QVariant(true) << 0;
+ QTest::newRow("bool3") << QVariant(false) << QVariant(true) << -1;
+ QTest::newRow("bool4") << QVariant(true) << QVariant(false) << +1;
+
+ QTest::newRow("char1") << qVariantFromValue(char(0)) << qVariantFromValue(char(0)) << 0;
+ QTest::newRow("char2") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(CHAR_MAX) << 0;
+ QTest::newRow("char3") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(CHAR_MIN) << 0;
+ QTest::newRow("char4") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(CHAR_MAX) << -1;
+ QTest::newRow("char5") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(CHAR_MIN) << +1;
+
+ QTest::newRow("schar1") << qVariantFromValue(schar(0)) << qVariantFromValue(schar(0)) << 0;
+ QTest::newRow("schar2") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(SCHAR_MAX) << 0;
+ QTest::newRow("schar3") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(SCHAR_MIN) << 0;
+ QTest::newRow("schar4") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(SCHAR_MAX) << -1;
+ QTest::newRow("schar5") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(SCHAR_MIN) << +1;
+
+ QTest::newRow("uchar1") << qVariantFromValue(uchar(0)) << qVariantFromValue(uchar(0)) << 0;
+ QTest::newRow("uchar2") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(UCHAR_MAX) << 0;
+ QTest::newRow("uchar3") << qVariantFromValue(uchar(0)) << qVariantFromValue(UCHAR_MAX) << -1;
+ QTest::newRow("uchar4") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(uchar(0)) << +1;
+
+ QTest::newRow("short1") << qVariantFromValue(short(0)) << qVariantFromValue(short(0)) << 0;
+ QTest::newRow("short2") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(SHRT_MAX) << 0;
+ QTest::newRow("short3") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(SHRT_MIN) << 0;
+ QTest::newRow("short4") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(SHRT_MAX) << -1;
+ QTest::newRow("short5") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(SHRT_MIN) << +1;
+
+ QTest::newRow("ushort1") << qVariantFromValue(ushort(0)) << qVariantFromValue(ushort(0)) << 0;
+ QTest::newRow("ushort2") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(USHRT_MAX) << 0;
+ QTest::newRow("ushort3") << qVariantFromValue(ushort(0)) << qVariantFromValue(USHRT_MAX) << -1;
+ QTest::newRow("ushort4") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(ushort(0)) << +1;
+
+ QTest::newRow("int1") << qVariantFromValue(int(0)) << qVariantFromValue(int(0)) << 0;
+ QTest::newRow("int2") << qVariantFromValue(INT_MAX) << qVariantFromValue(INT_MAX) << 0;
+ QTest::newRow("int3") << qVariantFromValue(INT_MIN) << qVariantFromValue(INT_MIN) << 0;
+ QTest::newRow("int4") << qVariantFromValue(INT_MIN) << qVariantFromValue(INT_MAX) << -1;
+ QTest::newRow("int5") << qVariantFromValue(INT_MAX) << qVariantFromValue(INT_MIN) << +1;
+
+ QTest::newRow("uint1") << qVariantFromValue(uint(0)) << qVariantFromValue(uint(0)) << 0;
+ QTest::newRow("uint2") << qVariantFromValue(UINT_MAX) << qVariantFromValue(UINT_MAX) << 0;
+ QTest::newRow("uint3") << qVariantFromValue(uint(0)) << qVariantFromValue(UINT_MAX) << -1;
+ QTest::newRow("uint4") << qVariantFromValue(UINT_MAX) << qVariantFromValue(uint(0)) << +1;
+
+ QTest::newRow("long1") << qVariantFromValue(long(0)) << qVariantFromValue(long(0)) << 0;
+ QTest::newRow("long2") << qVariantFromValue(LONG_MAX) << qVariantFromValue(LONG_MAX) << 0;
+ QTest::newRow("long3") << qVariantFromValue(LONG_MIN) << qVariantFromValue(LONG_MIN) << 0;
+ QTest::newRow("long4") << qVariantFromValue(LONG_MIN) << qVariantFromValue(LONG_MAX) << -1;
+ QTest::newRow("long5") << qVariantFromValue(LONG_MAX) << qVariantFromValue(LONG_MIN) << +1;
+
+ QTest::newRow("ulong1") << qVariantFromValue(ulong(0)) << qVariantFromValue(ulong(0)) << 0;
+ QTest::newRow("ulong2") << qVariantFromValue(ULONG_MAX) << qVariantFromValue(ULONG_MAX) << 0;
+ QTest::newRow("ulong3") << qVariantFromValue(ulong(0)) << qVariantFromValue(ULONG_MAX) << -1;
+ QTest::newRow("ulong4") << qVariantFromValue(ULONG_MAX) << qVariantFromValue(ulong(0)) << +1;
+
+ QTest::newRow("llong1") << qVariantFromValue(qlonglong(0)) << qVariantFromValue(qlonglong(0)) << 0;
+ QTest::newRow("llong2") << qVariantFromValue(LLONG_MAX) << qVariantFromValue(LLONG_MAX) << 0;
+ QTest::newRow("llong3") << qVariantFromValue(LLONG_MIN) << qVariantFromValue(LLONG_MIN) << 0;
+ QTest::newRow("llong4") << qVariantFromValue(LLONG_MIN) << qVariantFromValue(LLONG_MAX) << -1;
+ QTest::newRow("llong5") << qVariantFromValue(LLONG_MAX) << qVariantFromValue(LLONG_MIN) << +1;
+
+ QTest::newRow("ullong1") << qVariantFromValue(qulonglong(0)) << qVariantFromValue(qulonglong(0)) << 0;
+ QTest::newRow("ullong2") << qVariantFromValue(ULLONG_MAX) << qVariantFromValue(ULLONG_MAX) << 0;
+ QTest::newRow("ullong3") << qVariantFromValue(qulonglong(0)) << qVariantFromValue(ULLONG_MAX) << -1;
+ QTest::newRow("ullong4") << qVariantFromValue(ULLONG_MAX) << qVariantFromValue(qulonglong(0)) << +1;
+
+ QTest::newRow("float1") << qVariantFromValue(0.f) << qVariantFromValue(0.f) << 0;
+ QTest::newRow("float2") << qVariantFromValue(-1.f) << qVariantFromValue(0.f) << -1;
+ QTest::newRow("float3") << qVariantFromValue(0.f) << qVariantFromValue(-1.f) << +1;
+ QTest::newRow("float4") << qVariantFromValue(-float(qInf())) << qVariantFromValue(0.f) << -1;
+ QTest::newRow("float5") << qVariantFromValue(0.f) << qVariantFromValue(-float(qInf())) << +1;
+
+ QTest::newRow("double1") << qVariantFromValue(0.) << qVariantFromValue(0.) << 0;
+ QTest::newRow("double2") << qVariantFromValue(-1.) << qVariantFromValue(0.) << -1;
+ QTest::newRow("double3") << qVariantFromValue(0.) << qVariantFromValue(-1.) << +1;
+ QTest::newRow("double4") << qVariantFromValue(-qInf()) << qVariantFromValue(0.) << -1;
+ QTest::newRow("double5") << qVariantFromValue(0.) << qVariantFromValue(-qInf()) << +1;
+
+ // mixed comparisons
+ // fp + fp
+ QTest::newRow("float+double1") << qVariantFromValue(0.f) << qVariantFromValue(0.) << 0;
+ QTest::newRow("float+double2") << qVariantFromValue(-1.f) << qVariantFromValue(0.) << -1;
+ QTest::newRow("float+double3") << qVariantFromValue(0.f) << qVariantFromValue(-1.) << +1;
+ QTest::newRow("float+double4") << qVariantFromValue(-float(qInf())) << qVariantFromValue(0.) << -1;
+ QTest::newRow("float+double5") << qVariantFromValue(0.f) << qVariantFromValue(-qInf()) << +1;
+
+ // fp + int
+ QTest::newRow("float+int1") << qVariantFromValue(0.f) << qVariantFromValue(0) << 0;
+ QTest::newRow("double+int1") << qVariantFromValue(0.) << qVariantFromValue(0) << 0;
+ QTest::newRow("float+int2") << qVariantFromValue(-1.f) << qVariantFromValue(0) << -1;
+ QTest::newRow("double+int2") << qVariantFromValue(-1.) << qVariantFromValue(0) << -1;
+ QTest::newRow("float+int3") << qVariantFromValue(0.f) << qVariantFromValue(-1) << +1;
+ QTest::newRow("double+int3") << qVariantFromValue(0.) << qVariantFromValue(-1) << +1;
+ QTest::newRow("float+int4") << qVariantFromValue(1.5f) << qVariantFromValue(1) << +1;
+ QTest::newRow("double+int4") << qVariantFromValue(1.5) << qVariantFromValue(1) << +1;
+
+ // fp + uint
+ QTest::newRow("float+uint1") << qVariantFromValue(0.f) << qVariantFromValue(0U) << 0;
+ QTest::newRow("double+uint1") << qVariantFromValue(0.) << qVariantFromValue(0U) << 0;
+ QTest::newRow("float+uint2") << qVariantFromValue(-1.f) << qVariantFromValue(0U) << -1;
+ QTest::newRow("double+uint2") << qVariantFromValue(-1.) << qVariantFromValue(0U) << -1;
+ QTest::newRow("float+uint3") << qVariantFromValue(0.f) << qVariantFromValue(1U) << -1;
+ QTest::newRow("double+uint3") << qVariantFromValue(0.) << qVariantFromValue(1U) << -1;
+ QTest::newRow("float+uint4") << qVariantFromValue(1.5f) << qVariantFromValue(1U) << +1;
+ QTest::newRow("double+uint4") << qVariantFromValue(1.5) << qVariantFromValue(1U) << +1;
+
+ // lower ranked + int
+ QTest::newRow("bool+int1") << qVariantFromValue(false) << qVariantFromValue(0) << 0;
+ QTest::newRow("bool+int2") << qVariantFromValue(false) << qVariantFromValue(1) << -1;
+ QTest::newRow("bool+int3") << qVariantFromValue(true) << qVariantFromValue(0) << +1;
+ QTest::newRow("bool+int4") << qVariantFromValue(true) << qVariantFromValue(1) << 0;
+ QTest::newRow("bool+int5") << qVariantFromValue(true) << qVariantFromValue(2) << -1;
+
+ QTest::newRow("char+int1") << qVariantFromValue(char(0)) << qVariantFromValue(0) << 0;
+ QTest::newRow("char+int2") << qVariantFromValue(char(0)) << qVariantFromValue(1) << -1;
+ QTest::newRow("char+int3") << qVariantFromValue(char(1)) << qVariantFromValue(0) << +1;
+ QTest::newRow("char+int4") << qVariantFromValue(char(1)) << qVariantFromValue(1) << 0;
+ if (std::numeric_limits<char>::is_signed) {
+ QTest::newRow("char+int5") << qVariantFromValue(char(-1)) << qVariantFromValue(0) << -1;
+ QTest::newRow("char+int6") << qVariantFromValue(char(-1)) << qVariantFromValue(-1) << 0;
+ }
+
+ QTest::newRow("schar+int1") << qVariantFromValue(schar(0)) << qVariantFromValue(0) << 0;
+ QTest::newRow("schar+int2") << qVariantFromValue(schar(0)) << qVariantFromValue(1) << -1;
+ QTest::newRow("schar+int3") << qVariantFromValue(schar(1)) << qVariantFromValue(0) << +1;
+ QTest::newRow("schar+int4") << qVariantFromValue(schar(1)) << qVariantFromValue(1) << 0;
+ QTest::newRow("schar+int5") << qVariantFromValue(schar(-1)) << qVariantFromValue(0) << -1;
+ QTest::newRow("schar+int6") << qVariantFromValue(schar(-1)) << qVariantFromValue(-1) << 0;
+
+ QTest::newRow("uchar+int1") << qVariantFromValue(uchar(0)) << qVariantFromValue(0) << 0;
+ QTest::newRow("uchar+int2") << qVariantFromValue(uchar(0)) << qVariantFromValue(1) << -1;
+ QTest::newRow("uchar+int3") << qVariantFromValue(uchar(1)) << qVariantFromValue(0) << +1;
+ QTest::newRow("uchar+int4") << qVariantFromValue(uchar(1)) << qVariantFromValue(1) << 0;
+
+ QTest::newRow("short+int1") << qVariantFromValue(short(0)) << qVariantFromValue(0) << 0;
+ QTest::newRow("short+int2") << qVariantFromValue(short(0)) << qVariantFromValue(1) << -1;
+ QTest::newRow("short+int3") << qVariantFromValue(short(1)) << qVariantFromValue(0) << +1;
+ QTest::newRow("short+int4") << qVariantFromValue(short(1)) << qVariantFromValue(1) << 0;
+ QTest::newRow("short+int5") << qVariantFromValue(short(-1)) << qVariantFromValue(0) << -1;
+ QTest::newRow("short+int6") << qVariantFromValue(short(-1)) << qVariantFromValue(-1) << 0;
+
+ QTest::newRow("ushort+int1") << qVariantFromValue(ushort(0)) << qVariantFromValue(0) << 0;
+ QTest::newRow("ushort+int2") << qVariantFromValue(ushort(0)) << qVariantFromValue(1) << -1;
+ QTest::newRow("ushort+int3") << qVariantFromValue(ushort(1)) << qVariantFromValue(0) << +1;
+ QTest::newRow("ushort+int4") << qVariantFromValue(ushort(1)) << qVariantFromValue(1) << 0;
+
+ // lower ranked + uint (without sign change)
+ QTest::newRow("bool+uint1") << qVariantFromValue(false) << qVariantFromValue(0U) << 0;
+ QTest::newRow("bool+uint2") << qVariantFromValue(false) << qVariantFromValue(1U) << -1;
+ QTest::newRow("bool+uint3") << qVariantFromValue(true) << qVariantFromValue(0U) << +1;
+ QTest::newRow("bool+uint4") << qVariantFromValue(true) << qVariantFromValue(1U) << 0;
+ QTest::newRow("bool+uint5") << qVariantFromValue(true) << qVariantFromValue(2U) << -1;
+
+ QTest::newRow("char+uint1") << qVariantFromValue(char(0)) << qVariantFromValue(0U) << 0;
+ QTest::newRow("char+uint2") << qVariantFromValue(char(0)) << qVariantFromValue(1U) << -1;
+ QTest::newRow("char+uint3") << qVariantFromValue(char(1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("char+uint4") << qVariantFromValue(char(1)) << qVariantFromValue(1U) << 0;
+
+ QTest::newRow("schar+uint1") << qVariantFromValue(schar(0)) << qVariantFromValue(0U) << 0;
+ QTest::newRow("schar+uint2") << qVariantFromValue(schar(0)) << qVariantFromValue(1U) << -1;
+ QTest::newRow("schar+uint3") << qVariantFromValue(schar(1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("schar+uint4") << qVariantFromValue(schar(1)) << qVariantFromValue(1U) << 0;
+
+ QTest::newRow("uchar+uint1") << qVariantFromValue(uchar(0)) << qVariantFromValue(0U) << 0;
+ QTest::newRow("uchar+uint2") << qVariantFromValue(uchar(0)) << qVariantFromValue(1U) << -1;
+ QTest::newRow("uchar+uint3") << qVariantFromValue(uchar(1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("uchar+uint4") << qVariantFromValue(uchar(1)) << qVariantFromValue(1U) << 0;
+
+ QTest::newRow("short+uint1") << qVariantFromValue(short(0)) << qVariantFromValue(0U) << 0;
+ QTest::newRow("short+uint2") << qVariantFromValue(short(0)) << qVariantFromValue(1U) << -1;
+ QTest::newRow("short+uint3") << qVariantFromValue(short(1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("short+uint4") << qVariantFromValue(short(1)) << qVariantFromValue(1U) << 0;
+
+ QTest::newRow("ushort+uint1") << qVariantFromValue(ushort(0)) << qVariantFromValue(0U) << 0;
+ QTest::newRow("ushort+uint2") << qVariantFromValue(ushort(0)) << qVariantFromValue(1U) << -1;
+ QTest::newRow("ushort+uint3") << qVariantFromValue(ushort(1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("ushort+uint4") << qVariantFromValue(ushort(1)) << qVariantFromValue(1U) << 0;
+
+ // int + qlonglong
+ QTest::newRow("int+qlonglong1") << qVariantFromValue(0) << qVariantFromValue(Q_INT64_C(0)) << 0;
+ QTest::newRow("int+qlonglong2") << qVariantFromValue(1) << qVariantFromValue(Q_INT64_C(0)) << +1;
+ QTest::newRow("int+qlonglong3") << qVariantFromValue(0) << qVariantFromValue(Q_INT64_C(1)) << -1;
+ QTest::newRow("int+qlonglong4") << qVariantFromValue(1) << qVariantFromValue(Q_INT64_C(1)) << 0;
+ QTest::newRow("int+qlonglong5") << qVariantFromValue(0) << qVariantFromValue(Q_INT64_C(-1)) << +1;
+ QTest::newRow("int+qlonglong6") << qVariantFromValue(-1) << qVariantFromValue(Q_INT64_C(0)) << -1;
+ QTest::newRow("int+qlonglong7") << qVariantFromValue(-1) << qVariantFromValue(Q_INT64_C(-1)) << 0;
+
+ // uint + qulonglong
+ QTest::newRow("uint+qulonglong1") << qVariantFromValue(0U) << qVariantFromValue(Q_UINT64_C(0)) << 0;
+ QTest::newRow("uint+qulonglong2") << qVariantFromValue(1U) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("uint+qulonglong3") << qVariantFromValue(0U) << qVariantFromValue(Q_UINT64_C(1)) << -1;
+ QTest::newRow("uint+qulonglong4") << qVariantFromValue(1U) << qVariantFromValue(Q_UINT64_C(1)) << 0;
+
+ // int + uint (without sign change)
+ QTest::newRow("int+uint1") << qVariantFromValue(0) << qVariantFromValue(0U) << 0;
+ QTest::newRow("int+uint2") << qVariantFromValue(1) << qVariantFromValue(0U) << +1;
+ QTest::newRow("int+uint3") << qVariantFromValue(0) << qVariantFromValue(1U) << -1;
+ QTest::newRow("int+uint4") << qVariantFromValue(1) << qVariantFromValue(1U) << 0;
+
+ // uint + qlonglong
+ QTest::newRow("uint+qlonglong1") << qVariantFromValue(0U) << qVariantFromValue(Q_INT64_C(0)) << 0;
+ QTest::newRow("uint+qlonglong2") << qVariantFromValue(1U) << qVariantFromValue(Q_INT64_C(0)) << +1;
+ QTest::newRow("uint+qlonglong3") << qVariantFromValue(0U) << qVariantFromValue(Q_INT64_C(1)) << -1;
+ QTest::newRow("uint+qlonglong4") << qVariantFromValue(1U) << qVariantFromValue(Q_INT64_C(1)) << 0;
+ QTest::newRow("uint+qlonglong5") << qVariantFromValue(0U) << qVariantFromValue(Q_INT64_C(-1)) << +1;
+
+ // boundary conditions
+ QTest::newRow("charmax+intmax") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(INT_MAX) << -1;
+ QTest::newRow("charmax+uintmax") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(UINT_MAX) << -1;
+ QTest::newRow("scharmax+intmax") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(INT_MAX) << -1;
+ QTest::newRow("scharmax+uintmax") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(UINT_MAX) << -1;
+ QTest::newRow("ucharmax+intmax") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(INT_MAX) << -1;
+ QTest::newRow("ucharmax+uintmax") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(UINT_MAX) << -1;
+ QTest::newRow("shortmax+intmax") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(INT_MAX) << -1;
+ QTest::newRow("shortmax+uintmax") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(UINT_MAX) << -1;
+ QTest::newRow("ushortmax+intmax") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(INT_MAX) << -1;
+ QTest::newRow("ushortmax+uintmax") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(UINT_MAX) << -1;
+
+ QTest::newRow("intmin+qlonglongmin") << qVariantFromValue(INT_MIN) << qVariantFromValue(LLONG_MIN) << +1;
+ QTest::newRow("intmax+uintmax") << qVariantFromValue(INT_MAX) << qVariantFromValue(UINT_MAX) << -1;
+ QTest::newRow("intmax+qlonglongmax") << qVariantFromValue(INT_MAX) << qVariantFromValue(LLONG_MAX) << -1;
+ QTest::newRow("uintmax+qlonglongmax") << qVariantFromValue(UINT_MAX) << qVariantFromValue(LLONG_MAX) << -1;
+ QTest::newRow("intmax+qulonglongmax") << qVariantFromValue(INT_MAX) << qVariantFromValue(ULLONG_MAX) << -1;
+ QTest::newRow("qlonglongmax+qulonglongmax") << qVariantFromValue(LLONG_MAX) << qVariantFromValue(ULLONG_MAX) << -1;
+ QTest::newRow("uintmax+qlonglongmin") << qVariantFromValue(UINT_MAX) << qVariantFromValue(LLONG_MIN) << +1;
+
+ // check for no sign-extension issues
+ QTest::newRow("ushortmax+intzero") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(0) << +1;
+ QTest::newRow("ushortmax+qlonglongzero") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(Q_INT64_C(0)) << +1;
+ QTest::newRow("uintmax+qlonglongzero") << qVariantFromValue(UINT_MAX) << qVariantFromValue(Q_INT64_C(0)) << +1;
+
+ // sign changes
+ // the tests below check that a signed negative number sign-changes to a non-zero unsigned number and that
+ // signed -1 sign-changes to unsigned maximum (all bits set, ~0). This works on two's complement machines
+ // (all that Qt supports), and would also work on one's complement.
+ if (std::numeric_limits<char>::is_signed) {
+ QTest::newRow("signchange-char+uint") << qVariantFromValue(char(-1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-char+uintmax") << qVariantFromValue(char(-1)) << qVariantFromValue(UINT_MAX) << 0;
+ QTest::newRow("signchange-charmin+uint") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-char+qulonglong") << qVariantFromValue(char(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-char+qulonglongmax") << qVariantFromValue(char(-1)) << qVariantFromValue(ULLONG_MAX) << 0;
+ QTest::newRow("signchange-charmin+qulonglong") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ }
+ QTest::newRow("signchange-schar+uint") << qVariantFromValue(schar(-1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-schar+uintmax") << qVariantFromValue(schar(-1)) << qVariantFromValue(UINT_MAX) << 0;
+ QTest::newRow("signchange-scharmin+uint") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-schar+qulonglong") << qVariantFromValue(schar(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-schar+qulonglongmax") << qVariantFromValue(schar(-1)) << qVariantFromValue(ULLONG_MAX) << 0;
+ QTest::newRow("signchange-scharmin+qulonglong") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-short+uint") << qVariantFromValue(short(-1)) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-short+uintmax") << qVariantFromValue(short(-1)) << qVariantFromValue(UINT_MAX) << 0;
+ QTest::newRow("signchange-shortmin+uint") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-short+qulonglong") << qVariantFromValue(short(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-short+qulonglongmax") << qVariantFromValue(short(-1)) << qVariantFromValue(ULLONG_MAX) << 0;
+ QTest::newRow("signchange-shortmin+qulonglong") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-int+uint") << qVariantFromValue(-1) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-int+uintmax") << qVariantFromValue(-1) << qVariantFromValue(UINT_MAX) << 0;
+ QTest::newRow("signchange-intmin+uint") << qVariantFromValue(INT_MIN) << qVariantFromValue(0U) << +1;
+ QTest::newRow("signchange-int+qulonglong") << qVariantFromValue(-1) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-int+qulonglongmax") << qVariantFromValue(-1) << qVariantFromValue(ULLONG_MAX) << 0;
+ QTest::newRow("signchange-intmin+qulonglong") << qVariantFromValue(INT_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ // no qlonglong+uint, since that should promote to qlonglong and then the comparison is signed (tested above)
+ QTest::newRow("signchange-qlonglong+qulonglong") << qVariantFromValue(Q_INT64_C(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+ QTest::newRow("signchange-qlonglong+qulonglongmax") << qVariantFromValue(Q_INT64_C(-1)) << qVariantFromValue(ULLONG_MAX) << 0;
+ QTest::newRow("signchange-qlonglongmin+qulonglong") << qVariantFromValue(LLONG_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1;
+}
+
+void tst_QVariant::compareNumbers() const
+{
+ QFETCH(QVariant, v1);
+ QFETCH(QVariant, v2);
+ QFETCH(int, expected);
+
+ if (expected == -1) {
+ QVERIFY(v1 < v2);
+ QVERIFY(v1 <= v2);
+ QVERIFY(!(v1 == v2));
+ QVERIFY(!(v1 > v2));
+ QVERIFY(!(v1 >= v2));
+
+ QVERIFY(!(v2 < v1));
+ QVERIFY(!(v2 <= v1));
+ QVERIFY(!(v2 == v1));
+ QVERIFY(v2 >= v1);
+ QVERIFY(v2 > v1);
+ } else if (expected == 0) {
+ QVERIFY(!(v1 < v2));
+ QVERIFY(v1 <= v2);
+ QCOMPARE(v1, v2);
+ QVERIFY(!(v1 > v2));
+ QVERIFY(v1 >= v2);
+
+ QVERIFY(!(v2 < v1));
+ QVERIFY(v2 <= v1);
+ QCOMPARE(v2, v1);
+ QVERIFY(v2 >= v1);
+ QVERIFY(!(v2 > v1));
+ } else {
+ QVERIFY(!(v1 < v2));
+ QVERIFY(!(v1 <= v2));
+ QVERIFY(!(v1 == v2));
+ QVERIFY(v1 > v2);
+ QVERIFY(v1 >= v2);
+
+ QVERIFY(v2 < v1);
+ QVERIFY(v2 <= v1);
+ QVERIFY(!(v2 == v1));
+ QVERIFY(!(v2 >= v1));
+ QVERIFY(!(v2 > v1));
+ }
+}
+
void tst_QVariant::typeName_data()
{
QTest::addColumn<int>("type");
@@ -2945,41 +3277,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 +3577,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/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
index 425a07b3a7..605a1525e3 100644
--- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
+++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
@@ -94,13 +94,9 @@
# define QATOMIC_TEST_NOT_SUPPORTED
#endif
-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
-# pragma GCC diagnostic ignored "-Wtype-limits"
-# pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
-# pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
-#endif
+QT_WARNING_DISABLE_GCC("-Wtype-limits")
+QT_WARNING_DISABLE_GCC("-Wsign-compare")
+QT_WARNING_DISABLE_CLANG("-Wtautological-constant-out-of-range-compare")
typedef signed char schar;
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/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index a4350ea2fe..55c911a5fc 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -47,6 +47,8 @@ public slots:
void init();
void cleanup();
private slots:
+ void operators_data();
+ void operators();
void toUpper();
void toLower();
void toTitle();
@@ -99,6 +101,33 @@ void tst_QChar::cleanup()
#endif
}
+void tst_QChar::operators_data()
+{
+ QTest::addColumn<QChar>("lhs");
+ QTest::addColumn<QChar>("rhs");
+
+ for (int i = 0; i < 3; ++i) {
+ for (int j = 0; j < 3; ++j)
+ QTest::newRow(qPrintable(QString().sprintf("'\\%d' (op) '\\%d'", i, j)))
+ << QChar(ushort(i)) << QChar(ushort(j));
+ }
+}
+
+void tst_QChar::operators()
+{
+ QFETCH(QChar, lhs);
+ QFETCH(QChar, rhs);
+
+#define CHECK(op) QCOMPARE((lhs op rhs), (lhs.unicode() op rhs.unicode()))
+ CHECK(==);
+ CHECK(!=);
+ CHECK(< );
+ CHECK(> );
+ CHECK(<=);
+ CHECK(>=);
+#undef CHECK
+}
+
void tst_QChar::toUpper()
{
QVERIFY(QChar('a').toUpper() == 'A');
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..ed72b58d6e 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();
@@ -812,10 +813,8 @@ void tst_QString::acc_01()
}
}
-#ifdef Q_CC_GNU
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wformat-security"
-#endif
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wformat-security")
void tst_QString::isNull()
{
@@ -827,9 +826,7 @@ void tst_QString::isNull()
QVERIFY(!a.isNull());
}
-#ifdef Q_CC_GNU
-# pragma GCC diagnostic pop
-#endif
+QT_WARNING_POP
void tst_QString::isEmpty()
{
@@ -1182,6 +1179,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 +1299,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 +1402,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 +1437,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 +1880,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 +1941,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 +2063,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 +2114,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 +4508,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/dbus/qdbusmetatype/tst_qdbusmetatype.cpp b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
index fc20b47768..f80a969384 100644
--- a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
+++ b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
@@ -69,6 +69,19 @@ struct Struct4 // (ssa(ss)sayasx)
QStringList m6;
qlonglong m7;
};
+struct Struct5 // a{sa{sv}} - non-standard outer struct is used as a local
+{ // container, see marshalling operator below.
+ QVariantMap m1;
+ QVariantMap m2;
+ QVariantMap m3;
+};
+struct Struct6 // av - non-standard outer struct is used as a local container,
+{ // see marshalling operator below.
+ QVariant v1;
+ QVariant v2;
+ QVariant v3;
+};
+
struct Invalid0 { }; // empty
struct Invalid1 { }; // s
@@ -84,6 +97,8 @@ Q_DECLARE_METATYPE(Struct2)
Q_DECLARE_METATYPE(Struct3)
Q_DECLARE_METATYPE(Struct4)
Q_DECLARE_METATYPE(StringPair)
+Q_DECLARE_METATYPE(Struct5)
+Q_DECLARE_METATYPE(Struct6)
Q_DECLARE_METATYPE(Invalid0)
Q_DECLARE_METATYPE(Invalid1)
@@ -141,6 +156,34 @@ QDBusArgument &operator<<(QDBusArgument &arg, const Struct4 &s)
return arg;
}
+QDBusArgument &operator<<(QDBusArgument &arg, const Struct5 &s)
+{
+ arg.beginMap(qMetaTypeId<QString>(), qMetaTypeId<QVariantMap>());
+
+ arg.beginMapEntry();
+ arg << QStringLiteral("map1") << s.m1;
+ arg.endMapEntry();
+
+ arg.beginMapEntry();
+ arg << QStringLiteral("map2") << s.m2;
+ arg.endMapEntry();
+
+ arg.beginMapEntry();
+ arg << QStringLiteral("map3") << s.m3;
+ arg.endMapEntry();
+
+ arg.endMap();
+ return arg;
+}
+
+QDBusArgument &operator<<(QDBusArgument &arg, const Struct6 &s)
+{
+ arg.beginArray(qMetaTypeId<QDBusVariant>());
+ arg << QDBusVariant(s.v1) << QDBusVariant(s.v2) << QDBusVariant(s.v3);
+ arg.endArray();
+ return arg;
+}
+
QDBusArgument &operator<<(QDBusArgument &arg, const Invalid0 &)
{
return arg;
@@ -194,6 +237,10 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, Struct3 &)
{ return arg; }
const QDBusArgument &operator>>(const QDBusArgument &arg, Struct4 &)
{ return arg; }
+const QDBusArgument &operator>>(const QDBusArgument &arg, Struct5 &)
+{ return arg; }
+const QDBusArgument &operator>>(const QDBusArgument &arg, Struct6 &)
+{ return arg; }
const QDBusArgument &operator>>(const QDBusArgument &arg, StringPair &)
{ return arg; }
const QDBusArgument &operator>>(const QDBusArgument &arg, Invalid0 &)
@@ -220,6 +267,8 @@ void tst_QDBusMetaType::initTestCase()
qDBusRegisterMetaType<Struct2>();
qDBusRegisterMetaType<Struct3>();
qDBusRegisterMetaType<Struct4>();
+ qDBusRegisterMetaType<Struct5>();
+ qDBusRegisterMetaType<Struct6>();
qDBusRegisterMetaType<StringPair>();
qDBusRegisterMetaType<QList<Struct1> >();
@@ -297,6 +346,10 @@ void tst_QDBusMetaType::dynamicTypes_data()
QTest::newRow("Struct4") << QVariant::Type(qMetaTypeId<Struct4>()) << "(ssa(ss)sayasx)";
QTest::newRow("QList<Struct4>") << QVariant::Type(qMetaTypeId<QList<Struct4> >()) << "a(ssa(ss)sayasx)";
+ QTest::newRow("Struct5") << QVariant::Type(qMetaTypeId<Struct5>()) << "a{sa{sv}}";
+
+ QTest::newRow("Struct6") << QVariant::Type(qMetaTypeId<Struct6>()) << "av";
+
QTest::newRow("QMap<int,QString>") << QVariant::Type(intStringMap) << "a{is}";
QTest::newRow("QMap<QString,QString>") << QVariant::Type(stringStringMap) << "a{ss}";
QTest::newRow("QMap<QString,Struct1>") << QVariant::Type(stringStruct1Map) << "a{s(s)}";
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 f1c1012371..f6b8fbcab9 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 a5442968c6..12ca2bb68a 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();
@@ -161,10 +162,21 @@ 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();
- else if (event->type() == QEvent::Move)
+ break;
+
+ case QEvent::PlatformSurface:
+ m_surfaceventType = static_cast<QPlatformSurfaceEvent *>(event)->surfaceEventType();
+ break;
+
+ case QEvent::Move:
m_framePositionsOnMove << framePosition();
+ break;
+ default:
+ break;
+ }
return QWindow::event(event);
}
@@ -184,11 +196,17 @@ public:
return m_exposeRegion;
}
+ QPlatformSurfaceEvent::SurfaceEventType surfaceEventType() const
+ {
+ return m_surfaceventType;
+ }
+
QVector<QPoint> m_framePositionsOnMove;
private:
QHash<QEvent::Type, int> m_received;
QVector<QEvent::Type> m_order;
QRegion m_exposeRegion;
+ QPlatformSurfaceEvent::SurfaceEventType m_surfaceventType;
};
void tst_QWindow::eventOrderOnShow()
@@ -353,6 +371,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 3ccedf6248..7afffff00b 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/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index aa954429de..868a6119a8 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -47,21 +47,33 @@
#include <QAuthenticator>
#include "private/qhostinfo_p.h"
+#include "private/qiodevice_p.h" // for QIODEVICE_BUFFERSIZE
+
+#include "../../../network-settings.h"
+
#ifndef QT_NO_SSL
+#ifndef QT_NO_OPENSSL
#include "private/qsslsocket_openssl_p.h"
#include "private/qsslsocket_openssl_symbols_p.h"
-#include "private/qsslconfiguration_p.h"
#endif
+#include "private/qsslsocket_p.h"
+#include "private/qsslconfiguration_p.h"
-#include "../../../network-settings.h"
-
-#ifndef QT_NO_SSL
Q_DECLARE_METATYPE(QSslSocket::SslMode)
typedef QList<QSslError::SslError> SslErrorList;
Q_DECLARE_METATYPE(SslErrorList)
Q_DECLARE_METATYPE(QSslError)
Q_DECLARE_METATYPE(QSsl::SslProtocol)
+typedef QSharedPointer<QSslSocket> QSslSocketPtr;
+
+// Non-OpenSSL backends are not able to report a specific error code
+// for self-signed certificate for certificates.
+#ifndef QT_NO_OPENSSL
+#define FLUKE_CERTIFICATE_ERROR QSslError::SelfSignedCertificate
+#else
+#define FLUKE_CERTIFICATE_ERROR QSslError::CertificateUntrusted
#endif
+#endif // QT_NO_SSL
#if defined Q_OS_HPUX && defined Q_CC_GNU
// This error is delivered every time we try to use the fluke CA
@@ -69,10 +81,6 @@ Q_DECLARE_METATYPE(QSsl::SslProtocol)
#define QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
#endif
-#ifndef QT_NO_SSL
-typedef QSharedPointer<QSslSocket> QSslSocketPtr;
-#endif
-
class tst_QSslSocket : public QObject
{
Q_OBJECT
@@ -168,7 +176,6 @@ private slots:
void waitForMinusOne();
void verifyMode();
void verifyDepth();
- void peerVerifyError();
void disconnectFromHostWhenConnecting();
void disconnectFromHostWhenConnected();
void resetProxy();
@@ -546,37 +553,53 @@ void tst_QSslSocket::sslErrors_data()
{
QTest::addColumn<QString>("host");
QTest::addColumn<int>("port");
- QTest::addColumn<SslErrorList>("expected");
- QTest::newRow(qPrintable(QtNetworkSettings::serverLocalName()))
- << QtNetworkSettings::serverLocalName()
- << 993
- << (SslErrorList() << QSslError::HostNameMismatch
- << QSslError::SelfSignedCertificate);
+ QString name = QtNetworkSettings::serverLocalName();
+ QTest::newRow(qPrintable(name)) << name << 993;
+
+ name = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString();
+ QTest::newRow(qPrintable(name)) << name << 443;
}
void tst_QSslSocket::sslErrors()
{
QFETCH(QString, host);
QFETCH(int, port);
- QFETCH(SslErrorList, expected);
QSslSocketPtr socket = newSocket();
+ QSignalSpy sslErrorsSpy(socket.data(), SIGNAL(sslErrors(QList<QSslError>)));
+ QSignalSpy peerVerifyErrorSpy(socket.data(), SIGNAL(peerVerifyError(QSslError)));
+
socket->connectToHostEncrypted(host, port);
if (!socket->waitForConnected())
- QEXPECT_FAIL("imap.trolltech.com", "server not open to internet", Continue);
- socket->waitForEncrypted(5000);
+ QSKIP("Skipping flaky test - See QTBUG-29941");
+ socket->waitForEncrypted(10000);
- SslErrorList output;
- foreach (QSslError error, socket->sslErrors()) {
- output << error.error();
- }
+ // check the SSL errors contain HostNameMismatch and an error due to
+ // the certificate being self-signed
+ SslErrorList sslErrors;
+ foreach (const QSslError &err, socket->sslErrors())
+ sslErrors << err.error();
+ qSort(sslErrors);
+ QVERIFY(sslErrors.contains(QSslError::HostNameMismatch));
+ QVERIFY(sslErrors.contains(FLUKE_CERTIFICATE_ERROR));
-#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
- if (output.count() && output.last() == QSslError::CertificateUntrusted)
- output.takeLast();
-#endif
- QCOMPARE(output, expected);
+ // check the same errors were emitted by sslErrors
+ QVERIFY(!sslErrorsSpy.isEmpty());
+ SslErrorList emittedErrors;
+ foreach (const QSslError &err, qvariant_cast<QList<QSslError> >(sslErrorsSpy.first().first()))
+ emittedErrors << err.error();
+ qSort(emittedErrors);
+ QCOMPARE(sslErrors, emittedErrors);
+
+ // check the same errors were emitted by peerVerifyError
+ QVERIFY(!peerVerifyErrorSpy.isEmpty());
+ SslErrorList peerErrors;
+ const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy;
+ foreach (const QVariantList &args, peerVerifyList)
+ peerErrors << qvariant_cast<QSslError>(args.first()).error();
+ qSort(peerErrors);
+ QCOMPARE(sslErrors, peerErrors);
}
void tst_QSslSocket::addCaCertificate()
@@ -1950,7 +1973,7 @@ void tst_QSslSocket::verifyMode()
QSKIP("Skipping flaky test - See QTBUG-29941");
QList<QSslError> expectedErrors = QList<QSslError>()
- << QSslError(QSslError::SelfSignedCertificate, socket.peerCertificate());
+ << QSslError(FLUKE_CERTIFICATE_ERROR, socket.peerCertificate());
QCOMPARE(socket.sslErrors(), expectedErrors);
socket.abort();
@@ -1981,34 +2004,6 @@ void tst_QSslSocket::verifyDepth()
QCOMPARE(socket.peerVerifyDepth(), 1);
}
-void tst_QSslSocket::peerVerifyError()
-{
- QSslSocketPtr socket = newSocket();
- QSignalSpy sslErrorsSpy(socket.data(), SIGNAL(sslErrors(QList<QSslError>)));
- QSignalSpy peerVerifyErrorSpy(socket.data(), SIGNAL(peerVerifyError(QSslError)));
-
- socket->connectToHostEncrypted(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(), 443);
- if (socket->waitForEncrypted(10000))
- QSKIP("Skipping flaky test - See QTBUG-29941");
-
- // check HostNameMismatch was emitted by peerVerifyError
- QVERIFY(!peerVerifyErrorSpy.isEmpty());
- SslErrorList peerErrors;
- const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy;
- foreach (const QVariantList &args, peerVerifyList)
- peerErrors << qvariant_cast<QSslError>(args.first()).error();
- QVERIFY(peerErrors.contains(QSslError::HostNameMismatch));
-
- // check HostNameMismatch was emitted by sslErrors
- QVERIFY(!sslErrorsSpy.isEmpty());
- SslErrorList sslErrors;
- foreach (const QSslError &err, qvariant_cast<QList<QSslError> >(sslErrorsSpy.first().first()))
- sslErrors << err.error();
- QVERIFY(peerErrors.contains(QSslError::HostNameMismatch));
-
- QCOMPARE(sslErrors.size(), peerErrors.size());
-}
-
void tst_QSslSocket::disconnectFromHostWhenConnecting()
{
QSslSocketPtr socket = newSocket();
@@ -2105,8 +2100,8 @@ void tst_QSslSocket::ignoreSslErrorsList_data()
QList<QSslError> expectedSslErrors;
// fromPath gives us a list of certs, but it actually only contains one
QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
- QSslError rightError(QSslError::SelfSignedCertificate, certs.at(0));
- QSslError wrongError(QSslError::SelfSignedCertificate);
+ QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
+ QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
QTest::newRow("SSL-failure-empty-list") << expectedSslErrors << 1;
@@ -2368,8 +2363,8 @@ void tst_QSslSocket::resume_data()
QTest::newRow("ignoreAllErrors") << true << QList<QSslError>() << true;
QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
- QSslError rightError(QSslError::SelfSignedCertificate, certs.at(0));
- QSslError wrongError(QSslError::SelfSignedCertificate);
+ QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
+ QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
errorsList.append(wrongError);
QTest::newRow("ignoreSpecificErrors-Wrong") << true << errorsList << false;
errorsList.clear();
@@ -2757,8 +2752,10 @@ void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last,
QSslConfiguration emptyConf;
QSslConfiguration::setDefaultConfiguration(emptyConf);
- QSslSocketPtr socket = newSocket();
- connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
+ QSslSocketPtr client = newSocket();
+ socket = client.data();
+
+ connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
QFETCH_GLOBAL(bool, setProxy);
if (setProxy && socket->waitForEncrypted(4000))
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..d67b3e011a 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -572,6 +572,8 @@ private slots:
void relatedMetaObjectsInGadget();
void relatedMetaObjectsNameConflict_data();
void relatedMetaObjectsNameConflict();
+ void strignLiteralsInMacroExtension();
+ void veryLongStringData();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -1299,13 +1301,13 @@ public:
PrivatePropertyTest(QObject *parent = 0) : QObject(parent), mFoo(0), d (new MyDPointer) {}
int foo() { return mFoo ; }
void setFoo(int value) { mFoo = value; }
- MyDPointer *d_func() {return d;}
+ MyDPointer *d_func() {return d.data();}
signals:
void blub4Changed();
void blub5Changed(const QString &newBlub);
private:
int mFoo;
- MyDPointer *d;
+ QScopedPointer<MyDPointer> d;
};
@@ -1409,19 +1411,19 @@ void tst_Moc::constructors()
QCOMPARE(mo->indexOfConstructor("CtorTestClass2(QObject*)"), -1);
QCOMPARE(mo->indexOfConstructor("CtorTestClass(float,float)"), -1);
- QObject *o1 = mo->newInstance();
+ QScopedPointer<QObject> o1(mo->newInstance());
QVERIFY(o1 != 0);
QCOMPARE(o1->parent(), (QObject*)0);
- QVERIFY(qobject_cast<CtorTestClass*>(o1) != 0);
+ QVERIFY(qobject_cast<CtorTestClass*>(o1.data()) != 0);
- QObject *o2 = mo->newInstance(Q_ARG(QObject*, o1));
+ QObject *o2 = mo->newInstance(Q_ARG(QObject*, o1.data()));
QVERIFY(o2 != 0);
- QCOMPARE(o2->parent(), o1);
+ QCOMPARE(o2->parent(), o1.data());
QString str = QString::fromLatin1("hello");
- QObject *o3 = mo->newInstance(Q_ARG(QString, str));
+ QScopedPointer<QObject> o3(mo->newInstance(Q_ARG(QString, str)));
QVERIFY(o3 != 0);
- QCOMPARE(qobject_cast<CtorTestClass*>(o3)->m_str, str);
+ QCOMPARE(qobject_cast<CtorTestClass*>(o3.data())->m_str, str);
{
//explicit constructor
@@ -3269,6 +3271,114 @@ 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");
+}
+
+class VeryLongStringData : public QObject
+{
+ Q_OBJECT
+
+ #define repeat2(V) V V
+ #define repeat4(V) repeat2(V) repeat2(V)
+ #define repeat8(V) repeat4(V) repeat4(V)
+ #define repeat16(V) repeat8(V) repeat8(V)
+ #define repeat32(V) repeat16(V) repeat16(V)
+ #define repeat64(V) repeat32(V) repeat32(V)
+ #define repeat128(V) repeat64(V) repeat64(V)
+ #define repeat256(V) repeat128(V) repeat128(V)
+ #define repeat512(V) repeat256(V) repeat256(V)
+ #define repeat1024(V) repeat512(V) repeat512(V)
+ #define repeat2048(V) repeat1024(V) repeat1024(V)
+ #define repeat4096(V) repeat2048(V) repeat2048(V)
+ #define repeat8192(V) repeat4096(V) repeat4096(V)
+ #define repeat16384(V) repeat8192(V) repeat8192(V)
+ #define repeat32768(V) repeat16384(V) repeat16384(V)
+ #define repeat65534(V) repeat32768(V) repeat16384(V) repeat8192(V) repeat4096(V) repeat2048(V) repeat1024(V) repeat512(V) repeat256(V) repeat128(V) repeat64(V) repeat32(V) repeat16(V) repeat8(V) repeat4(V) repeat2(V)
+
+ Q_CLASSINFO(repeat65534("n"), repeat65534("i"))
+ Q_CLASSINFO(repeat65534("e"), repeat65534("r"))
+ Q_CLASSINFO(repeat32768("o"), repeat32768("b"))
+ Q_CLASSINFO(":", ")")
+
+ #undef repeat2
+ #undef repeat4
+ #undef repeat8
+ #undef repeat16
+ #undef repeat32
+ #undef repeat64
+ #undef repeat128
+ #undef repeat256
+ #undef repeat512
+ #undef repeat1024
+ #undef repeat2048
+ #undef repeat4096
+ #undef repeat8192
+ #undef repeat16384
+ #undef repeat32768
+ #undef repeat65534
+};
+
+void tst_Moc::veryLongStringData()
+{
+ const QMetaObject *mobj = &VeryLongStringData::staticMetaObject;
+ QCOMPARE(mobj->classInfoCount(), 4);
+
+ strlen(0);
+ QCOMPARE(mobj->classInfo(0).name()[0], 'n');
+ QCOMPARE(mobj->classInfo(0).value()[0], 'i');
+ QCOMPARE(mobj->classInfo(1).name()[0], 'e');
+ QCOMPARE(mobj->classInfo(1).value()[0], 'r');
+ QCOMPARE(mobj->classInfo(2).name()[0], 'o');
+ QCOMPARE(mobj->classInfo(2).value()[0], 'b');
+ QCOMPARE(mobj->classInfo(3).name()[0], ':');
+ QCOMPARE(mobj->classInfo(3).value()[0], ')');
+
+ QCOMPARE(strlen(mobj->classInfo(0).name()), static_cast<size_t>(65534));
+ QCOMPARE(strlen(mobj->classInfo(0).value()), static_cast<size_t>(65534));
+ QCOMPARE(strlen(mobj->classInfo(1).name()), static_cast<size_t>(65534));
+ QCOMPARE(strlen(mobj->classInfo(1).value()), static_cast<size_t>(65534));
+ QCOMPARE(strlen(mobj->classInfo(2).name()), static_cast<size_t>(32768));
+ QCOMPARE(strlen(mobj->classInfo(2).value()), static_cast<size_t>(32768));
+ QCOMPARE(strlen(mobj->classInfo(3).name()), static_cast<size_t>(1));
+ QCOMPARE(strlen(mobj->classInfo(3).value()), static_cast<size_t>(1));
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 3b55fcd5fc..7eb682075e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -1682,6 +1682,23 @@ void tst_QGraphicsGridLayout::sizeHint_data()
<< QSizeF(100, 100)
<< QSizeF(100, 100);
+ QTest::newRow("colSpan_with_ignored_column") << (ItemList()
+ << ItemDesc(0,0)
+ .minSize(QSizeF(40,20))
+ .maxSize(QSizeF(60,20))
+ .colSpan(2)
+ << ItemDesc(0,2)
+ .minSize(QSizeF(20, 20))
+ .maxSize(QSizeF(30, 20))
+ << ItemDesc(1,0)
+ .minSize(QSizeF(60, 20))
+ .maxSize(QSizeF(90, 20))
+ .colSpan(3)
+ )
+ << QSizeF(60, 40)
+ << QSizeF(80, 40)
+ << QSizeF(90, 40);
+
}
// public QSizeF sizeHint(Qt::SizeHint which, QSizeF const& constraint = QSizeF()) const
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 ff910ba359..f487e256a3 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -530,11 +530,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/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 408e98b873..eacf2e51fd 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -176,6 +176,7 @@ private slots:
void moveSectionAndRemove();
void saveRestore();
void defaultSectionSizeTest();
+ void defaultSectionSizeTestStyles();
void defaultAlignment_data();
void defaultAlignment();
@@ -1679,6 +1680,41 @@ void tst_QHeaderView::defaultSectionSizeTest()
QVERIFY(hv->sectionSize(2) == 0); // section is hidden. It should not be resized.
}
+class TestHeaderViewStyle : public QProxyStyle
+{
+public:
+ TestHeaderViewStyle() : horizontalSectionSize(100) {}
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE
+ {
+ if (metric == QStyle::PM_HeaderDefaultSectionSizeHorizontal)
+ return horizontalSectionSize;
+ else
+ return QProxyStyle::pixelMetric(metric, option, widget);
+ }
+ int horizontalSectionSize;
+};
+
+void tst_QHeaderView::defaultSectionSizeTestStyles()
+{
+ TestHeaderViewStyle style1;
+ TestHeaderViewStyle style2;
+ style1.horizontalSectionSize = 100;
+ style2.horizontalSectionSize = 200;
+
+ QHeaderView hv(Qt::Horizontal);
+ hv.setStyle(&style1);
+ QCOMPARE(hv.defaultSectionSize(), style1.horizontalSectionSize);
+ hv.setStyle(&style2);
+ QCOMPARE(hv.defaultSectionSize(), style2.horizontalSectionSize);
+ hv.setDefaultSectionSize(70);
+ QCOMPARE(hv.defaultSectionSize(), 70);
+ hv.setStyle(&style1);
+ QCOMPARE(hv.defaultSectionSize(), 70);
+ hv.resetDefaultSectionSize();
+ QCOMPARE(hv.defaultSectionSize(), style1.horizontalSectionSize);
+ hv.setStyle(&style2);
+ QCOMPARE(hv.defaultSectionSize(), style2.horizontalSectionSize);
+}
void tst_QHeaderView::defaultAlignment_data()
{
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index f000907e0e..f035094a37 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1084,7 +1084,6 @@ void tst_QItemDelegate::decoration()
void tst_QItemDelegate::editorEvent_data()
{
QTest::addColumn<QRect>("rect");
- QTest::addColumn<QString>("text");
QTest::addColumn<int>("checkState");
QTest::addColumn<int>("flags");
QTest::addColumn<bool>("inCheck");
@@ -1093,16 +1092,17 @@ void tst_QItemDelegate::editorEvent_data()
QTest::addColumn<bool>("edited");
QTest::addColumn<int>("expectedCheckState");
- QTest::newRow("unchecked, checkable, release")
- << QRect(0, 0, 20, 20)
- << QString("foo")
- << (int)(Qt::Unchecked)
- << (int)(Qt::ItemIsEditable
+ const int defaultFlags = (int)(Qt::ItemIsEditable
|Qt::ItemIsSelectable
|Qt::ItemIsUserCheckable
|Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ |Qt::ItemIsDropEnabled);
+
+ QTest::newRow("unchecked, checkable, release")
+ << QRect(0, 0, 20, 20)
+ << (int)(Qt::Unchecked)
+ << defaultFlags
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1111,14 +1111,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("checked, checkable, release")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Checked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << defaultFlags
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1127,14 +1121,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, checkable, release")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Unchecked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << defaultFlags
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1143,14 +1131,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, checkable, release, right button")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Unchecked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << defaultFlags
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::RightButton)
@@ -1159,14 +1141,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, checkable, release outside")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Unchecked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << defaultFlags
<< false
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1175,14 +1151,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, checkable, dblclick")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Unchecked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << defaultFlags
<< true
<< (int)(QEvent::MouseButtonDblClick)
<< (int)(Qt::LeftButton)
@@ -1191,15 +1161,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, tristate, release")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Unchecked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsTristate
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << (int)(defaultFlags | Qt::ItemIsTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1208,15 +1171,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("partially checked, tristate, release")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::PartiallyChecked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsTristate
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << (int)(defaultFlags | Qt::ItemIsTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1225,15 +1181,8 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("checked, tristate, release")
<< QRect(0, 0, 20, 20)
- << QString("foo")
<< (int)(Qt::Checked)
- << (int)(Qt::ItemIsEditable
- |Qt::ItemIsSelectable
- |Qt::ItemIsUserCheckable
- |Qt::ItemIsTristate
- |Qt::ItemIsEnabled
- |Qt::ItemIsDragEnabled
- |Qt::ItemIsDropEnabled)
+ << (int)(defaultFlags | Qt::ItemIsTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1244,7 +1193,6 @@ void tst_QItemDelegate::editorEvent_data()
void tst_QItemDelegate::editorEvent()
{
QFETCH(QRect, rect);
- QFETCH(QString, text);
QFETCH(int, checkState);
QFETCH(int, flags);
QFETCH(bool, inCheck);
@@ -1258,7 +1206,7 @@ void tst_QItemDelegate::editorEvent()
QVERIFY(index.isValid());
QStandardItem *item = model.itemFromIndex(index);
- item->setText(text);
+ item->setText("foo");
item->setCheckState((Qt::CheckState)checkState);
item->setFlags((Qt::ItemFlags)flags);
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/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
index b18801220c..83e6b94db9 100644
--- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -60,6 +60,8 @@ private slots:
void viewportCrash();
void task214488_layoutDirection_data();
void task214488_layoutDirection();
+
+ void margins();
};
tst_QAbstractScrollArea::tst_QAbstractScrollArea()
@@ -375,5 +377,22 @@ void tst_QAbstractScrollArea::patternBackground()
QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
}
+class ScrollArea : public QAbstractScrollArea
+{
+public:
+ using QAbstractScrollArea::setViewportMargins;
+ using QAbstractScrollArea::viewportMargins;
+};
+
+void tst_QAbstractScrollArea::margins()
+{
+ ScrollArea area;
+ QCOMPARE(area.viewportMargins(), QMargins());
+
+ QMargins margins(10, 20, 30, 40);
+ area.setViewportMargins(margins);
+ QCOMPARE(area.viewportMargins(), margins);
+}
+
QTEST_MAIN(tst_QAbstractScrollArea)
#include "tst_qabstractscrollarea.moc"
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());
}
}