diff options
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 49 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qbackingstore/qbackingstore.pro | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qinputmethod/qinputmethod.pro | 1 | ||||
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 81 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 81 | ||||
-rw-r--r-- | tests/auto/gui/text/qcssparser/tst_qcssparser.cpp | 5 | ||||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/qfontdatabase.pro | 3 | ||||
-rw-r--r-- | tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp | 13 |
8 files changed, 188 insertions, 46 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 2cd5216c59..7fdb2f4cba 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -728,6 +728,24 @@ void tst_QImage::convertToFormat_data() << int(QImage::Format_RGB888) << 0xffffffffu; QTest::newRow("semiblack pm -> rgb888") << int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u << int(QImage::Format_RGB888) << 0xff000000u; + + QTest::newRow("red rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xffff0000 + << int(QImage::Format_ARGB32) << 0xffff0000; + QTest::newRow("green rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xff00ff00 + << int(QImage::Format_ARGB32) << 0xff00ff00; + QTest::newRow("blue rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xff0000ff + << int(QImage::Format_ARGB32) << 0xff0000ff; + + QTest::newRow("semired rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7fff0000u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f0000u; + QTest::newRow("semigreen rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f00ff00u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f007f00u; + QTest::newRow("semiblue rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f0000ffu + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f00007fu; + QTest::newRow("semiwhite rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7fffffffu + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f7f7fu; + QTest::newRow("semiblack rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f000000u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u; } @@ -953,6 +971,10 @@ void tst_QImage::rotate_data() << QImage::Format_RGB888 << d; QTest::newRow(qPrintable(title.arg("Format_Indexed8"))) << QImage::Format_Indexed8 << d; + QTest::newRow(qPrintable(title.arg("Format_RGBX8888"))) + << QImage::Format_RGBX8888 << d; + QTest::newRow(qPrintable(title.arg("Format_RGBA8888_Premultiplied"))) + << QImage::Format_RGBA8888_Premultiplied << d; } } @@ -1161,6 +1183,21 @@ void tst_QImage::setPixel_data() << 0xff00ff00 << 0x00ff00u; QTest::newRow("RGB888 blue") << int(QImage::Format_RGB888) << 0xff0000ff << 0x0000ffu; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) + << 0xffff0000u << 0xff0000ffu; + QTest::newRow("RGBA8888 green") << int(QImage::Format_RGBA8888) + << 0xff00ff00u << 0x00ff00ffu; + QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888) + << 0xff0000ffu << 0x0000ffffu; +#else + QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) + << 0xffff0000u << 0xff0000ffu; + QTest::newRow("RGBA8888 green") << int(QImage::Format_RGBA8888) + << 0xff00ff00u << 0xff00ff00u; + QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888) + << 0xff0000ffu << 0xffff0000u; +#endif } void tst_QImage::setPixel() @@ -1184,6 +1221,9 @@ void tst_QImage::setPixel() case int(QImage::Format_RGB32): case int(QImage::Format_ARGB32): case int(QImage::Format_ARGB32_Premultiplied): + case int(QImage::Format_RGBX8888): + case int(QImage::Format_RGBA8888): + case int(QImage::Format_RGBA8888_Premultiplied): { for (int y = 0; y < h; ++y) { const quint32 *row = (const quint32*)(img.scanLine(y)); @@ -1901,6 +1941,8 @@ void tst_QImage::fillColor_data() "RGB888", "RGB444", "ARGB4444pm", + "RGBx8888", + "RGBA8888pm", 0 }; @@ -1917,7 +1959,9 @@ void tst_QImage::fillColor_data() QImage::Format_ARGB8555_Premultiplied, QImage::Format_RGB888, QImage::Format_RGB444, - QImage::Format_ARGB4444_Premultiplied + QImage::Format_ARGB4444_Premultiplied, + QImage::Format_RGBX8888, + QImage::Format_RGBA8888_Premultiplied, }; for (int i=0; names[i] != 0; ++i) { @@ -1935,6 +1979,7 @@ void tst_QImage::fillColor_data() QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << Qt::transparent << 0xff000000; QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << Qt::transparent << 0x00000000u; QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << Qt::transparent << 0x00000000u; + QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << Qt::transparent << 0x00000000u; } void tst_QImage::fillColor() @@ -2013,6 +2058,8 @@ void tst_QImage::rgbSwapped_data() QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Format_RGB888") << QImage::Format_RGB888; QTest::newRow("Format_RGB444") << QImage::Format_RGB444; + QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888; + QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied; } void tst_QImage::rgbSwapped() diff --git a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro index c3113ed4b1..211be4c1c0 100644 --- a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro +++ b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qbackingstore QT += core-private gui-private testlib diff --git a/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro b/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro index ff491c1e25..015cc782eb 100644 --- a/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro +++ b/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qinputmethod SOURCES += tst_qinputmethod.cpp QT += core-private gui-private testlib diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 6fe7961545..1b1f5575b1 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -61,6 +61,8 @@ private slots: void name_data(); void name(); + void namehex_data(); + void namehex(); void setNamedColor(); void constructNamedColorWithSpace(); @@ -254,36 +256,75 @@ void tst_QColor::isValid() QVERIFY(color.isValid() == isValid); } +Q_DECLARE_METATYPE(QColor::NameFormat); + void tst_QColor::name_data() { QTest::addColumn<QColor>("color"); QTest::addColumn<QString>("name"); - - QTest::newRow("invalid") << QColor() << "#000000"; - QTest::newRow("global color black") << QColor(Qt::black) << "#000000"; - QTest::newRow("global color white") << QColor(Qt::white) << "#ffffff"; - QTest::newRow("global color darkGray") << QColor(Qt::darkGray) << "#808080"; - QTest::newRow("global color gray") << QColor(Qt::gray) << "#a0a0a4"; - QTest::newRow("global color lightGray") << QColor(Qt::lightGray) << "#c0c0c0"; - QTest::newRow("global color red") << QColor(Qt::red) << "#ff0000"; - QTest::newRow("global color green") << QColor(Qt::green) << "#00ff00"; - QTest::newRow("global color blue") << QColor(Qt::blue) << "#0000ff"; - QTest::newRow("global color cyan") << QColor(Qt::cyan) << "#00ffff"; - QTest::newRow("global color magenta") << QColor(Qt::magenta) << "#ff00ff"; - QTest::newRow("global color yellow") << QColor(Qt::yellow) << "#ffff00"; - QTest::newRow("global color darkRed") << QColor(Qt::darkRed) << "#800000"; - QTest::newRow("global color darkGreen") << QColor(Qt::darkGreen) << "#008000"; - QTest::newRow("global color darkBlue") << QColor(Qt::darkBlue) << "#000080"; - QTest::newRow("global color darkCyan") << QColor(Qt::darkCyan) << "#008080"; - QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080"; - QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000"; + QTest::addColumn<QColor::NameFormat>("nameFormat"); + + QTest::newRow("invalid") << QColor() << "#000000" << QColor::HexRgb; + QTest::newRow("global color black") << QColor(Qt::black) << "#000000" << QColor::HexRgb; + QTest::newRow("global color white") << QColor(Qt::white) << "#ffffff" << QColor::HexRgb; + QTest::newRow("global color darkGray") << QColor(Qt::darkGray) << "#808080" << QColor::HexRgb; + QTest::newRow("global color gray") << QColor(Qt::gray) << "#a0a0a4" << QColor::HexRgb; + QTest::newRow("global color lightGray") << QColor(Qt::lightGray) << "#c0c0c0" << QColor::HexRgb; + QTest::newRow("global color red") << QColor(Qt::red) << "#ff0000" << QColor::HexRgb; + QTest::newRow("global color green") << QColor(Qt::green) << "#00ff00" << QColor::HexRgb; + QTest::newRow("global color blue") << QColor(Qt::blue) << "#0000ff" << QColor::HexRgb; + QTest::newRow("global color cyan") << QColor(Qt::cyan) << "#00ffff" << QColor::HexRgb; + QTest::newRow("global color magenta") << QColor(Qt::magenta) << "#ff00ff" << QColor::HexRgb; + QTest::newRow("global color yellow") << QColor(Qt::yellow) << "#ffff00" << QColor::HexRgb; + QTest::newRow("global color darkRed") << QColor(Qt::darkRed) << "#800000" << QColor::HexRgb; + QTest::newRow("global color darkGreen") << QColor(Qt::darkGreen) << "#008000" << QColor::HexRgb; + QTest::newRow("global color darkBlue") << QColor(Qt::darkBlue) << "#000080" << QColor::HexRgb; + QTest::newRow("global color darkCyan") << QColor(Qt::darkCyan) << "#008080" << QColor::HexRgb; + QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080" << QColor::HexRgb; + QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000" << QColor::HexRgb; + QTest::newRow("transparent red") << QColor(255, 0, 0, 102) << "#66ff0000" << QColor::HexArgb; } void tst_QColor::name() { QFETCH(QColor, color); QFETCH(QString, name); - QCOMPARE(color.name(), name); + QFETCH(QColor::NameFormat, nameFormat); + QCOMPARE(color.name(nameFormat), name); +} + +void tst_QColor::namehex_data() +{ + QTest::addColumn<QString>("hexcolor"); + QTest::addColumn<QColor>("color"); + + QTest::newRow("global color black") << "#000000" << QColor(Qt::black); + QTest::newRow("global color white") << "#ffffff" << QColor(Qt::white); + QTest::newRow("global color darkGray") << "#808080" << QColor(Qt::darkGray); + QTest::newRow("global color gray") << "#a0a0a4" << QColor(Qt::gray); + QTest::newRow("global color lightGray") << "#c0c0c0" << QColor(Qt::lightGray); + QTest::newRow("global color red") << "#ff0000" << QColor(Qt::red); + QTest::newRow("global color green") << "#00ff00" << QColor(Qt::green); + QTest::newRow("global color blue") << "#0000ff" << QColor(Qt::blue); + QTest::newRow("global color cyan") << "#00ffff" << QColor(Qt::cyan); + QTest::newRow("global color magenta") << "#ff00ff" << QColor(Qt::magenta); + QTest::newRow("global color yellow") << "#ffff00" << QColor(Qt::yellow); + QTest::newRow("global color darkRed") << "#800000" << QColor(Qt::darkRed); + QTest::newRow("global color darkGreen") << "#008000" << QColor(Qt::darkGreen); + QTest::newRow("global color darkBlue") << "#000080" << QColor(Qt::darkBlue); + QTest::newRow("global color darkCyan") << "#008080" << QColor(Qt::darkCyan); + QTest::newRow("global color darkMagenta") << "#800080" << QColor(Qt::darkMagenta); + QTest::newRow("global color darkYellow") << "#808000" << QColor(Qt::darkYellow); + QTest::newRow("transparent red") << "#66ff0000" << QColor(255, 0, 0, 102); + QTest::newRow("invalid red") << "#gg0000" << QColor(); + QTest::newRow("invalid transparent") << "#gg00ff00" << QColor(); +} + +void tst_QColor::namehex() +{ + QFETCH(QString, hexcolor); + QFETCH(QColor, color); + QCOMPARE(QColor(hexcolor), color); } void tst_QColor::globalColors_data() diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 4f1213dff9..5a1ca855a1 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -122,10 +122,15 @@ private slots: void drawRect(); void drawRect2(); + void fillRect_data(); void fillRect(); + void fillRect2_data(); void fillRect2(); + void fillRect3_data() { fillRect2_data(); } void fillRect3(); + void fillRect4_data() { fillRect2_data(); } void fillRect4(); + void fillRectNonPremul(); void drawEllipse_data(); void drawEllipse(); @@ -1079,9 +1084,19 @@ void tst_QPainter::drawRect2() } } +void tst_QPainter::fillRect_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; +} + void tst_QPainter::fillRect() { - QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); + QFETCH(QImage::Format, format); + + QImage image(100, 100, format); image.fill(QColor(0, 0, 0, 0).rgba()); QPainter p(&image); @@ -1103,17 +1118,29 @@ void tst_QPainter::fillRect() QRect(0, 0, 50, 100)); } +void tst_QPainter::fillRect2_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32") << QImage::Format_ARGB32; + QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("rgba8888") << QImage::Format_RGBA8888; + QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; +} + void tst_QPainter::fillRect2() { + QFETCH(QImage::Format, format); + QRgb background = 0x0; - QImage img(1, 20, QImage::Format_ARGB32_Premultiplied); + QImage img(1, 20, format); img.fill(background); QPainter p(&img); QRectF rect(0, 1, 1.2, 18); - p.fillRect(rect, Qt::black); + p.fillRect(rect, Qt::yellow); p.end(); @@ -1122,11 +1149,14 @@ void tst_QPainter::fillRect2() QCOMPARE(img.pixel(0, 1), img.pixel(0, 2)); QCOMPARE(img.pixel(0, img.height() - 2), img.pixel(0, img.height() - 3)); + QCOMPARE(img.pixel(0, 1), QColor(Qt::yellow).rgba()); } void tst_QPainter::fillRect3() { - QImage img(1, 1, QImage::Format_ARGB32_Premultiplied); + QFETCH(QImage::Format, format); + + QImage img(1, 1, format); img.fill(QColor(Qt::black).rgba()); QPainter p(&img); @@ -1139,7 +1169,9 @@ void tst_QPainter::fillRect3() void tst_QPainter::fillRect4() { - QImage image(100, 1, QImage::Format_ARGB32_Premultiplied); + QFETCH(QImage::Format, format); + + QImage image(100, 1, format); image.fill(0x0); QImage expected = image; @@ -1157,6 +1189,24 @@ void tst_QPainter::fillRect4() QCOMPARE(image, expected); } +void tst_QPainter::fillRectNonPremul() +{ + QImage img1(1, 1, QImage::Format_ARGB32); + QImage img2(1, 1, QImage::Format_RGBA8888); + + QPainter p1(&img1); + QPainter p2(&img2); + + QRectF rect(0, 0, 1, 1); + p1.fillRect(rect, qRgba(31, 63, 127, 127)); + p2.fillRect(rect, qRgba(31, 63, 127, 127)); + + p1.end(); + p2.end(); + + QCOMPARE(img1.pixel(0, 0), img2.pixel(0,0)); +} + void tst_QPainter::drawPath_data() { QTest::addColumn<QPainterPath>("path"); @@ -2265,6 +2315,27 @@ void tst_QPainter::setOpacity_data() QTest::newRow("RGB444 on RGB444") << QImage::Format_RGB444 << QImage::Format_RGB444; + + QTest::newRow("RGBA8888P on RGBA8888P") << QImage::Format_RGBA8888_Premultiplied + << QImage::Format_RGBA8888_Premultiplied; + + QTest::newRow("RGBA8888 on RGBA8888") << QImage::Format_RGBA8888 + << QImage::Format_RGBA8888; + + QTest::newRow("RGBx8888 on RGBx8888") << QImage::Format_RGBX8888 + << QImage::Format_RGBX8888; + + QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_RGBA8888_Premultiplied + << QImage::Format_ARGB32_Premultiplied; + + QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_RGBX8888 + << QImage::Format_ARGB32_Premultiplied; + + QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_RGBA8888_Premultiplied; + + QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32 + << QImage::Format_RGBX8888; } void tst_QPainter::setOpacity() diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index ca6c42c9bd..86e282fad2 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -344,8 +344,6 @@ void tst_QCssParser::term_data() val.variant = QVariant(QColor("#ffbb00")); QTest::newRow("hexcolor2") << true << "#fb0" << val; - QTest::newRow("hexcolor_failure") << false << "#cafebabe" << val; - val.type = QCss::Value::Uri; val.variant = QString("www.kde.org"); QTest::newRow("uri1") << true << "url(\"www.kde.org\")" << val; @@ -367,9 +365,6 @@ void tst_QCssParser::term() QFETCH(QString, css); QFETCH(QCss::Value, expectedValue); - if (strcmp(QTest::currentDataTag(), "hexcolor_failure") == 0) - QTest::ignoreMessage(QtWarningMsg, "QCssParser::parseHexColor: Unknown color name '#cafebabe'"); - QCss::Parser parser(css); QCss::Value val; QVERIFY(parser.testTerm()); diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 37868dcfde..6975c4088b 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -2,8 +2,7 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qfontdatabase SOURCES += tst_qfontdatabase.cpp -QT += testlib -!mac: QT += core-private gui-private +QT += testlib core-private gui-private wince* { additionalFiles.files = FreeMono.ttf diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 9cf4082287..104d3465f2 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -44,6 +44,7 @@ #include <qfontdatabase.h> #include <qfontinfo.h> #include <qfontmetrics.h> +#include <qpa/qplatformfontdatabase.h> class tst_QFontDatabase : public QObject { @@ -252,11 +253,8 @@ void tst_QFontDatabase::addAppFont() return; #endif QCOMPARE(fontDbChangedSpy.count(), 1); -// addApplicationFont is supported on Mac, don't skip the test if it breaks. -#ifndef Q_OS_MAC if (id == -1) QSKIP("Skip the test since app fonts are not supported on this system"); -#endif const QStringList addedFamilies = QFontDatabase::applicationFontFamilies(id); QVERIFY(!addedFamilies.isEmpty()); @@ -271,16 +269,9 @@ void tst_QFontDatabase::addAppFont() QVERIFY(QFontDatabase::removeApplicationFont(id)); QCOMPARE(fontDbChangedSpy.count(), 2); -#ifdef Q_OS_MAC - QEXPECT_FAIL("font file", "QTBUG-23062", Continue); -#endif QCOMPARE(db.families(), oldFamilies); } -QT_BEGIN_NAMESPACE -Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); -QT_END_NAMESPACE - void tst_QFontDatabase::aliases() { QFontDatabase db; @@ -290,7 +281,7 @@ void tst_QFontDatabase::aliases() QVERIFY(db.hasFamily(firstFont)); const QString alias = QStringLiteral("AliasToFirstFont") + firstFont; QVERIFY(!db.hasFamily(alias)); - qt_registerAliasToFontFamily(firstFont, alias); + QPlatformFontDatabase::registerAliasToFontFamily(firstFont, alias); QVERIFY(db.hasFamily(alias)); } |