diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 42 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qchar/tst_qchar.cpp | 14 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 11 | ||||
-rw-r--r-- | tests/auto/opengl/qgl/tst_qgl.cpp | 4 | ||||
-rw-r--r-- | tests/auto/tools/moc/no-keywords.h | 2 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 14 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 25 |
7 files changed, 106 insertions, 6 deletions
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index fff65a50a4..dab40db0ec 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -142,6 +142,9 @@ private slots: void toDouble_data(); void toDouble(); + void toFloat_data(); + void toFloat(); + void toPointF_data(); void toPointF(); @@ -459,6 +462,9 @@ void tst_QVariant::canConvert_data() var = QVariant::fromValue<signed char>(-1); QTest::newRow("SChar") << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; + var = QVariant::fromValue<QJsonValue>(QJsonValue(QStringLiteral("hello"))); + QTest::newRow("JsonValue") + << var << N << N << Y << N << N << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; #undef N #undef Y @@ -514,6 +520,7 @@ void tst_QVariant::toInt_data() bytearray[2] = '0'; bytearray[3] = '0'; QTest::newRow( "QByteArray2" ) << QVariant( bytearray ) << 4500 << true; + QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << 321 << true; } void tst_QVariant::toInt() @@ -560,6 +567,7 @@ void tst_QVariant::toUInt_data() bytearray[2] = '2'; bytearray[3] = '1'; QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (uint)4321 << true; + QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (uint)321 << true; } void tst_QVariant::toUInt() @@ -745,6 +753,8 @@ void tst_QVariant::toBool_data() QTest::newRow( "ulonglong1" ) << QVariant( (qulonglong)1 ) << true; QTest::newRow( "QChar" ) << QVariant(QChar('a')) << true; QTest::newRow( "Null_QChar" ) << QVariant(QChar(0)) << false; + QTest::newRow("QJsonValue(true)") << QVariant(QJsonValue(true)) << true; + QTest::newRow("QJsonValue(false)") << QVariant(QJsonValue(false)) << false; } void tst_QVariant::toBool() @@ -808,6 +818,7 @@ void tst_QVariant::toDouble_data() bytearray[2] = '.'; bytearray[3] = '1'; QTest::newRow( "bytearray" ) << QVariant( bytearray ) << 32.1 << true; + QTest::newRow("QJsonValue") << QVariant(QJsonValue(32.1)) << 32.1 << true; } void tst_QVariant::toDouble() @@ -823,6 +834,34 @@ void tst_QVariant::toDouble() QVERIFY( ok == valueOK ); } +void tst_QVariant::toFloat_data() +{ + QTest::addColumn<QVariant>("value"); + QTest::addColumn<float>("result"); + QTest::addColumn<bool>("valueOK"); + + QByteArray bytearray(4, ' '); + bytearray[0] = '3'; + bytearray[1] = '2'; + bytearray[2] = '.'; + bytearray[3] = '1'; + QTest::newRow("QByteArray") << QVariant(bytearray) << float(32.1) << true; + QTest::newRow("QJsonValue") << QVariant(QJsonValue(32.1)) << float(32.1) << true; +} + +void tst_QVariant::toFloat() +{ + QFETCH(QVariant, value ); + QFETCH(float, result); + QFETCH(bool, valueOK); + QVERIFY(value.isValid()); + QVERIFY(value.canConvert(QMetaType::Float)); + bool ok; + float d = value.toFloat(&ok); + QCOMPARE(d, result); + QVERIFY(ok == valueOK); +} + void tst_QVariant::toLongLong_data() { QTest::addColumn<QVariant>("value"); @@ -846,6 +885,7 @@ void tst_QVariant::toLongLong_data() bytearray[2] = '0'; bytearray[3] = '0'; QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qlonglong) 3200 << true; + QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qlonglong)321 << true; } void tst_QVariant::toLongLong() @@ -890,6 +930,7 @@ void tst_QVariant::toULongLong_data() bytearray[2] = '0'; bytearray[3] = '1'; QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qulonglong) 3201 << true; + QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qulonglong)321 << true; } void tst_QVariant::toULongLong() @@ -956,6 +997,7 @@ void tst_QVariant::toString_data() QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56.000" ); QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) << QString( "123456789012" ); + QTest::newRow("QJsonValue") << QVariant(QJsonValue(QString("hello"))) << QString("hello"); } void tst_QVariant::toString() diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index c89d553112..2ec85882b8 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -909,6 +909,20 @@ void tst_QChar::normalization_manual() QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed); QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed); } + { + QString composed; + composed += QChar(0x0061); + composed += QChar(0x00f2); + QString decomposed; + decomposed += QChar(0x0061); + decomposed += QChar(0x006f); + decomposed += QChar(0x0300); + + QVERIFY(decomposed.normalized(QString::NormalizationForm_D) == decomposed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_C) == composed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_KD) == decomposed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_KC) == composed); + } { // hangul QString composed; composed += QChar(0xc154); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 29c72cc02e..d34ab069c3 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -176,6 +176,12 @@ void tst_QWindow::positioning() QSKIP("Multiple failures in this test on Mac OS X, see QTBUG-23059"); #endif + + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability( + QPlatformIntegration::NonFullScreenWindows)) { + QSKIP("This platform does not support non-fullscreen windows"); + } + // Some platforms enforce minimum widths for windows, which can cause extra resize // events, so set the width to suitably large value to avoid those. const QSize size = QSize(300, 40); @@ -187,7 +193,8 @@ void tst_QWindow::positioning() QCOMPARE(window.geometry().size(), size); window.setGeometry(geometry); QCOMPARE(window.geometry(), geometry); - window.show(); + // explicitly use non-fullscreen show. show() can be fullscreen on some platforms + window.showNormal(); QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 1); @@ -431,7 +438,7 @@ void tst_QWindow::testInputEvents() { InputTestWindow window; window.setGeometry(80, 80, 40, 40); - window.show(); + window.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyPress, Qt::Key_A, Qt::NoModifier); diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 28ec699427..3fc89acb67 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -1309,14 +1309,17 @@ void tst_QGL::glWidgetReparent() { // Try it as a top-level first: GLWidget *widget = new GLWidget; + widget->setObjectName(QStringLiteral("glWidget1")); widget->setGeometry(0, 0, 200, 30); widget->show(); QWidget grandParentWidget; + grandParentWidget.setObjectName(QStringLiteral("grandParentWidget")); grandParentWidget.setPalette(Qt::blue); QVBoxLayout grandParentLayout(&grandParentWidget); QWidget parentWidget(&grandParentWidget); + parentWidget.setObjectName(QStringLiteral("parentWidget")); grandParentLayout.addWidget(&parentWidget); parentWidget.setPalette(Qt::green); parentWidget.setAutoFillBackground(true); @@ -1348,6 +1351,7 @@ void tst_QGL::glWidgetReparent() // Now do pretty much the same thing, but don't show the // widget first: widget = new GLWidget; + widget->setObjectName(QStringLiteral("glWidget2")); parentLayout.addWidget(widget); QVERIFY(QTest::qWaitForWindowExposed(&grandParentWidget)); diff --git a/tests/auto/tools/moc/no-keywords.h b/tests/auto/tools/moc/no-keywords.h index e04e36b678..ffd5928370 100644 --- a/tests/auto/tools/moc/no-keywords.h +++ b/tests/auto/tools/moc/no-keywords.h @@ -47,7 +47,7 @@ #define slots Baz #define emit Yoyodyne -#include <QtGui/QtGui> +#include <QtConcurrent/QtConcurrent> #include <QtCore> #include <QtNetwork/QtNetwork> #include <QtSql/QtSql> diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 5d7925aeec..268276bd4a 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -1469,7 +1469,15 @@ void tst_QListView::wordWrap() lv.setModel(&model); lv.setWordWrap(true); lv.setFixedSize(150, 150); - lv.show(); +#ifdef Q_OS_BLACKBERRY + // BB standard font size is too big, triggering + // a horizontal scrollbar even when word-wrapping + // is enabled + QFont font = lv.font(); + font.setPointSize(5); + lv.setFont(font); +#endif // Q_OS_BLACKBERRY + lv.showNormal(); QApplication::processEvents(); QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), false); @@ -2013,7 +2021,7 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() w.setMovement(QListView::Static); const int spacing = 40; w.setSpacing(spacing); - w.show(); + w.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&w)); QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); } @@ -2117,7 +2125,7 @@ void tst_QListView::taskQTBUG_21115_scrollToAndHiddenItems() list << QString::number(i); model.setStringList(list); lv.setModel(&model); - lv.show(); + lv.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&lv)); // Save first item rect for reference diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index c6835f6076..c9079e222c 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -783,6 +783,31 @@ void tst_QApplication::quitOnLastWindowClosed() QVERIFY(timerSpy.count() > 15); // Should be around 20 if closing did not caused the quit } + { // QTBUG-31569: If the last widget with Qt::WA_QuitOnClose set is closed, other + // widgets that don't have the attribute set should be closed automatically. + int argc = 0; + QApplication app(argc, 0); + QVERIFY(app.quitOnLastWindowClosed()); + + QWidget w1; + w1.show(); + + QWidget w2; + w2.setAttribute(Qt::WA_QuitOnClose, false); + w2.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&w2)); + + QTimer timer; + timer.setInterval(100); + timer.start(); + QSignalSpy timerSpy(&timer, SIGNAL(timeout())); + + QTimer::singleShot(100, &w1, SLOT(close())); + app.exec(); + + QVERIFY(timerSpy.count() < 10); + } } class PromptOnCloseWidget : public QWidget |