[Telepathy-commits] [telepathy-qt4/master] tests/pinocchio: add a PinocchioTest base class
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Nov 27 05:50:52 PST 2008
---
tests/pinocchio/Makefile.am | 17 +++++++++++---
tests/pinocchio/do-nothing.cpp | 47 ++++++----------------------------------
tests/pinocchio/lib.cpp | 46 +++++++++++++++++++++++++++++++++++++++
tests/pinocchio/lib.h | 28 +++++++++++++++++++++++
4 files changed, 94 insertions(+), 44 deletions(-)
create mode 100644 tests/pinocchio/lib.cpp
create mode 100644 tests/pinocchio/lib.h
diff --git a/tests/pinocchio/Makefile.am b/tests/pinocchio/Makefile.am
index 286d5df..55ed855 100644
--- a/tests/pinocchio/Makefile.am
+++ b/tests/pinocchio/Makefile.am
@@ -6,16 +6,17 @@ TESTS = \
test-do-nothing
BUILT_SOURCES = \
- _gen/do-nothing.moc.hpp
+ _gen/do-nothing.cpp.moc.hpp \
+ _gen/lib.h.moc.hpp
-_gen/%.moc.hpp: %.cpp
+_gen/%.moc.hpp: %
$(mkdir_p) _gen
$(MOC) $(LIB_CFLAGS) -i $< -o $@
noinst_PROGRAMS = $(TESTS)
test_do_nothing_SOURCES = do-nothing.cpp
-test_do_nothing_LDADD = $(TP_QT4_LIBS) $(QTTEST_LIBS)
+test_do_nothing_LDADD = $(TP_QT4_LIBS) $(QTTEST_LIBS) $(noinst_LTLIBRARIES)
LIB_CFLAGS = \
$(QTCORE_CFLAGS) \
@@ -33,10 +34,18 @@ TESTS_ENV = \
XDG_DATA_HOME=@abs_top_builddir@/tests \
XDG_DATA_DIRS=@abs_top_srcdir@/tests \
PINOCCHIO=@PINOCCHIO@ \
- PINOCCHIO_CTL=@PINOCCHIO_CTL@
+ PINOCCHIO_CTL=@PINOCCHIO_CTL@ \
+ PINOCCHIO_DATA_DIR=@abs_srcdir@ \
+ PINOCCHIO_SAVE_DIR=@abs_builddir@
TESTS_ENVIRONMENT = \
$(TESTS_ENV) \
sh $(top_srcdir)/tools/with-session-bus.sh --session --
+noinst_LTLIBRARIES = libpinocchio-tests.la
+
+libpinocchio_tests_la_SOURCES = \
+ lib.cpp \
+ lib.h
+
endif
diff --git a/tests/pinocchio/do-nothing.cpp b/tests/pinocchio/do-nothing.cpp
index 5a7ba56..64bb1a3 100644
--- a/tests/pinocchio/do-nothing.cpp
+++ b/tests/pinocchio/do-nothing.cpp
@@ -1,29 +1,14 @@
-#include <cstdlib>
-
-#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
-#include <QtCore/QProcess>
#include <QtCore/QTimer>
#include <QtDBus/QtDBus>
-#include <QtTest/QtTest>
+#include <tests/pinocchio/lib.h>
-class TestDoNothing : public QObject
+class TestDoNothing : public PinocchioTest
{
Q_OBJECT
-public:
- TestDoNothing(QObject *parent = 0)
- : QObject(parent), mLoop(new QEventLoop(this))
- { }
-
-private:
- QString mPinocchioPath;
- QString mPinocchioCtlPath;
- QProcess mPinocchio;
- QEventLoop *mLoop;
-
private slots:
void initTestCase();
void init();
@@ -38,26 +23,13 @@ private slots:
void TestDoNothing::initTestCase()
{
- mPinocchioPath = QString::fromLocal8Bit(::getenv("PINOCCHIO"));
- mPinocchioCtlPath = QString::fromLocal8Bit(::getenv("PINOCCHIO_CTL"));
-
- QVERIFY2(!mPinocchioPath.isEmpty(), "Put $PINOCCHIO in your environment");
- QVERIFY2(!mPinocchioCtlPath.isEmpty(),
- "Put $PINOCCHIO_CTL in your environment");
- QVERIFY(QDBusConnection::sessionBus().isConnected());
-
- mPinocchio.setProcessChannelMode(QProcess::ForwardedChannels);
- mPinocchio.start(mPinocchioPath, QStringList());
-
- QVERIFY(mPinocchio.waitForStarted(5000));
- mPinocchio.closeWriteChannel();
-
- qDebug() << "Started Pinocchio";
+ initTestCaseImpl();
}
void TestDoNothing::init()
{
+ initImpl();
}
@@ -77,20 +49,15 @@ void TestDoNothing::doNothing2()
void TestDoNothing::cleanup()
{
+ cleanupImpl();
}
void TestDoNothing::cleanupTestCase()
{
- qDebug() << "Terminating Pinocchio";
-
- mPinocchio.terminate();
-
- if (!mPinocchio.waitForFinished(1000)) {
- mPinocchio.kill();
- }
+ cleanupTestCaseImpl();
}
QTEST_MAIN(TestDoNothing)
-#include "_gen/do-nothing.moc.hpp"
+#include "_gen/do-nothing.cpp.moc.hpp"
diff --git a/tests/pinocchio/lib.cpp b/tests/pinocchio/lib.cpp
new file mode 100644
index 0000000..1a0f5b2
--- /dev/null
+++ b/tests/pinocchio/lib.cpp
@@ -0,0 +1,46 @@
+#include "tests/pinocchio/lib.h"
+
+#include <cstdlib>
+
+void PinocchioTest::initTestCaseImpl()
+{
+ mPinocchioPath = QString::fromLocal8Bit(::getenv("PINOCCHIO"));
+ mPinocchioCtlPath = QString::fromLocal8Bit(::getenv("PINOCCHIO_CTL"));
+
+ QVERIFY2(!mPinocchioPath.isEmpty(), "Put $PINOCCHIO in your environment");
+ QVERIFY2(!mPinocchioCtlPath.isEmpty(),
+ "Put $PINOCCHIO_CTL in your environment");
+ QVERIFY(QDBusConnection::sessionBus().isConnected());
+
+ mPinocchio.setProcessChannelMode(QProcess::ForwardedChannels);
+ mPinocchio.start(mPinocchioPath, QStringList());
+
+ QVERIFY(mPinocchio.waitForStarted(5000));
+ mPinocchio.closeWriteChannel();
+
+ qDebug() << "Started Pinocchio";
+}
+
+
+void PinocchioTest::initImpl()
+{
+}
+
+
+void PinocchioTest::cleanupImpl()
+{
+}
+
+
+void PinocchioTest::cleanupTestCaseImpl()
+{
+ qDebug() << "Terminating Pinocchio";
+
+ mPinocchio.terminate();
+
+ if (!mPinocchio.waitForFinished(1000)) {
+ mPinocchio.kill();
+ }
+}
+
+#include "_gen/lib.h.moc.hpp"
diff --git a/tests/pinocchio/lib.h b/tests/pinocchio/lib.h
new file mode 100644
index 0000000..77b7219
--- /dev/null
+++ b/tests/pinocchio/lib.h
@@ -0,0 +1,28 @@
+#include <QtCore/QProcess>
+
+#include <QtDBus/QtDBus>
+
+#include <QtTest/QtTest>
+
+class PinocchioTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ PinocchioTest(QObject *parent = 0)
+ : QObject(parent), mLoop(new QEventLoop(this))
+ { }
+
+protected:
+ QString mPinocchioPath;
+ QString mPinocchioCtlPath;
+ QProcess mPinocchio;
+ QEventLoop *mLoop;
+
+protected slots:
+ virtual void initTestCaseImpl();
+ virtual void initImpl();
+
+ virtual void cleanupImpl();
+ virtual void cleanupTestCaseImpl();
+};
--
1.5.6.5
More information about the Telepathy-commits
mailing list