diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-09-24 12:51:36 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-26 20:08:19 +0200 |
commit | 0150202cc710e580695656fee049bf25091c0ded (patch) | |
tree | 217f5fbf792b5d40baeea0916064bb0ac2050b84 /tests/auto/quick/qquickanimators/tst_qquickanimators.cpp | |
parent | c40d9f64a6bd9671edc807bc74cf5b73c7465250 (diff) |
Allow animators to work properly with multiple windows
Change-Id: I5ba663ba0fa089ea786cf43cb4dfa40cbc955342
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'tests/auto/quick/qquickanimators/tst_qquickanimators.cpp')
-rw-r--r-- | tests/auto/quick/qquickanimators/tst_qquickanimators.cpp | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp index f3f982091f..3311fa6bf2 100644 --- a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp +++ b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp @@ -39,6 +39,75 @@ ** ****************************************************************************/ -#include <QtQuickTest/quicktest.h> +#include <qtest.h> + +#include <QtQuick> +#include <private/qquickanimator_p.h> + +#include <QtQml> + +class tst_Animators: public QObject +{ + Q_OBJECT + +private slots: + void testMultiWinAnimator_data(); + void testMultiWinAnimator(); +}; + +void tst_Animators::testMultiWinAnimator_data() +{ + QTest::addColumn<int>("count"); + + QTest::newRow("1") << 1; + QTest::newRow("10") << 10; +} + +void tst_Animators::testMultiWinAnimator() +{ + QFETCH(int, count); + + QQmlEngine engine; + QQmlComponent component(&engine, "data/windowWithAnimator.qml"); + + QList<QQuickWindow *> windows; + for (int i=0; i<count; ++i) { + QQuickWindow *win = qobject_cast<QQuickWindow *>(component.create()); + windows << win; + + // As the windows are all the same size, if they are positioned at the + // same place only the top-most one will strictly be "exposed" and rendering + // for all the others will be disabled. Move the windows a little bit + // to ensure they are exposed and actually rendering. + if (i > 0) { + QPoint pos = win->position(); + if (pos == windows.first()->position()) + pos += QPoint(10 * i, 10 * i); + win->setPosition(pos); + } + } + + // let all animations run their course... + while (true) { + QTest::qWait(200); + bool allDone = true; + for (int i=0; i<count; ++i) { + QQuickWindow *win = windows.at(i); + allDone = win->isExposed() && win->property("animationDone").toBool(); + } + + if (allDone) { + for (int i=0; i<count; ++i) { + QQuickWindow *win = windows.at(i); + delete win; + } + break; + } + } + QVERIFY(true); +} + +#include "tst_qquickanimators.moc" + +QTEST_MAIN(tst_Animators) -QUICK_TEST_MAIN(qquickanimators) |