summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile21
-rw-r--r--tests/test-resource-engine/test-resource-engine.cpp62
-rw-r--r--tests/test-resource-engine/test-resource-engine.h32
-rw-r--r--tests/test-resource-engine/test-resource-engine.pro29
-rw-r--r--tests/test-resource-set/test-resource-set.cpp (renamed from tests/test-resource-set.cpp)0
-rw-r--r--tests/test-resource-set/test-resource-set.h (renamed from tests/test-resource-set.h)0
-rw-r--r--tests/test-resource-set/test-resource-set.pro (renamed from tests/test-resource-set.pro)0
-rw-r--r--tests/test-resource/test-resource.cpp (renamed from tests/test-resource.cpp)0
-rw-r--r--tests/test-resource/test-resource.h (renamed from tests/test-resource.h)0
-rw-r--r--tests/test-resource/test-resource.pro (renamed from tests/test-resource.pro)0
10 files changed, 123 insertions, 21 deletions
diff --git a/tests/Makefile b/tests/Makefile
deleted file mode 100644
index 20ae9ef..0000000
--- a/tests/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-QMAKE = qmake
-MAKEFILES = $(patsubst %.pro,%.make,$(wildcard *.pro))
-MAKEOVERRIDES =
-
-%.make: %.pro
- $(QMAKE) -o $@ $<
-
-tests: all
- find build -type f -name 'test-*' -exec sh -c "if test -x {}; then {}; fi" \;
-
-clean:
- $(RM) $(MAKEFILES)
- $(RM) -r build
-
-all: $(MAKEFILES)
- for makefile in $(MAKEFILES); do $(MAKE) -f "$$makefile" all; done
-
-install: $(MAKEFILES)
- for makefile in $(MAKEFILES); do $(MAKE) -f "$$makefile" install; done
-
-.phony: install tests all clean
diff --git a/tests/test-resource-engine/test-resource-engine.cpp b/tests/test-resource-engine/test-resource-engine.cpp
new file mode 100644
index 0000000..5c95224
--- /dev/null
+++ b/tests/test-resource-engine/test-resource-engine.cpp
@@ -0,0 +1,62 @@
+#include "test-resource-engine.h"
+#include <dbus/dbus.h>
+
+using namespace ResourcePolicy;
+
+TestResourceEngine::TestResourceEngine()
+ : resourceEngine(NULL), resourceSet(NULL),
+ audioPlayback(AudioPlaybackResource), videoPlayback(VideoPlaybackResource),
+ audioRecorder(AudioRecorderResource), videoRecorder(VideoRecorderResource)
+{
+ resourceSet = new ResourceSet("player", this);
+ resourceSet->addResource(audioPlayback);
+ resourceSet->addResource(videoPlayback);
+ resourceSet->addResource(audioRecorder);
+ resourceSet->addResource(videoRecorder);
+}
+
+TestResourceEngine::~TestResourceEngine()
+{
+}
+
+void TestResourceEngine::init()
+{
+ resourceEngine = new ResourceEngine(resourceSet);
+ bool initializeSucceeded = resourceEngine->initialize();
+ QVERIFY(!resourceEngine->isConnected());
+ QVERIFY(initializeSucceeded);
+}
+
+void TestResourceEngine::testConnect()
+{
+ bool connectIsSuccessful = resourceEngine->connect();
+ QVERIFY(connectIsSuccessful);
+}
+
+QTEST_MAIN(TestResourceEngine)
+
+////////////////////////////////////////////////////////////////
+
+resconn_t* resproto_init(resproto_role_t role, resproto_transport_t transport, ...)
+{
+ resconn_t *resourceConnection;
+ resconn_linkup_t callbackFunction;
+ DBusConnection *dbusConnection, systemBus;
+ va_list args;
+
+ va_start();
+ callbackFunction = va_arg(args, resconn_linkup_t);
+ dbusConnection = va_arg(args, DBusConnection *);
+ va_end();
+
+ systemBus = dbus_bus_get(DBUS_BUS_SYSTEM);
+
+ QVERIFY(callbackFunction != NULL);
+ QVERIFY(dbusConnection == systemBus);
+ QVERIFY(role == RESPROTO_ROLE_CLIENT);
+ QVERIFY(transport == RESPROTO_TRANSPORT_DBUS);
+
+ resourceConnection =(resconn_t *) calloc(1, sizeof(resconn_t));
+
+ return resourceConnection;
+}
diff --git a/tests/test-resource-engine/test-resource-engine.h b/tests/test-resource-engine/test-resource-engine.h
new file mode 100644
index 0000000..5484a05
--- /dev/null
+++ b/tests/test-resource-engine/test-resource-engine.h
@@ -0,0 +1,32 @@
+#ifndef TEST_RESOURCE_ENGINE_H
+#define TEST_RESOURCE_ENGINE_H
+
+#include <QtTest/QTest>
+#include "resource-engine.h"
+
+using namespace ResourcePolicy;
+
+class TestResourceEngine: public QObject
+{
+ Q_OBJECT
+ friend resconn_t* resproto_init(resproto_role_t, resproto_transport_t, ...);
+private:
+ ResourceEngine *resourceEngine;
+ ResourceSet *resourceSet;
+ Resource audioPlayback;
+ Resource videoPlayback;
+ Resource audioRecorder;
+ Resource videoRecorder;
+ bool libresourceInitialized;
+public:
+ TestResourceEngine();
+ ~TestResourceEngine();
+public slots:
+
+private slots:
+ void init();
+
+ void testConnect();
+};
+
+#endif
diff --git a/tests/test-resource-engine/test-resource-engine.pro b/tests/test-resource-engine/test-resource-engine.pro
new file mode 100644
index 0000000..9413609
--- /dev/null
+++ b/tests/test-resource-engine/test-resource-engine.pro
@@ -0,0 +1,29 @@
+BASE = ..
+TEMPLATE = app
+TARGET = test-resource-engine
+DESTDIR = build
+DEPENDPATH += $${BASE}/include $${BASE}/src .
+INCLUDEPATH += $${BASE}/src $${BASE}/include $${BASE}/../libresource/src
+
+# Input
+HEADERS += $${BASE}/include/resource.h \
+ $${BASE}/include/resource-set.h \
+ $${BASE}/src/resource-engine.h \
+ test-resource-engine.h
+
+SOURCES += $${BASE}/src/resource.cpp \
+ $${BASE}/src/resource-set.cpp \
+ $${BASE}/src/resource-engine.cpp \
+ test-resource-engine.cpp
+
+OBJECTS_DIR = build
+MOC_DIR = build
+
+CONFIG += qt qtestlib debug warn_on link_pkgconfig
+QT -= gui
+PKGCONFIG += dbus-1
+
+# Install directives
+INSTALLBASE = /usr
+target.path = $${INSTALLBASE}/share/libresourceqt/tests
+INSTALLS = target
diff --git a/tests/test-resource-set.cpp b/tests/test-resource-set/test-resource-set.cpp
index e9ee74b..e9ee74b 100644
--- a/tests/test-resource-set.cpp
+++ b/tests/test-resource-set/test-resource-set.cpp
diff --git a/tests/test-resource-set.h b/tests/test-resource-set/test-resource-set.h
index 0a3eeef..0a3eeef 100644
--- a/tests/test-resource-set.h
+++ b/tests/test-resource-set/test-resource-set.h
diff --git a/tests/test-resource-set.pro b/tests/test-resource-set/test-resource-set.pro
index ad6d90d..ad6d90d 100644
--- a/tests/test-resource-set.pro
+++ b/tests/test-resource-set/test-resource-set.pro
diff --git a/tests/test-resource.cpp b/tests/test-resource/test-resource.cpp
index 2098a88..2098a88 100644
--- a/tests/test-resource.cpp
+++ b/tests/test-resource/test-resource.cpp
diff --git a/tests/test-resource.h b/tests/test-resource/test-resource.h
index fc04c47..fc04c47 100644
--- a/tests/test-resource.h
+++ b/tests/test-resource/test-resource.h
diff --git a/tests/test-resource.pro b/tests/test-resource/test-resource.pro
index 7ab2678..7ab2678 100644
--- a/tests/test-resource.pro
+++ b/tests/test-resource/test-resource.pro