24ea5b8aa9f86cf5bfedba4ba56798f7bf884e18
[profile/ivi/automotive-message-broker.git] / tests / testProtocolClient.cpp
1 #include "testProtocolCommon.h"
2
3 #include <debugout.h>
4 #include <jsonprotocol.h>
5
6 #include <QLocalSocket>
7 #include <QLocalServer>
8 #include <QCoreApplication>
9 #include <QObject>
10
11 #include <memory>
12
13 void runTest(amb::AmbRemoteClient *c)
14 {
15         DebugOut(0) << "calling client->list()" << endl;
16         c->list([](std::vector<amb::Object> supported)
17         {
18                 DebugOut(0) << "list call reply" << endl;
19                 g_assert(supported.size() == 2);
20         });
21
22         DebugOut(0) << "calling client->get()" << endl;
23         c->get("interface1", [](amb::Object &obj)
24         {
25                 DebugOut(0) << "get call reply" << endl;
26                 g_assert(obj.size() == 3);
27         });
28 }
29
30 int main(int argc, char** argv)
31 {
32         DebugOut::setDebugThreshhold(7);
33         DebugOut::setThrowErr(true);
34         DebugOut::setThrowWarn(false);
35
36         DebugOut(0) << "Testing AMB json server/client" << endl;
37
38         QCoreApplication app(argc, argv);
39
40         DomainSocket socket;
41
42         socket.open();
43
44         socket.getSocket()->waitForConnected();
45
46         DebugOut(0) << "We are connected!" << endl;
47
48         amb::AmbRemoteClient client(&socket);
49
50         runTest(&client);
51
52         app.exec();
53 }