summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp68
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp29
-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.cpp54
-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/painting/qpainter/tst_qpainter.cpp3
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp65
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp8
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp5
11 files changed, 414 insertions, 137 deletions
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/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/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 3edc9cc965..054cb733a1 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -155,6 +155,7 @@ private slots:
void lastIndexOfInvalidRegex();
void indexOf_data();
void indexOf();
+ void indexOfInvalidRegex();
void indexOf2_data();
void indexOf2();
void indexOf3_data();
@@ -1182,6 +1183,18 @@ void tst_QString::indexOf()
QRegularExpression re(QRegularExpression::escape(needle), options);
QCOMPARE( haystack.indexOf(re, startpos), resultpos );
+ QCOMPARE(haystack.indexOf(re, startpos, Q_NULLPTR), resultpos);
+
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QCOMPARE(haystack.indexOf(re, startpos, &match), resultpos);
+ QCOMPARE(match.hasMatch(), resultpos != -1);
+ if (resultpos > -1 && needleIsLatin) {
+ if (bcs)
+ QVERIFY(match.captured() == needle);
+ else
+ QVERIFY(match.captured().toLower() == needle.toLower());
+ }
}
if (cs == Qt::CaseSensitive) {
@@ -1290,6 +1303,20 @@ void tst_QString::indexOf2()
}
}
+void tst_QString::indexOfInvalidRegex()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\")), -1);
+ QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, Q_NULLPTR), -1);
+
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, &match), -1);
+ QVERIFY(!match.hasMatch());
+}
+
void tst_QString::lastIndexOf_data()
{
QTest::addColumn<QString>("haystack" );
@@ -1379,6 +1406,17 @@ void tst_QString::lastIndexOf()
QRegularExpression re(QRegularExpression::escape(needle), options);
QCOMPARE(haystack.lastIndexOf(re, from), expected);
+ QCOMPARE(haystack.lastIndexOf(re, from, Q_NULLPTR), expected);
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QCOMPARE(haystack.lastIndexOf(re, from, &match), expected);
+ QCOMPARE(match.hasMatch(), expected > -1);
+ if (expected > -1) {
+ if (caseSensitive)
+ QCOMPARE(match.captured(), needle);
+ else
+ QCOMPARE(match.captured().toLower(), needle.toLower());
+ }
}
}
@@ -1403,7 +1441,15 @@ void tst_QString::lastIndexOf()
void tst_QString::lastIndexOfInvalidRegex()
{
QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object");
- QCOMPARE(QString("").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1);
+ QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1);
+ QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, Q_NULLPTR), -1);
+
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+ QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object");
+ QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, &match), -1);
+ QVERIFY(!match.hasMatch());
}
void tst_QString::count()
@@ -1838,6 +1884,7 @@ void tst_QString::toUpper()
{
QCOMPARE( QString().toUpper(), QString() );
QCOMPARE( QString("").toUpper(), QString("") );
+ QCOMPARE( QStringLiteral("text").toUpper(), QString("TEXT") );
QCOMPARE( QString("text").toUpper(), QString("TEXT") );
QCOMPARE( QString("Text").toUpper(), QString("TEXT") );
QCOMPARE( QString("tExt").toUpper(), QString("TEXT") );
@@ -1898,6 +1945,7 @@ void tst_QString::toLower()
QCOMPARE( QString().toLower(), QString() );
QCOMPARE( QString("").toLower(), QString("") );
QCOMPARE( QString("text").toLower(), QString("text") );
+ QCOMPARE( QStringLiteral("Text").toLower(), QString("text") );
QCOMPARE( QString("Text").toLower(), QString("text") );
QCOMPARE( QString("tExt").toLower(), QString("text") );
QCOMPARE( QString("teXt").toLower(), QString("text") );
@@ -2063,8 +2111,6 @@ 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));
}
}
@@ -4432,6 +4478,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/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 5f581c9d0f..4cb70612ea 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -773,6 +773,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;
}
@@ -1002,6 +1009,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;
}
}
@@ -2090,16 +2101,20 @@ void tst_QImage::fillPixel_data()
QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u;
QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u;
QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u;
+ QTest::newRow("Alpha8, transparent") << QImage::Format_Alpha8 << 0x0u << 0x00000000u;
QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u;
QTest::newRow("RGB32, red") << QImage::Format_RGB32 << 0xffff0000u << 0xffff0000u;
QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u;
QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u;
+ QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0xff808080u << 0xff808080u;
+
QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u;
QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u;
QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u;
QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u;
+ QTest::newRow("Alpha8, semi-red") << QImage::Format_Alpha8 << 0x80000080u << 0x80000000u;
}
void tst_QImage::fillPixel()
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index 184cc872a1..e0eaba9896 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -487,13 +487,13 @@ void tst_QImageReader::imageFormat_data()
QTest::addColumn<QImage::Format>("imageFormat");
QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm") << QImage::Format_Mono;
- QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Indexed8;
+ QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Grayscale8;
QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-3") << QString("runners.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-4") << QString("test.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
- QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Indexed8;
+ QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Grayscale8;
QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
diff --git a/tests/auto/gui/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/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/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index e6bcc33771..1c8121f142 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/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 3f8b8ec067..f2a40576f6 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -518,11 +518,16 @@ void tst_QAbstractItemView::basic_tests(TestView *view)
// setIconSize
view->setIconSize(QSize(16, 16));
QCOMPARE(view->iconSize(), QSize(16, 16));
+ QSignalSpy spy(view, &QAbstractItemView::iconSizeChanged);
+ QVERIFY(spy.isValid());
view->setIconSize(QSize(32, 32));
QCOMPARE(view->iconSize(), QSize(32, 32));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).value<QSize>(), QSize(32, 32));
// Should this happen?
view->setIconSize(QSize(-1, -1));
QCOMPARE(view->iconSize(), QSize(-1, -1));
+ QCOMPARE(spy.count(), 2);
QCOMPARE(view->currentIndex(), QModelIndex());
QCOMPARE(view->rootIndex(), QModelIndex());