diff options
author | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-08-17 19:55:41 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-08-17 19:55:41 +0200 |
commit | 5a039bf53e88a727cc52bfedb21796ebfade01a1 (patch) | |
tree | abce106bf1cb1042dcacd249152a11343caa0313 /tests/auto | |
parent | dbcf5730ac2d4f61f872e50126d3ce73e3f6031e (diff) | |
parent | 89302b8b88b2bfa9581bb15c1caa052cb6d76988 (diff) |
Merge dev into 5.6
Change-Id: I061f2513ef58f696e75b11928d89aaaf059659a3
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 20 | ||||
-rw-r--r-- | tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 2 | ||||
-rw-r--r-- | tests/auto/dbus/qdbustype/tst_qdbustype.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 19 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp | 16 | ||||
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 64 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp | 93 |
8 files changed, 221 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 0ffac21186..e810f48d6c 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -122,6 +122,7 @@ private slots: void removeFileWhileProcessIsRunning(); void fileWriterProcess(); void switchReadChannels(); + void discardUnwantedOutput(); void setWorkingDirectory(); void setNonExistentWorkingDirectory(); #endif // not Q_OS_WINCE @@ -2228,6 +2229,25 @@ void tst_QProcess::switchReadChannels() } #endif +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::discardUnwantedOutput() +{ + QProcess process; + + process.setProgram("testProcessEcho2/testProcessEcho2"); + process.start(QIODevice::WriteOnly); + process.write("Hello, World"); + process.closeWriteChannel(); + QVERIFY(process.waitForFinished(5000)); + + process.setReadChannel(QProcess::StandardOutput); + QCOMPARE(process.bytesAvailable(), Q_INT64_C(0)); + process.setReadChannel(QProcess::StandardError); + QCOMPARE(process.bytesAvailable(), Q_INT64_C(0)); +} +#endif + //----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index a07247316e..b681f9829a 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -1079,7 +1079,7 @@ static bool canSendUnixFd(DBusConnection *connection) # if DBUS_VERSION-0 >= 0x010400 can_send_type = dbus_connection_can_send_type; # endif -#else +#elif !defined(QT_NO_LIBRARY) // run-time check if the next functions are available can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp index 63444b61ad..4408729e7c 100644 --- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp +++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp @@ -94,7 +94,11 @@ static void addFixedTypes() // the library recognizes this as valid type first. // The following function was added for Unix FD support, so if it is // present, so is support for Unix FDs. +# ifndef QT_NO_LIBRARY bool supportsUnixFds = qdbus_resolve_conditionally("dbus_connection_can_send_type"); +# else + bool supportsUnixFds = false; +# endif # else bool supportsUnixFds = true; # endif diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index b9d17bae62..b81a4e2c4c 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -107,6 +107,7 @@ private slots: void premultiply(); void unpremultiply_sse4(); void qrgba64(); + void qrgba64MemoryLayout(); void qrgba64Premultiply(); void qrgba64Equivalence(); @@ -1495,6 +1496,24 @@ void tst_QColor::qrgba64() QCOMPARE(rgb64.green(), quint16(0x4422)); } +void tst_QColor::qrgba64MemoryLayout() +{ + QRgba64 rgb64 = QRgba64::fromRgba64(0x0123, 0x4567, 0x89ab, 0xcdef); + QCOMPARE(rgb64.red(), quint16(0x0123)); + QCOMPARE(rgb64.green(), quint16(0x4567)); + QCOMPARE(rgb64.blue(), quint16(0x89ab)); + QCOMPARE(rgb64.alpha(), quint16(0xcdef)); + + // Check in-memory order, so it can be used by things like SSE + Q_STATIC_ASSERT(sizeof(QRgba64) == sizeof(quint64)); + quint16 memory[4]; + memcpy(memory, &rgb64, sizeof(QRgba64)); + QCOMPARE(memory[0], quint16(0x0123)); + QCOMPARE(memory[1], quint16(0x4567)); + QCOMPARE(memory[2], quint16(0x89ab)); + QCOMPARE(memory[3], quint16(0xcdef)); +} + void tst_QColor::qrgba64Premultiply() { // Tests that qPremultiply(qUnpremultiply(rgba64)) returns rgba64. diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 3e98e630c2..e8d90edd2d 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -4882,8 +4882,12 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85; QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85; + QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 + << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85; QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85; + QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170; QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp index 3bf59910f3..48a15641b2 100644 --- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -47,6 +47,7 @@ #include <QtCore/QVariant> #include <QtCore/QDebug> #include <QtCore/QTextStream> +#include <QtCore/QJsonDocument> #include <algorithm> @@ -107,6 +108,7 @@ private slots: void testConfiguration(); void testGlConfiguration(); void testBugList(); + void testDefaultWindowsBlacklist(); }; static void dumpConfiguration(QTextStream &str) @@ -284,6 +286,20 @@ void tst_QOpenGlConfig::testBugList() msgSetMismatch(expectedFeatures, actualFeatures)); } +void tst_QOpenGlConfig::testDefaultWindowsBlacklist() +{ + if (qGuiApp->platformName() != QStringLiteral("windows")) + QSKIP("Only applicable to Windows"); + + QFile f(QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json")); + QVERIFY(f.open(QIODevice::ReadOnly | QIODevice::Text)); + QJsonParseError err; + QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err); + QVERIFY2(err.error == 0, + QStringLiteral("Failed to parse built-in Windows GPU blacklist. %1 : %2") + .arg(err.offset).arg(err.errorString()).toLatin1()); +} + QTEST_MAIN(tst_QOpenGlConfig) #include "tst_qopenglconfig.moc" diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 61586eb841..b98ab68ae9 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -241,6 +241,10 @@ private slots: void aggregateFunctionTypes_data() { generic_data(); } void aggregateFunctionTypes(); + + void integralTypesMysql_data() { generic_data("QMYSQL"); } + void integralTypesMysql(); + private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -3974,5 +3978,65 @@ void tst_QSqlQuery::aggregateFunctionTypes() } } +template<typename T> +void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QString &type, const bool withPreparedStatement, + const T min = std::numeric_limits<T>::min(), const T max = std::numeric_limits<T>::max()) +{ + QSqlQuery q(db); + QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName)); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ")")); + + const int steps = 20; + const T increment = max / steps - min / steps; + + // insert some values + QVector<T> values; + values.resize(steps); + T v = min; + if (withPreparedStatement) { + QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (id) VALUES (?)")); + } + for (int i = 0; i < values.size(); ++i) { + if (withPreparedStatement) { + q.bindValue(0, v); + QVERIFY_SQL(q, exec()); + } else { + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + ")")); + } + values[i] = v; + v += increment; + } + + // ensure we can read them back properly + QVERIFY_SQL(q, exec("SELECT id FROM " + tableName)); + QVector<T> actualValues; + actualValues.reserve(values.size()); + while (q.next()) { + actualValues << q.value(0).value<T>(); + } + QCOMPARE(actualValues, values); +} + +void tst_QSqlQuery::integralTypesMysql() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + for (int i = 0; i < 2; ++i) { + const bool withPreparedStatement = (i == 1); + runIntegralTypesMysqlTest<char>(db, "tinyIntTest", "TINYINT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned char>(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<char>(db, "smallIntTest", "SMALLINT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned char>(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<int>(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1); + runIntegralTypesMysqlTest<unsigned int>(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1); + runIntegralTypesMysqlTest<int>(db, "intTest", "INT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned int>(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<long long>(db, "bigIntTest", "BIGINT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned long long>(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement); + } +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index e8c533f301..6282028746 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -149,6 +149,8 @@ private slots: void toggleUnifiedTitleAndToolBarOnMac(); #endif void QTBUG21378_animationFinished(); + void resizeDocks(); + void resizeDocks_data(); }; @@ -1950,5 +1952,96 @@ void tst_QMainWindow::QTBUG21378_animationFinished() delete mwClickTimer; QVERIFY(true); } + +Q_DECLARE_METATYPE(Qt::Orientation) + +void tst_QMainWindow::resizeDocks_data() +{ + QTest::addColumn<Qt::Orientation>("orientation"); + QTest::addColumn<QStringList>("docks"); + QTest::addColumn<QList<int> >("sizes"); + + QTest::newRow("1") << Qt::Horizontal + << (QStringList() << "blue" << "orange" << "green" << "gray") + << (QList<int>() << 190 << 190 << 320 << 160); + + QTest::newRow("2") << Qt::Vertical + << (QStringList() << "yellow" << "orange") + << (QList<int>() << 147 << 133 ); + + + QTest::newRow("3") << Qt::Horizontal + << (QStringList() << "blue" << "yellow") + << (QList<int>() << 190 << 600); +} + +void tst_QMainWindow::resizeDocks() +{ + AddList addList; + addList + << AddDockWidget("blue", Qt::LeftDockWidgetArea) + << AddDockWidget("red", Qt::TopDockWidgetArea) + << AddDockWidget("pink", "red") + << AddDockWidget("yellow", Qt::RightDockWidgetArea) + << AddDockWidget("orange", Qt::RightDockWidgetArea) + << AddDockWidget("green", "orange", Qt::Horizontal) + << AddDockWidget("gray", "orange", Qt::Horizontal); + /* + +--------------------------------+ + | red/pink | + +------+-+-----------------------+ + | | | yellow | + | blue + +--------+------+-------+ + | | | orange | gray | green | + +------+-+--------+------+-------+ + + */ + + QMainWindow mw(0, Qt::BypassWindowManagerHint); + mw.setDockNestingEnabled(true); + mw.resize(1800, 600); + + foreach (const AddDockWidget &i, addList) + i.apply(&mw); + + foreach (QDockWidget *dw, mw.findChildren<QDockWidget *>()) + dw->setStyleSheet( "* { background-color: " + dw->objectName() +" }"); + + mw.setCentralWidget(new QTextEdit); + + mw.show(); + QTest::qWaitForWindowExposed(&mw); + + QFETCH(Qt::Orientation, orientation); + QFETCH(QStringList, docks); + QFETCH(QList<int>, sizes); + + QList<QDockWidget *> list; + foreach (const QString &name, docks) { + QDockWidget *d = mw.findChild<QDockWidget *>(name); + QVERIFY(d); + list << d; + } + + mw.resizeDocks(list, sizes, orientation); + + qApp->processEvents(); + + int totalFromList = 0; + int actualTotal = 0; + for (int i = 0; i < docks.count(); ++i) { + totalFromList += sizes[i]; + QSize s = list[i]->size(); + actualTotal += (orientation == Qt::Horizontal) ? s.width() : s.height(); +// qDebug() << list[i] << list[i]->size() << sizes[i]; + } + + for (int i = 0; i < docks.count(); ++i) { + QSize s = list[i]->size(); + int value = (orientation == Qt::Horizontal) ? s.width() : s.height(); + QCOMPARE(value, qRound(sizes[i]*actualTotal/double(totalFromList))); + } +} + QTEST_MAIN(tst_QMainWindow) #include "tst_qmainwindow.moc" |