[AMBClient] - somewhat working json protocol engine
[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
23 int main(int argc, char** argv)
24 {
25         DebugOut::setDebugThreshhold(7);
26         DebugOut::setThrowErr(true);
27         DebugOut::setThrowWarn(false);
28
29         DebugOut(0) << "Testing AMB json server/client" << endl;
30
31         QCoreApplication app(argc, argv);
32
33         DomainSocket socket;
34
35         socket.open();
36
37         socket.getSocket()->waitForConnected();
38
39         DebugOut(0) << "We are connected!" << endl;
40
41         amb::AmbRemoteClient client(&socket);
42
43         runTest(&client);
44
45         app.exec();
46 }