diff options
Diffstat (limited to 'tests')
11 files changed, 195 insertions, 43 deletions
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index 1afcf05135..004ace4e2e 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -32,14 +32,18 @@ ****************************************************************************/ #include <QtTest/QtTest> - #include <QStorageInfo> +#include <stdarg.h> + +#include "../../../../manual/qstorageinfo/printvolumes.cpp" + class tst_QStorageInfo : public QObject { Q_OBJECT private slots: void defaultValues(); + void dump(); void operatorEqual(); #ifndef Q_OS_WINRT void operatorNotEqual(); @@ -66,6 +70,33 @@ void tst_QStorageInfo::defaultValues() QVERIFY(storage.bytesAvailable() == -1); } +static int qInfoPrinter(const char *format, ...) +{ + static char buf[1024]; + static size_t bufuse = 0; + + va_list ap; + va_start(ap, format); // use variable arg list + int n = qvsnprintf(buf + bufuse, sizeof(buf) - bufuse, format, ap); + va_end(ap); + + bufuse += n; + if (bufuse >= sizeof(buf) - 1 || format[strlen(format) - 1] == '\n') { + // flush + QtMessageHandler qt_message_print = qInstallMessageHandler(0); + qInstallMessageHandler(qt_message_print); // restore the handler + qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf)); + bufuse = 0; + } + + return 1; +} + +void tst_QStorageInfo::dump() +{ + printVolumes(QStorageInfo::mountedVolumes(), qInfoPrinter); +} + void tst_QStorageInfo::operatorEqual() { { diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index f2f3baae6b..76230ccec8 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -4629,6 +4629,16 @@ template<typename Enum> void testVariant(Enum value, bool *ok) QVERIFY(var2.convert(QMetaType::Int)); QCOMPARE(var2.value<int>(), static_cast<int>(value)); + if (static_cast<qint64>(value) <= INT_MAX) { + int intValue = static_cast<int>(value); + QVariant intVar = intValue; + QVERIFY(intVar.canConvert<Enum>()); + QCOMPARE(intVar.value<Enum>(), value); + } + qint64 longValue = static_cast<qint64>(value); + QVERIFY(QVariant(longValue).canConvert<Enum>()); + QCOMPARE(QVariant(longValue).value<Enum>(), value); + *ok = true; } diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 026a2a2722..90a6aa5811 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -52,6 +52,8 @@ private Q_SLOTS: void ntlmAuth_data(); void ntlmAuth(); + + void equalityOperators(); }; tst_QAuthenticator::tst_QAuthenticator() @@ -152,6 +154,20 @@ void tst_QAuthenticator::ntlmAuth() QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); } +void tst_QAuthenticator::equalityOperators() +{ + QAuthenticator s1, s2; + QVERIFY(s2 == s1); + QVERIFY(s1 == s2); + QVERIFY(!(s1 != s2)); + QVERIFY(!(s2 != s1)); + s1.setUser("User"); + QVERIFY(!(s2 == s1)); + QVERIFY(!(s1 == s2)); + QVERIFY(s1 != s2); + QVERIFY(s2 != s1); +} + QTEST_MAIN(tst_QAuthenticator); #include "tst_qauthenticator.moc" diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index fb8455e6d3..3e936aebf6 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -6,15 +6,3 @@ osx osx [multicast:same bind, group ipv4 address] osx -[writeDatagramToNonExistingPeer] -windows -[asyncReadDatagram] -windows -[multicastLeaveAfterClose] -osx -[readyRead] -osx -[readyReadForEmptyDatagram] -osx -[asyncReadDatagram] -osx diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index e4812416dc..8ad16c652d 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -22,3 +22,5 @@ wince* { } TARGET = tst_qudpsocket + +CONFIG+=insignificant_test # QTBUG-25367, QTBUG-25368 diff --git a/tests/auto/tools/moc/backslash-newlines.h b/tests/auto/tools/moc/backslash-newlines.h index fea3045eb1..764d8f87da 100644 --- a/tests/auto/tools/moc/backslash-newlines.h +++ b/tests/auto/tools/moc/backslash-newlines.h @@ -57,3 +57,5 @@ public slots: #undef value #endif // BACKSLASH_NEWLINES_H + +// ends with \\\r should not make moc crash (QTBUG-53441) (no new lines on purpose!!) \
\ No newline at end of file diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 796b4b9fdb..9aacd3105e 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -193,11 +193,14 @@ void tst_QFontDialog::task256466_wrongStyle() for (int i = 0; i < familyList->model()->rowCount(); ++i) { QModelIndex currentFamily = familyList->model()->index(i, 0); familyList->setCurrentIndex(currentFamily); + int expectedSize = sizeList->currentIndex().data().toInt(); const QFont current = dialog.currentFont(), expected = fdb.font(currentFamily.data().toString(), - styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt()); + styleList->currentIndex().data().toString(), expectedSize); QCOMPARE(current.family(), expected.family()); QCOMPARE(current.style(), expected.style()); + if (expectedSize == 0 && !QFontDatabase().isScalable(current.family(), current.styleName())) + QEXPECT_FAIL("", "QTBUG-53299: Smooth sizes for unscalable font contains unsupported size", Continue); QCOMPARE(current.pointSizeF(), expected.pointSizeF()); } } diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index d8a8ed6b4b..ea2599fcf9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3682,16 +3682,19 @@ static QByteArray msgPointMismatch(const QPoint &actual, const QPoint &expected) void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 { const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); - const QSize size = availableGeometry.size() / 5; + const QSize size = availableGeometry.size() / 4; QGraphicsScene scene; QGraphicsView view(&scene); + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setTransform(QTransform::fromScale(2, 2)); // QTBUG-50136, use transform. view.setWindowTitle(QTest::currentTestFunction()); view.resize(size); view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100)); - QWidget *embeddedWidget = new QWidget; - embeddedWidget->setFixedSize(size / 2); - QWidget *childWidget = new QWidget(embeddedWidget); + QWidget *embeddedWidget = new QGroupBox(QLatin1String("Embedded")); + embeddedWidget->setStyleSheet(QLatin1String("background-color: \"yellow\"; ")); + embeddedWidget->setFixedSize((size - QSize(10, 10)) / 2); + QWidget *childWidget = new QGroupBox(QLatin1String("Child"), embeddedWidget); childWidget->setStyleSheet(QLatin1String("background-color: \"red\"; ")); childWidget->resize(embeddedWidget->size() / 2); childWidget->move(embeddedWidget->width() / 4, embeddedWidget->height() / 4); // center in embeddedWidget @@ -3705,18 +3708,16 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 // This should be equivalent to the view center give or take rounding // errors due to odd window margins const QPoint viewCenter = view.geometry().center(); - QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2, + QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 3, msgPointMismatch(embeddedCenterGlobal, viewCenter).constData()); - // Same test with child centered on embeddedWidget. The correct - // mapping is not implemented yet, but at least make sure + // Same test with child centered on embeddedWidget. Also make sure // the roundtrip maptoGlobal()/mapFromGlobal() returns the same // point since that is important for mouse event handling (QTBUG-50030, // QTBUG-50136). const QPoint childCenter = childWidget->rect().center(); const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter); QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter); - QEXPECT_FAIL("", "Not implemented for child widgets of embedded widgets", Continue); QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4, msgPointMismatch(childCenterGlobal, viewCenter).constData()); } diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index f787d73a02..b2d15fffef 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -132,10 +132,12 @@ private slots: void closeOnSecondClickAndOpenOnThirdClick(); void cornerWidgets_data(); void cornerWidgets(); + void taskQTBUG53205_crashReparentNested(); protected slots: void onSimpleActivated( QAction*); void onComplexActionTriggered(); + void slotForTaskQTBUG53205(); private: TestMenu initSimpleMenuBar(QMenuBar *mb); @@ -148,6 +150,7 @@ private: QAction* m_lastSimpleAcceleratorId; int m_simpleActivatedCount; int m_complexTriggerCount[int('k')]; + QMenuBar* taskQTBUG53205MenuBar; }; // Testing get/set functions @@ -1438,5 +1441,61 @@ void tst_QMenuBar::cornerWidgets() delete cornerLabel; } + +void tst_QMenuBar::taskQTBUG53205_crashReparentNested() +{ + // This test was largely inspired by the test case submitted for the bug + QMainWindow mainWindow; + mainWindow.resize(300, 200); + centerOnScreen(&mainWindow); + const TestMenu testMenus = initWindowWithComplexMenuBar(mainWindow); + QApplication::setActiveWindow(&mainWindow); + + // they can't be windows + QWidget hiddenParent(&mainWindow, 0); + //this one is going to be moved around + QWidget movingParent(&hiddenParent, 0); + + //set up the container widget + QWidget containerWidget(&movingParent,0); + + //set the new parent, a window + QScopedPointer<QWidget> windowedParent; + windowedParent.reset(new QWidget(Q_NULLPTR, Qt::WindowFlags())); + windowedParent->setGeometry(400, 10, 300, 300); + + windowedParent->show(); + QVERIFY(QTest::qWaitForWindowExposed(windowedParent.data())); + + //set the "container", can't be a window + QWidget containedWidget(&containerWidget, 0); + + taskQTBUG53205MenuBar = new QMenuBar(&containedWidget); + + connect(testMenus.actions[0], &QAction::triggered, this, &tst_QMenuBar::slotForTaskQTBUG53205); + //now, move things around + //from : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar + //to windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar + movingParent.setParent(windowedParent.data(),0); + // this resets the parenting and the menu bar's window + taskQTBUG53205MenuBar->setParent(Q_NULLPTR); + taskQTBUG53205MenuBar->setParent(&containedWidget); + //from windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar + //to : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar + movingParent.setParent(&hiddenParent,0); + windowedParent.reset(); //make the old window invalid + // trigger the aciton, reset the menu bar's window, this used to crash here. + testMenus.actions[0]->trigger(); +} + +void tst_QMenuBar::slotForTaskQTBUG53205() +{ + QWidget *parent = taskQTBUG53205MenuBar->parentWidget(); + taskQTBUG53205MenuBar->setParent(Q_NULLPTR); + taskQTBUG53205MenuBar->setParent(parent); +} + + + QTEST_MAIN(tst_QMenuBar) #include "tst_qmenubar.moc" diff --git a/tests/manual/qstorageinfo/main.cpp b/tests/manual/qstorageinfo/main.cpp index 5c106ff45b..61cdd55922 100644 --- a/tests/manual/qstorageinfo/main.cpp +++ b/tests/manual/qstorageinfo/main.cpp @@ -32,10 +32,11 @@ ****************************************************************************/ #include <QtCore/QCoreApplication> -#include <QtCore/QStorageInfo> #include <stdio.h> +#include "printvolumes.cpp" + int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); @@ -57,26 +58,7 @@ int main(int argc, char *argv[]) if (volumes.isEmpty()) volumes = QStorageInfo::mountedVolumes(); - // Sample output: - // Filesystem (Type) Size Available BSize Label Mounted on - // /dev/sda2 (ext4) RO 388480 171218 1024 /boot - // /dev/mapper/system-root (btrfs) RW - // 214958080 39088272 4096 / - // /dev/disk1s2 (hfs) RW 488050672 419909696 4096 Macintosh HD2 /Volumes/Macintosh HD2 - - printf("Filesystem (Type) Size Available BSize Label Mounted on\n"); - foreach (const QStorageInfo &info, volumes) { - QByteArray fsAndType = info.device(); - if (info.fileSystemType() != fsAndType) - fsAndType += " (" + info.fileSystemType() + ')'; - - printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W'); - if (fsAndType.size() > 19) - printf("\n%23s", ""); - - printf("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize()); - printf("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath())); - } + printVolumes(volumes, printf); return 0; } diff --git a/tests/manual/qstorageinfo/printvolumes.cpp b/tests/manual/qstorageinfo/printvolumes.cpp new file mode 100644 index 0000000000..1b1660b433 --- /dev/null +++ b/tests/manual/qstorageinfo/printvolumes.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QStorageInfo> + +void printVolumes(const QList<QStorageInfo> &volumes, int (*printer)(const char *, ...)) +{ + // Sample output: + // Filesystem (Type) Size Available BSize Label Mounted on + // /dev/sda2 (ext4) RO 388480 171218 1024 /boot + // /dev/mapper/system-root (btrfs) RW + // 214958080 39088272 4096 / + // /dev/disk1s2 (hfs) RW 488050672 419909696 4096 Macintosh HD2 /Volumes/Macintosh HD2 + + printf("Filesystem (Type) Size Available BSize Label Mounted on\n"); + foreach (const QStorageInfo &info, volumes) { + QByteArray fsAndType = info.device(); + if (info.fileSystemType() != fsAndType) + fsAndType += " (" + info.fileSystemType() + ')'; + + printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W'); + if (fsAndType.size() > 19) + printf("\n%23s", ""); + + printf("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize()); + printf("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath())); + } +} |