summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorAnselmo L. S. Melo <anselmo.melo@openbossa.org>2012-01-27 07:49:34 -0300
committerQt by Nokia <qt-info@nokia.com>2012-01-31 07:05:09 +0100
commit8839a0a001c7017a1acf1d7460c4c19893c74967 (patch)
treeb85e72ac6e15314799e45ccf5a0bb42d9a5aa0ac /tests/auto/gui
parente8105e4783f3932885695353eefa1a60937929a1 (diff)
Fix QGuiApplication::topLevelWindows(), introducing allWindows()
As discussed on the development mailing list, the window list returned by QGuiApplication::topLevellWindows() included all QWindows, even the non top-level ones. This commit introduces the new method allWindows(), which returns the list of all QWindows, fixes the list returned by topLevelWindows() and also introduces tests for both methods. Change-Id: I761f0fcdec79f83949012c628655ed12cd18572c Reviewed-by: Jonas Gastal <jgastal@profusion.mobi> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index 4ea415b826..2fd875b7f4 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <QtGui/QGuiApplication>
+#include <QtGui/QWindow>
#include <QDebug>
class tst_QGuiApplication: public QObject
@@ -50,6 +51,8 @@ class tst_QGuiApplication: public QObject
private slots:
void focusObject();
+ void allWindows();
+ void topLevelWindows();
};
class DummyWindow : public QWindow
@@ -115,6 +118,39 @@ void tst_QGuiApplication::focusObject()
QCOMPARE(app.focusObject(), &obj3);
}
+void tst_QGuiApplication::allWindows()
+{
+ int argc = 0;
+ QGuiApplication app(argc, 0);
+ QWindow *window1 = new QWindow;
+ QWindow *window2 = new QWindow(window1);
+ QVERIFY(app.allWindows().contains(window1));
+ QVERIFY(app.allWindows().contains(window2));
+ QCOMPARE(app.allWindows().count(), 2);
+ delete window1;
+ window1 = 0;
+ window2 = 0;
+ QVERIFY(!app.allWindows().contains(window2));
+ QVERIFY(!app.allWindows().contains(window1));
+ QCOMPARE(app.allWindows().count(), 0);
+}
+
+void tst_QGuiApplication::topLevelWindows()
+{
+ int argc = 0;
+ QGuiApplication app(argc, 0);
+ QWindow *window1 = new QWindow;
+ QWindow *window2 = new QWindow(window1);
+ QVERIFY(app.topLevelWindows().contains(window1));
+ QVERIFY(!app.topLevelWindows().contains(window2));
+ QCOMPARE(app.topLevelWindows().count(), 1);
+ delete window1;
+ window1 = 0;
+ window2 = 0;
+ QVERIFY(!app.topLevelWindows().contains(window2));
+ QVERIFY(!app.topLevelWindows().contains(window1));
+ QCOMPARE(app.topLevelWindows().count(), 0);
+}
QTEST_APPLESS_MAIN(tst_QGuiApplication)
#include "tst_qguiapplication.moc"