diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-25 09:42:07 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-08-25 12:19:25 +0000 |
commit | e9f0766d12367e7f853901f0e2721ef702555685 (patch) | |
tree | 19550979567f275d9fd1c814f603899a4ee68a69 /tests | |
parent | 02af5155283d55f0eac0bec2dc1fd7c074861993 (diff) | |
parent | 6f5835879141210b386cad710065b644f72049a1 (diff) |
Merge "Merge remote-tracking branch 'origin/5.8' into dev" into refs/staging/dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp | 26 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp | 6 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 9 | ||||
-rw-r--r-- | tests/auto/gui/text/qfontcache/tst_qfontcache.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp | 20 | ||||
-rw-r--r-- | tests/auto/gui/text/qrawfont/testdata.qrc | 1 | ||||
-rw-r--r-- | tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf | bin | 0 -> 72960 bytes | |||
-rw-r--r-- | tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 30 | ||||
-rw-r--r-- | tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 48 |
9 files changed, 89 insertions, 53 deletions
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 5825bdb6d6..2a93250ba5 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -61,6 +61,9 @@ struct Match QStringList captured; QHash<QString, QString> namedCaptured; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(Match, Q_MOVABLE_TYPE); +QT_END_NAMESPACE Q_DECLARE_METATYPE(Match) @@ -85,9 +88,9 @@ bool operator==(const QRegularExpressionMatch &rem, const Match &m) } } - Q_FOREACH (const QString &name, m.namedCaptured.keys()) { - QString remCaptured = rem.captured(name); - QString mCaptured = m.namedCaptured.value(name); + for (auto it = m.namedCaptured.begin(), end = m.namedCaptured.end(); it != end; ++it) { + const QString remCaptured = rem.captured(it.key()); + const QString mCaptured = it.value(); if (remCaptured != mCaptured || remCaptured.isNull() != mCaptured.isNull() || remCaptured.isEmpty() != mCaptured.isEmpty()) { @@ -115,12 +118,11 @@ bool operator!=(const Match &m, const QRegularExpressionMatch &rem) } -bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList) +bool operator==(const QRegularExpressionMatchIterator &iterator, const QVector<Match> &expectedMatchList) { QRegularExpressionMatchIterator i = iterator; - foreach (const Match &expectedMatch, expectedMatchList) - { + for (const Match &expectedMatch : expectedMatchList) { if (!i.hasNext()) return false; @@ -135,17 +137,17 @@ bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Mat return true; } -bool operator==(const QList<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) +bool operator==(const QVector<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) { return operator==(iterator, expectedMatchList); } -bool operator!=(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList) +bool operator!=(const QRegularExpressionMatchIterator &iterator, const QVector<Match> &expectedMatchList) { return !operator==(iterator, expectedMatchList); } -bool operator!=(const QList<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) +bool operator!=(const QVector<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) { return !operator==(expectedMatchList, iterator); } @@ -1117,9 +1119,9 @@ void tst_QRegularExpression::globalMatch_data() QTest::addColumn<int>("offset"); QTest::addColumn<QRegularExpression::MatchType>("matchType"); QTest::addColumn<QRegularExpression::MatchOptions>("matchOptions"); - QTest::addColumn<QList<Match> >("matchList"); + QTest::addColumn<QVector<Match> >("matchList"); - QList<Match> matchList; + QVector<Match> matchList; Match m; matchList.clear(); @@ -1375,7 +1377,7 @@ void tst_QRegularExpression::globalMatch() QFETCH(int, offset); QFETCH(QRegularExpression::MatchType, matchType); QFETCH(QRegularExpression::MatchOptions, matchOptions); - QFETCH(QList<Match>, matchList); + QFETCH(QVector<Match>, matchList); testMatch<QRegularExpressionMatchIterator>(regexp, static_cast<QREGlobalMatchStringPMF>(&QRegularExpression::globalMatch), diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 1bba41816b..d0a0feb125 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -1738,9 +1738,6 @@ void tst_QSharedPointer::creating() void tst_QSharedPointer::creatingVariadic() { -#if !defined(Q_COMPILER_RVALUE_REFS) || !defined(Q_COMPILER_VARIADIC_TEMPLATES) - QSKIP("This compiler is not in C++11 mode or it doesn't support rvalue refs and variadic templates"); -#else int i = 42; { @@ -1768,12 +1765,10 @@ void tst_QSharedPointer::creatingVariadic() QCOMPARE(ptr->i, 2); QCOMPARE(ptr->ptr, (void*)0); -#ifdef Q_COMPILER_NULLPTR NoDefaultConstructor2(nullptr, 3); // control check ptr = QSharedPointer<NoDefaultConstructor2>::create(nullptr, 3); QCOMPARE(ptr->i, 3); QCOMPARE(ptr->ptr, (void*)nullptr); -#endif } { NoDefaultConstructorRef1 x(i); // control check @@ -1809,7 +1804,6 @@ void tst_QSharedPointer::creatingVariadic() QCOMPARE(ptr->str, QString("bytearray")); QCOMPARE(ptr->i, 42); } -#endif } void tst_QSharedPointer::creatingQObject() diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 8f0f599622..a0a872710c 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -84,11 +84,11 @@ public: template <typename MemFun> void apply0(QString &s, MemFun mf) const - { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(ch); } + { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(ch); } template <typename MemFun, typename A1> void apply1(QString &s, MemFun mf, A1 a1) const - { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(a1, ch); } + { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(a1, ch); } }; template <> @@ -254,6 +254,9 @@ public: }; } // unnamed namespace +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(CharStarContainer, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE Q_DECLARE_METATYPE(CharStarContainer) @@ -645,7 +648,7 @@ QString verifyZeroTermination(const QString &str) } while (0) \ /**/ -typedef QList<int> IntList; +typedef QVector<int> IntList; tst_QString::tst_QString() { diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp index 54bc802cf0..fbca313ea3 100644 --- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp +++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp @@ -101,8 +101,6 @@ void tst_QFontCache::engineData() } if (req.pointSize < 0) req.pointSize = req.pixelSize*72.0/d->dpi; - if (req.stretch == 0) - req.stretch = 100; req.family = cacheKey; diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index adaf3b1f7a..f71d808390 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -64,6 +64,8 @@ private slots: void aliases(); void fallbackFonts(); + void liberationFont(); + private: const QString m_testFont; }; @@ -275,5 +277,23 @@ void tst_QFontDatabase::fallbackFonts() } } +void tst_QFontDatabase::liberationFont() +{ + QString libSans("Liberation Sans"); + QString libSansNarrow("Liberation Sans Narrow"); + + QFontDatabase db; + if (!db.hasFamily(libSans) || !db.hasFamily(libSansNarrow)) + QSKIP("Requires Liberation Sans installed"); + + QFont fontLS(libSans); + QFont fontLSN(libSansNarrow); + + QFontMetrics fmLS(fontLS); + QFontMetrics fmLSN(fontLSN); + + QVERIFY(fmLS.width(QStringLiteral("foo bar")) > fmLSN.width(QStringLiteral("foo bar"))); +} + QTEST_MAIN(tst_QFontDatabase) #include "tst_qfontdatabase.moc" diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc index 8f8e32ed24..c7ac9641d1 100644 --- a/tests/auto/gui/text/qrawfont/testdata.qrc +++ b/tests/auto/gui/text/qrawfont/testdata.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/"> <file>testfont_bold_italic.ttf</file> + <file>testfont_os2_v1.ttf</file> <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file> </qresource> </RCC> diff --git a/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf b/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf Binary files differnew file mode 100644 index 0000000000..ee8b67d892 --- /dev/null +++ b/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 471b32dd50..3cf108ed62 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -93,6 +93,7 @@ private slots: private: QString testFont; QString testFontBoldItalic; + QString testFontOs2V1; #endif // QT_NO_RAWFONT }; @@ -110,6 +111,7 @@ void tst_QRawFont::initTestCase() { testFont = QFINDTESTDATA("testfont.ttf"); testFontBoldItalic = QFINDTESTDATA("testfont_bold_italic.ttf"); + testFontOs2V1 = QFINDTESTDATA("testfont_os2_v1.ttf"); if (testFont.isEmpty() || testFontBoldItalic.isEmpty()) QFAIL("qrawfont unittest font files not found!"); @@ -184,6 +186,7 @@ void tst_QRawFont::correctFontData_data() QTest::addColumn<QFont::HintingPreference>("hintingPreference"); QTest::addColumn<qreal>("unitsPerEm"); QTest::addColumn<qreal>("pixelSize"); + QTest::addColumn<int>("capHeight"); int hintingPreferences[] = { int(QFont::PreferDefaultHinting), @@ -207,7 +210,8 @@ void tst_QRawFont::correctFontData_data() << QFont::Normal << QFont::HintingPreference(*hintingPreference) << qreal(1000.0) - << qreal(10.0); + << qreal(10.0) + << 7; fileName = testFontBoldItalic; title = fileName @@ -221,7 +225,23 @@ void tst_QRawFont::correctFontData_data() << QFont::Bold << QFont::HintingPreference(*hintingPreference) << qreal(1000.0) - << qreal(10.0); + << qreal(10.0) + << 7; + + fileName = testFontOs2V1; + title = fileName + + QLatin1String(": hintingPreference=") + + QString::number(*hintingPreference); + + QTest::newRow(qPrintable(title)) + << fileName + << QString::fromLatin1("QtBidiTestFont") + << QFont::StyleNormal + << QFont::Normal + << QFont::HintingPreference(*hintingPreference) + << qreal(1000.0) + << qreal(10.0) + << 7; ++hintingPreference; } @@ -236,6 +256,7 @@ void tst_QRawFont::correctFontData() QFETCH(QFont::HintingPreference, hintingPreference); QFETCH(qreal, unitsPerEm); QFETCH(qreal, pixelSize); + QFETCH(int, capHeight); QRawFont font(fileName, 10, hintingPreference); QVERIFY(font.isValid()); @@ -246,6 +267,11 @@ void tst_QRawFont::correctFontData() QCOMPARE(font.hintingPreference(), hintingPreference); QCOMPARE(font.unitsPerEm(), unitsPerEm); QCOMPARE(font.pixelSize(), pixelSize); + + // Some platforms return the actual fractional height of the + // H character when the value is missing from the OS/2 table, + // so we ceil it off to match (any touched pixel counts). + QCOMPARE(qCeil(font.capHeight()), capHeight); } void tst_QRawFont::glyphIndices() diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 8d84addedb..b95a17bd4e 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -817,6 +817,24 @@ static bool testForColors(const QImage& image, const QColor& color, bool ensureP return false; } +static const QList<QWidget*> sample_widgets() // returning const to avoid detaching when passing to range-for +{ + QList<QWidget *> widgets; + widgets << new QPushButton("TESTING TESTING"); + widgets << new QLineEdit("TESTING TESTING"); + widgets << new QLabel("TESTING TESTING"); + QSpinBox *spinbox = new QSpinBox; + spinbox->setMaximum(1000000000); + spinbox->setValue(123456789); + widgets << spinbox; + QComboBox *combobox = new QComboBox; + combobox->setEditable(true); + combobox->addItems(QStringList() << "TESTING TESTING"); + widgets << combobox; + widgets << new QLabel("<b>TESTING TESTING</b>"); + return widgets; +} + void tst_QStyleSheetStyle::focusColors() { // Tests if colors can be changed by altering the focus of the widget. @@ -833,22 +851,9 @@ void tst_QStyleSheetStyle::focusColors() " (for example, QTBUG-33959)." "That doesn't mean that the feature doesn't work in practice."); #endif - QList<QWidget *> widgets; - widgets << new QPushButton("TESTING TESTING"); - widgets << new QLineEdit("TESTING TESTING"); - widgets << new QLabel("TESTING TESTING"); - QSpinBox *spinbox = new QSpinBox; - spinbox->setMaximum(1000000000); - spinbox->setValue(123456789); - widgets << spinbox; - QComboBox *combobox = new QComboBox; - combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING TESTING"); - widgets << combobox; - widgets << new QLabel("TESTING TESTING"); - foreach (QWidget *widget, widgets) { + for (QWidget *widget : sample_widgets()) { QDialog frame; QLayout* layout = new QGridLayout; @@ -891,21 +896,8 @@ void tst_QStyleSheetStyle::hoverColors() #ifdef Q_OS_OSX QSKIP("This test is fragile on Mac, most likely due to QTBUG-33959."); #endif - QList<QWidget *> widgets; - widgets << new QPushButton("TESTING TESTING"); - widgets << new QLineEdit("TESTING TESTING"); - widgets << new QLabel("TESTING TESTING"); - QSpinBox *spinbox = new QSpinBox; - spinbox->setMaximum(1000000000); - spinbox->setValue(123456789); - widgets << spinbox; - QComboBox *combobox = new QComboBox; - combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING TESTING"); - widgets << combobox; - widgets << new QLabel("<b>TESTING TESTING</b>"); - foreach (QWidget *widget, widgets) { + for (QWidget *widget : sample_widgets()) { //without Qt::X11BypassWindowManagerHint the window manager may move the window after we moved the cursor QDialog frame(0, Qt::X11BypassWindowManagerHint); QLayout* layout = new QGridLayout; |