summaryrefslogtreecommitdiffstats
path: root/tests/resourcecommunicationtest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/resourcecommunicationtest.cpp')
-rw-r--r--tests/resourcecommunicationtest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp
new file mode 100644
index 0000000..f1cef50
--- /dev/null
+++ b/tests/resourcecommunicationtest.cpp
@@ -0,0 +1,41 @@
1#include <QtTest>
2
3#include "resourceaccess.h"
4#include "listener.h"
5#include "commands.h"
6#include "handshake_generated.h"
7
8class ResourceCommunicationTest : public QObject
9{
10 Q_OBJECT
11private Q_SLOTS:
12 void testConnect()
13 {
14 const QByteArray resourceIdentifier("test");
15 Listener listener(resourceIdentifier);
16 Akonadi2::ResourceAccess resourceAccess(resourceIdentifier);
17
18 QSignalSpy spy(&resourceAccess, &Akonadi2::ResourceAccess::ready);
19 resourceAccess.open();
20 QTRY_COMPARE(spy.size(), 1);
21 }
22
23 void testHandshake()
24 {
25 const QByteArray resourceIdentifier("test");
26 Listener listener(resourceIdentifier);
27 Akonadi2::ResourceAccess resourceAccess(resourceIdentifier);
28 resourceAccess.open();
29
30 flatbuffers::FlatBufferBuilder fbb;
31 auto name = fbb.CreateString("test");
32 auto command = Akonadi2::CreateHandshake(fbb, name);
33 Akonadi2::FinishHandshakeBuffer(fbb, command);
34 auto result = resourceAccess.sendCommand(Akonadi2::Commands::HandshakeCommand, fbb).exec();
35 result.waitForFinished();
36 QVERIFY(!result.errorCode());
37 }
38};
39
40QTEST_MAIN(ResourceCommunicationTest)
41#include "resourcecommunicationtest.moc"