diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-22 09:04:29 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-22 09:25:54 +0200 |
commit | aed5a7168354c6ae47687d20b4bd3f0adcc14f8e (patch) | |
tree | d2060479a7c12fdba8c1955e5d363754feffabb8 /tests/auto/gui | |
parent | d3d10cf23d61f4a011f1a7e9abdee1a92717e80f (diff) | |
parent | 628fa13ea4d6ff0e2e2ee76c9adfc78676de3c59 (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
src/corelib/statemachine/qstatemachine.cpp
src/corelib/statemachine/qstatemachine_p.h
src/gui/painting/qdrawhelper.cpp
src/plugins/platforms/xcb/qxcbnativeinterface.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.h
src/testlib/qtestblacklist.cpp
src/tools/qdoc/node.cpp
src/tools/qdoc/node.h
tests/auto/gui/painting/qcolor/tst_qcolor.cpp
Change-Id: I6c78b7b162001712d5774293f501b06b4ff32684
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 103 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 17 | ||||
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 19 | ||||
-rw-r--r-- | tests/auto/gui/qopenglconfig/buglist.json | 8 | ||||
-rw-r--r-- | tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp | 38 |
5 files changed, 107 insertions, 78 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 660809fb16..525d5b33a0 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -108,6 +108,7 @@ private slots: void cacheKey(); void smoothScale(); + void smoothScale2_data(); void smoothScale2(); void smoothScale3(); @@ -1539,58 +1540,68 @@ void tst_QImage::smoothScale() } // test area sampling -void tst_QImage::smoothScale2() +void tst_QImage::smoothScale2_data() { - int sizes[] = { 2, 4, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 }; - QImage::Format formats[] = { QImage::Format_ARGB32, QImage::Format_RGB32, QImage::Format_Invalid }; - for (int i = 0; sizes[i] != 0; ++i) { - for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) { - int size = sizes[i]; - - QRgb expected = formats[j] == QImage::Format_ARGB32 ? qRgba(63, 127, 255, 255) : qRgb(63, 127, 255); - - QImage img(size, size, formats[j]); - img.fill(expected); + QTest::addColumn<int>("format"); + QTest::addColumn<int>("size"); + + int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 }; + QImage::Format formats[] = { QImage::Format_RGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Invalid }; + for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) { + QString formatstr = formats[j] == QImage::Format_RGB32 ? QStringLiteral("rgb32") : QStringLiteral("argb32pm"); + for (int i = 0; sizes[i] != 0; ++i) { + QTest::newRow(QString("%1 %2x%2").arg(formatstr).arg(sizes[i]).toUtf8()) << (int)formats[j] << sizes[i]; + } + } +} - // scale x down, y down - QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - QRgb pixel = scaled.pixel(0, 0); +void tst_QImage::smoothScale2() +{ + QFETCH(int, format); + QFETCH(int, size); + + QRgb expected = format == QImage::Format_RGB32 ? qRgb(63, 127, 255) : qRgba(31, 63, 127, 127); + + QImage img(size, size, (QImage::Format)format); + img.fill(expected); + + // scale x down, y down + QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + QRgb pixel = scaled.pixel(0, 0); + QCOMPARE(qAlpha(pixel), qAlpha(expected)); + QCOMPARE(qRed(pixel), qRed(expected)); + QCOMPARE(qGreen(pixel), qGreen(expected)); + QCOMPARE(qBlue(pixel), qBlue(expected)); + + // scale x down, y up + scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + for (int y = 0; y < scaled.height(); ++y) { + pixel = scaled.pixel(0, y); + QCOMPARE(qAlpha(pixel), qAlpha(expected)); + QCOMPARE(qRed(pixel), qRed(expected)); + QCOMPARE(qGreen(pixel), qGreen(expected)); + QCOMPARE(qBlue(pixel), qBlue(expected)); + } + + // scale x up, y down + scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + for (int x = 0; x < scaled.width(); ++x) { + pixel = scaled.pixel(x, 0); + QCOMPARE(qAlpha(pixel), qAlpha(expected)); + QCOMPARE(qRed(pixel), qRed(expected)); + QCOMPARE(qGreen(pixel), qGreen(expected)); + QCOMPARE(qBlue(pixel), qBlue(expected)); + } + + // scale x up, y up + scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + for (int y = 0; y < scaled.height(); ++y) { + for (int x = 0; x < scaled.width(); ++x) { + pixel = scaled.pixel(x, y); QCOMPARE(qAlpha(pixel), qAlpha(expected)); QCOMPARE(qRed(pixel), qRed(expected)); QCOMPARE(qGreen(pixel), qGreen(expected)); QCOMPARE(qBlue(pixel), qBlue(expected)); - - // scale x down, y up - scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - for (int y = 0; y < scaled.height(); ++y) { - pixel = scaled.pixel(0, y); - QCOMPARE(qAlpha(pixel), qAlpha(expected)); - QCOMPARE(qRed(pixel), qRed(expected)); - QCOMPARE(qGreen(pixel), qGreen(expected)); - QCOMPARE(qBlue(pixel), qBlue(expected)); - } - - // scale x up, y down - scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - for (int x = 0; x < scaled.width(); ++x) { - pixel = scaled.pixel(x, 0); - QCOMPARE(qAlpha(pixel), qAlpha(expected)); - QCOMPARE(qRed(pixel), qRed(expected)); - QCOMPARE(qGreen(pixel), qGreen(expected)); - QCOMPARE(qBlue(pixel), qBlue(expected)); - } - - // scale x up, y up - scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - for (int y = 0; y < scaled.height(); ++y) { - for (int x = 0; x < scaled.width(); ++x) { - pixel = scaled.pixel(x, y); - QCOMPARE(qAlpha(pixel), qAlpha(expected)); - QCOMPARE(qRed(pixel), qRed(expected)); - QCOMPARE(qGreen(pixel), qGreen(expected)); - QCOMPARE(qBlue(pixel), qBlue(expected)); - } - } } } } diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index b921e1519f..19365bffdd 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -76,6 +76,7 @@ private slots: void genericPluginsAndWindowSystemEvents(); void layoutDirection(); void globalShareContext(); + void testSetPaletteAttribute(); void staticFunctions(); @@ -968,6 +969,22 @@ void tst_QGuiApplication::globalShareContext() #endif } +void tst_QGuiApplication::testSetPaletteAttribute() +{ + QCoreApplication::setAttribute(Qt::AA_SetPalette, false); + int argc = 1; + char *argv[] = { const_cast<char*>("tst_qguiapplication") }; + + QGuiApplication app(argc, argv); + + QVERIFY(!QCoreApplication::testAttribute(Qt::AA_SetPalette)); + QPalette palette; + palette.setColor(QPalette::Foreground, Qt::red); + QGuiApplication::setPalette(palette); + + QVERIFY(QCoreApplication::testAttribute(Qt::AA_SetPalette)); +} + // Test that static functions do not crash if there is no application instance. void tst_QGuiApplication::staticFunctions() { diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 7d17794c0b..ca9f6cb9f4 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -39,7 +39,6 @@ #include <qcolor.h> #include <qdebug.h> #include <qrgba64.h> -#include <private/qdrawingprimitive_sse2_p.h> class tst_QColor : public QObject { @@ -105,7 +104,6 @@ private slots: void achromaticHslHue(); void premultiply(); - void unpremultiply_sse4(); void qrgba64(); void qrgba64Premultiply(); void qrgba64Equivalence(); @@ -1451,23 +1449,6 @@ void tst_QColor::premultiply() } } -void tst_QColor::unpremultiply_sse4() -{ - // Tests that qUnpremultiply_sse4 returns the same as qUnpremultiply. -#if QT_COMPILER_SUPPORTS_HERE(SSE4_1) - if (qCpuHasFeature(SSE4_1)) { - for (uint a = 0; a < 256; a++) { - for (uint c = 0; c <= a; c++) { - QRgb p = qRgba(c, a-c, c, a); - QCOMPARE(qUnpremultiply_sse4(p), qUnpremultiply(p)); - } - } - return; - } -#endif - QSKIP("SSE4 not supported on this CPU."); -} - void tst_QColor::qrgba64() { QRgba64 rgb64 = QRgba64::fromRgba(0x22, 0x33, 0x44, 0xff); diff --git a/tests/auto/gui/qopenglconfig/buglist.json b/tests/auto/gui/qopenglconfig/buglist.json index d2d06645aa..c7b8e61bc8 100644 --- a/tests/auto/gui/qopenglconfig/buglist.json +++ b/tests/auto/gui/qopenglconfig/buglist.json @@ -101,6 +101,14 @@ "features": [ "feature1" ] + }, + { + "id": 128, + "description": "check for matching GL_VENDOR", + "gl_vendor": "The Qt Company", + "features": [ + "cool_feature" + ] } ] } diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp index bfb2623508..f88cbdc758 100644 --- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -217,6 +217,11 @@ void tst_QOpenGlConfig::testGlConfiguration() context.doneCurrent(); qDebug().noquote() << '\n' << result; + + // fromContext either uses the current context or creates a temporary dummy one. + QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromContext(); + qDebug().noquote() << '\n' << "GL_VENDOR queried by QOpenGLConfig::Gpu:" << gpu.glVendor; + QVERIFY(!gpu.glVendor.isEmpty()); } static inline QByteArray msgSetMismatch(const QSet<QString> &expected, @@ -235,21 +240,28 @@ void tst_QOpenGlConfig::testBugList() const QString fileName = QFINDTESTDATA("buglist.json"); QVERIFY(!fileName.isEmpty()); - QSet<QString> expectedFeatures; - expectedFeatures << "feature1"; + QSet<QString> expectedFeatures; + expectedFeatures << "feature1"; - QOpenGLConfig::Gpu gpu; - gpu.vendorId = 0x10DE; - gpu.deviceId = 0x0DE9; + QVersionNumber driverVersion(QVector<int>() << 9 << 18 << 13 << 4460); + QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromDevice(0x10DE, 0x0DE9, driverVersion); -#ifdef Q_COMPILER_INITIALIZER_LISTS - gpu.driverVersion = QVersionNumber({9, 18, 13, 4460}); -#else - gpu.driverVersion = QVersionNumber(QVector<int>() << 9 << 18 << 13 << 4460); -#endif - const QSet<QString> actualFeatures = - QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"), - QVersionNumber(6, 3), fileName); + QSet<QString> actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"), + QVersionNumber(6, 3), fileName); + QVERIFY2(expectedFeatures == actualFeatures, + msgSetMismatch(expectedFeatures, actualFeatures)); + + gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("Somebody Else")); + expectedFeatures.clear(); + actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"), + QVersionNumber(1, 0), fileName); + QVERIFY2(expectedFeatures == actualFeatures, + msgSetMismatch(expectedFeatures, actualFeatures)); + + gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("The Qt Company")); + expectedFeatures = QSet<QString>() << "cool_feature"; + actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"), + QVersionNumber(1, 0), fileName); QVERIFY2(expectedFeatures == actualFeatures, msgSetMismatch(expectedFeatures, actualFeatures)); } |