diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-04-17 13:01:20 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-17 13:09:29 +0200 |
commit | 576a8e152ec36e7465bfdc8ad63998cffbab4091 (patch) | |
tree | 07472de61c7542a90f675869e480b99076c5b439 /tests/auto/gui | |
parent | fb7f30d2bad0c84ffea4db862a71ba2e03d855d0 (diff) | |
parent | 64255ef6502b1144f7b0aa4b2bf62803e0d4788b (diff) |
Merge "Merge remote-tracking branch 'origin/api_changes'" into refs/staging/master
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/kernel/kernel.pro | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qbackingstore/qbackingstore.pro | 9 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp | 103 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/qwindow.pro | 4 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 65 |
7 files changed, 174 insertions, 14 deletions
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index 932d652b69..827fa3606c 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -112,7 +112,7 @@ static void initializePadding(QImage *image) if (paddingBytes == 0) return; for (int y = 0; y < image->height(); ++y) { - qMemSet(image->scanLine(y) + effectiveBytesPerLine, 0, paddingBytes); + memset(image->scanLine(y) + effectiveBytesPerLine, 0, paddingBytes); } } @@ -454,7 +454,7 @@ void tst_QImageWriter::saveWithNoFormat() SKIP_IF_UNSUPPORTED(format); QImage niceImage(64, 64, QImage::Format_ARGB32); - qMemSet(niceImage.bits(), 0, niceImage.byteCount()); + memset(niceImage.bits(), 0, niceImage.byteCount()); QImageWriter writer(fileName /* , 0 - no format! */); if (error != 0) { diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 6d9112f130..8f191bd42d 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -1,5 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ + qbackingstore \ qclipboard \ qdrag \ qevent \ diff --git a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro new file mode 100644 index 0000000000..cc0a2c69f7 --- /dev/null +++ b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qbackingstore + +QT += core-private gui-private testlib + +SOURCES += tst_qbackingstore.cpp + +mac: CONFIG += insignificant_test # QTBUG-23059 +win32: CONFIG += insignificant_test # QTBUG-24885 diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp new file mode 100644 index 0000000000..678e616b19 --- /dev/null +++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qwindow.h> +#include <qbackingstore.h> +#include <qpainter.h> + +#include <QtTest/QtTest> + +#include <QEvent> + +// For QSignalSpy slot connections. +Q_DECLARE_METATYPE(Qt::ScreenOrientation) + +class tst_QBackingStore : public QObject +{ + Q_OBJECT + +private slots: + void flush(); +}; + +class Window : public QWindow +{ +public: + Window() + : backingStore(this) + { + } + + void resizeEvent(QResizeEvent *) + { + backingStore.resize(size()); + } + + void exposeEvent(QExposeEvent *event) + { + QRect rect(QPoint(), size()); + + backingStore.beginPaint(rect); + + QPainter p(backingStore.paintDevice()); + p.fillRect(rect, Qt::white); + p.end(); + + backingStore.endPaint(); + + backingStore.flush(event->region().boundingRect()); + } + +private: + QBackingStore backingStore; +}; + +void tst_QBackingStore::flush() +{ + Window window; + window.setGeometry(20, 20, 200, 200); + window.showMaximized(); + + QTRY_VERIFY(window.isExposed()); +} + +#include <tst_qbackingstore.moc> +QTEST_MAIN(tst_QBackingStore); diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 391600dd57..997e15ed55 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -595,7 +595,7 @@ void tst_QTouchEvent::basicRawEventTranslation() rawTouchPoint.setState(Qt::TouchPointPressed); rawTouchPoint.setScreenPos(screenPos); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); - QList<QPointF> rawPosList; + QVector<QPointF> rawPosList; rawPosList << QPointF(12, 34) << QPointF(56, 78); rawTouchPoint.setRawScreenPositions(rawPosList); const ulong timestamp = 1234; diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index e419a10440..fb8132afab 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -4,3 +4,7 @@ TARGET = tst_qwindow QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp + +mac: CONFIG += insignificant_test # QTBUG-23059 +win32: CONFIG += insignificant_test # QTBUG-24904 + diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 7bbcb8db7d..3dc2886b80 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -54,8 +54,10 @@ class tst_QWindow: public QObject Q_OBJECT private slots: + void eventOrderOnShow(); void mapGlobal(); void positioning(); + void isExposed(); void isActive(); void testInputEvents(); void touchToMouseTranslation(); @@ -117,6 +119,7 @@ public: bool event(QEvent *event) { m_received[event->type()]++; + m_order << event->type(); return QWindow::event(event); } @@ -126,10 +129,32 @@ public: return m_received.value(type, 0); } + int eventIndex(QEvent::Type type) + { + return m_order.indexOf(type); + } + private: QHash<QEvent::Type, int> m_received; + QVector<QEvent::Type> m_order; }; +void tst_QWindow::eventOrderOnShow() +{ + QRect geometry(80, 80, 40, 40); + + Window window; + window.setGeometry(geometry); + window.show(); + + QTRY_COMPARE(window.received(QEvent::Show), 1); + QTRY_COMPARE(window.received(QEvent::Resize), 1); + QTRY_VERIFY(window.isExposed()); + + QVERIFY(window.eventIndex(QEvent::Show) < window.eventIndex(QEvent::Resize)); + QVERIFY(window.eventIndex(QEvent::Resize) < window.eventIndex(QEvent::Expose)); +} + void tst_QWindow::positioning() { QRect geometry(80, 80, 40, 40); @@ -139,11 +164,8 @@ void tst_QWindow::positioning() QCOMPARE(window.geometry(), geometry); window.show(); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); -#endif QTRY_COMPARE(window.received(QEvent::Resize), 1); - QTRY_COMPARE(window.received(QEvent::Map), 1); + QTRY_VERIFY(window.received(QEvent::Expose) > 0); QMargins originalMargins = window.frameMargins(); @@ -154,6 +176,9 @@ void tst_QWindow::positioning() QPoint originalFramePos = window.framePos(); window.setWindowState(Qt::WindowFullScreen); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24904 - Too many resize events on setting window state", Continue); +#endif QTRY_COMPARE(window.received(QEvent::Resize), 2); window.setWindowState(Qt::WindowNoState); @@ -185,16 +210,35 @@ void tst_QWindow::positioning() } } -void tst_QWindow::isActive() +void tst_QWindow::isExposed() { + QRect geometry(80, 80, 40, 40); + Window window; - window.setGeometry(80, 80, 40, 40); + window.setGeometry(geometry); + QCOMPARE(window.geometry(), geometry); window.show(); + QTRY_VERIFY(window.received(QEvent::Expose) > 0); + QTRY_VERIFY(window.isExposed()); + + window.hide(); + #ifdef Q_OS_MAC QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); #endif - QTRY_COMPARE(window.received(QEvent::Map), 1); + QTRY_VERIFY(window.received(QEvent::Expose) > 1); + QTRY_VERIFY(!window.isExposed()); +} + + +void tst_QWindow::isActive() +{ + Window window; + window.setGeometry(80, 80, 40, 40); + window.show(); + + QTRY_VERIFY(window.isExposed()); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); QVERIFY(window.isActive()); @@ -204,15 +248,14 @@ void tst_QWindow::isActive() child.setGeometry(10, 10, 20, 20); child.show(); - QTRY_COMPARE(child.received(QEvent::Map), 1); + QTRY_VERIFY(child.isExposed()); child.requestActivateWindow(); QTRY_VERIFY(QGuiApplication::focusWindow() == &child); QVERIFY(child.isActive()); - // parent shouldn't receive new map or resize events from child being shown - QTRY_COMPARE(window.received(QEvent::Map), 1); + // parent shouldn't receive new resize events from child being shown QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 1); QTRY_COMPARE(window.received(QEvent::FocusOut), 1); @@ -228,7 +271,7 @@ void tst_QWindow::isActive() dialog.requestActivateWindow(); - QTRY_COMPARE(dialog.received(QEvent::Map), 1); + QTRY_VERIFY(dialog.isExposed()); QTRY_COMPARE(dialog.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog); QVERIFY(dialog.isActive()); |