From f9c10b52dda4fe9a46a436edafaf0c2c199a0980 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 4 Jan 2012 14:50:52 +0100 Subject: [PATCH] Use QSignalSpy to save some code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: If4a9b68c39facdca34482bbf3dc22ae607b294e8 Reviewed-by: Samuel Rødal --- .../qtquick2/qquickcanvas/tst_qquickcanvas.cpp | 29 ++++------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp index 9ded975..a6f4137 100644 --- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp +++ b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp @@ -49,6 +49,7 @@ #include #include #include "../../shared/util.h" +#include struct TouchEventData { QEvent::Type type; @@ -609,25 +610,6 @@ void tst_qquickcanvas::animationsWhileHidden() } -class SceneGraphListener : public QObject -{ - Q_OBJECT - -public: - SceneGraphListener() - : wasInitialized(false) - , wasInvalidated(false) - { - } - - bool wasInitialized; - bool wasInvalidated; - -public slots: - void initialized() { wasInitialized = true; } - void invalidated() { wasInvalidated = true; } -}; - void tst_qquickcanvas::headless() { QDeclarativeEngine engine; @@ -641,9 +623,8 @@ void tst_qquickcanvas::headless() QTest::qWaitForWindowShown(canvas); QVERIFY(canvas->visible()); - SceneGraphListener listener; - connect(canvas, SIGNAL(sceneGraphInitialized()), &listener, SLOT(initialized()), Qt::DirectConnection); - connect(canvas, SIGNAL(sceneGraphInvalidated()), &listener, SLOT(invalidated()), Qt::DirectConnection); + QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized())); + QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated())); // Verify that the canvas is alive and kicking QVERIFY(canvas->openglContext() != 0); @@ -653,7 +634,7 @@ void tst_qquickcanvas::headless() // Hide the canvas and verify signal emittion and GL context deletion canvas->hide(); - QVERIFY(listener.wasInvalidated); + QCOMPARE(invalidated.size(), 1); QVERIFY(canvas->openglContext() == 0); // Destroy the native windowing system buffers @@ -664,7 +645,7 @@ void tst_qquickcanvas::headless() canvas->show(); QTest::qWaitForWindowShown(canvas); - QVERIFY(listener.wasInitialized); + QCOMPARE(initialized.size(), 1); QVERIFY(canvas->openglContext() != 0); // Verify that the visual output is the same -- 2.7.4