diff options
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r-- | tests/auto/gui/kernel/kernel.pro | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qcursor/qcursor.pro | 6 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qcursor/tst_qcursor.cpp | 123 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 6 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qguitimer/qguitimer.pro | 2 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp | 12 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp | 10 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/BLACKLIST | 4 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 57 |
11 files changed, 196 insertions, 31 deletions
diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 559395a9ae..46786262c0 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -2,6 +2,7 @@ TEMPLATE=subdirs SUBDIRS=\ qbackingstore \ qclipboard \ + qcursor \ qdrag \ qevent \ qfileopenevent \ diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index 37d97cd3db..4fca9a07fc 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -64,7 +64,7 @@ public: m_received.clear(); } - bool event(QEvent *event) + bool event(QEvent *event) override { m_received[event->type()]++; return QWindow::event(event); diff --git a/tests/auto/gui/kernel/qcursor/qcursor.pro b/tests/auto/gui/kernel/qcursor/qcursor.pro new file mode 100644 index 0000000000..16e7d7c41c --- /dev/null +++ b/tests/auto/gui/kernel/qcursor/qcursor.pro @@ -0,0 +1,6 @@ +QT += testlib +TARGET = tst_qcursor +CONFIG += testcase +CONFIG -= app_bundle + +SOURCES += tst_qcursor.cpp diff --git a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp new file mode 100644 index 0000000000..d505f5a655 --- /dev/null +++ b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** 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/QTest> +#include <qcursor.h> +#include <qpixmap.h> +#include <qbitmap.h> + +class tst_QCursor : public QObject +{ + Q_OBJECT + +private slots: + void equality(); +}; + +#define VERIFY_EQUAL(lhs, rhs) \ + QVERIFY(lhs == rhs); \ + QVERIFY(rhs == lhs); \ + QVERIFY(!(rhs != lhs)); \ + QVERIFY(!(lhs != rhs)) + +#define VERIFY_DIFFERENT(lhs, rhs) \ + QVERIFY(lhs != rhs); \ + QVERIFY(rhs != lhs); \ + QVERIFY(!(rhs == lhs)); \ + QVERIFY(!(lhs == rhs)) + +void tst_QCursor::equality() +{ + VERIFY_EQUAL(QCursor(), QCursor()); + VERIFY_EQUAL(QCursor(Qt::CrossCursor), QCursor(Qt::CrossCursor)); + VERIFY_DIFFERENT(QCursor(Qt::CrossCursor), QCursor()); + + // Shape + QCursor shapeCursor(Qt::WaitCursor); + VERIFY_EQUAL(shapeCursor, shapeCursor); + QCursor shapeCursorCopy(shapeCursor); + VERIFY_EQUAL(shapeCursor, shapeCursorCopy); + shapeCursorCopy.setShape(Qt::DragMoveCursor); + VERIFY_DIFFERENT(shapeCursor, shapeCursorCopy); + shapeCursorCopy.setShape(shapeCursor.shape()); + VERIFY_EQUAL(shapeCursor, shapeCursorCopy); + + // Pixmap + QPixmap pixmap(16, 16); + QCursor pixmapCursor(pixmap); + VERIFY_EQUAL(pixmapCursor, pixmapCursor); + VERIFY_EQUAL(pixmapCursor, QCursor(pixmapCursor)); + VERIFY_EQUAL(pixmapCursor, QCursor(pixmap)); + VERIFY_DIFFERENT(pixmapCursor, QCursor()); + VERIFY_DIFFERENT(pixmapCursor, QCursor(pixmap, 5, 5)); + VERIFY_DIFFERENT(pixmapCursor, QCursor(QPixmap(16, 16))); + VERIFY_DIFFERENT(pixmapCursor, shapeCursor); + + // Bitmap & mask + QBitmap bitmap(16, 16); + QBitmap mask(16, 16); + QCursor bitmapCursor(bitmap, mask); + VERIFY_EQUAL(bitmapCursor, bitmapCursor); + VERIFY_EQUAL(bitmapCursor, QCursor(bitmapCursor)); + VERIFY_EQUAL(bitmapCursor, QCursor(bitmap, mask)); + VERIFY_DIFFERENT(bitmapCursor, QCursor()); + VERIFY_DIFFERENT(bitmapCursor, QCursor(bitmap, mask, 5, 5)); + VERIFY_DIFFERENT(bitmapCursor, QCursor(bitmap, QBitmap(16, 16))); + VERIFY_DIFFERENT(bitmapCursor, QCursor(QBitmap(16, 16), mask)); + VERIFY_DIFFERENT(bitmapCursor, shapeCursor); + VERIFY_DIFFERENT(bitmapCursor, pixmapCursor); + + // Empty pixmap + QPixmap emptyPixmap; + QCursor emptyPixmapCursor(emptyPixmap); + QCOMPARE(emptyPixmapCursor.shape(), Qt::ArrowCursor); + VERIFY_EQUAL(emptyPixmapCursor, QCursor()); + VERIFY_EQUAL(emptyPixmapCursor, QCursor(emptyPixmap, 5, 5)); + VERIFY_DIFFERENT(emptyPixmapCursor, shapeCursor); + VERIFY_DIFFERENT(emptyPixmapCursor, pixmapCursor); + VERIFY_DIFFERENT(emptyPixmapCursor, bitmapCursor); + + // Empty bitmap & mask + QBitmap emptyBitmap; + QCursor emptyBitmapCursor(emptyBitmap, emptyBitmap); + QCOMPARE(emptyBitmapCursor.shape(), Qt::ArrowCursor); + VERIFY_EQUAL(emptyBitmapCursor, QCursor()); + VERIFY_EQUAL(emptyBitmapCursor, QCursor(emptyBitmap, emptyBitmap, 5, 5)); + VERIFY_EQUAL(emptyBitmapCursor, QCursor(emptyBitmap, mask)); + VERIFY_EQUAL(emptyBitmapCursor, QCursor(bitmap, emptyBitmap)); + VERIFY_EQUAL(emptyBitmapCursor, emptyPixmapCursor); + VERIFY_DIFFERENT(emptyBitmapCursor, shapeCursor); + VERIFY_DIFFERENT(emptyBitmapCursor, pixmapCursor); + VERIFY_DIFFERENT(emptyBitmapCursor, bitmapCursor); +} + +#undef VERIFY_EQUAL +#undef VERIFY_DIFFERENT + +QTEST_MAIN(tst_QCursor) +#include "tst_qcursor.moc" diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index a935258fb8..6ba488aaa7 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -227,7 +227,7 @@ void tst_QGuiApplication::focusObject() QOpenGLContext context; context.create(); context.makeCurrent(&window1); - QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window + QVERIFY(QTest::qWaitForWindowExposed(&window1)); // Buffer swap only succeeds with exposed window context.swapBuffers(&window1); #endif @@ -392,7 +392,7 @@ void tst_QGuiApplication::changeFocusWindow() QOpenGLContext context; context.create(); context.makeCurrent(&window1); - QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window + QVERIFY(QTest::qWaitForWindowExposed(&window1)); // Buffer swap only succeeds with exposed window context.swapBuffers(&window1); #endif FocusChangeWindow window2; @@ -406,7 +406,7 @@ void tst_QGuiApplication::changeFocusWindow() #if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store // and then post the window in order for screen to show the window context.makeCurrent(&window2); - QTest::qWaitForWindowExposed(&window2); // Buffer swap only succeeds with exposed window + QVERIFY(QTest::qWaitForWindowExposed(&window2)); // Buffer swap only succeeds with exposed window context.swapBuffers(&window2); #endif QVERIFY(QTest::qWaitForWindowExposed(&window1)); diff --git a/tests/auto/gui/kernel/qguitimer/qguitimer.pro b/tests/auto/gui/kernel/qguitimer/qguitimer.pro index 8a71e48007..9c58f0e22c 100644 --- a/tests/auto/gui/kernel/qguitimer/qguitimer.pro +++ b/tests/auto/gui/kernel/qguitimer/qguitimer.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qguitimer -QT = core gui testlib +QT = core core-private gui testlib SOURCES += ../../../corelib/kernel/qtimer/tst_qtimer.cpp diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 6394a956bd..f8b6bf064a 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -36,14 +36,18 @@ #include <QLibraryInfo> #ifdef Q_OS_MAC -#ifdef Q_OS_OSX -#include <Carbon/Carbon.h> -#endif struct MacSpecialKey { int key; ushort macSymbol; }; +// Unicode code points for the glyphs associated with these keys +// Defined by Carbon headers but not anywhere in Cocoa +static const int kShiftUnicode = 0x21E7; +static const int kControlUnicode = 0x2303; +static const int kOptionUnicode = 0x2325; +static const int kCommandUnicode = 0x2318; + static const int NumEntries = 21; static const MacSpecialKey entries[NumEntries] = { { Qt::Key_Escape, 0x238B }, @@ -61,12 +65,10 @@ static const MacSpecialKey entries[NumEntries] = { { Qt::Key_Down, 0x2193 }, { Qt::Key_PageUp, 0x21DE }, { Qt::Key_PageDown, 0x21DF }, -#ifdef Q_OS_OSX { Qt::Key_Shift, kShiftUnicode }, { Qt::Key_Control, kCommandUnicode }, { Qt::Key_Meta, kControlUnicode }, { Qt::Key_Alt, kOptionUnicode }, -#endif { Qt::Key_CapsLock, 0x21EA }, }; diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp index 58dee6f6ca..d882dc3888 100644 --- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp +++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp @@ -62,7 +62,7 @@ void tst_QOpenGLWindow::create() w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY(w.isValid()); } @@ -111,7 +111,7 @@ void tst_QOpenGLWindow::basic() w.reset(); w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Check that the virtuals are invoked. QCOMPARE(w.initCount, 1); @@ -170,7 +170,7 @@ void tst_QOpenGLWindow::painter() PainterWindow w; w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QCOMPARE(w.img.size(), w.size() * w.devicePixelRatio()); QVERIFY(w.img.pixel(QPoint(5, 5) * w.devicePixelRatio()) == qRgb(0, 0, 255)); @@ -212,7 +212,7 @@ void tst_QOpenGLWindow::partial() PartialPainterWindow w(u); w.resize(800, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // Add a couple of small blue rects. for (int i = 0; i < 10; ++i) { @@ -285,7 +285,7 @@ void tst_QOpenGLWindow::underOver() PaintUnderOverWindow w; w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); // under -> paint -> over -> under -> paint -> ... is the only acceptable sequence QCOMPARE(w.m_state, PaintUnderOverWindow::PaintOver); diff --git a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp index 41fcdf9f30..3421622fe3 100644 --- a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp +++ b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp @@ -46,7 +46,7 @@ void tst_QRasterWindow::create() w.resize(640, 480); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w)); } class PainterWindow : public QRasterWindow @@ -70,7 +70,7 @@ void tst_QRasterWindow::basic() w.reset(); w.resize(400, 400); w.show(); - QTest::qWaitForWindowExposed(&w); + QVERIFY(QTest::qWaitForWindowExposed(&w));; QVERIFY(w.paintCount >= 1); diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 1a4885b895..3e03d9e236 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -19,5 +19,9 @@ ubuntu-16.04 osx [modalWindowModallity] osx +[visibility] +osx-10.11 ci +osx-10.12 ci + [testInputEvents] rhel-7.4 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 6452b9ecd0..039d095ce6 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -269,12 +269,21 @@ class Window : public QWindow { public: Window(const Qt::WindowFlags flags = Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) + : QWindow(), lastReceivedWindowState(windowState()) { reset(); setFlags(flags); #if defined(Q_OS_QNX) setSurfaceType(QSurface::OpenGLSurface); #endif + +#if !defined(Q_OS_MACOS) + // FIXME: All platforms should send window-state change events, regardless + // of the sync/async nature of the the underlying platform, but they don't. + connect(this, &QWindow::windowStateChanged, [=]() { + lastReceivedWindowState = windowState(); + }); +#endif } void reset() @@ -299,6 +308,10 @@ public: case QEvent::Move: m_framePositionsOnMove << framePosition(); break; + + case QEvent::WindowStateChange: + lastReceivedWindowState = windowState(); + default: break; } @@ -327,6 +340,8 @@ public: } QVector<QPoint> m_framePositionsOnMove; + Qt::WindowStates lastReceivedWindowState; + private: QHash<QEvent::Type, int> m_received; QVector<QEvent::Type> m_order; @@ -475,7 +490,7 @@ void tst_QWindow::positioning() window.showNormal(); QCoreApplication::processEvents(); - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QMargins originalMargins = window.frameMargins(); @@ -487,17 +502,15 @@ void tst_QWindow::positioning() window.reset(); window.setWindowState(Qt::WindowFullScreen); - QCoreApplication::processEvents(); + QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowFullScreen); QTRY_VERIFY(window.received(QEvent::Resize) > 0); - QTest::qWait(2000); window.reset(); window.setWindowState(Qt::WindowNoState); - QCoreApplication::processEvents(); + QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowNoState); QTRY_VERIFY(window.received(QEvent::Resize) > 0); - QTest::qWait(2000); QTRY_COMPARE(originalPos, window.position()); QTRY_COMPARE(originalFramePos, window.framePosition()); @@ -1470,7 +1483,7 @@ void tst_QWindow::activateAndClose() window.showNormal(); #if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store // and then post the window in order for screen to show the window - QTest::qWaitForWindowExposed(&window); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QOpenGLContext context; context.create(); context.makeCurrent(&window); @@ -1753,7 +1766,7 @@ void tst_QWindow::visibility() { qRegisterMetaType<Qt::WindowModality>("QWindow::Visibility"); - QWindow window; + Window window; QSignalSpy spy(&window, SIGNAL(visibilityChanged(QWindow::Visibility))); window.setVisibility(QWindow::AutomaticVisibility); @@ -1774,11 +1787,13 @@ void tst_QWindow::visibility() QCOMPARE(window.windowState(), Qt::WindowFullScreen); QCOMPARE(window.visibility(), QWindow::FullScreen); QCOMPARE(spy.count(), 1); + QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowFullScreen); spy.clear(); window.setWindowState(Qt::WindowNoState); QCOMPARE(window.visibility(), QWindow::Windowed); QCOMPARE(spy.count(), 1); + QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowNoState); spy.clear(); window.setVisible(false); @@ -1791,16 +1806,27 @@ void tst_QWindow::mask() { QRegion mask = QRect(10, 10, 800 - 20, 600 - 20); - QWindow window; - window.resize(800, 600); - window.setMask(mask); + { + QWindow window; + window.resize(800, 600); + QCOMPARE(window.mask(), QRegion()); - QCOMPARE(window.mask(), QRegion()); + window.create(); + window.setMask(mask); + QCOMPARE(window.mask(), mask); + } - window.create(); - window.setMask(mask); + { + QWindow window; + window.resize(800, 600); + QCOMPARE(window.mask(), QRegion()); + + window.setMask(mask); + QCOMPARE(window.mask(), mask); + window.create(); + QCOMPARE(window.mask(), mask); + } - QCOMPARE(window.mask(), mask); } void tst_QWindow::initialSize() @@ -1845,6 +1871,9 @@ void tst_QWindow::modalDialog() if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); + if (QGuiApplication::platformName() == QLatin1String("cocoa")) + QSKIP("Test fails due to QTBUG-61965, and is slow due to QTBUG-61964"); + QWindow normalWindow; normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80)); normalWindow.resize(m_testWindowSize); |