aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-10-10 09:41:43 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-11 11:44:20 +0200
commitbb9eb695003d786d86ff7ab44be51bb8cdca2573 (patch)
treee57885f243f115c3d4fb80d6776792f8713ebb3d /tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
parent16a2e13e2b84e0f76b99a317d1d4c5cc674707cd (diff)
Fix and re-enable constantUpdateOnWindow test.
Change-Id: I0015ea58bfd673352405642153a038b72d44aa37 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp48
1 files changed, 33 insertions, 15 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 55f91db603..28dacb1f81 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -346,7 +346,11 @@ void tst_qquickwindow::constantUpdates()
window.resize(250, 250);
ConstantUpdateItem item(window.contentItem());
window.show();
- QTRY_VERIFY(item.iterations > 60);
+
+ QSignalSpy spy(&window, SIGNAL(beforeSynchronizing()));
+
+ QTRY_VERIFY(item.iterations > 10);
+ QTRY_VERIFY(spy.count() > 10);
}
void tst_qquickwindow::constantUpdatesOnWindow_data()
@@ -361,42 +365,56 @@ void tst_qquickwindow::constantUpdatesOnWindow_data()
bool threaded = window.openglContext()->thread() != QGuiApplication::instance()->thread();
if (threaded) {
- QTest::newRow("blocked, beforeSync") << true << QByteArray(SIGNAL(beforeSynchronizing()));
QTest::newRow("blocked, beforeRender") << true << QByteArray(SIGNAL(beforeRendering()));
QTest::newRow("blocked, afterRender") << true << QByteArray(SIGNAL(afterRendering()));
QTest::newRow("blocked, swapped") << true << QByteArray(SIGNAL(frameSwapped()));
}
- QTest::newRow("unblocked, beforeSync") << false << QByteArray(SIGNAL(beforeSynchronizing()));
QTest::newRow("unblocked, beforeRender") << false << QByteArray(SIGNAL(beforeRendering()));
QTest::newRow("unblocked, afterRender") << false << QByteArray(SIGNAL(afterRendering()));
QTest::newRow("unblocked, swapped") << false << QByteArray(SIGNAL(frameSwapped()));
}
+class FrameCounter : public QObject
+{
+ Q_OBJECT
+public slots:
+ void incr() { QMutexLocker locker(&m_mutex); ++m_counter; }
+public:
+ FrameCounter() : m_counter(0) {}
+ int count() { QMutexLocker locker(&m_mutex); int x = m_counter; return x; }
+private:
+ int m_counter;
+ QMutex m_mutex;
+};
+
void tst_qquickwindow::constantUpdatesOnWindow()
{
- QSKIP("This test fails frequently on the present overworked CI mac machines");
QFETCH(bool, blockedGui);
QFETCH(QByteArray, signal);
QQuickWindow window;
window.setGeometry(100, 100, 300, 200);
- connect(&window, signal.constData(), &window, SLOT(update()), Qt::DirectConnection);
+ bool ok = connect(&window, signal.constData(), &window, SLOT(update()), Qt::DirectConnection);
+ Q_ASSERT(ok);
window.show();
- QTRY_VERIFY(window.isExposed());
+ QTest::qWaitForWindowExposed(&window);
- QSignalSpy catcher(&window, SIGNAL(frameSwapped()));
- if (blockedGui)
- QTest::qSleep(1000);
- else {
+ FrameCounter counter;
+ connect(&window, SIGNAL(frameSwapped()), &counter, SLOT(incr()), Qt::DirectConnection);
+
+ int frameCount = 10;
+ QElapsedTimer timer;
+ timer.start();
+ if (blockedGui) {
+ while (counter.count() < frameCount)
+ QTest::qSleep(100);
+ QVERIFY(counter.count() >= frameCount);
+ } else {
window.update();
- QTest::qWait(1000);
+ QTRY_VERIFY(counter.count() > frameCount);
}
window.hide();
-
- // We should expect 60, but under loaded conditions we could be skipping
- // frames, so don't expect too much.
- QVERIFY(catcher.size() > 10);
}
void tst_qquickwindow::touchEvent_basic()