diff options
author | Jani Heikkinen <jani.heikkinen@digia.com> | 2014-03-17 13:48:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-17 13:48:12 +0100 |
commit | 23b47a8d4e32453086ae7cd9c3fdd0d039178c2b (patch) | |
tree | 8d3dbacb0126b17849246f19ab35a4111faf9e58 /tests | |
parent | 2c175d3748dc60469c65ba005001f43a6d3b6243 (diff) | |
parent | a2850e54d5ec7bc02c265459e3b8c8958df2e595 (diff) |
Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 28 | ||||
-rw-r--r-- | tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 32 |
2 files changed, 53 insertions, 7 deletions
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 46f97840af..4ae70fe137 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -87,6 +87,7 @@ private slots: void plainTextVsRichText(); + void setPenPlainText_data(); void setPenPlainText(); void setPenRichText(); void richTextOverridesPen(); @@ -106,6 +107,8 @@ private: QImage const m_whiteSquare; }; +Q_DECLARE_METATYPE(QImage::Format); + void tst_QStaticText::initTestCase() { // a "blank" square; we compare against in our testfunctions to verify @@ -615,30 +618,41 @@ void tst_QStaticText::plainTextVsRichText() QCOMPARE(imagePlainText, imageRichText); } +void tst_QStaticText::setPenPlainText_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("rgb32") << QImage::Format_RGB32; + QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; + QTest::newRow("rgbx8888") << QImage::Format_RGBX8888; +} + void tst_QStaticText::setPenPlainText() { + QFETCH(QImage::Format, format); + QFont font = QGuiApplication::font(); font.setStyleStrategy(QFont::NoAntialias); QFontMetricsF fm(font); - QPixmap image(qCeil(fm.width("XXXXX")), qCeil(fm.height())); + QImage image(qCeil(fm.width("XXXXX")), qCeil(fm.height()), format); image.fill(Qt::white); { QPainter p(&image); p.setFont(font); - p.setPen(Qt::green); + p.setPen(Qt::yellow); QStaticText staticText("XXXXX"); staticText.setTextFormat(Qt::PlainText); p.drawStaticText(0, 0, staticText); } - QImage img = image.toImage(); - for (int x=0; x<img.width(); ++x) { - for (int y=0; y<img.height(); ++y) { - QRgb pixel = img.pixel(x, y); + for (int x=0; x<image.width(); ++x) { + for (int y=0; y<image.height(); ++y) { + QRgb pixel = image.pixel(x, y); QVERIFY(pixel == QColor(Qt::white).rgba() - || pixel == QColor(Qt::green).rgba()); + || pixel == QColor(Qt::yellow).rgba()); } } } diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 24e3ac2c99..5a36ffc671 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -99,6 +99,7 @@ private slots: void task232085_spinBoxLineEditBg(); void changeStyleInChangeEvent(); void QTBUG15910_crashNullWidget(); + void QTBUG36933_brokenPseudoClassLookup(); //at the end because it mess with the style. void widgetStyle(); @@ -1656,6 +1657,37 @@ void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget() QVERIFY(QTest::qWaitForWindowExposed(&w)); } +void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup() +{ + const int rowCount = 10; + const int columnCount = 10; + + QTableWidget widget(rowCount, columnCount); + + for (int row = 0; row < rowCount; ++row) { + for (int column = 0; column < columnCount; ++column) + widget.setItem(row, column, new QTableWidgetItem(QStringLiteral("row %1 column %2").arg(row + 1).arg(column + 1))); + + // put no visible text for the vertical headers, but still put some text or they will collapse + widget.setVerticalHeaderItem(row, new QTableWidgetItem(QStringLiteral(" "))); + } + + // parsing of this stylesheet must not crash, and it must be correctly applied + widget.setStyleSheet(QStringLiteral("QHeaderView::section:vertical { background-color: #FF0000 }")); + + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + + widget.activateWindow(); + QApplication::setActiveWindow(&widget); + QVERIFY(QTest::qWaitForWindowActive(&widget)); + + QHeaderView *verticalHeader = widget.verticalHeader(); + QImage image(verticalHeader->size(), QImage::Format_ARGB32); + verticalHeader->render(&image); + QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00))); +} + QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" |