* wrapping DLT calls in a new Class because of performance, codesize and lazyness...
[profile/ivi/audiomanager.git] / PluginCommandInterfaceDbus / test / dbuscommandpluginInterfaceTest.cpp
1 /**
2 * Copyright (C) 2011, BMW AG
3 *
4 * GeniviAudioMananger AudioManagerDaemon
5 *
6 * \file dbuscommandpluginInterfaceTest.cpp
7 *
8 * \date 20-Oct-2011 3:42:04 PM
9 * \author Christian Mueller (christian.ei.mueller@bmw.de)
10 *
11 * \section License
12 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13 * Copyright (C) 2011, BMW AG Christian Mueller  Christian.ei.mueller@bmw.de
14 *
15 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
17 * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
18 * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
19 * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
20 * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
21 * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
22 *
23 * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
24 */
25
26 #include <python2.6/Python.h>
27 #include <dbus/DBusWrapper.h>
28 #include "dbuscommandpluginInterfaceTest.h"
29 #include <iostream>
30 #include <fstream>
31 #include "../include/DBusCommandSender.h"
32 #include "../include/DBusMessageHandler.h"
33 #include "DbusCommandInterfaceBackdoor.h"
34 #include "MockInterfaces.h"
35 #include "DLTWrapper.h"
36
37 using namespace am;
38 using namespace testing;
39
40 //DLT_DECLARE_CONTEXT(DLT_CONTEXT)
41
42 std::string DBUSCOMMAND = "dbus-send --session --print-reply --dest=org.genivi.audiomanager /org/genivi/audiomanager/CommandInterface org.genivi.audiomanager.CommandInterface.";
43
44 void* run_the_loop(void* wrapper)
45 {
46         DBusWrapper* wrap=(DBusWrapper*)wrapper;
47         wrap->dbusMainLoop();
48         return (NULL);
49 }
50
51 dbuscommandpluginInterfaceTest::dbuscommandpluginInterfaceTest()
52 {
53     DLTWrapper::instance()->registerApp("dbusTest","dbusTest");
54 }
55
56 dbuscommandpluginInterfaceTest::~dbuscommandpluginInterfaceTest()
57 {
58
59 }
60
61 void dbuscommandpluginInterfaceTest::SetUp()
62 {
63
64 }
65
66
67
68 void dbuscommandpluginInterfaceTest::TearDown()
69 {
70
71 }
72
73 ACTION(returnListConnections)
74 {
75         std::vector<am::am_MainConnectionType_s> list;
76         am::am_MainConnectionType_s listItem;
77         listItem.mainConnectionID=15;
78         listItem.sinkID=4;
79         listItem.sourceID=3;
80         listItem.connectionState=CS_MIN;
81         listItem.delay=34;
82         list.push_back(listItem);
83         arg0=list;
84 }
85
86 ACTION(returnListSinks)
87 {
88         std::vector<am::am_SinkType_s> list;
89         am::am_SinkType_s listItem;
90         listItem.availability.availability=A_MIN;
91         listItem.availability.availabilityReason=AR_NOMEDIA;
92         listItem.muteState=MS_UNMUTED;
93         listItem.name="mySink";
94         listItem.sinkClassID=34;
95         listItem.sinkID=24;
96         listItem.volume=124;
97         list.push_back(listItem);
98         arg0=list;
99 }
100
101 ACTION(returnListSources)
102 {
103         std::vector<am::am_SourceType_s> list;
104         am::am_SourceType_s listItem;
105         listItem.availability.availability=A_MAX;
106         listItem.availability.availabilityReason=AR_SAMEMEDIA;
107         listItem.name="MySource";
108         listItem.sourceClassID=12;
109         listItem.sourceID=224;
110         list.push_back(listItem);
111         listItem.name="NextSource";
112         listItem.sourceID=22;
113         list.push_back(listItem);
114         arg0=list;
115 }
116
117 ACTION(returnListMainSinkSoundProperties)
118 {
119         std::vector<am::am_MainSoundProperty_s> list;
120         am::am_MainSoundProperty_s listItem;
121         listItem.type=MSP_MAX;
122         listItem.value=223;
123         list.push_back(listItem);
124         listItem.type=MSP_MIN;
125         listItem.value=2;
126         list.push_back(listItem);
127         arg1=list;
128 }
129
130 ACTION(returnListSourceClasses)
131 {
132         std::vector<am::am_SourceClass_s> list;
133         am::am_SourceClass_s listItem;
134         am::am_ClassProperty_s property;
135         property.classProperty=CP_SINK_TYPE;
136         property.value=12;
137         listItem.name="FirstCLass";
138         listItem.sourceClassID=23;
139         listItem.listClassProperties.push_back(property);
140         list.push_back(listItem);
141         listItem.name="SecondCLass";
142         listItem.sourceClassID=2;
143         listItem.listClassProperties.push_back(property);
144         list.push_back(listItem);
145         arg0=list;
146 }
147
148 ACTION(returnListSinkClasses)
149 {
150         std::vector<am::am_SinkClass_s> list;
151         am::am_SinkClass_s listItem;
152         am::am_ClassProperty_s property;
153         property.classProperty=CP_SOURCE_TYPE;
154         property.value=122;
155         listItem.name="FirstCLass";
156         listItem.sinkClassID=2123;
157         listItem.listClassProperties.push_back(property);
158         list.push_back(listItem);
159         listItem.name="SecondCLass";
160         listItem.sinkClassID=23;
161         listItem.listClassProperties.push_back(property);
162         list.push_back(listItem);
163         arg0=list;
164 }
165
166 ACTION(returnListSystemProperties)
167 {
168         std::vector<am::am_SystemProperty_s> list;
169         am::am_SystemProperty_s listItem;
170         listItem.type=SYP_TEST;
171         listItem.value=-2245;
172         list.push_back(listItem);
173         arg0=list;
174 }
175
176 ACTION(returnTimingInfo)
177 {
178         am::am_timeSync_t time=23;
179         arg1=time;
180 }
181
182
183 TEST_F(dbuscommandpluginInterfaceTest,Connect)
184 {
185         Py_Initialize();
186         //unfortunatly we need to put all in one testcase because testing with the dbus loop caused problems...
187         DBusWrapper pDBusWrapper;
188         pthread_t ptestThread;
189         std::vector<std::string> plistCommandPluginDirs;
190         plistCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
191
192         CommandSender pCommandSender(plistCommandPluginDirs);
193         MockCommandReceiveInterface pReceiveInterface;
194
195         //this class just creates the thread that will handle the mainloop...
196         pthread_create(&ptestThread,NULL,run_the_loop,(void*)&pDBusWrapper);
197
198 //      ok, here we give the DBusWrapper pointer to the Plugin and start the interface
199         EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper),Return(E_OK)));
200         pCommandSender.startupInterface(&pReceiveInterface);
201
202         EXPECT_CALL(pReceiveInterface,connect(2,3,_)).WillRepeatedly(DoAll(SetArgReferee<2>(35),Return(E_OK)));
203         system((DBUSCOMMAND + std::string("Connect uint16:2 uint16:3 > /tmp/result.txt ")).c_str());
204
205         //check the results
206         std::ifstream ifs("/tmp/result.txt");
207         std::string line;
208         int lineCounter=0, result=0;
209         while(std::getline(ifs, line))
210         {
211             if(lineCounter==1)
212             {
213                 std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
214                 ASSERT_EQ(result,E_OK);
215             }
216             else if (lineCounter==2)
217             {
218                 std::stringstream(line.substr(line.find_first_not_of("   uint16 "))) >> result;
219                 ASSERT_EQ(result,35);
220             }
221             lineCounter++;
222         }
223         ifs.close();
224
225         std::cout<<"[connect   ]"<<std::endl;
226
227         EXPECT_CALL(pReceiveInterface,disconnect(2)).WillOnce(Return(E_OK));
228         system((DBUSCOMMAND + std::string("Disconnect uint16:2 > /tmp/result.txt ")).c_str());
229
230         //check the results
231         lineCounter=0;
232         result=0;
233         ifs.open("/tmp/result.txt");
234         while(std::getline(ifs, line))
235         {
236                 if(lineCounter==1)
237                 {
238                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
239                         ASSERT_EQ(result,E_OK);
240                 }
241                 lineCounter++;
242         }
243         ifs.close();
244
245         std::cout<<"[disconnect]"<<std::endl;
246
247         EXPECT_CALL(pReceiveInterface,setVolume(22,12)).WillOnce(Return(E_OK));
248         system((DBUSCOMMAND + std::string("SetVolume uint16:22 int16:12 > /tmp/result.txt ")).c_str());
249
250         //check the results
251         lineCounter=0;
252         result=0;
253         ifs.open("/tmp/result.txt");
254         while(std::getline(ifs, line))
255         {
256                 if(lineCounter==1)
257                 {
258                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
259                         ASSERT_EQ(result,E_OK);
260                 }
261                 lineCounter++;
262         }
263         ifs.close();
264
265         std::cout<<"[setVolume ]"<<std::endl;
266
267         EXPECT_CALL(pReceiveInterface,volumeStep(2,1)).WillOnce(Return(E_OK));
268         system((DBUSCOMMAND + std::string("VolumeStep uint16:2 int16:1 > /tmp/result.txt ")).c_str());
269
270         //check the results
271         lineCounter=0;
272         result=0;
273         ifs.open("/tmp/result.txt");
274         while(std::getline(ifs, line))
275         {
276                 if(lineCounter==1)
277                 {
278                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
279                         ASSERT_EQ(result,E_OK);
280                 }
281                 lineCounter++;
282         }
283         ifs.close();
284
285         std::cout<<"[volumeStep]"<<std::endl;
286
287         EXPECT_CALL(pReceiveInterface,setSinkMuteState(1,MS_MIN)).WillOnce(Return(E_OK));
288         system((DBUSCOMMAND + std::string("SetSinkMuteState uint16:1 int16:0 > /tmp/result.txt ")).c_str());
289
290         //check the results
291         lineCounter=0;
292         result=0;
293         ifs.open("/tmp/result.txt");
294         while(std::getline(ifs, line))
295         {
296                 if(lineCounter==1)
297                 {
298                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
299                         ASSERT_EQ(result,E_OK);
300                 }
301                 lineCounter++;
302         }
303         ifs.close();
304
305         std::cout<<"[sinkmutest]"<<std::endl;
306
307         EXPECT_CALL(pReceiveInterface,setMainSinkSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), \
308                                         Field(&am_MainSoundProperty_s::type,MSP_MIN)),1)).WillOnce(Return(E_ABORTED));
309
310
311         PyRun_SimpleStringFlags("import dbus\n"
312                                                         "f = open('/tmp/result.txt','w')\n"
313                                         "bus = dbus.SessionBus()\n"
314                                                         "retVal=dbus.Bus().call_blocking(\n"
315                                                         "bus_name='org.genivi.audiomanager',\n"
316                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
317                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
318                                                         "method='SetMainSinkSoundProperty',\n"
319                                                         "signature='q(nn)',\n"
320                                                         "args=[1,(0,3)],) \n"
321                                                         "f.write(str(retVal));\n"
322                                                         "f.close()",NULL);
323         result=0;
324         ifs.open("/tmp/result.txt");
325         while(std::getline(ifs, line))
326         {
327                 std::stringstream(line) >> result;
328         }
329         ASSERT_EQ(result,E_ABORTED);
330         ifs.close();
331
332         std::cout<<"[sinksound ]"<<std::endl;
333
334         EXPECT_CALL(pReceiveInterface,setMainSourceSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), \
335                                                 Field(&am_MainSoundProperty_s::type,MSP_MIN)),1)).WillOnce(Return(E_ABORTED));
336
337         PyRun_SimpleStringFlags("import dbus\n"
338                                                         "f = open('/tmp/result.txt','w')\n"
339                                         "bus = dbus.SessionBus()\n"
340                                                         "retVal=dbus.Bus().call_blocking(\n"
341                                                         "bus_name='org.genivi.audiomanager',\n"
342                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
343                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
344                                                         "method='SetMainSourceSoundProperty',\n"
345                                                         "signature='q(nn)',\n"
346                                                         "args=[1,(0,3)],) \n"
347                                                         "f.write(str(retVal));\n"
348                                                         "f.close()",NULL);
349         result=0;
350         ifs.open("/tmp/result.txt");
351         while(std::getline(ifs, line))
352         {
353                 std::stringstream(line) >> result;
354         }
355         ASSERT_EQ(result,E_ABORTED);
356         ifs.close();
357
358         std::cout<<"[sourcesnd ]"<<std::endl;
359
360
361         EXPECT_CALL(pReceiveInterface,setSystemProperty(Field(&am_SystemProperty_s::value,2))).WillOnce(Return(E_DATABASE_ERROR));
362
363         PyRun_SimpleStringFlags("import dbus\n"
364                                                         "f = open('/tmp/result.txt','w')\n"
365                                         "bus = dbus.SessionBus()\n"
366                                                         "retVal=dbus.Bus().call_blocking(\n"
367                                                         "bus_name='org.genivi.audiomanager',\n"
368                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
369                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
370                                                         "method='SetSystemProperty',\n"
371                                                         "signature='(nn)',\n"
372                                                         "args=[(2,2)],) \n"
373                                                         "f.write(str(retVal));\n"
374                                                         "f.close()",NULL);
375
376         result=0;
377         ifs.open("/tmp/result.txt");
378         while(std::getline(ifs, line))
379         {
380                 std::stringstream(line) >> result;
381         }
382         ASSERT_EQ(result,E_DATABASE_ERROR);
383         ifs.close();
384
385         std::cout<<"[systemprop]"<<std::endl;
386
387         EXPECT_CALL(pReceiveInterface,getListMainConnections(_)).WillOnce(DoAll(returnListConnections(),Return(E_ABORTED)));
388
389         PyRun_SimpleStringFlags("import dbus\n"
390                                                         "f = open('/tmp/result.txt','w')\n"
391                                         "bus = dbus.SessionBus()\n"
392                                                         "retVal=dbus.Bus().call_blocking(\n"
393                                                         "bus_name='org.genivi.audiomanager',\n"
394                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
395                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
396                                                         "method='GetListMainConnections',\n"
397                                                         "signature='',\n"
398                                                         "args=[],) \n"
399                                                         "f.write(str(retVal));\n"
400                                                         "f.close()",NULL);
401         result=0;
402         ifs.open("/tmp/result.txt");
403         while(std::getline(ifs, line))
404         {
405                 //we could parse here, but this is the fastest way....
406                 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);
407         }
408         ifs.close();
409
410         std::cout<<"[listmainc ]"<<std::endl;
411
412         EXPECT_CALL(pReceiveInterface,getListMainSinks(_)).WillOnce(DoAll(returnListSinks(),Return(E_ABORTED)));
413
414         PyRun_SimpleStringFlags("import dbus\n"
415                                                         "f = open('/tmp/result.txt','w')\n"
416                                         "bus = dbus.SessionBus()\n"
417                                                         "retVal=dbus.Bus().call_blocking(\n"
418                                                         "bus_name='org.genivi.audiomanager',\n"
419                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
420                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
421                                                         "method='GetListMainSinks',\n"
422                                                         "signature='',\n"
423                                                         "args=[],) \n"
424                                                         "f.write(str(retVal));\n"
425                                                         "f.close()",NULL);
426         result=0;
427         ifs.open("/tmp/result.txt");
428         while(std::getline(ifs, line))
429         {
430                 //we could parse here, but this is the fastest way....
431                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(24), dbus.String(u'mySink'), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None), dbus.Int16(124), dbus.Int16(1), dbus.UInt16(34)), signature=None)], signature=dbus.Signature('(qs(nn)nnq)')))"),0);
432         }
433         ifs.close();
434
435         std::cout<<"[listsinks ]"<<std::endl;
436
437         EXPECT_CALL(pReceiveInterface,getListMainSources(_)).WillOnce(DoAll(returnListSources(),Return(E_ABORTED)));
438
439         PyRun_SimpleStringFlags("import dbus\n"
440                                                         "f = open('/tmp/result.txt','w')\n"
441                                         "bus = dbus.SessionBus()\n"
442                                                         "retVal=dbus.Bus().call_blocking(\n"
443                                                         "bus_name='org.genivi.audiomanager',\n"
444                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
445                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
446                                                         "method='GetListMainSources',\n"
447                                                         "signature='',\n"
448                                                         "args=[],) \n"
449                                                         "f.write(str(retVal));\n"
450                                                         "f.close()",NULL);
451         result=0;
452         ifs.open("/tmp/result.txt");
453         while(std::getline(ifs, line))
454         {
455                 //we could parse here, but this is the fastest way....
456                 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(1)), signature=None), dbus.UInt16(12)), signature=None), dbus.Struct((dbus.UInt16(22), dbus.String(u'NextSource'), dbus.Struct((dbus.Int16(3), dbus.Int16(1)), signature=None), dbus.UInt16(12)), signature=None)], signature=dbus.Signature('(qs(nn)q)')))"),0);
457         }
458         ifs.close();
459
460         std::cout<<"[listsource]"<<std::endl;
461
462         EXPECT_CALL(pReceiveInterface,getListMainSinkSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(),Return(E_ABORTED)));
463
464         PyRun_SimpleStringFlags("import dbus\n"
465                                                         "f = open('/tmp/result.txt','w')\n"
466                                         "bus = dbus.SessionBus()\n"
467                                                         "retVal=dbus.Bus().call_blocking(\n"
468                                                         "bus_name='org.genivi.audiomanager',\n"
469                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
470                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
471                                                         "method='GetListMainSinkSoundProperties',\n"
472                                                         "signature='q',\n"
473                                                         "args=[1],) \n"
474                                                         "f.write(str(retVal));\n"
475                                                         "f.close()",NULL);
476         result=0;
477         ifs.open("/tmp/result.txt");
478         while(std::getline(ifs, line))
479         {
480                 //we could parse here, but this is the fastest way....
481                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"),0);
482         }
483         ifs.close();
484
485         std::cout<<"[lMainSiPro]"<<std::endl;
486
487         EXPECT_CALL(pReceiveInterface,getListMainSourceSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(),Return(E_ABORTED)));
488
489         PyRun_SimpleStringFlags("import dbus\n"
490                                                         "f = open('/tmp/result.txt','w')\n"
491                                         "bus = dbus.SessionBus()\n"
492                                                         "retVal=dbus.Bus().call_blocking(\n"
493                                                         "bus_name='org.genivi.audiomanager',\n"
494                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
495                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
496                                                         "method='GetListMainSourceSoundProperties',\n"
497                                                         "signature='q',\n"
498                                                         "args=[1],) \n"
499                                                         "f.write(str(retVal));\n"
500                                                         "f.close()",NULL);
501         result=0;
502         ifs.open("/tmp/result.txt");
503         while(std::getline(ifs, line))
504         {
505                 //we could parse here, but this is the fastest way....
506                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"),0);
507         }
508         ifs.close();
509
510         std::cout<<"[lMainSoPro]"<<std::endl;
511
512         EXPECT_CALL(pReceiveInterface,getListSourceClasses(_)).WillOnce(DoAll(returnListSourceClasses(),Return(E_ABORTED)));
513
514         PyRun_SimpleStringFlags("import dbus\n"
515                                                         "f = open('/tmp/result.txt','w')\n"
516                                         "bus = dbus.SessionBus()\n"
517                                                         "retVal=dbus.Bus().call_blocking(\n"
518                                                         "bus_name='org.genivi.audiomanager',\n"
519                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
520                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
521                                                         "method='GetListSourceClasses',\n"
522                                                         "signature='',\n"
523                                                         "args=[],) \n"
524                                                         "f.write(str(retVal));\n"
525                                                         "f.close()",NULL);
526         result=0;
527         ifs.open("/tmp/result.txt");
528         while(std::getline(ifs, line))
529         {
530                 //we could parse here, but this is the fastest way....
531                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(23), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), 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(1), dbus.Int16(12)), signature=None), dbus.Struct((dbus.Int16(1), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"),0);
532         }
533         ifs.close();
534
535         std::cout<<"[lSourceCla]"<<std::endl;
536
537         EXPECT_CALL(pReceiveInterface,getListSinkClasses(_)).WillOnce(DoAll(returnListSinkClasses(),Return(E_ABORTED)));
538
539         PyRun_SimpleStringFlags("import dbus\n"
540                                                         "f = open('/tmp/result.txt','w')\n"
541                                         "bus = dbus.SessionBus()\n"
542                                                         "retVal=dbus.Bus().call_blocking(\n"
543                                                         "bus_name='org.genivi.audiomanager',\n"
544                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
545                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
546                                                         "method='GetListSinkClasses',\n"
547                                                         "signature='',\n"
548                                                         "args=[],) \n"
549                                                         "f.write(str(retVal));\n"
550                                                         "f.close()",NULL);
551         result=0;
552         ifs.open("/tmp/result.txt");
553         while(std::getline(ifs, line))
554         {
555                 //we could parse here, but this is the fastest way....
556                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(2123), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(0), 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(0), dbus.Int16(122)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"),0);
557         }
558         ifs.close();
559
560         std::cout<<"[lSinkClass]"<<std::endl;
561
562         EXPECT_CALL(pReceiveInterface,getListSystemProperties(_)).WillOnce(DoAll(returnListSystemProperties(),Return(E_ABORTED)));
563
564         PyRun_SimpleStringFlags("import dbus\n"
565                                                         "f = open('/tmp/result.txt','w')\n"
566                                         "bus = dbus.SessionBus()\n"
567                                                         "retVal=dbus.Bus().call_blocking(\n"
568                                                         "bus_name='org.genivi.audiomanager',\n"
569                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
570                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
571                                                         "method='GetListSystemProperties',\n"
572                                                         "signature='',\n"
573                                                         "args=[],) \n"
574                                                         "f.write(str(retVal));\n"
575                                                         "f.close()",NULL);
576         result=0;
577         ifs.open("/tmp/result.txt");
578         while(std::getline(ifs, line))
579         {
580                 //we could parse here, but this is the fastest way....
581                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(0), dbus.Int16(-2245)), signature=None)], signature=dbus.Signature('(nn)')))"),0);
582         }
583         ifs.close();
584
585         std::cout<<"[lSysProp  ]"<<std::endl;
586
587         EXPECT_CALL(pReceiveInterface,getTimingInformation(2,_)).WillOnce(DoAll(returnTimingInfo(),Return(E_ABORTED)));
588
589         PyRun_SimpleStringFlags("import dbus\n"
590                                                         "f = open('/tmp/result.txt','w')\n"
591                                         "bus = dbus.SessionBus()\n"
592                                                         "retVal=dbus.Bus().call_blocking(\n"
593                                                         "bus_name='org.genivi.audiomanager',\n"
594                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
595                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
596                                                         "method='GetTimingInformation',\n"
597                                                         "signature='q',\n"
598                                                         "args=[2],) \n"
599                                                         "f.write(str(retVal));\n"
600                                                         "f.close()",NULL);
601         result=0;
602         ifs.open("/tmp/result.txt");
603         while(std::getline(ifs, line))
604         {
605                 //we could parse here, but this is the fastest way....
606                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Int16(23))"),0);
607         }
608         ifs.close();
609
610         std::cout<<"[timingInfo]"<<std::endl;
611         Py_Finalize();
612 }
613
614
615 int main(int argc, char **argv)
616 {
617         ::testing::InitGoogleTest(&argc, argv);
618         return RUN_ALL_TESTS();
619 }
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637