summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-01-08 09:34:24 +0100
committerLiang Qi <liang.qi@qt.io>2019-01-08 09:34:24 +0100
commit0e96b5fe482802935ae202e2297404845e440d71 (patch)
tree79c566f18bc605261f69d750d2935b91edba3861 /tests/auto/corelib
parentda43362921a62ea3163a042be20ec0f550d05cfa (diff)
parent5733dfbd90fd059e7310786faefb022b00289592 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.12.1
Conflicts: src/widgets/kernel/qtooltip.cpp Change-Id: Ic2f9a425359050eb56b3a4e5162cf5e3447058c8
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp20
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp11
-rw-r--r--tests/auto/corelib/kernel/qtimer/BLACKLIST2
-rw-r--r--tests/auto/corelib/tools/qcollator/tst_qcollator.cpp18
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp76
5 files changed, 82 insertions, 45 deletions
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index 9a54c0a70d..1b40e77648 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -81,6 +81,8 @@ private slots:
void setData_emits_both_roles_data();
void setData_emits_both_roles();
+ void setData_emits_on_change_only();
+
void supportedDragDropActions();
};
@@ -246,6 +248,24 @@ void tst_QStringListModel::setData_emits_both_roles()
expected);
}
+void tst_QStringListModel::setData_emits_on_change_only()
+{
+ QStringListModel model(QStringList{QStringLiteral("one"), QStringLiteral("two")});
+ QSignalSpy dataChangedSpy(&model, &QAbstractItemModel::dataChanged);
+ QVERIFY(dataChangedSpy.isValid());
+ const QModelIndex modelIdx = model.index(0, 0);
+ const QString newStringData = QStringLiteral("test");
+ QVERIFY(model.setData(modelIdx, newStringData));
+ QCOMPARE(dataChangedSpy.count(), 1);
+ const QList<QVariant> spyList = dataChangedSpy.takeFirst();
+ QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx);
+ QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx);
+ const QVector<int> expectedRoles{Qt::DisplayRole, Qt::EditRole};
+ QCOMPARE(spyList.at(2).value<QVector<int> >(), expectedRoles);
+ QVERIFY(model.setData(modelIdx, newStringData));
+ QVERIFY(dataChangedSpy.isEmpty());
+}
+
void tst_QStringListModel::supportedDragDropActions()
{
QStringListModel model;
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 5d9b5ca95c..e6fac74ccc 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -123,6 +123,7 @@ private slots:
void compareCustomType();
void compareCustomEqualOnlyType();
void customDebugStream();
+ void unknownType();
};
struct BaseGenericType
@@ -2529,6 +2530,16 @@ void tst_QMetaType::customDebugStream()
qDebug() << v1;
}
+void tst_QMetaType::unknownType()
+{
+ QMetaType invalid(QMetaType::UnknownType);
+ QVERIFY(!invalid.create());
+ QVERIFY(!invalid.sizeOf());
+ QVERIFY(!invalid.metaObject());
+ int buffer = 0xBAD;
+ invalid.construct(&buffer);
+ QCOMPARE(buffer, 0xBAD);
+}
// Compile-time test, it should be possible to register function pointer types
class Undefined;
diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST
index b355bc22c2..e5136624d8 100644
--- a/tests/auto/corelib/kernel/qtimer/BLACKLIST
+++ b/tests/auto/corelib/kernel/qtimer/BLACKLIST
@@ -1,5 +1,3 @@
[remainingTime]
windows
osx
-[basic_chrono]
-osx ci
diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
index 2d65d3433f..72f88a235d 100644
--- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
+++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
@@ -93,7 +93,7 @@ void tst_QCollator::compare_data()
QTest::addColumn<int>("caseInsensitiveResult");
QTest::addColumn<bool>("numericMode");
QTest::addColumn<bool>("ignorePunctuation");
- QTest::addColumn<int>("punctuationResult");
+ QTest::addColumn<int>("punctuationResult"); // Test ignores punctuation *and case*
/*
It's hard to test English, because it's treated differently
@@ -169,8 +169,12 @@ void tst_QCollator::compare_data()
QTest::newRow("french6") << QString("fr_FR") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("french7") << QString("fr_FR") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("french8") << QString("fr_FR") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
-}
+ // C locale: case sensitive [A-Z] < [a-z] but case insensitive [Aa] < [Bb] <...< [Zz]
+ const QString C = QStringLiteral("C");
+ QTest::newRow("C:ABBA:AaaA") << C << QStringLiteral("ABBA") << QStringLiteral("AaaA") << -1 << 1 << false << false << 1;
+ QTest::newRow("C:AZa:aAZ") << C << QStringLiteral("AZa") << QStringLiteral("aAZ") << -1 << 1 << false << false << 1;
+}
void tst_QCollator::compare()
{
@@ -184,6 +188,10 @@ void tst_QCollator::compare()
QFETCH(int, punctuationResult);
QCollator collator(locale);
+ // Need to canonicalize sign to -1, 0 or 1, as .compare() can produce any -ve for <, any +ve for >.
+ auto asSign = [](int compared) {
+ return compared < 0 ? -1 : compared > 0 ? 1 : 0;
+ };
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
if (collator.locale() != QLocale())
@@ -193,12 +201,12 @@ void tst_QCollator::compare()
if (numericMode)
collator.setNumericMode(true);
- QCOMPARE(collator.compare(s1, s2), result);
+ QCOMPARE(asSign(collator.compare(s1, s2)), result);
collator.setCaseSensitivity(Qt::CaseInsensitive);
- QCOMPARE(collator.compare(s1, s2), caseInsensitiveResult);
+ QCOMPARE(asSign(collator.compare(s1, s2)), caseInsensitiveResult);
#if !QT_CONFIG(iconv)
collator.setIgnorePunctuation(ignorePunctuation);
- QCOMPARE(collator.compare(s1, s2), punctuationResult);
+ QCOMPARE(asSign(collator.compare(s1, s2)), punctuationResult);
#endif
}
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index c23ee3b0ba..c02756d76a 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -2169,47 +2169,47 @@ void tst_QRegularExpression::wildcard_data()
addRow("*.html", "test.html", 0);
addRow("*.html", "test.htm", -1);
- addRow("bar*", "foobarbaz", 3);
+ addRow("*bar*", "foobarbaz", 0);
addRow("*", "Qt Rocks!", 0);
- addRow(".html", "test.html", 4);
- addRow(".h", "test.cpp", -1);
- addRow(".???l", "test.html", 4);
- addRow("?", "test.html", 0);
- addRow("?m", "test.html", 6);
- addRow("[*]", "test.html", -1);
- addRow("[?]","test.html", -1);
- addRow("[?]","test.h?ml", 6);
- addRow("[[]","test.h[ml", 6);
- addRow("[]]","test.h]ml", 6);
- addRow(".h[a-z]ml", "test.html", 4);
- addRow(".h[A-Z]ml", "test.html", -1);
- addRow(".h[A-Z]ml", "test.hTml", 4);
- addRow(".h[!A-Z]ml", "test.hTml", -1);
- addRow(".h[!A-Z]ml", "test.html", 4);
- addRow(".h[!T]ml", "test.hTml", -1);
- addRow(".h[!T]ml", "test.html", 4);
- addRow(".h[!T]m[!L]", "test.htmL", -1);
- addRow(".h[!T]m[!L]", "test.html", 4);
- addRow(".h[][!]", "test.h]ml", 4);
- addRow(".h[][!]", "test.h[ml", 4);
- addRow(".h[][!]", "test.h!ml", 4);
-
- addRow("foo/*/bar", "Qt/foo/baz/bar", 3);
- addRow("foo/(*)/bar", "Qt/foo/baz/bar", -1);
- addRow("foo/(*)/bar", "Qt/foo/(baz)/bar", 3);
- addRow("foo/?/bar", "Qt/foo/Q/bar", 3);
- addRow("foo/?/bar", "Qt/foo/Qt/bar", -1);
- addRow("foo/(?)/bar", "Qt/foo/Q/bar", -1);
- addRow("foo/(?)/bar", "Qt/foo/(Q)/bar", 3);
+ addRow("*.html", "test.html", 0);
+ addRow("*.h", "test.cpp", -1);
+ addRow("*.???l", "test.html", 0);
+ addRow("*?", "test.html", 0);
+ addRow("*?ml", "test.html", 0);
+ addRow("*[*]", "test.html", -1);
+ addRow("*[?]","test.html", -1);
+ addRow("*[?]ml","test.h?ml", 0);
+ addRow("*[[]ml","test.h[ml", 0);
+ addRow("*[]]ml","test.h]ml", 0);
+ addRow("*.h[a-z]ml", "test.html", 0);
+ addRow("*.h[A-Z]ml", "test.html", -1);
+ addRow("*.h[A-Z]ml", "test.hTml", 0);
+ addRow("*.h[!A-Z]ml", "test.hTml", -1);
+ addRow("*.h[!A-Z]ml", "test.html", 0);
+ addRow("*.h[!T]ml", "test.hTml", -1);
+ addRow("*.h[!T]ml", "test.html", 0);
+ addRow("*.h[!T]m[!L]", "test.htmL", -1);
+ addRow("*.h[!T]m[!L]", "test.html", 0);
+ addRow("*.h[][!]ml", "test.h]ml", 0);
+ addRow("*.h[][!]ml", "test.h[ml", 0);
+ addRow("*.h[][!]ml", "test.h!ml", 0);
+
+ addRow("foo/*/bar", "foo/baz/bar", 0);
+ addRow("foo/(*)/bar", "foo/baz/bar", -1);
+ addRow("foo/(*)/bar", "foo/(baz)/bar", 0);
+ addRow("foo/?/bar", "foo/Q/bar", 0);
+ addRow("foo/?/bar", "foo/Qt/bar", -1);
+ addRow("foo/(?)/bar", "foo/Q/bar", -1);
+ addRow("foo/(?)/bar", "foo/(Q)/bar", 0);
#ifdef Q_OS_WIN
- addRow("foo\\*\\bar", "Qt\\foo\\baz\\bar", 3);
- addRow("foo\\(*)\\bar", "Qt\\foo\\baz\\bar", -1);
- addRow("foo\\(*)\\bar", "Qt\\foo\\(baz)\\bar", 3);
- addRow("foo\\?\\bar", "Qt\\foo\\Q\\bar", 3);
- addRow("foo\\?\\bar", "Qt\\foo\\Qt\\bar", -1);
- addRow("foo\\(?)\\bar", "Qt\\foo\\Q\\bar", -1);
- addRow("foo\\(?)\\bar", "Qt\\foo\\(Q)\\bar", 3);
+ addRow("foo\\*\\bar", "foo\\baz\\bar", 0);
+ addRow("foo\\(*)\\bar", "foo\\baz\\bar", -1);
+ addRow("foo\\(*)\\bar", "foo\\(baz)\\bar", 0);
+ addRow("foo\\?\\bar", "foo\\Q\\bar", 0);
+ addRow("foo\\?\\bar", "foo\\Qt\\bar", -1);
+ addRow("foo\\(?)\\bar", "foo\\Q\\bar", -1);
+ addRow("foo\\(?)\\bar", "foo\\(Q)\\bar", 0);
#endif
}