diff options
Diffstat (limited to 'tests/auto/other')
9 files changed, 289 insertions, 40 deletions
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 9abe9a77c0..c1d39d8b72 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -106,7 +106,7 @@ public: QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event) { if (event->type() == CustomEvent::EventType) { - QGestureRecognizer::Result result = 0; + QGestureRecognizer::Result result; if (CustomGestureRecognizer::ConsumeEvents) result |= QGestureRecognizer::ConsumeEventHint; CustomGesture *g = static_cast<CustomGesture*>(state); @@ -2200,41 +2200,41 @@ void tst_Gestures::testReuseCanceledGestures() targetPos = gv->viewport()->mapFromParent(targetPos); // "Tap" starts on child widget - QTest::mousePress(gv->viewport(), Qt::LeftButton, 0, targetPos); + QTest::mousePress(gv->viewport(), Qt::LeftButton, { }, targetPos); QCOMPARE(target->started(), 1); QCOMPARE(target->updated(), 0); QCOMPARE(target->finished(), 0); QCOMPARE(target->canceled(), 0); // Canceling gesture starts on parent - QTest::mousePress(gv->viewport(), Qt::RightButton, 0, targetPos); + QTest::mousePress(gv->viewport(), Qt::RightButton, { }, targetPos); QCOMPARE(target->started(), 1); QCOMPARE(target->updated(), 0); QCOMPARE(target->finished(), 0); QCOMPARE(target->canceled(), 1); // <- child canceled // Canceling gesture ends - QTest::mouseRelease(gv->viewport(), Qt::RightButton, 0, targetPos); + QTest::mouseRelease(gv->viewport(), Qt::RightButton, { }, targetPos); QCOMPARE(target->started(), 1); QCOMPARE(target->updated(), 0); QCOMPARE(target->finished(), 0); QCOMPARE(target->canceled(), 1); // Tap would end if not canceled - QTest::mouseRelease(gv->viewport(), Qt::LeftButton, 0, targetPos); + QTest::mouseRelease(gv->viewport(), Qt::LeftButton, { }, targetPos); QCOMPARE(target->started(), 1); QCOMPARE(target->updated(), 0); QCOMPARE(target->finished(), 0); QCOMPARE(target->canceled(), 1); // New "Tap" starts - QTest::mousePress(gv->viewport(), Qt::LeftButton, 0, targetPos); + QTest::mousePress(gv->viewport(), Qt::LeftButton, { }, targetPos); QCOMPARE(target->started(), 2); QCOMPARE(target->updated(), 0); QCOMPARE(target->finished(), 0); QCOMPARE(target->canceled(), 1); - QTest::mouseRelease(gv->viewport(), Qt::LeftButton, 0, targetPos); + QTest::mouseRelease(gv->viewport(), Qt::LeftButton, { }, targetPos); QCOMPARE(target->started(), 2); QCOMPARE(target->updated(), 0); QCOMPARE(target->finished(), 1); diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 215a4c2a29..7430c93a8e 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -230,9 +230,9 @@ void PaintCommands::staticInit() "begin_block <blockName>", "begin_block blockName"); DECL_PAINTCOMMAND("end_block", command_end_block, - "^end_block$", - "end_block", - "end_block"); + "^end_block\\s*(\\w*)$", + "end_block [blockName]", + "end_block blockName"); DECL_PAINTCOMMAND("repeat_block", command_repeat_block, "^repeat_block\\s+(\\w*)$", "repeat_block <blockName>", @@ -744,6 +744,13 @@ void PaintCommands::runCommands() if (height <= 0) height = 800; + m_pathMap.clear(); + m_imageMap.clear(); + m_pixmapMap.clear(); + m_regionMap.clear(); + m_gradientStops.clear(); + m_blockMap.clear(); + // paint background if (m_checkers_background) { QPixmap pm(20, 20); @@ -901,6 +908,8 @@ void PaintCommands::command_begin_block(QRegularExpressionMatch re) const QString &blockName = re.captured(1); if (m_verboseMode) printf(" -(lance) begin_block (%s)\n", qPrintable(blockName)); + if (m_blockMap.contains(blockName)) + qFatal("Two blocks named (%s)", qPrintable(blockName)); m_commands[m_currentCommandIndex] = QLatin1String("# begin block (") + blockName + QLatin1Char(')'); QStringList newBlock; diff --git a/tests/auto/other/lancelot/scripts/filltest.qps b/tests/auto/other/lancelot/scripts/filltest.qps index 2eeba2ecf6..112ffc85be 100644 --- a/tests/auto/other/lancelot/scripts/filltest.qps +++ b/tests/auto/other/lancelot/scripts/filltest.qps @@ -133,7 +133,7 @@ setPen nopen translate 50 0 -begin_block rects +begin_block rects2 drawPath rect drawRect 0 20 10 10 drawImage img 0 40 @@ -154,59 +154,59 @@ translate 10 20 rotate 90 drawRect 0 0 10 10 restore -end_block rects +end_block rects2 setPen red drawText -5 -10 "0.0" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.1" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.2" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.3" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.4" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.5" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.6" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.7" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.8" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "0.9" setPen nopen translate 40 0.1 -repeat_block rects +repeat_block rects2 setPen red drawText -5 -10 "1.0" setPen nopen @@ -410,4 +410,4 @@ drawText 0 0 "outline/fill consistency" setPen red setBrush green translate 80 -30 -drawPolygon [13.6965 -99.1837 -71.4767 13.823 32.4596 -33.1847]
\ No newline at end of file +drawPolygon [13.6965 -99.1837 -71.4767 13.823 32.4596 -33.1847] diff --git a/tests/auto/other/lancelot/scripts/perspectives2.qps b/tests/auto/other/lancelot/scripts/perspectives2.qps index 2f6d1d653c..6762e21af4 100644 --- a/tests/auto/other/lancelot/scripts/perspectives2.qps +++ b/tests/auto/other/lancelot/scripts/perspectives2.qps @@ -8,7 +8,7 @@ image_convertToFormat zebra_png zebra ARGB32_Premultiplied translate 75 100 # standard draw -begin_block row +begin_block row1 drawImage zebra -50 -50 translate 90 0 @@ -136,12 +136,12 @@ save rotate_y 180 drawImage zebra -50 -50 restore -end_block +end_block row1 resetMatrix translate 75 280 setRenderHint SmoothPixmapTransform -repeat_block row +repeat_block row1 resetMatrix setPen black @@ -162,7 +162,7 @@ setRenderHint SmoothPixmapTransform false translate 75 100 # standard draw -begin_block row +begin_block row2 drawImage dome -50 -50 translate 90 0 @@ -290,13 +290,13 @@ save rotate_y 180 drawImage dome -50 -50 restore -end_block +end_block row2 resetMatrix translate 0 400 translate 75 280 setRenderHint SmoothPixmapTransform -repeat_block row +repeat_block row2 resetMatrix setPen black @@ -306,4 +306,4 @@ drawText 0 0 "Fast Pixmap Transform" resetMatrix translate 0 400 translate 300 210 -drawText 0 0 "Smooth Pixmap Transform"
\ No newline at end of file +drawText 0 0 "Smooth Pixmap Transform" diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 1b125d8825..0f50718328 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -302,7 +302,7 @@ static void netChat(int port, const QList<Chat> &chat) if (it + 1 != chat.constEnd()) break; - // fall through: + Q_FALLTHROUGH(); case Chat::RemoteDisconnect: case Chat::DiscardUntilDisconnect: qDebug() << i << "Waiting for remote disconnect"; @@ -428,7 +428,7 @@ void tst_NetworkSelfTest::serverReachability() QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); - QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError, + QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError, QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); } @@ -458,7 +458,7 @@ void tst_NetworkSelfTest::remotePortsOpen() socket.connectToHost(QtNetworkSettings::serverName(), portNumber); if (!socket.waitForConnected(10000)) { - if (socket.error() == QAbstractSocket::SocketTimeoutError) + if (socket.socketError() == QAbstractSocket::SocketTimeoutError) QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit()); else QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit()); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 82dc826db2..ed38976d94 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -243,6 +243,7 @@ private slots: void accelerators(); #endif void bridgeTest(); + void focusChild(); protected slots: void onClicked(); @@ -316,7 +317,7 @@ void tst_QAccessibility::eventTest() QVERIFY(QTestAccessibility::containsEvent(&showEvent)); button->setFocus(Qt::MouseFocusReason); QTestAccessibility::clearEvents(); - QTest::mouseClick(button, Qt::LeftButton, 0); + QTest::mouseClick(button, Qt::LeftButton, { }); button->setAccessibleName("Olaf the second"); QAccessibleEvent nameEvent(button, QAccessible::NameChanged); @@ -2843,14 +2844,14 @@ void tst_QAccessibility::listTest() QTestAccessibility::clearEvents(); // Check for events - QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(1)).center()); + QTest::mouseClick(listView->viewport(), Qt::LeftButton, { }, listView->visualItemRect(listView->item(1)).center()); QAccessibleEvent selectionEvent(listView, QAccessible::SelectionAdd); selectionEvent.setChild(1); QAccessibleEvent focusEvent(listView, QAccessible::Focus); focusEvent.setChild(1); QVERIFY(QTestAccessibility::containsEvent(&selectionEvent)); QVERIFY(QTestAccessibility::containsEvent(&focusEvent)); - QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(2)).center()); + QTest::mouseClick(listView->viewport(), Qt::LeftButton, { }, listView->visualItemRect(listView->item(2)).center()); QAccessibleEvent selectionEvent2(listView, QAccessible::SelectionAdd); selectionEvent2.setChild(2); @@ -3931,5 +3932,173 @@ void tst_QAccessibility::bridgeTest() #endif } +class FocusChildTestAccessibleInterface : public QAccessibleInterface +{ +public: + FocusChildTestAccessibleInterface(int index, bool focus, QAccessibleInterface *parent) + : m_parent(parent) + , m_index(index) + , m_focus(focus) + { + QAccessible::registerAccessibleInterface(this); + } + + bool isValid() const override { return true; } + QObject *object() const override { return nullptr; } + QAccessibleInterface *childAt(int, int) const override { return nullptr; } + QAccessibleInterface *parent() const override { return m_parent; } + QAccessibleInterface *child(int) const override { return nullptr; } + int childCount() const override { return 0; } + int indexOfChild(const QAccessibleInterface *) const override { return -1; } + QString text(QAccessible::Text) const override { return QStringLiteral("FocusChildTestAccessibleInterface %1").arg(m_index); } + void setText(QAccessible::Text, const QString &) override { } + QRect rect() const override { return QRect(); } + QAccessible::Role role() const override { return QAccessible::StaticText; } + + QAccessible::State state() const override + { + QAccessible::State s; + s.focused = m_focus; + return s; + } + +private: + QAccessibleInterface *m_parent; + int m_index; + bool m_focus; +}; + +class FocusChildTestAccessibleWidget : public QAccessibleWidget +{ +public: + static QAccessibleInterface *ifaceFactory(const QString &key, QObject *o) + { + if (key == "QtTestAccessibleWidget") + return new FocusChildTestAccessibleWidget(static_cast<QtTestAccessibleWidget *>(o)); + return 0; + } + + FocusChildTestAccessibleWidget(QtTestAccessibleWidget *w) + : QAccessibleWidget(w) + { + m_children.push_back(new FocusChildTestAccessibleInterface(0, false, this)); + m_children.push_back(new FocusChildTestAccessibleInterface(1, true, this)); + m_children.push_back(new FocusChildTestAccessibleInterface(2, false, this)); + } + + QAccessible::State state() const override + { + QAccessible::State s = QAccessibleWidget::state(); + s.focused = false; + return s; + } + + QAccessibleInterface *focusChild() const override + { + for (int i = 0; i < childCount(); ++i) { + if (child(i)->state().focused) + return child(i); + } + + return nullptr; + } + + QAccessibleInterface *child(int index) const override + { + return m_children[index]; + } + + int childCount() const override + { + return m_children.size(); + } + +private: + QVector<QAccessibleInterface *> m_children; +}; + +void tst_QAccessibility::focusChild() +{ + { + QMainWindow mainWindow; + QtTestAccessibleWidget *widget1 = new QtTestAccessibleWidget(0, "Widget1"); + QAccessibleInterface *iface1 = QAccessible::queryAccessibleInterface(widget1); + QtTestAccessibleWidget *widget2 = new QtTestAccessibleWidget(0, "Widget2"); + QAccessibleInterface *iface2 = QAccessible::queryAccessibleInterface(widget2); + + QWidget *centralWidget = new QWidget; + QHBoxLayout *centralLayout = new QHBoxLayout; + centralWidget->setLayout(centralLayout); + mainWindow.setCentralWidget(centralWidget); + centralLayout->addWidget(widget1); + centralLayout->addWidget(widget2); + + mainWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); + + // widget1 has not been focused yet -> it has no active focus nor focus widget. + QVERIFY(!iface1->focusChild()); + + // widget1 is focused -> it has active focus and focus widget. + widget1->setFocus(); + QCOMPARE(iface1->focusChild(), iface1); + QCOMPARE(QAccessible::queryAccessibleInterface(&mainWindow)->focusChild(), iface1); + + // widget1 lose focus -> it has no active focus but has focus widget what is itself. + // In this case, the focus child of widget1's interface is itself and the focusChild() call + // should not run into an infinite recursion. + widget2->setFocus(); + QCOMPARE(iface1->focusChild(), iface1); + QCOMPARE(iface2->focusChild(), iface2); + QCOMPARE(QAccessible::queryAccessibleInterface(&mainWindow)->focusChild(), iface2); + + delete widget1; + delete widget2; + delete centralWidget; + QTestAccessibility::clearEvents(); + } + + { + QMainWindow mainWindow; + QAccessible::installFactory(&FocusChildTestAccessibleWidget::ifaceFactory); + QtTestAccessibleWidget *widget = new QtTestAccessibleWidget(0, "FocusChildTestWidget"); + mainWindow.setCentralWidget(widget); + mainWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); + + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&mainWindow); + QVERIFY(!iface->focusChild()); + widget->setFocus(); + QCOMPARE(iface->focusChild(), QAccessible::queryAccessibleInterface(widget)->child(1)); + + delete widget; + QAccessible::removeFactory(FocusChildTestAccessibleWidget::ifaceFactory); + QTestAccessibility::clearEvents(); + } + + { + QMainWindow mainWindow; + QTabBar *tabBar = new QTabBar(); + tabBar->insertTab(0, "First tab"); + tabBar->insertTab(1, "Second tab"); + tabBar->insertTab(2, "Third tab"); + mainWindow.setCentralWidget(tabBar); + mainWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); + + tabBar->setFocus(); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&mainWindow); + QCOMPARE(iface->focusChild()->text(QAccessible::Name), QStringLiteral("First tab")); + QCOMPARE(iface->focusChild()->role(), QAccessible::PageTab); + tabBar->setCurrentIndex(1); + QCOMPARE(iface->focusChild()->text(QAccessible::Name), QStringLiteral("Second tab")); + QCOMPARE(iface->focusChild()->role(), QAccessible::PageTab); + + delete tabBar; + QTestAccessibility::clearEvents(); + } +} + + QTEST_MAIN(tst_QAccessibility) #include "tst_qaccessibility.moc" diff --git a/tests/auto/other/sessionmanagement_macos/sessionmanagement_macos.pro b/tests/auto/other/sessionmanagement_macos/sessionmanagement_macos.pro new file mode 100644 index 0000000000..cef53bdf28 --- /dev/null +++ b/tests/auto/other/sessionmanagement_macos/sessionmanagement_macos.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_sessionmanagement_macos + +OBJECTIVE_SOURCES += tst_sessionmanagement_macos.mm + +QT = testlib gui core +LIBS += -framework AppKit + +requires(mac) +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm b/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm new file mode 100644 index 0000000000..934b15ca44 --- /dev/null +++ b/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> +#include <QSignalSpy> +#include <QSessionManager> +#include <AppKit/AppKit.h> + +// Q_DECLARE_METATYPE(QSessionManager) + +class tst_SessionManagement_macOS : public QObject +{ + Q_OBJECT + +private slots: + void stopApplication(); +}; + +/* + Test that session handling code is properly called +*/ +void tst_SessionManagement_macOS::stopApplication() +{ + int argc = 0; + QGuiApplication app(argc, nullptr); + QSignalSpy spy(&app, &QGuiApplication::commitDataRequest); + QTimer::singleShot(1000, []() { + [NSApp terminate:nil]; + }); + app.exec(); + QCOMPARE(spy.count(), 1); +} + +QTEST_APPLESS_MAIN(tst_SessionManagement_macOS) +#include "tst_sessionmanagement_macos.moc" diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index ab7bca8322..9591eca16a 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -97,14 +97,14 @@ void tst_toolsupport::offsets_data() { QTestData &data = QTest::newRow("sizeof(QObjectData)") << sizeof(QObjectData); - data << 28 << 48; // vptr + 3 ptr + 2 int + ptr + data << 36 << 64; // vptr + 2 ptr + (2*ptr + int) + 2 int + ptr } #if RUN_MEMBER_OFFSET_TEST { QTestData &data = QTest::newRow("QObjectPrivate::extraData") << pmm_to_offsetof(&QObjectPrivate::extraData); - data << 28 << 48; // sizeof(QObjectData) + data << 36 << 64; // sizeof(QObjectData) } { @@ -126,9 +126,9 @@ void tst_toolsupport::offsets_data() #ifdef Q_PROCESSOR_X86 // x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in // qglobal.h for more details. - data << 152 << 224; + data << 184 << 288; #else - data << 156 << 224; + data << 188 << 288; #endif } #endif |