diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:46:57 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:49:28 +0100 |
commit | 76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch) | |
tree | f165b7bc319548fb0082365411a871028f92e89e /tests/auto/widgets/kernel | |
parent | 27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff) | |
parent | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Conflicts:
src/gui/text/qfontdatabase.cpp
src/gui/text/qharfbuzz_copy_p.h
src/widgets/kernel/qapplication.cpp
src/widgets/kernel/qcoreapplication.cpp
Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'tests/auto/widgets/kernel')
10 files changed, 282 insertions, 13 deletions
diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index b280f44f05..20720dc928 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -15,6 +15,7 @@ SUBDIRS=\ qwidgetaction \ qwidgetmetatype \ qwidgetsvariant \ + qwindowcontainer \ qshortcut \ qsizepolicy diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp b/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp index e24c21feab..e935cfd53a 100644 --- a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp +++ b/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp @@ -40,14 +40,15 @@ ****************************************************************************/ #include <QApplication> #include <stdio.h> -int main(int argc, char *argv[]) + +int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QApplication app(argc, argv); if (argc > 1) fprintf(stderr, "%s", argv[1]); else fprintf(stderr, "Failed"); fflush(stderr); - return 0; + return 0; } diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp index 63ffc13c68..4efe8c4273 100644 --- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp +++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <QtWidgets/QDesktopWidget> +#include <QtGui/QWindow> #include <QDebug> class tst_QDesktopWidget : public QObject @@ -63,6 +64,7 @@ private slots: void screenNumberForQPoint(); void availableGeometry(); void screenGeometry(); + void topLevels(); }; tst_QDesktopWidget::tst_QDesktopWidget() @@ -177,6 +179,21 @@ void tst_QDesktopWidget::screenGeometry() } } +void tst_QDesktopWidget::topLevels() +{ + // Desktop widgets/windows should not be listed as top-levels. + int topLevelDesktopWidgets = 0; + int topLevelDesktopWindows = 0; + foreach (const QWidget *w, QApplication::topLevelWidgets()) + if (w->windowType() == Qt::Desktop) + topLevelDesktopWidgets++; + foreach (const QWindow *w, QGuiApplication::topLevelWindows()) + if (w->type() == Qt::Desktop) + topLevelDesktopWindows++; + QCOMPARE(topLevelDesktopWidgets, 0); + QCOMPARE(topLevelDesktopWindows, 0); +} + QTEST_MAIN(tst_QDesktopWidget) #include "tst_qdesktopwidget.moc" diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index d77dd003d7..b970de8e87 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -169,11 +169,11 @@ void tst_QFormLayout::rowCount() fl->addRow(tr("Label 2"), new QLineEdit); fl->addRow(tr("Label 3"), new QLineEdit); QCOMPARE(fl->rowCount(), 3); - + fl->addRow(new QWidget); fl->addRow(new QHBoxLayout); QCOMPARE(fl->rowCount(), 5); - + fl->insertRow(1, tr("Label 0.5"), new QLineEdit); QCOMPARE(fl->rowCount(), 6); @@ -206,7 +206,7 @@ void tst_QFormLayout::buddies() fl->addRow(le3); QWidget *label3 = fl->labelForField(le3); QVERIFY(label3 == 0); - + //TODO: empty label? delete w; diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index f830ead6c0..2b9b4fd761 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -155,7 +155,7 @@ void tst_QLayout::geometry() void tst_QLayout::smartMaxSize() { - QVector<int> expectedWidths; + QVector<int> expectedWidths; QFile f(QFINDTESTDATA("baseline/smartmaxsize")); @@ -170,9 +170,9 @@ void tst_QLayout::smartMaxSize() f.close(); int sizeCombinations[] = { 0, 10, 20, QWIDGETSIZE_MAX}; - QSizePolicy::Policy policies[] = { QSizePolicy::Fixed, - QSizePolicy::Minimum, - QSizePolicy::Maximum, + QSizePolicy::Policy policies[] = { QSizePolicy::Fixed, + QSizePolicy::Minimum, + QSizePolicy::Maximum, QSizePolicy::Preferred, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding, @@ -250,7 +250,7 @@ void tst_QLayout::setContentsMargins() MyLayout layout; layout.invalidated = false; int left, top, right, bottom; - + layout.setContentsMargins(52, 53, 54, 55); QVERIFY(layout.invalidated); layout.invalidated = false; @@ -260,7 +260,7 @@ void tst_QLayout::setContentsMargins() QCOMPARE(top, 53); QCOMPARE(right, 54); QCOMPARE(bottom, 55); - + layout.setContentsMargins(52, 53, 54, 55); QVERIFY(!layout.invalidated); } diff --git a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp index 2d3e3c1702..441277ef53 100644 --- a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp +++ b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp @@ -132,7 +132,7 @@ void tst_QToolTip::whatsThis() { qApp->setStyleSheet( "QWidget { font-size: 72px; }" ); QWhatsThis::showText(QPoint(0,0), "THis is text"); - QTest::qWait(400); + QTest::qWait(400); QWidget *whatsthis = 0; foreach (QWidget *widget, QApplication::topLevelWidgets()) { if (widget->inherits("QWhatsThat")) { diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index f9ee2e485a..252d47f698 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -412,6 +412,7 @@ private slots: void keyboardModifiers(); void mouseDoubleClickBubbling_QTBUG29680(); + void largerThanScreen_QTBUG30142(); private: bool ensureScreenSize(int width, int height); @@ -5632,6 +5633,7 @@ void tst_QWidget::showHideShowX11() qApp->installNativeEventFilter(&w); w.show(); + QVERIFY(QTest::qWaitForWindowExposed(&w)); w.hide(); QEventLoop eventLoop; @@ -10079,5 +10081,20 @@ void tst_QWidget::mouseDoubleClickBubbling_QTBUG29680() QTRY_VERIFY(parent.triggered); } +void tst_QWidget::largerThanScreen_QTBUG30142() +{ + QWidget widget; + widget.resize(200, 4000); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QVERIFY(widget.frameGeometry().y() >= 0); + + QWidget widget2; + widget2.resize(10000, 400); + widget2.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget2)); + QVERIFY(widget2.frameGeometry().x() >= 0); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/widgets/kernel/qwindowcontainer/.gitignore b/tests/auto/widgets/kernel/qwindowcontainer/.gitignore new file mode 100644 index 0000000000..038f477220 --- /dev/null +++ b/tests/auto/widgets/kernel/qwindowcontainer/.gitignore @@ -0,0 +1 @@ +tst_qwindowcontainer diff --git a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro new file mode 100644 index 0000000000..4ff05eb04a --- /dev/null +++ b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +mac:CONFIG -= app_bundle +# CONFIG += parallel_test // Cannot be parallel due to the activation test +TARGET = tst_qwindowcontainer +QT += widgets testlib +SOURCES += tst_qwindowcontainer.cpp diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp new file mode 100644 index 0000000000..440639cd49 --- /dev/null +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> + +#include <qapplication.h> +#include <qwindow.h> +#include <qwidget.h> + + + +class Window : public QWindow +{ +public: + Window() + : numberOfExposes(0) + , numberOfObscures(0) + { + } + + void exposeEvent(QExposeEvent *) { + if (isExposed()) + ++numberOfExposes; + else + ++numberOfObscures; + } + + int numberOfExposes; + int numberOfObscures; +}; + + + +class tst_QWindowContainer: public QObject +{ + Q_OBJECT +private slots: + void testShow(); + void testPositionAndSize(); + void testExposeObscure(); + void testOwnership(); + void testBehindTheScenesDeletion(); + void testUnparenting(); + void testActivation(); +}; + + + +void tst_QWindowContainer::testShow() +{ + QWidget root; + root.setGeometry(100, 100, 400, 400); + + Window *window = new Window(); + QWidget *container = QWidget::createWindowContainer(window, &root); + + container->setGeometry(50, 50, 200, 200); + + root.show(); + + QVERIFY(QTest::qWaitForWindowExposed(window)); +} + + + +void tst_QWindowContainer::testPositionAndSize() +{ + QWindow *window = new QWindow(); + window->setGeometry(300, 400, 500, 600); + + QWidget *container = QWidget::createWindowContainer(window); + container->setGeometry(50, 50, 200, 200); + + + container->show(); + QVERIFY(QTest::qWaitForWindowExposed(container)); + + QCOMPARE(window->x(), 0); + QCOMPARE(window->y(), 0); + QCOMPARE(window->width(), container->width()); + QCOMPARE(window->height(), container->height()); +} + + + +void tst_QWindowContainer::testExposeObscure() +{ + Window *window = new Window(); + + QWidget *container = QWidget::createWindowContainer(window); + container->setGeometry(50, 50, 200, 200); + + container->show(); + QVERIFY(QTest::qWaitForWindowExposed(container)); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QVERIFY(window->numberOfExposes > 0); + + container->hide(); + + QElapsedTimer timer; + timer.start(); + while (window->numberOfObscures == 0 && timer.elapsed() < 5000) { + QTest::qWait(10); + } + + QVERIFY(window->numberOfObscures > 0); +} + + + +void tst_QWindowContainer::testOwnership() +{ + QPointer<QWindow> window(new QWindow()); + QWidget *container = QWidget::createWindowContainer(window); + + delete container; + + QCOMPARE(window.data(), (QWindow *) 0); +} + + + +void tst_QWindowContainer::testBehindTheScenesDeletion() +{ + QWindow *window = new QWindow(); + QWidget *container = QWidget::createWindowContainer(window); + + delete window; + + // The child got removed, showing not should not have any side effects, + // such as for instance, crashing... + container->show(); + QVERIFY(QTest::qWaitForWindowExposed(container)); + delete container; +} + + + +void tst_QWindowContainer::testActivation() +{ + QWidget root; + + QWindow *window = new QWindow(); + QWidget *container = QWidget::createWindowContainer(window, &root); + + container->setGeometry(100, 100, 200, 100); + root.setGeometry(100, 100, 400, 300); + + root.show(); + root.activateWindow(); + + QVERIFY(QTest::qWaitForWindowActive(root.windowHandle())); + QVERIFY(QGuiApplication::focusWindow() == root.windowHandle()); + + // Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row + // does not work. The second gets ignored by the window manager, even though the + // timestamp in the xcb connection is unique for both. + if (QGuiApplication::platformName() == "xcb") + QTest::qWait(100); + + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); +} + + + +void tst_QWindowContainer::testUnparenting() +{ + QWindow *window = new QWindow(); + QWidget *container = QWidget::createWindowContainer(window); + container->setGeometry(100, 100, 200, 100); + + window->setParent(0); + + container->show(); + + QVERIFY(QTest::qWaitForWindowExposed(container)); + + // Window should not be made visible by container.. + QVERIFY(!window->isVisible()); +} + +QTEST_MAIN(tst_QWindowContainer) + +#include "tst_qwindowcontainer.moc" |