1 #include "testProtocolCommon.h"
4 #include <jsonprotocol.h>
6 #include <QLocalSocket>
7 #include <QLocalServer>
8 #include <QCoreApplication>
13 void runTest(amb::AmbRemoteClient *c)
15 DebugOut(0) << "calling client->list()" << endl;
16 c->list([](std::vector<amb::Object::Ptr> supported)
18 DebugOut(0) << "list call reply" << endl;
19 g_assert(supported.size() == 2);
22 c->subscribe("interface1", [](amb::Object::Ptr obj)
24 DebugOut(0) << obj->interfaceName << " changed!" << endl;
27 DebugOut(0) << "calling client->get()" << endl;
28 c->get("interface1", [](amb::Object::Ptr obj)
30 DebugOut(0) << "get call reply" << endl;
31 g_assert(obj->size() == 2);
33 obj->emplace("vehicleSpeed", amb::make_shared(new VehicleProperty::VehicleSpeedType(69)));
37 amb::Object::Ptr obj = amb::Object::create();
39 obj->interfaceName = "interface1";
40 obj->emplace("vehicleSpeed", amb::make_shared(new VehicleProperty::VehicleSpeedType(22)));
42 c->set("interface1", obj, [](bool s)
44 DebugOut(0) << "set call reply status: " << (s ? "success!" : "fail") << endl;
49 int main(int argc, char** argv)
51 DebugOut::setDebugThreshhold(7);
52 DebugOut::setThrowErr(true);
53 DebugOut::setThrowWarn(false);
55 DebugOut(0) << "Testing AMB json server/client" << endl;
57 QCoreApplication app(argc, argv);
63 if(!socket.getSocket()->waitForConnected())
65 DebugOut("Could not connect");
69 DebugOut(0) << "We are connected!" << endl;
71 amb::AmbRemoteClient client(&socket);