* [GAM-74] resolving issues found by coverity scan
[profile/ivi/genivi/genivi-audio-manager.git] / PluginCommandInterfaceDbus / test / CAmCommandSenderDbusTest.cpp
1 /**
2  *  Copyright (c) 2012 BMW
3  *
4  *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
5  *
6  *  \copyright
7  *  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
8  *  including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9  *  subject to the following conditions:
10  *  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
12  *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
13  *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14  *
15  *  For further information see http://www.genivi.org/.
16  */
17
18 #include "CAmCommandSenderDbusTest.h"
19 #include <python2.6/Python.h>
20 #include <iostream>
21 #include <fstream>
22 #include <sstream>
23 #include <algorithm>
24 #include <string>
25 #include <vector>
26 #include <set>
27 #include "TAmPluginTemplate.h"
28 #include "MockIAmCommandReceive.h"
29 #include "shared/CAmDltWrapper.h"
30 #include "shared/CAmSocketHandler.h"
31 #include "shared/CAmDbusWrapper.h"
32 #include "../include/CAmCommandSenderDbus.h"
33 #include "../include/CAmDbusMessageHandler.h"
34
35 using namespace am;
36 using namespace testing;
37
38 std::string DBUSCOMMAND = "dbus-send --session --print-reply --dest=org.genivi.audiomanager /org/genivi/audiomanager/CommandInterface org.genivi.audiomanager.CommandInterface.";
39
40 void* run_the_loop(void* wrapper)
41 {
42     CAmSocketHandler* wrap = (CAmSocketHandler*) wrapper;
43     wrap->start_listenting();
44     return (NULL);
45 }
46
47 CAmCommandSenderDbusTest::CAmCommandSenderDbusTest() :
48         ppCommandSend(NULL) //
49 {
50     CAmDltWrapper::instance()->registerApp("dbusTest", "dbusTest");
51 }
52
53 CAmCommandSenderDbusTest::~CAmCommandSenderDbusTest()
54 {
55
56 }
57
58 void CAmCommandSenderDbusTest::SetUp()
59 {
60
61 }
62
63 void CAmCommandSenderDbusTest::TearDown()
64 {
65
66 }
67
68 ACTION(returnListConnections){
69 std::vector<am::am_MainConnectionType_s> list;
70 am::am_MainConnectionType_s listItem;
71 listItem.mainConnectionID=15;
72 listItem.sinkID=4;
73 listItem.sourceID=3;
74 listItem.connectionState=CS_UNKNOWN;
75 listItem.delay=34;
76 list.push_back(listItem);
77 arg0=list;
78 }
79
80 ACTION(returnListSinks){
81 std::vector<am::am_SinkType_s> list;
82 am::am_SinkType_s listItem;
83 listItem.availability.availability=A_UNAVAILABLE;
84 listItem.availability.availabilityReason=AR_GENIVI_NOMEDIA;
85 listItem.muteState=MS_UNMUTED;
86 listItem.name="mySink";
87 listItem.sinkClassID=34;
88 listItem.sinkID=24;
89 listItem.volume=124;
90 list.push_back(listItem);
91 arg0=list;
92 }
93
94 ACTION(returnListSources){
95 std::vector<am::am_SourceType_s> list;
96 am::am_SourceType_s listItem;
97 listItem.availability.availability=A_MAX;
98 listItem.availability.availabilityReason=AR_GENIVI_SAMEMEDIA;
99 listItem.name="MySource";
100 listItem.sourceClassID=12;
101 listItem.sourceID=224;
102 list.push_back(listItem);
103 listItem.name="NextSource";
104 listItem.sourceID=22;
105 list.push_back(listItem);
106 arg0=list;
107 }
108
109 ACTION(returnListMainSinkSoundProperties){
110 std::vector<am::am_MainSoundProperty_s> list;
111 am::am_MainSoundProperty_s listItem;
112 listItem.type=MSP_MAX;
113 listItem.value=223;
114 list.push_back(listItem);
115 listItem.type=MSP_UNKNOWN;
116 listItem.value=2;
117 list.push_back(listItem);
118 arg1=list;
119 }
120
121 ACTION(returnListSourceClasses){
122 std::vector<am::am_SourceClass_s> list;
123 am::am_SourceClass_s listItem;
124 am::am_ClassProperty_s property;
125 property.classProperty=CP_GENIVI_SINK_TYPE;
126 property.value=12;
127 listItem.name="FirstCLass";
128 listItem.sourceClassID=23;
129 listItem.listClassProperties.push_back(property);
130 list.push_back(listItem);
131 listItem.name="SecondCLass";
132 listItem.sourceClassID=2;
133 listItem.listClassProperties.push_back(property);
134 list.push_back(listItem);
135 arg0=list;
136 }
137
138 ACTION(returnListSinkClasses){
139 std::vector<am::am_SinkClass_s> list;
140 am::am_SinkClass_s listItem;
141 am::am_ClassProperty_s property;
142 property.classProperty=CP_GENIVI_SOURCE_TYPE;
143 property.value=122;
144 listItem.name="FirstCLass";
145 listItem.sinkClassID=2123;
146 listItem.listClassProperties.push_back(property);
147 list.push_back(listItem);
148 listItem.name="SecondCLass";
149 listItem.sinkClassID=23;
150 listItem.listClassProperties.push_back(property);
151 list.push_back(listItem);
152 arg0=list;
153 }
154
155 ACTION(returnListSystemProperties){
156 std::vector<am::am_SystemProperty_s> list;
157 am::am_SystemProperty_s listItem;
158 listItem.type=SYP_UNKNOWN;
159 listItem.value=-2245;
160 list.push_back(listItem);
161 arg0=list;
162 }
163
164 ACTION(returnTimingInfo){
165 am::am_timeSync_t time=23;
166 arg1=time;
167 }
168
169 TEST_F(CAmCommandSenderDbusTest, MessageTest)
170 {
171     Py_Initialize();
172     //unfortunatly we need to put all in one testcase because testing with the dbus loop caused problems...
173     CAmSocketHandler pSocketHandler;
174     CAmDbusWrapper pDBusWrapper(&pSocketHandler);
175     pthread_t ptestThread;
176     std::vector<std::string> plistCommandPluginDirs;
177     plistCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
178
179     MockIAmCommandReceive pReceiveInterface;
180
181     //this class just creates the thread that will handle the mainloop...
182     pthread_create(&ptestThread, NULL, run_the_loop, (void*) &pSocketHandler);
183
184     IAmCommandSend* (*createFunc)();
185     void* tempLibHandle = NULL;
186     std::string libname("../plugins/command/libPluginCommandInterfaceDbus.so");
187     createFunc = getCreateFunction<IAmCommandSend*()>(libname, tempLibHandle);
188
189     if (!createFunc)
190     {
191         logError("CommandSendInterface Test Entry point of RoutingPlugin not found");
192         exit(1);
193     }
194
195     ppCommandSend = createFunc();
196
197     if (!ppCommandSend)
198     {
199         logError("CommandSendInterface Test RoutingPlugin initialization failed. Entry Function not callable");
200         exit(1);
201     }
202
203 //      ok, here we give the DBusWrapper pointer to the Plugin and start the interface
204     EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper), Return(E_OK)));
205     EXPECT_CALL(pReceiveInterface, confirmCommandReady(10));
206
207     ppCommandSend->startupInterface(&pReceiveInterface);
208     ppCommandSend->setCommandReady(10);
209
210     EXPECT_CALL(pReceiveInterface,connect(2,3,_)).WillRepeatedly(DoAll(SetArgReferee<2>(35), Return(E_OK)));
211     system((DBUSCOMMAND + std::string("Connect uint16:2 uint16:3 > /tmp/result.txt ")).c_str());
212
213     //check the results
214     std::ifstream ifs("/tmp/result.txt");
215     std::string line;
216     int lineCounter = 0, result = 0;
217     while (std::getline(ifs, line))
218     {
219         if (lineCounter == 1)
220         {
221             std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
222             ASSERT_EQ(result, E_OK);
223         }
224         else if (lineCounter == 2)
225         {
226             std::stringstream(line.replace(line.begin(), line.begin() + 10, "")) >> result;
227             ASSERT_EQ(result, 35);
228         }
229         lineCounter++;
230     }
231     ifs.close();
232
233     std::cout << "[connect   ]" << std::endl;
234
235     EXPECT_CALL(pReceiveInterface,disconnect(2)).WillOnce(Return(E_OK));
236     system((DBUSCOMMAND + std::string("Disconnect uint16:2 > /tmp/result.txt ")).c_str());
237
238     //check the results
239     lineCounter = 0;
240     result = 0;
241     ifs.open("/tmp/result.txt");
242     while (std::getline(ifs, line))
243     {
244         if (lineCounter == 1)
245         {
246             std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
247             ASSERT_EQ(result, E_OK);
248         }
249         lineCounter++;
250     }
251     ifs.close();
252
253     std::cout << "[disconnect]" << std::endl;
254
255     EXPECT_CALL(pReceiveInterface,setVolume(22,12)).WillOnce(Return(E_OK));
256     system((DBUSCOMMAND + std::string("SetVolume uint16:22 int16:12 > /tmp/result.txt ")).c_str());
257
258     //check the results
259     lineCounter = 0;
260     result = 0;
261     ifs.open("/tmp/result.txt");
262     while (std::getline(ifs, line))
263     {
264         if (lineCounter == 1)
265         {
266             std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
267             ASSERT_EQ(result, E_OK);
268         }
269         lineCounter++;
270     }
271     ifs.close();
272
273     std::cout << "[setVolume ]" << std::endl;
274
275     EXPECT_CALL(pReceiveInterface,volumeStep(2,1)).WillOnce(Return(E_OK));
276     system((DBUSCOMMAND + std::string("VolumeStep uint16:2 int16:1 > /tmp/result.txt ")).c_str());
277
278     //check the results
279     lineCounter = 0;
280     result = 0;
281     ifs.open("/tmp/result.txt");
282     while (std::getline(ifs, line))
283     {
284         if (lineCounter == 1)
285         {
286             std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
287             ASSERT_EQ(result, E_OK);
288         }
289         lineCounter++;
290     }
291     ifs.close();
292
293     std::cout << "[volumeStep]" << std::endl;
294
295     EXPECT_CALL(pReceiveInterface,setSinkMuteState(1,MS_UNKNOWN)).WillOnce(Return(E_OK));
296     system((DBUSCOMMAND + std::string("SetSinkMuteState uint16:1 int16:0 > /tmp/result.txt ")).c_str());
297
298     //check the results
299     lineCounter = 0;
300     result = 0;
301     ifs.open("/tmp/result.txt");
302     while (std::getline(ifs, line))
303     {
304         if (lineCounter == 1)
305         {
306             std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
307             ASSERT_EQ(result, E_OK);
308         }
309         lineCounter++;
310     }
311     ifs.close();
312
313     std::cout << "[sinkmutest]" << std::endl;
314
315     EXPECT_CALL(pReceiveInterface,setMainSinkSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3),
316                             Field(&am_MainSoundProperty_s::type,MSP_UNKNOWN)),1)).WillOnce(Return(E_ABORTED));
317
318     PyRun_SimpleStringFlags("import dbus\n"
319             "f = open('/tmp/result.txt','w')\n"
320             "bus = dbus.SessionBus()\n"
321             "retVal=dbus.Bus().call_blocking(\n"
322             "bus_name='org.genivi.audiomanager',\n"
323             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
324             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
325             "method='SetMainSinkSoundProperty',\n"
326             "signature='q(nn)',\n"
327             "args=[1,(0,3)],) \n"
328             "f.write(str(retVal));\n"
329             "f.close()", NULL);
330     result = 0;
331     ifs.open("/tmp/result.txt");
332     while (std::getline(ifs, line))
333     {
334         std::stringstream(line) >> result;
335     }ASSERT_EQ(result, E_ABORTED);
336     ifs.close();
337
338     std::cout << "[sinksound ]" << std::endl;
339
340     EXPECT_CALL(pReceiveInterface,setMainSourceSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3),
341                             Field(&am_MainSoundProperty_s::type,MSP_UNKNOWN)),1)).WillOnce(Return(E_ABORTED));
342
343     PyRun_SimpleStringFlags("import dbus\n"
344             "f = open('/tmp/result.txt','w')\n"
345             "bus = dbus.SessionBus()\n"
346             "retVal=dbus.Bus().call_blocking(\n"
347             "bus_name='org.genivi.audiomanager',\n"
348             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
349             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
350             "method='SetMainSourceSoundProperty',\n"
351             "signature='q(nn)',\n"
352             "args=[1,(0,3)],) \n"
353             "f.write(str(retVal));\n"
354             "f.close()", NULL);
355     result = 0;
356     ifs.open("/tmp/result.txt");
357     while (std::getline(ifs, line))
358     {
359         std::stringstream(line) >> result;
360     }ASSERT_EQ(result, E_ABORTED);
361     ifs.close();
362
363     std::cout << "[sourcesnd ]" << std::endl;
364
365     EXPECT_CALL(pReceiveInterface,setSystemProperty(Field(&am_SystemProperty_s::value,2))).WillOnce(Return(E_DATABASE_ERROR));
366
367     PyRun_SimpleStringFlags("import dbus\n"
368             "f = open('/tmp/result.txt','w')\n"
369             "bus = dbus.SessionBus()\n"
370             "retVal=dbus.Bus().call_blocking(\n"
371             "bus_name='org.genivi.audiomanager',\n"
372             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
373             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
374             "method='SetSystemProperty',\n"
375             "signature='(nn)',\n"
376             "args=[(2,2)],) \n"
377             "f.write(str(retVal));\n"
378             "f.close()", NULL);
379
380     result = 0;
381     ifs.open("/tmp/result.txt");
382     while (std::getline(ifs, line))
383     {
384         std::stringstream(line) >> result;
385     }ASSERT_EQ(result, E_DATABASE_ERROR);
386     ifs.close();
387
388     std::cout << "[systemprop]" << std::endl;
389
390     EXPECT_CALL(pReceiveInterface,getListMainConnections(_)).WillOnce(DoAll(returnListConnections(), Return(E_ABORTED)));
391
392     PyRun_SimpleStringFlags("import dbus\n"
393             "f = open('/tmp/result.txt','w')\n"
394             "bus = dbus.SessionBus()\n"
395             "retVal=dbus.Bus().call_blocking(\n"
396             "bus_name='org.genivi.audiomanager',\n"
397             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
398             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
399             "method='GetListMainConnections',\n"
400             "signature='',\n"
401             "args=[],) \n"
402             "f.write(str(retVal));\n"
403             "f.close()", NULL);
404     result = 0;
405     ifs.open("/tmp/result.txt");
406     while (std::getline(ifs, line))
407     {
408         //we could parse here, but this is the fastest way....
409         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(15), dbus.UInt16(3), dbus.UInt16(4), dbus.Int16(34), dbus.Int16(0)), signature=None)], signature=dbus.Signature('(qqqnn)')))"), 0);
410     }
411     ifs.close();
412
413     std::cout << "[listmainc ]" << std::endl;
414
415     EXPECT_CALL(pReceiveInterface,getListMainSinks(_)).WillOnce(DoAll(returnListSinks(), Return(E_ABORTED)));
416
417     PyRun_SimpleStringFlags("import dbus\n"
418             "f = open('/tmp/result.txt','w')\n"
419             "bus = dbus.SessionBus()\n"
420             "retVal=dbus.Bus().call_blocking(\n"
421             "bus_name='org.genivi.audiomanager',\n"
422             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
423             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
424             "method='GetListMainSinks',\n"
425             "signature='',\n"
426             "args=[],) \n"
427             "f.write(str(retVal));\n"
428             "f.close()", NULL);
429     result = 0;
430     ifs.open("/tmp/result.txt");
431     while (std::getline(ifs, line))
432     {
433         //we could parse here, but this is the fastest way....
434         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(24), dbus.String(u'mySink'), dbus.Struct((dbus.Int16(2), dbus.Int16(3)), signature=None), dbus.Int16(124), dbus.Int16(2), dbus.UInt16(34)), signature=None)], signature=dbus.Signature('(qs(nn)nnq)')))"), 0);
435     }
436     ifs.close();
437
438     std::cout << "[listsinks ]" << std::endl;
439
440     EXPECT_CALL(pReceiveInterface,getListMainSources(_)).WillOnce(DoAll(returnListSources(), Return(E_ABORTED)));
441
442     PyRun_SimpleStringFlags("import dbus\n"
443             "f = open('/tmp/result.txt','w')\n"
444             "bus = dbus.SessionBus()\n"
445             "retVal=dbus.Bus().call_blocking(\n"
446             "bus_name='org.genivi.audiomanager',\n"
447             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
448             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
449             "method='GetListMainSources',\n"
450             "signature='',\n"
451             "args=[],) \n"
452             "f.write(str(retVal));\n"
453             "f.close()", NULL);
454     result = 0;
455     ifs.open("/tmp/result.txt");
456     while (std::getline(ifs, line))
457     {
458         //we could parse here, but this is the fastest way....
459         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(224), dbus.String(u'MySource'), dbus.Struct((dbus.Int16(3), dbus.Int16(2)), signature=None), dbus.UInt16(12)), signature=None), dbus.Struct((dbus.UInt16(22), dbus.String(u'NextSource'), dbus.Struct((dbus.Int16(3), dbus.Int16(2)), signature=None), dbus.UInt16(12)), signature=None)], signature=dbus.Signature('(qs(nn)q)')))"), 0);
460     }
461     ifs.close();
462
463     std::cout << "[listsource]" << std::endl;
464
465     EXPECT_CALL(pReceiveInterface,getListMainSinkSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_ABORTED)));
466
467     PyRun_SimpleStringFlags("import dbus\n"
468             "f = open('/tmp/result.txt','w')\n"
469             "bus = dbus.SessionBus()\n"
470             "retVal=dbus.Bus().call_blocking(\n"
471             "bus_name='org.genivi.audiomanager',\n"
472             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
473             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
474             "method='GetListMainSinkSoundProperties',\n"
475             "signature='q',\n"
476             "args=[1],) \n"
477             "f.write(str(retVal));\n"
478             "f.close()", NULL);
479     result = 0;
480     ifs.open("/tmp/result.txt");
481     while (std::getline(ifs, line))
482     {
483         //we could parse here, but this is the fastest way....
484         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(4), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
485     }
486     ifs.close();
487
488     std::cout << "[lMainSiPro]" << std::endl;
489
490     EXPECT_CALL(pReceiveInterface,getListMainSourceSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_ABORTED)));
491
492     PyRun_SimpleStringFlags("import dbus\n"
493             "f = open('/tmp/result.txt','w')\n"
494             "bus = dbus.SessionBus()\n"
495             "retVal=dbus.Bus().call_blocking(\n"
496             "bus_name='org.genivi.audiomanager',\n"
497             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
498             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
499             "method='GetListMainSourceSoundProperties',\n"
500             "signature='q',\n"
501             "args=[1],) \n"
502             "f.write(str(retVal));\n"
503             "f.close()", NULL);
504     result = 0;
505     ifs.open("/tmp/result.txt");
506     while (std::getline(ifs, line))
507     {
508         //we could parse here, but this is the fastest way....
509         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(4), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
510     }
511     ifs.close();
512
513     std::cout << "[lMainSoPro]" << std::endl;
514
515     EXPECT_CALL(pReceiveInterface,getListSourceClasses(_)).WillOnce(DoAll(returnListSourceClasses(), Return(E_ABORTED)));
516
517     PyRun_SimpleStringFlags("import dbus\n"
518             "f = open('/tmp/result.txt','w')\n"
519             "bus = dbus.SessionBus()\n"
520             "retVal=dbus.Bus().call_blocking(\n"
521             "bus_name='org.genivi.audiomanager',\n"
522             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
523             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
524             "method='GetListSourceClasses',\n"
525             "signature='',\n"
526             "args=[],) \n"
527             "f.write(str(retVal));\n"
528             "f.close()", NULL);
529     result = 0;
530     ifs.open("/tmp/result.txt");
531     while (std::getline(ifs, line))
532     {
533         //we could parse here, but this is the fastest way....
534         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(23), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None), dbus.Struct((dbus.UInt16(2), dbus.String(u'SecondCLass'), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(12)), signature=None), dbus.Struct((dbus.Int16(2), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"), 0);
535     }
536     ifs.close();
537
538     std::cout << "[lSourceCla]" << std::endl;
539
540     EXPECT_CALL(pReceiveInterface,getListSinkClasses(_)).WillOnce(DoAll(returnListSinkClasses(), Return(E_ABORTED)));
541
542     PyRun_SimpleStringFlags("import dbus\n"
543             "f = open('/tmp/result.txt','w')\n"
544             "bus = dbus.SessionBus()\n"
545             "retVal=dbus.Bus().call_blocking(\n"
546             "bus_name='org.genivi.audiomanager',\n"
547             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
548             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
549             "method='GetListSinkClasses',\n"
550             "signature='',\n"
551             "args=[],) \n"
552             "f.write(str(retVal));\n"
553             "f.close()", NULL);
554     result = 0;
555     ifs.open("/tmp/result.txt");
556     while (std::getline(ifs, line))
557     {
558         //we could parse here, but this is the fastest way....
559         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(2123), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None), dbus.Struct((dbus.UInt16(23), dbus.String(u'SecondCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), dbus.Int16(122)), signature=None), dbus.Struct((dbus.Int16(1), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"), 0);
560     }
561     ifs.close();
562
563     std::cout << "[lSinkClass]" << std::endl;
564
565     EXPECT_CALL(pReceiveInterface,getListSystemProperties(_)).WillOnce(DoAll(returnListSystemProperties(), Return(E_ABORTED)));
566
567     PyRun_SimpleStringFlags("import dbus\n"
568             "f = open('/tmp/result.txt','w')\n"
569             "bus = dbus.SessionBus()\n"
570             "retVal=dbus.Bus().call_blocking(\n"
571             "bus_name='org.genivi.audiomanager',\n"
572             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
573             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
574             "method='GetListSystemProperties',\n"
575             "signature='',\n"
576             "args=[],) \n"
577             "f.write(str(retVal));\n"
578             "f.close()", NULL);
579     result = 0;
580     ifs.open("/tmp/result.txt");
581     while (std::getline(ifs, line))
582     {
583         //we could parse here, but this is the fastest way....
584         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(0), dbus.Int16(-2245)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
585     }
586     ifs.close();
587
588     std::cout << "[lSysProp  ]" << std::endl;
589
590     EXPECT_CALL(pReceiveInterface,getTimingInformation(2,_)).WillOnce(DoAll(returnTimingInfo(), Return(E_ABORTED)));
591
592     PyRun_SimpleStringFlags("import dbus\n"
593             "f = open('/tmp/result.txt','w')\n"
594             "bus = dbus.SessionBus()\n"
595             "retVal=dbus.Bus().call_blocking(\n"
596             "bus_name='org.genivi.audiomanager',\n"
597             "object_path='/org/genivi/audiomanager/CommandInterface',\n"
598             "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
599             "method='GetTimingInformation',\n"
600             "signature='q',\n"
601             "args=[2],) \n"
602             "f.write(str(retVal));\n"
603             "f.close()", NULL);
604     result = 0;
605     ifs.open("/tmp/result.txt");
606     while (std::getline(ifs, line))
607     {
608         //we could parse here, but this is the fastest way....
609         ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Int16(23))"), 0);
610     }
611     ifs.close();
612
613     std::cout << "[timingInfo]" << std::endl;
614     Py_Finalize();
615 }
616
617 int main(int argc, char **argv)
618 {
619     ::testing::InitGoogleTest(&argc, argv);
620     return RUN_ALL_TESTS();
621 }
622