diff options
-rw-r--r-- | tests/auto/auto.pro | 2 | ||||
-rw-r--r-- | tests/auto/gui.pro | 25 | ||||
-rw-r--r-- | tests/auto/qtransformedscreen/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/qtransformedscreen/qtransformedscreen.pro | 9 | ||||
-rw-r--r-- | tests/auto/qtransformedscreen/tst_qtransformedscreen.cpp | 188 | ||||
-rw-r--r-- | tests/auto/qwindowsurface/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/qwindowsurface/qwindowsurface.pro | 10 | ||||
-rw-r--r-- | tests/auto/qwindowsurface/tst_qwindowsurface.cpp | 289 | ||||
-rw-r--r-- | tests/auto/qwsembedwidget/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/qwsembedwidget/qwsembedwidget.pro | 4 | ||||
-rw-r--r-- | tests/auto/qwsembedwidget/tst_qwsembedwidget.cpp | 100 | ||||
-rw-r--r-- | tests/auto/qwsinputmethod/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/qwsinputmethod/qwsinputmethod.pro | 4 | ||||
-rw-r--r-- | tests/auto/qwsinputmethod/tst_qwsinputmethod.cpp | 86 | ||||
-rw-r--r-- | tests/auto/qwswindowsystem/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/qwswindowsystem/qwswindowsystem.pro | 4 | ||||
-rw-r--r-- | tests/auto/qwswindowsystem/tst_qwswindowsystem.cpp | 648 |
17 files changed, 1 insertions, 1373 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 4b22604dea..14ba4a9e06 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -4,7 +4,7 @@ SUBDIRS += \ corelib.pro \ dbus \ host.pro \ - gui.pro \ + gui \ integrationtests \ network \ opengl \ diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro deleted file mode 100644 index 2a954e7977..0000000000 --- a/tests/auto/gui.pro +++ /dev/null @@ -1,25 +0,0 @@ -# The tests in this .pro file _MUST_ use QtCore, QtNetwork and QtGui only -# (i.e. QT=core gui network). -# The test system is allowed to run these tests before the rest of Qt has -# been compiled. -# -TEMPLATE=subdirs -SUBDIRS=\ - gui \ - qtransformedscreen \ - qwindowsurface \ - qwsembedwidget \ - qwsinputmethod \ - qwswindowsystem - -# This test cannot be run on Mac OS -mac*:SUBDIRS -= \ - qwindowsurface \ - -# These tests are only valid for QWS -!embedded|wince*:SUBDIRS -= \ - qtransformedscreen \ - qwsembedwidget \ - qwsinputmethod \ - qwswindowsystem \ - diff --git a/tests/auto/qtransformedscreen/.gitignore b/tests/auto/qtransformedscreen/.gitignore deleted file mode 100644 index eb34212242..0000000000 --- a/tests/auto/qtransformedscreen/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtransformedscreen diff --git a/tests/auto/qtransformedscreen/qtransformedscreen.pro b/tests/auto/qtransformedscreen/qtransformedscreen.pro deleted file mode 100644 index daea2dd09f..0000000000 --- a/tests/auto/qtransformedscreen/qtransformedscreen.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qtransformedscreen -SOURCES += tst_qtransformedscreen.cpp -QT += testlib - -embedded:!contains(gfx-drivers, transformed) { -LIBS += ../../../plugins/gfxdrivers/libqgfxtransformed.so -} - diff --git a/tests/auto/qtransformedscreen/tst_qtransformedscreen.cpp b/tests/auto/qtransformedscreen/tst_qtransformedscreen.cpp deleted file mode 100644 index 7aa19bcf82..0000000000 --- a/tests/auto/qtransformedscreen/tst_qtransformedscreen.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 <QtTest/QtTest> - -//TESTED_CLASS= -//TESTED_FILES= - -#include <qdesktopwidget.h> -#include <qwindowsystem_qws.h> -#include <qscreen_qws.h> -#include <qscreendriverfactory_qws.h> -#include <qwsdisplay_qws.h> - -#ifdef QT_NO_QWS_TRANSFORMED -# undef QT_NO_QWS_TRANSFORMED -#endif - -#include <qscreentransformed_qws.h> - -class tst_QTransformedScreen : public QObject -{ - Q_OBJECT - -public: - tst_QTransformedScreen() {} - ~tst_QTransformedScreen() { } - -private slots: - void initTestCase(); - void cleanupTestCase(); - void setTransformation_data(); - void setTransformation(); - void qwsDisplay_setTransformation(); - -private: - QTransformedScreen *screen; - QScreen *oldScreen; - int id; -}; - -Q_DECLARE_METATYPE(QTransformedScreen::Transformation); - -void tst_QTransformedScreen::initTestCase() -{ - oldScreen = qt_screen; - - QVERIFY(QScreenDriverFactory::keys().contains(QLatin1String("Transformed"))); - QVERIFY(QScreenDriverFactory::keys().contains(QLatin1String("VNC"))); - - id = 10; - screen = static_cast<QTransformedScreen*>(QScreenDriverFactory::create("Transformed", id)); - QVERIFY(screen); - QVERIFY(screen->connect(QString("Transformed:Rot90:VNC:%1").arg(id))); - QVERIFY(screen->initDevice()); -} - -void tst_QTransformedScreen::cleanupTestCase() -{ - screen->shutdownDevice(); - screen->disconnect(); - delete screen; - screen = 0; - - qt_screen = oldScreen; -} - -void tst_QTransformedScreen::setTransformation_data() -{ - QTest::addColumn<QTransformedScreen::Transformation>("transformation"); - QTest::addColumn<bool>("swap"); - - QTest::newRow("Rot0") << QTransformedScreen::None << false; - QTest::newRow("Rot90") << QTransformedScreen::Rot90 << true; - QTest::newRow("Rot180") << QTransformedScreen::Rot180 << false; - QTest::newRow("Rot270") << QTransformedScreen::Rot270 << true; -} - -void tst_QTransformedScreen::setTransformation() -{ - // Not really failures but equal height and width makes this test useless - QVERIFY(screen->deviceWidth() != screen->deviceHeight()); - - screen->setTransformation(QTransformedScreen::None); - int dw = screen->deviceWidth(); - int dh = screen->deviceHeight(); - int mmw = screen->physicalWidth(); - int mmh = screen->physicalHeight(); - - QFETCH(QTransformedScreen::Transformation, transformation); - QFETCH(bool, swap); - - screen->setTransformation(transformation); - QCOMPARE(screen->deviceWidth(), dw); - QCOMPARE(screen->deviceHeight(), dh); - - if (swap) { - QCOMPARE(screen->width(), dh); - QCOMPARE(screen->height(), dw); - QCOMPARE(screen->physicalWidth(), mmh); - QCOMPARE(screen->physicalHeight(), mmw); - } else { - QCOMPARE(screen->width(), dw); - QCOMPARE(screen->height(), dh); - QCOMPARE(screen->physicalWidth(), mmw); - QCOMPARE(screen->physicalHeight(), mmh); - } -} - -void tst_QTransformedScreen::qwsDisplay_setTransformation() -{ - QDesktopWidget *desktop = QApplication::desktop(); - - // test maximized windows - { - QWidget w; - w.showMaximized(); - QApplication::processEvents(); - - const int screen = desktop->screenNumber(&w); - QCOMPARE(desktop->availableGeometry(screen), w.frameGeometry()); - - for (int i = QTransformedScreen::None; i <= QTransformedScreen::Rot270; ++i) { - QWSDisplay::instance()->setTransformation(i, screen); - QApplication::processEvents(); - QCOMPARE(desktop->availableGeometry(screen), w.frameGeometry()); - } - } - - // test fullscreen windows - { - QWidget w; - w.showFullScreen(); - QApplication::processEvents(); - - const int screen = desktop->screenNumber(&w); - QCOMPARE(desktop->screenGeometry(screen), w.geometry()); - - for (int i = QTransformedScreen::None; i <= QTransformedScreen::Rot270; ++i) { - QWSDisplay::instance()->setTransformation(i, screen); - QApplication::processEvents(); - QCOMPARE(desktop->screenGeometry(screen), w.geometry()); - } - } -} - -QTEST_MAIN(tst_QTransformedScreen) - -#include "tst_qtransformedscreen.moc" diff --git a/tests/auto/qwindowsurface/.gitignore b/tests/auto/qwindowsurface/.gitignore deleted file mode 100644 index e4be7d078d..0000000000 --- a/tests/auto/qwindowsurface/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qwindowsurface diff --git a/tests/auto/qwindowsurface/qwindowsurface.pro b/tests/auto/qwindowsurface/qwindowsurface.pro deleted file mode 100644 index 726be7202b..0000000000 --- a/tests/auto/qwindowsurface/qwindowsurface.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwindowsurface - -QT += widgets widgets-private testlib -QT += gui-private - -SOURCES += tst_qwindowsurface.cpp - - - diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp deleted file mode 100644 index 22a0110423..0000000000 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 <QtTest/QtTest> -#include <QPainter> -#include <QPalette> -#include <QWindowsStyle> -#include <QDesktopWidget> - -#if QT_VERSION < 0x050000 -#include <private/qwindowsurface_p.h> -#endif - -class tst_QWindowSurface : public QObject -{ - Q_OBJECT - -#if QT_VERSION >= 0x050000 -public slots: - void initTestCase(); -#else -private slots: - void getSetWindowSurface(); - void flushOutsidePaintEvent(); - void grabWidget(); -#endif -}; - -#if QT_VERSION >= 0x050000 -void tst_QWindowSurface::initTestCase() -{ - QSKIP("This test is temporarily skipped until it is fixed for Qt5"); -} - -#else - -class MyWindowSurface : public QWindowSurface -{ -public: - MyWindowSurface(QWidget *w) : QWindowSurface(w) {} - - QPaintDevice *paintDevice() { - return ℑ - } - - void flush(QWidget*, const QRegion&, const QPoint&) { - /* nothing */ - } - -private: - QImage image; -}; - -class ColorWidget : public QWidget -{ -public: - ColorWidget(QWidget *parent = 0, const QColor &c = QColor(Qt::red)) - : QWidget(parent, Qt::FramelessWindowHint), color(c) - { - QPalette opaquePalette = palette(); - opaquePalette.setColor(backgroundRole(), color); - setPalette(opaquePalette); - setAutoFillBackground(true); - } - - void paintEvent(QPaintEvent *e) { - r += e->region(); - } - - void reset() { - r = QRegion(); - } - - QColor color; - QRegion r; -}; - -//from tst_qwidget.cpp -static void VERIFY_COLOR(const QRegion ®ion, const QColor &color) -{ - const QRegion r = QRegion(region); - for (int i = 0; i < r.rects().size(); ++i) { - const QRect rect = r.rects().at(i); - for (int t = 0; t < 5; t++) { - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), - rect.left(), rect.top(), - rect.width(), rect.height()); - QCOMPARE(pixmap.size(), rect.size()); - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ - expectedPixmap.fill(color); - if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) - { QTest::qWait(200); continue; } - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); - QCOMPARE(pixmap, expectedPixmap); - break; - } - } -} - -void tst_QWindowSurface::getSetWindowSurface() -{ - QWidget w; - QVERIFY(!w.windowSurface()); - - w.show(); - QApplication::processEvents(); - QVERIFY(w.windowSurface()); - - for (int i = 0; i < 2; ++i) { - MyWindowSurface *surface = new MyWindowSurface(&w); - QCOMPARE(w.windowSurface(), (QWindowSurface *)surface); - - w.setWindowSurface(surface); - QCOMPARE(w.windowSurface(), (QWindowSurface *)surface); - } -} - -void tst_QWindowSurface::flushOutsidePaintEvent() -{ -#ifdef Q_WS_X11 - if (QX11Info::isCompositingManagerRunning()) - QSKIP("Test is unreliable with composition manager"); -#endif - -#ifdef Q_WS_WIN - if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) { - QTest::qWait(1000); - } -#endif - ColorWidget w(0, Qt::red); - w.setGeometry(10, 100, 50, 50); - // prevent custom styles from messing up the background - w.setStyle(new QWindowsStyle); - w.show(); - QTest::qWaitForWindowShown(&w); - - QApplication::processEvents(); -#if defined(Q_WS_QWS) - QApplication::sendPostedEvents(); //for the glib event loop -#endif - VERIFY_COLOR(w.geometry(), w.color); - w.reset(); - - // trigger a paintEvent() the next time the event loop is entered - w.update(); - - // draw a black rectangle inside the widget - QWindowSurface *surface = w.windowSurface(); - QVERIFY(surface); - const QRect rect = surface->rect(&w); - surface->beginPaint(rect); - QImage *img = surface->buffer(&w); - if (img) { - QPainter p(img); - p.fillRect(QRect(QPoint(),img->size()), Qt::black); - } - surface->endPaint(rect); - surface->flush(&w, rect, QPoint()); - -#ifdef Q_WS_QWS - VERIFY_COLOR(w.geometry(), Qt::black); -#endif - - // the paintEvent() should overwrite the painted rectangle - QApplication::processEvents(); - -#if defined(Q_WS_QWS) - QSKIP("task 176755"); -#endif - VERIFY_COLOR(w.geometry(), w.color); - QCOMPARE(QRegion(w.rect()), w.r); - w.reset(); -} - - -void tst_QWindowSurface::grabWidget() -{ - QWidget parentWidget; - QWidget childWidget(&parentWidget); - QWidget babyWidget(&childWidget); - - parentWidget.resize(300, 300); - childWidget.setGeometry(50, 50, 200, 200); - childWidget.setAutoFillBackground(true); - babyWidget.setGeometry(50, 50, 100, 100); - babyWidget.setAutoFillBackground(true); - - QPalette pal = parentWidget.palette(); - pal.setColor(QPalette::Window, QColor(Qt::blue)); - parentWidget.setPalette(pal); - - pal = childWidget.palette(); - pal.setColor(QPalette::Window, QColor(Qt::white)); - childWidget.setPalette(pal); - - pal = babyWidget.palette(); - pal.setColor(QPalette::Window, QColor(Qt::red)); - babyWidget.setPalette(pal); - - // prevent custom styles from messing up the background - parentWidget.setStyle(new QWindowsStyle); - - babyWidget.show(); - childWidget.show(); - parentWidget.show(); - QTest::qWaitForWindowShown(&parentWidget); - - QPixmap parentPixmap; - QTRY_COMPARE((parentPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget)).size(), - QSize(300,300)); - QPixmap childPixmap = childWidget.windowSurface()->grabWidget(&childWidget); - QPixmap babyPixmap = babyWidget.windowSurface()->grabWidget(&babyWidget); - QPixmap parentSubPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget, QRect(25, 25, 100, 100)); - QPixmap childSubPixmap = childWidget.windowSurface()->grabWidget(&childWidget, QRect(55, 55, 50, 50)); - QPixmap childInvalidSubPixmap = childWidget.windowSurface()->grabWidget(&childWidget, QRect(-50, -50, 150, 150)); - - QCOMPARE(parentPixmap.size(), QSize(300, 300)); - QCOMPARE(childPixmap.size(), QSize(200, 200)); - QCOMPARE(babyPixmap.size(), QSize(100, 100)); - QCOMPARE(parentSubPixmap.size(), QSize(100, 100)); - QCOMPARE(childSubPixmap.size(), QSize(50, 50)); - QCOMPARE(childInvalidSubPixmap.size(), QSize(100, 100)); - - QImage parentImage = parentPixmap.toImage(); - QImage childImage = childPixmap.toImage(); - QImage babyImage = babyPixmap.toImage(); - QImage parentSubImage = parentSubPixmap.toImage(); - QImage childSubImage = childSubPixmap.toImage(); - QImage childInvalidSubImage = childInvalidSubPixmap.toImage(); - - QVERIFY(QColor(parentImage.pixel(0, 0)) == QColor(Qt::blue)); - QVERIFY(QColor(parentImage.pixel(75, 75)) == QColor(Qt::white)); - QVERIFY(QColor(parentImage.pixel(149, 149)) == QColor(Qt::red)); - - QVERIFY(QColor(childImage.pixel(0, 0)) == QColor(Qt::white)); - QVERIFY(QColor(childImage.pixel(99, 99)) == QColor(Qt::red)); - - QVERIFY(QColor(parentSubImage.pixel(0, 0)) == QColor(Qt::blue)); - QVERIFY(QColor(parentSubImage.pixel(30, 30)) == QColor(Qt::white)); - QVERIFY(QColor(parentSubImage.pixel(80, 80)) == QColor(Qt::red)); - - QVERIFY(QColor(childSubImage.pixel(0, 0)) == QColor(Qt::red)); - - QVERIFY(QColor(childInvalidSubImage.pixel(0, 0)) == QColor(Qt::white)); -} - -#endif - -QTEST_MAIN(tst_QWindowSurface) -#include "tst_qwindowsurface.moc" diff --git a/tests/auto/qwsembedwidget/.gitignore b/tests/auto/qwsembedwidget/.gitignore deleted file mode 100644 index d7a8b4438b..0000000000 --- a/tests/auto/qwsembedwidget/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qwsembedwidget diff --git a/tests/auto/qwsembedwidget/qwsembedwidget.pro b/tests/auto/qwsembedwidget/qwsembedwidget.pro deleted file mode 100644 index 97cbf94bf2..0000000000 --- a/tests/auto/qwsembedwidget/qwsembedwidget.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwsembedwidget -QT += widgets testlib -SOURCES += tst_qwsembedwidget.cpp diff --git a/tests/auto/qwsembedwidget/tst_qwsembedwidget.cpp b/tests/auto/qwsembedwidget/tst_qwsembedwidget.cpp deleted file mode 100644 index 2b6f87a262..0000000000 --- a/tests/auto/qwsembedwidget/tst_qwsembedwidget.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 <QtTest/QtTest> - -//TESTED_CLASS= -//TESTED_FILES= - -#include <QWSEmbedWidget> -#include <QLabel> - -class tst_QWSEmbedWidget : public QObject -{ - Q_OBJECT - -public: - tst_QWSEmbedWidget() {} - ~tst_QWSEmbedWidget() {} - -private slots: - void embedWidget(); -}; - -void tst_QWSEmbedWidget::embedWidget() -{ - QLabel embedded("hello"); - embedded.show(); - QApplication::processEvents(); - QVERIFY(embedded.isVisible()); - - { - QWSEmbedWidget embedder(embedded.winId()); - embedder.show(); - QApplication::processEvents(); - QVERIFY(embedded.isVisible()); - } - QApplication::processEvents(); - QVERIFY(!embedded.isVisible()); - - { - QWidget w; - embedded.setWindowFlags(Qt::FramelessWindowHint); - QWSEmbedWidget embedder(embedded.winId(), &w); - - const QRect geometry(100, 100, 100, 100); - embedder.setGeometry(geometry); - w.show(); - - QApplication::processEvents(); - - const QPoint offset = w.mapToGlobal(QPoint(0, 0)); - QCOMPARE(embedded.geometry(), geometry.translated(offset)); - QVERIFY(embedded.isVisible()); - } - QApplication::processEvents(); - QVERIFY(!embedded.isVisible()); -} - -QTEST_MAIN(tst_QWSEmbedWidget) - -#include "tst_qwsembedwidget.moc" diff --git a/tests/auto/qwsinputmethod/.gitignore b/tests/auto/qwsinputmethod/.gitignore deleted file mode 100644 index f5233eb89e..0000000000 --- a/tests/auto/qwsinputmethod/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qwsinputmethod diff --git a/tests/auto/qwsinputmethod/qwsinputmethod.pro b/tests/auto/qwsinputmethod/qwsinputmethod.pro deleted file mode 100644 index 83ea7f22f3..0000000000 --- a/tests/auto/qwsinputmethod/qwsinputmethod.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwsinputmethod -QT += testlib -SOURCES += tst_qwsinputmethod.cpp diff --git a/tests/auto/qwsinputmethod/tst_qwsinputmethod.cpp b/tests/auto/qwsinputmethod/tst_qwsinputmethod.cpp deleted file mode 100644 index c700abd9be..0000000000 --- a/tests/auto/qwsinputmethod/tst_qwsinputmethod.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 <QtTest/QtTest> - -//TESTED_CLASS= -//TESTED_FILES= - -#include <QWSInputMethod> - -class tst_QWSInputMethod : public QObject -{ - Q_OBJECT - -public: - tst_QWSInputMethod() {} - virtual ~tst_QWSInputMethod() {} - -private slots: - void createSubClass(); -}; - -/* - Dummy class just to make sure the QWSInputMethod header compiles. -*/ -class MyInputMethod : public QWSInputMethod -{ -public: - MyInputMethod() : QWSInputMethod() {} - ~MyInputMethod() {} - bool filter(int, int, int, bool, bool) { return true; } - bool filter(const QPoint &, int, int) { return true; } - void mouseHandler(int, int) {} - void queryResponse(int, const QVariant &) {} - void reset() {} - - void updateHandler(int) {} -}; - -void tst_QWSInputMethod::createSubClass() -{ - MyInputMethod im; -} - -QTEST_MAIN(tst_QWSInputMethod) - -#include "tst_qwsinputmethod.moc" diff --git a/tests/auto/qwswindowsystem/.gitignore b/tests/auto/qwswindowsystem/.gitignore deleted file mode 100644 index 6f646e6434..0000000000 --- a/tests/auto/qwswindowsystem/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qwswindowsystem diff --git a/tests/auto/qwswindowsystem/qwswindowsystem.pro b/tests/auto/qwswindowsystem/qwswindowsystem.pro deleted file mode 100644 index 41aa1aea9d..0000000000 --- a/tests/auto/qwswindowsystem/qwswindowsystem.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwswindowsystem -QT += testlib -SOURCES += tst_qwswindowsystem.cpp diff --git a/tests/auto/qwswindowsystem/tst_qwswindowsystem.cpp b/tests/auto/qwswindowsystem/tst_qwswindowsystem.cpp deleted file mode 100644 index dc520a4482..0000000000 --- a/tests/auto/qwswindowsystem/tst_qwswindowsystem.cpp +++ /dev/null @@ -1,648 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 <QtTest/QtTest> - -//TESTED_CLASS= -//TESTED_FILES=gui/embedded/qwindowsystem_qws.h gui/embedded/qwindowsystem_qws.cpp - -#include <qwindowsystem_qws.h> -#include <qpainter.h> -#include <qdesktopwidget.h> -#include <qdirectpainter_qws.h> -#include <qscreen_qws.h> -#include <private/qwindowsurface_qws_p.h> - -class tst_QWSWindowSystem : public QObject -{ - Q_OBJECT - -public: - tst_QWSWindowSystem() {} - ~tst_QWSWindowSystem() {} - -private slots: - void initTestCase(); - void showHideWindow(); - void raiseLowerWindow(); - void windowOpacity(); - void directPainter(); - void setMaxWindowRect(); - void initialGeometry(); - void WA_PaintOnScreen(); - void toplevelMove(); - void dontFlushUnitializedWindowSurfaces(); - void task188025_data(); - void task188025(); - -private: - QWSWindow* getWindow(int windId); - QColor bgColor; -}; - -class ColorWidget : public QWidget -{ -public: - ColorWidget(const QColor &color = QColor(Qt::red), Qt::WindowFlags f = 0) - : QWidget(0, f | Qt::FramelessWindowHint), c(color) {} - - QColor color() { return c; } - -protected: - void paintEvent(QPaintEvent*) { - QPainter p(this); - p.fillRect(rect(), QBrush(c)); - } - -private: - QColor c; -}; - -void tst_QWSWindowSystem::initTestCase() -{ - bgColor = QColor(Qt::green); - - QWSServer *server = QWSServer::instance(); - server->setBackground(bgColor); -} - -QWSWindow* tst_QWSWindowSystem::getWindow(int winId) -{ - QWSServer *server = QWSServer::instance(); - foreach (QWSWindow *w, server->clientWindows()) { - if (w->winId() == winId) - return w; - } - return 0; -} - -#define VERIFY_COLOR(rect, color) { \ - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ - rect.left(), rect.top(), \ - rect.width(), rect.height()); \ - QCOMPARE(pixmap.size(), rect.size()); \ - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ - expectedPixmap.fill(color); \ - QCOMPARE(pixmap, expectedPixmap); \ -} - -void tst_QWSWindowSystem::showHideWindow() -{ - ColorWidget w; - - const QRect rect(100, 100, 100, 100); - - w.setGeometry(rect); - QApplication::processEvents(); - - QWSWindow *win = getWindow(w.winId()); - QVERIFY(win); - QCOMPARE(win->requestedRegion(), QRegion()); - QCOMPARE(win->allocatedRegion(), QRegion()); - VERIFY_COLOR(rect, bgColor); - - w.show(); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - QCOMPARE(win->requestedRegion(), QRegion(rect)); - QCOMPARE(win->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w.color()); - - w.hide(); - QApplication::processEvents(); - QCOMPARE(win->requestedRegion(), QRegion()); - QCOMPARE(win->allocatedRegion(), QRegion()); - VERIFY_COLOR(rect, bgColor); -} - -void tst_QWSWindowSystem::raiseLowerWindow() -{ - const QRect rect(100, 100, 100, 100); - - ColorWidget w1(Qt::red); - w1.setGeometry(rect); - w1.show(); - QApplication::processEvents(); - - ColorWidget w2(Qt::blue); - w2.setGeometry(rect); - w2.show(); - - QWSWindow *win1 = getWindow(w1.winId()); - QWSWindow *win2 = getWindow(w2.winId()); - - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - QCOMPARE(win1->requestedRegion(), QRegion(rect)); - QCOMPARE(win2->requestedRegion(), QRegion(rect)); - QCOMPARE(win1->allocatedRegion(), QRegion()); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w2.color()); - - w1.raise(); - QApplication::processEvents(); - QCOMPARE(win1->requestedRegion(), QRegion(rect)); - QCOMPARE(win2->requestedRegion(), QRegion(rect)); - QCOMPARE(win1->allocatedRegion(), QRegion(rect)); - QCOMPARE(win2->allocatedRegion(), QRegion()); - VERIFY_COLOR(rect, w1.color()); - - w1.lower(); - QApplication::processEvents(); - QCOMPARE(win1->requestedRegion(), QRegion(rect)); - QCOMPARE(win2->requestedRegion(), QRegion(rect)); - QCOMPARE(win1->allocatedRegion(), QRegion()); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w2.color()); -} - -void tst_QWSWindowSystem::windowOpacity() -{ - const QRect rect(100, 100, 100, 100); - - ColorWidget w1(Qt::red); - w1.setGeometry(rect); - w1.show(); - - QWidget w2(0, Qt::FramelessWindowHint); - w2.setGeometry(rect); - w2.show(); - w2.raise(); - - QWSWindow *win1 = getWindow(w1.winId()); - QWSWindow *win2 = getWindow(w2.winId()); - - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - QCOMPARE(win1->allocatedRegion(), QRegion()); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w2.palette().color(w2.backgroundRole())); - - // Make w2 transparent so both widgets are shown. - - w2.setWindowOpacity(0.0); - QApplication::processEvents(); - QCOMPARE(win1->allocatedRegion(), QRegion(rect)); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w1.color()); - - w2.setWindowOpacity(1.0); - QApplication::processEvents(); - QCOMPARE(win1->allocatedRegion(), QRegion()); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w2.palette().color(w2.backgroundRole())); - - // Use the palette to make w2 transparent - QPalette palette = w2.palette(); - palette.setBrush(QPalette::All, QPalette::Background, - QColor(255, 255, 255, 0)); - w2.setPalette(palette); - QApplication::processEvents(); - QApplication::processEvents(); - QCOMPARE(win1->allocatedRegion(), QRegion(rect)); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w1.color()); - - palette.setBrush(QPalette::All, QPalette::Background, - QColor(255, 255, 255, 255)); - w2.setPalette(palette); - QApplication::processEvents(); - QApplication::processEvents(); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - QCOMPARE(win1->allocatedRegion(), QRegion()); - QCOMPARE(win2->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, QColor(255, 255, 255, 255)); -} - -void tst_QWSWindowSystem::directPainter() -{ - const QRect rect(100, 100, 100, 100); - - ColorWidget w(Qt::red); - w.setGeometry(rect); - w.show(); - - QWSWindow *win = getWindow(w.winId()); - - QApplication::processEvents(); - QCOMPARE(win->allocatedRegion(), QRegion(rect)); - - // reserve screen area using the static functions - - QDirectPainter::reserveRegion(QRegion(rect)); - QApplication::processEvents(); - QCOMPARE(win->allocatedRegion(), QRegion()); - QCOMPARE(QDirectPainter::reservedRegion(), QRegion(rect)); - - QDirectPainter::reserveRegion(QRegion()); - QApplication::processEvents(); - QCOMPARE(win->allocatedRegion(), QRegion(rect)); - QCOMPARE(QDirectPainter::reservedRegion(), QRegion()); - - // reserve screen area using a QDirectPainter object - { - QDirectPainter dp; - dp.setRegion(QRegion(rect)); - dp.lower(); - - QWSWindow *dpWin = getWindow(dp.winId()); - - QApplication::processEvents(); - QCOMPARE(win->allocatedRegion(), QRegion(rect)); - QCOMPARE(dpWin->allocatedRegion(), QRegion()); - - w.lower(); - QApplication::processEvents(); - QCOMPARE(win->allocatedRegion(), QRegion()); - QCOMPARE(dpWin->allocatedRegion(), QRegion(rect)); - } - - QApplication::processEvents(); - QCOMPARE(win->allocatedRegion(), QRegion(rect)); - VERIFY_COLOR(rect, w.color()); -} - -void tst_QWSWindowSystem::setMaxWindowRect() -{ - QDesktopWidget *desktop = QApplication::desktop(); - QSignalSpy spy(desktop, SIGNAL(workAreaResized(int))); - - const QRect screenRect = desktop->screenGeometry(); - - QWidget w; - w.showMaximized(); - QWidget w2; - QApplication::processEvents(); - - QCOMPARE(spy.count(), 0); - QCOMPARE(w.frameGeometry(), screenRect); - - QRect available = QRect(screenRect.left(), screenRect.top(), - screenRect.right() + 1, screenRect.bottom() - 20 + 1); - QWSServer::setMaxWindowRect(available); - QApplication::processEvents(); - - QCOMPARE(spy.count(), 1); - QCOMPARE(desktop->availableGeometry(), available); - QCOMPARE(w.frameGeometry(), desktop->availableGeometry()); - - w.hide(); - QApplication::processEvents(); - - QWSServer::setMaxWindowRect(screenRect); - QCOMPARE(spy.count(), 2); - w.show(); - QVERIFY(w.isMaximized()); - QCOMPARE(desktop->availableGeometry(), screenRect); - QCOMPARE(w.frameGeometry(), desktop->availableGeometry()); -} - -void tst_QWSWindowSystem::initialGeometry() -{ - ColorWidget w(Qt::red); - w.setGeometry(100, 0, 50, 50); - w.show(); - - const QRect rect(10, 200, 100, 100); - w.setGeometry(rect); - - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - - QCOMPARE(w.frameGeometry(), rect); - VERIFY_COLOR(rect, QColor(Qt::red)); -} - -void tst_QWSWindowSystem::WA_PaintOnScreen() -{ - ColorWidget w(Qt::red); - w.setAttribute(Qt::WA_PaintOnScreen); - - QRect rect; - - QVERIFY(w.testAttribute(Qt::WA_PaintOnScreen)); - rect = QRect(10, 0, 50, 50); - w.setGeometry(rect); - w.show(); - - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(w.windowSurface()); - QCOMPARE(surface->key(), QLatin1String("OnScreen")); - QVERIFY(w.testAttribute(Qt::WA_PaintOnScreen)); - VERIFY_COLOR(rect, QColor(Qt::red)); - - // move - rect = QRect(10, 100, 50, 50); - w.setGeometry(rect); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - VERIFY_COLOR(rect, QColor(Qt::red)); - - // resize - rect = QRect(10, 100, 60, 60); - w.setGeometry(rect); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - VERIFY_COLOR(rect, QColor(Qt::red)); -} - -class DummyMoveSurface : public QWSSharedMemSurface -{ -public: - DummyMoveSurface(QWidget *w) : QWSSharedMemSurface(w) {} - DummyMoveSurface() : QWSSharedMemSurface() {} - - // doesn't do any move - QRegion move(const QPoint &, const QRegion &) { - return QRegion(); - } - - QString key() const { return QLatin1String("dummy"); } -}; - -class DummyScreen : public QScreen -{ -private: - QScreen *s; - -public: - - DummyScreen() : QScreen(0), s(qt_screen) { - qt_screen = this; - w = s->width(); - h = s->height(); - dw = s->deviceWidth(); - dh = s->deviceHeight(); - d = s->depth(); - data = s->base(); - lstep = s->linestep(); - physWidth = s->physicalWidth(); - physHeight = s->physicalHeight(); - setPixelFormat(s->pixelFormat()); - } - - ~DummyScreen() { - qt_screen = s; - } - - bool initDevice() { return s->initDevice(); } - bool connect(const QString &displaySpec) { - return s->connect(displaySpec); - } - void disconnect() { s->disconnect(); } - void setMode(int w, int h, int d) { s->setMode(w, h, d); } - void exposeRegion(QRegion r, int changing) { - s->exposeRegion(r, changing); - } - void blit(const QImage &img, const QPoint &topLeft, const QRegion &r) { - s->blit(img, topLeft, r); - } - void solidFill(const QColor &color, const QRegion ®ion) { - s->solidFill(color, region); - } - QWSWindowSurface* createSurface(const QString &key) const { - if (key == QLatin1String("dummy")) - return new DummyMoveSurface; - return s->createSurface(key); - } -}; - -void tst_QWSWindowSystem::toplevelMove() -{ - { // default move implementation, opaque window - ColorWidget w(Qt::red); - w.show(); - - w.setGeometry(50, 50, 50, 50); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - VERIFY_COLOR(QRect(50, 50, 50, 50), w.color()); - VERIFY_COLOR(QRect(100, 100, 50, 50), bgColor); - - w.move(100, 100); - QApplication::processEvents(); - - VERIFY_COLOR(QRect(100, 100, 50, 50), w.color()); - VERIFY_COLOR(QRect(50, 50, 50, 50), bgColor); - } - - { // default move implementation, non-opaque window - ColorWidget w(Qt::red); - w.setWindowOpacity(0.5); - w.show(); - - w.setGeometry(50, 50, 50, 50); - QApplication::processEvents(); -// VERIFY_COLOR(QRect(50, 50, 50, 50), w.color()); - VERIFY_COLOR(QRect(100, 100, 50, 50), bgColor); - - w.move(100, 100); - QApplication::processEvents(); - -// VERIFY_COLOR(QRect(100, 100, 50, 50), w.color()); - VERIFY_COLOR(QRect(50, 50, 50, 50), bgColor); - } - - DummyScreen *screen = new DummyScreen; - { // dummy accelerated move - - ColorWidget w(Qt::red); - w.setWindowSurface(new DummyMoveSurface(&w)); - w.show(); - - w.setGeometry(50, 50, 50, 50); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - VERIFY_COLOR(QRect(50, 50, 50, 50), w.color()); - VERIFY_COLOR(QRect(100, 100, 50, 50), bgColor); - - w.move(100, 100); - QApplication::processEvents(); - // QEXPECT_FAIL("", "Task 169976", Continue); - //VERIFY_COLOR(QRect(50, 50, 50, 50), w.color()); // unchanged - VERIFY_COLOR(QRect(100, 100, 50, 50), bgColor); // unchanged - } - delete screen; -} - -static void fillWindowSurface(QWidget *w, const QColor &color) -{ - QWindowSurface *s = w->windowSurface(); - const QRect rect = s->rect(w); - s->beginPaint(rect); - QImage *img = s->buffer(w); - QPainter p(img); - p.fillRect(rect, color); - s->endPaint(rect); -} - -void tst_QWSWindowSystem::dontFlushUnitializedWindowSurfaces() -{ - QApplication::processEvents(); - - const QRect r(50, 50, 50, 50); - QDirectPainter p(0, QDirectPainter::ReservedSynchronous); - p.setRegion(r); - QCOMPARE(p.allocatedRegion(), QRegion(r)); - - { // Opaque widget, tests the blitting path in QScreen::compose() - ColorWidget w(Qt::red); - w.setGeometry(r); - w.show(); - QCOMPARE(w.visibleRegion(), QRegion()); - - // At this point w has a windowsurface but it's completely covered by - // the directpainter so nothing will be painted here and the - // windowsurface contains uninitialized data. - - QApplication::processEvents(); - QCOMPARE(p.allocatedRegion(), QRegion(r)); - QCOMPARE(w.visibleRegion(), QRegion()); - fillWindowSurface(&w, Qt::black); // fill with "uninitialized" data - - p.setRegion(QRegion()); - - QCOMPARE(w.visibleRegion(), QRegion()); - VERIFY_COLOR(r, bgColor); // don't blit uninitialized data - QTest::qWait(100); - - QApplication::processEvents(); // get new clip region - QCOMPARE(w.visibleRegion().translated(w.geometry().topLeft()), - QRegion(r)); - - QApplication::processEvents(); // do paint - VERIFY_COLOR(r, w.color()); - } - - p.setRegion(r); - - { // Semi-transparent widget, tests the blending path in QScreen::compose() - ColorWidget w(Qt::red); - w.setGeometry(r); - w.setWindowOpacity(0.44); - w.show(); - QCOMPARE(w.visibleRegion(), QRegion()); - - QApplication::processEvents(); - QCOMPARE(p.allocatedRegion(), QRegion(r)); - QCOMPARE(w.visibleRegion(), QRegion()); - fillWindowSurface(&w, Qt::black); // fill with "uninitialized" data - - p.setRegion(QRegion()); - - QCOMPARE(w.visibleRegion(), QRegion()); - VERIFY_COLOR(r, bgColor); - QTest::qWait(100); - - QApplication::processEvents(); - QCOMPARE(w.visibleRegion().translated(w.geometry().topLeft()), - QRegion(r)); - - QApplication::processEvents(); - - // compose expected color - QImage::Format screenFormat = QScreen::instance()->pixelFormat(); - if (screenFormat == QImage::Format_Invalid) - screenFormat = QImage::Format_ARGB32_Premultiplied; - - QImage img(1, 1, screenFormat); - { - QPainter p(&img); - p.fillRect(QRect(0, 0, 1, 1), bgColor); - p.setOpacity(w.windowOpacity()); -#if 1 - QImage colorImage(1,1, screenFormat); - { - QPainter urk(&colorImage); - urk.fillRect(QRect(0, 0, 1, 1), w.color()); - } - p.drawImage(0,0,colorImage); -#else - p.fillRect(QRect(0, 0, 1, 1), w.color()); -#endif - } - VERIFY_COLOR(r, img.pixel(0, 0)); - } -} - -void tst_QWSWindowSystem::task188025_data() -{ - QTest::addColumn<int>("windowFlags"); - - QTest::newRow("normal") << 0; - QTest::newRow("paintonscreen") << int(Qt::WA_PaintOnScreen | Qt::Window); -} - -void tst_QWSWindowSystem::task188025() -{ - QFETCH(int, windowFlags); - QRect r(-25, 50, 50, 50); - - ColorWidget w(Qt::red, Qt::WindowFlags(windowFlags)); - w.setGeometry(r); - w.show(); - QApplication::processEvents(); - QApplication::sendPostedEvents(); // glib event loop workaround - - const QRect visible(0, 50, 25, 50); - const QPoint topLeft = w.frameGeometry().topLeft(); - QCOMPARE(w.visibleRegion(), QRegion(visible.translated(-topLeft))); - VERIFY_COLOR(visible, Qt::red); - - w.setMask(QRect(25, 0, 25, 50)); - QApplication::processEvents(); - QCOMPARE(w.visibleRegion(), QRegion(visible.translated(-topLeft))); - VERIFY_COLOR(visible, Qt::red); - - // extend widget to the right (mask prevents new geometry to be exposed) - r = r.adjusted(0, 0, 25, 0); - w.setGeometry(r); - QApplication::processEvents(); - QCOMPARE(w.visibleRegion(), QRegion(visible.translated(-topLeft))); - VERIFY_COLOR(visible, Qt::red); -} - -QTEST_MAIN(tst_QWSWindowSystem) - -#include "tst_qwswindowsystem.moc" |