diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-30 17:34:45 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-30 17:34:45 +0200 |
commit | 93b208cc95114e39f5d3379e66646c94e70b6a02 (patch) | |
tree | 6bc896a259c813d3fee909962769a8feb5edd9e3 | |
parent | 25522af61f488a27fae7a24cdc7b2c949f442eed (diff) | |
download | sink-93b208cc95114e39f5d3379e66646c94e70b6a02.tar.gz sink-93b208cc95114e39f5d3379e66646c94e70b6a02.zip |
ResourceCommunicationTest
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/resourcecommunicationtest.cpp | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6a52101..542b4ed 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -41,6 +41,7 @@ auto_tests ( | |||
41 | indextest | 41 | indextest |
42 | genericresourcetest | 42 | genericresourcetest |
43 | genericfacadetest | 43 | genericfacadetest |
44 | resourcecommunicationtest | ||
44 | ) | 45 | ) |
45 | 46 | ||
46 | target_link_libraries(dummyresourcetest akonadi2_resource_dummy) | 47 | target_link_libraries(dummyresourcetest akonadi2_resource_dummy) |
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 | |||
8 | class ResourceCommunicationTest : public QObject | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | private 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 | |||
40 | QTEST_MAIN(ResourceCommunicationTest) | ||
41 | #include "resourcecommunicationtest.moc" | ||