213d8a32624c081e8cd978dcc0733980dfe4ca41
[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
27 #include "dbuscommandpluginInterfaceTest.h"
28 #include <iostream>
29 #include <fstream>
30 #include <Python.h>
31 #include "../include/DBusCommandSender.h"
32 #include "../include/DBusMessageHandler.h"
33 #include "DbusCommandInterfaceBackdoor.h"
34 #include "MockInterfaces.h"
35 #include "DBusWrapper.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 }
49
50 dbuscommandpluginInterfaceTest::dbuscommandpluginInterfaceTest()
51 {
52 }
53
54 dbuscommandpluginInterfaceTest::~dbuscommandpluginInterfaceTest()
55 {
56
57 }
58
59 void dbuscommandpluginInterfaceTest::SetUp()
60 {
61
62 }
63
64
65
66 void dbuscommandpluginInterfaceTest::TearDown()
67 {
68
69 }
70
71 ACTION(returnListConnections)
72 {
73         std::vector<am::am_MainConnectionType_s> list;
74         am::am_MainConnectionType_s listItem;
75         listItem.mainConnectionID=15;
76         listItem.sinkID=4;
77         listItem.sourceID=3;
78         listItem.connectionState=CS_MIN;
79         listItem.delay=34;
80         list.push_back(listItem);
81         arg0=list;
82 }
83
84 ACTION(returnListSinks)
85 {
86         std::vector<am::am_SinkType_s> list;
87         am::am_SinkType_s listItem;
88         listItem.availability.availability=A_MIN;
89         listItem.availability.availabilityReason=AR_NOMEDIA;
90         listItem.muteState=MS_UNMUTED;
91         listItem.name="mySink";
92         listItem.sinkClassID=34;
93         listItem.sinkID=24;
94         listItem.volume=124;
95         list.push_back(listItem);
96         arg0=list;
97 }
98
99 ACTION(returnListSources)
100 {
101         std::vector<am::am_SourceType_s> list;
102         am::am_SourceType_s listItem;
103         listItem.availability.availability=A_MAX;
104         listItem.availability.availabilityReason=AR_SAMEMEDIA;
105         listItem.name="MySource";
106         listItem.sourceClassID=12;
107         listItem.sourceID=224;
108         list.push_back(listItem);
109         listItem.name="NextSource";
110         listItem.sourceID=22;
111         list.push_back(listItem);
112         arg0=list;
113 }
114
115 ACTION(returnListMainSinkSoundProperties)
116 {
117         std::vector<am::am_MainSoundProperty_s> list;
118         am::am_MainSoundProperty_s listItem;
119         listItem.type=MSP_MAX;
120         listItem.value=223;
121         list.push_back(listItem);
122         listItem.type=MSP_MIN;
123         listItem.value=2;
124         list.push_back(listItem);
125         arg1=list;
126 }
127
128 ACTION(returnListSourceClasses)
129 {
130         std::vector<am::am_SourceClass_s> list;
131         am::am_SourceClass_s listItem;
132         am::am_ClassProperty_s property;
133         property.classProperty=CP_SINK_TYPE;
134         property.value=12;
135         listItem.name="FirstCLass";
136         listItem.sourceClassID=23;
137         listItem.listClassProperties.push_back(property);
138         list.push_back(listItem);
139         listItem.name="SecondCLass";
140         listItem.sourceClassID=2;
141         listItem.listClassProperties.push_back(property);
142         list.push_back(listItem);
143         arg0=list;
144 }
145
146 ACTION(returnListSinkClasses)
147 {
148         std::vector<am::am_SinkClass_s> list;
149         am::am_SinkClass_s listItem;
150         am::am_ClassProperty_s property;
151         property.classProperty=CP_SOURCE_TYPE;
152         property.value=122;
153         listItem.name="FirstCLass";
154         listItem.sinkClassID=2123;
155         listItem.listClassProperties.push_back(property);
156         list.push_back(listItem);
157         listItem.name="SecondCLass";
158         listItem.sinkClassID=23;
159         listItem.listClassProperties.push_back(property);
160         list.push_back(listItem);
161         arg0=list;
162 }
163
164 ACTION(returnListSystemProperties)
165 {
166         std::vector<am::am_SystemProperty_s> list;
167         am::am_SystemProperty_s listItem;
168         listItem.type=SYP_TEST;
169         listItem.value=-2245;
170         list.push_back(listItem);
171         arg0=list;
172 }
173
174 ACTION(returnTimingInfo)
175 {
176         am::am_timeSync_t time=23;
177         arg1=time;
178 }
179
180
181 TEST_F(dbuscommandpluginInterfaceTest,Connect)
182 {
183         Py_Initialize();
184         //unfortunatly we need to put all in one testcase because testing with the dbus loop caused problems...
185         DBusWrapper pDBusWrapper;
186         pthread_t ptestThread;
187         std::vector<std::string> plistCommandPluginDirs;
188         plistCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
189
190         CommandSender pCommandSender(plistCommandPluginDirs);
191         MockCommandReceiveInterface pReceiveInterface;
192
193         //this class just creates the thread that will handle the mainloop...
194         pthread_create(&ptestThread,NULL,run_the_loop,(void*)&pDBusWrapper);
195
196 //      ok, here we give the DBusWrapper pointer to the Plugin and start the interface
197         EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper),Return(E_OK)));
198         pCommandSender.startupInterface(&pReceiveInterface);
199
200         EXPECT_CALL(pReceiveInterface,connect(2,3,_)).WillRepeatedly(DoAll(SetArgReferee<2>(35),Return(E_OK)));
201         system((DBUSCOMMAND + std::string("Connect uint16:2 uint16:3 > /tmp/result.txt ")).c_str());
202
203         //check the results
204         std::ifstream ifs("/tmp/result.txt");
205         std::string line;
206         int lineCounter=0, result=0;
207         while(std::getline(ifs, line))
208         {
209             if(lineCounter==1)
210             {
211                 std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
212                 ASSERT_EQ(result,E_OK);
213             }
214             else if (lineCounter==2)
215             {
216                 std::stringstream(line.substr(line.find_first_not_of("   uint16 "))) >> result;
217                 ASSERT_EQ(result,35);
218             }
219             lineCounter++;
220         }
221         ifs.close();
222
223         std::cout<<"[connect   ]"<<std::endl;
224
225         EXPECT_CALL(pReceiveInterface,disconnect(2)).WillOnce(Return(E_OK));
226         system((DBUSCOMMAND + std::string("Disconnect uint16:2 > /tmp/result.txt ")).c_str());
227
228         //check the results
229         lineCounter=0;
230         result=0;
231         ifs.open("/tmp/result.txt");
232         while(std::getline(ifs, line))
233         {
234                 if(lineCounter==1)
235                 {
236                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
237                         ASSERT_EQ(result,E_OK);
238                 }
239                 lineCounter++;
240         }
241         ifs.close();
242
243         std::cout<<"[disconnect]"<<std::endl;
244
245         EXPECT_CALL(pReceiveInterface,setVolume(22,12)).WillOnce(Return(E_OK));
246         system((DBUSCOMMAND + std::string("SetVolume uint16:22 int16:12 > /tmp/result.txt ")).c_str());
247
248         //check the results
249         lineCounter=0;
250         result=0;
251         ifs.open("/tmp/result.txt");
252         while(std::getline(ifs, line))
253         {
254                 if(lineCounter==1)
255                 {
256                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
257                         ASSERT_EQ(result,E_OK);
258                 }
259                 lineCounter++;
260         }
261         ifs.close();
262
263         std::cout<<"[setVolume ]"<<std::endl;
264
265         EXPECT_CALL(pReceiveInterface,volumeStep(2,1)).WillOnce(Return(E_OK));
266         system((DBUSCOMMAND + std::string("VolumeStep uint16:2 int16:1 > /tmp/result.txt ")).c_str());
267
268         //check the results
269         lineCounter=0;
270         result=0;
271         ifs.open("/tmp/result.txt");
272         while(std::getline(ifs, line))
273         {
274                 if(lineCounter==1)
275                 {
276                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
277                         ASSERT_EQ(result,E_OK);
278                 }
279                 lineCounter++;
280         }
281         ifs.close();
282
283         std::cout<<"[volumeStep]"<<std::endl;
284
285         EXPECT_CALL(pReceiveInterface,setSinkMuteState(1,MS_MIN)).WillOnce(Return(E_OK));
286         system((DBUSCOMMAND + std::string("SetSinkMuteState uint16:1 int16:0 > /tmp/result.txt ")).c_str());
287
288         //check the results
289         lineCounter=0;
290         result=0;
291         ifs.open("/tmp/result.txt");
292         while(std::getline(ifs, line))
293         {
294                 if(lineCounter==1)
295                 {
296                         std::stringstream(line.substr(line.find_first_not_of("   int16 "))) >> result;
297                         ASSERT_EQ(result,E_OK);
298                 }
299                 lineCounter++;
300         }
301         ifs.close();
302
303         std::cout<<"[sinkmutest]"<<std::endl;
304
305         EXPECT_CALL(pReceiveInterface,setMainSinkSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), \
306                                         Field(&am_MainSoundProperty_s::type,MSP_MIN)),1)).WillOnce(Return(E_ABORTED));
307
308
309         PyRun_SimpleStringFlags("import dbus\n"
310                                                         "f = open('/tmp/result.txt','w')\n"
311                                         "bus = dbus.SessionBus()\n"
312                                                         "retVal=dbus.Bus().call_blocking(\n"
313                                                         "bus_name='org.genivi.audiomanager',\n"
314                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
315                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
316                                                         "method='SetMainSinkSoundProperty',\n"
317                                                         "signature='q(nn)',\n"
318                                                         "args=[1,(0,3)],) \n"
319                                                         "f.write(str(retVal));\n"
320                                                         "f.close()",NULL);
321         result=0;
322         ifs.open("/tmp/result.txt");
323         while(std::getline(ifs, line))
324         {
325                 std::stringstream(line) >> result;
326         }
327         ASSERT_EQ(result,E_ABORTED);
328         ifs.close();
329
330         std::cout<<"[sinksound ]"<<std::endl;
331
332         EXPECT_CALL(pReceiveInterface,setMainSourceSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), \
333                                                 Field(&am_MainSoundProperty_s::type,MSP_MIN)),1)).WillOnce(Return(E_ABORTED));
334
335         PyRun_SimpleStringFlags("import dbus\n"
336                                                         "f = open('/tmp/result.txt','w')\n"
337                                         "bus = dbus.SessionBus()\n"
338                                                         "retVal=dbus.Bus().call_blocking(\n"
339                                                         "bus_name='org.genivi.audiomanager',\n"
340                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
341                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
342                                                         "method='SetMainSourceSoundProperty',\n"
343                                                         "signature='q(nn)',\n"
344                                                         "args=[1,(0,3)],) \n"
345                                                         "f.write(str(retVal));\n"
346                                                         "f.close()",NULL);
347         result=0;
348         ifs.open("/tmp/result.txt");
349         while(std::getline(ifs, line))
350         {
351                 std::stringstream(line) >> result;
352         }
353         ASSERT_EQ(result,E_ABORTED);
354         ifs.close();
355
356         std::cout<<"[sourcesnd ]"<<std::endl;
357
358
359         EXPECT_CALL(pReceiveInterface,setSystemProperty(Field(&am_SystemProperty_s::value,2))).WillOnce(Return(E_DATABASE_ERROR));
360
361         PyRun_SimpleStringFlags("import dbus\n"
362                                                         "f = open('/tmp/result.txt','w')\n"
363                                         "bus = dbus.SessionBus()\n"
364                                                         "retVal=dbus.Bus().call_blocking(\n"
365                                                         "bus_name='org.genivi.audiomanager',\n"
366                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
367                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
368                                                         "method='SetSystemProperty',\n"
369                                                         "signature='(nn)',\n"
370                                                         "args=[(2,2)],) \n"
371                                                         "f.write(str(retVal));\n"
372                                                         "f.close()",NULL);
373
374         result=0;
375         ifs.open("/tmp/result.txt");
376         while(std::getline(ifs, line))
377         {
378                 std::stringstream(line) >> result;
379         }
380         ASSERT_EQ(result,E_DATABASE_ERROR);
381         ifs.close();
382
383         std::cout<<"[systemprop]"<<std::endl;
384
385         EXPECT_CALL(pReceiveInterface,getListMainConnections(_)).WillOnce(DoAll(returnListConnections(),Return(E_ABORTED)));
386
387         PyRun_SimpleStringFlags("import dbus\n"
388                                                         "f = open('/tmp/result.txt','w')\n"
389                                         "bus = dbus.SessionBus()\n"
390                                                         "retVal=dbus.Bus().call_blocking(\n"
391                                                         "bus_name='org.genivi.audiomanager',\n"
392                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
393                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
394                                                         "method='GetListMainConnections',\n"
395                                                         "signature='',\n"
396                                                         "args=[],) \n"
397                                                         "f.write(str(retVal));\n"
398                                                         "f.close()",NULL);
399         result=0;
400         ifs.open("/tmp/result.txt");
401         while(std::getline(ifs, line))
402         {
403                 //we could parse here, but this is the fastest way....
404                 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);
405         }
406         ifs.close();
407
408         std::cout<<"[listmainc ]"<<std::endl;
409
410         EXPECT_CALL(pReceiveInterface,getListMainSinks(_)).WillOnce(DoAll(returnListSinks(),Return(E_ABORTED)));
411
412         PyRun_SimpleStringFlags("import dbus\n"
413                                                         "f = open('/tmp/result.txt','w')\n"
414                                         "bus = dbus.SessionBus()\n"
415                                                         "retVal=dbus.Bus().call_blocking(\n"
416                                                         "bus_name='org.genivi.audiomanager',\n"
417                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
418                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
419                                                         "method='GetListMainSinks',\n"
420                                                         "signature='',\n"
421                                                         "args=[],) \n"
422                                                         "f.write(str(retVal));\n"
423                                                         "f.close()",NULL);
424         result=0;
425         ifs.open("/tmp/result.txt");
426         while(std::getline(ifs, line))
427         {
428                 //we could parse here, but this is the fastest way....
429                 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);
430         }
431         ifs.close();
432
433         std::cout<<"[listsinks ]"<<std::endl;
434
435         EXPECT_CALL(pReceiveInterface,getListMainSources(_)).WillOnce(DoAll(returnListSources(),Return(E_ABORTED)));
436
437         PyRun_SimpleStringFlags("import dbus\n"
438                                                         "f = open('/tmp/result.txt','w')\n"
439                                         "bus = dbus.SessionBus()\n"
440                                                         "retVal=dbus.Bus().call_blocking(\n"
441                                                         "bus_name='org.genivi.audiomanager',\n"
442                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
443                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
444                                                         "method='GetListMainSources',\n"
445                                                         "signature='',\n"
446                                                         "args=[],) \n"
447                                                         "f.write(str(retVal));\n"
448                                                         "f.close()",NULL);
449         result=0;
450         ifs.open("/tmp/result.txt");
451         while(std::getline(ifs, line))
452         {
453                 //we could parse here, but this is the fastest way....
454                 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);
455         }
456         ifs.close();
457
458         std::cout<<"[listsource]"<<std::endl;
459
460         EXPECT_CALL(pReceiveInterface,getListMainSinkSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(),Return(E_ABORTED)));
461
462         PyRun_SimpleStringFlags("import dbus\n"
463                                                         "f = open('/tmp/result.txt','w')\n"
464                                         "bus = dbus.SessionBus()\n"
465                                                         "retVal=dbus.Bus().call_blocking(\n"
466                                                         "bus_name='org.genivi.audiomanager',\n"
467                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
468                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
469                                                         "method='GetListMainSinkSoundProperties',\n"
470                                                         "signature='q',\n"
471                                                         "args=[1],) \n"
472                                                         "f.write(str(retVal));\n"
473                                                         "f.close()",NULL);
474         result=0;
475         ifs.open("/tmp/result.txt");
476         while(std::getline(ifs, line))
477         {
478                 //we could parse here, but this is the fastest way....
479                 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);
480         }
481         ifs.close();
482
483         std::cout<<"[lMainSiPro]"<<std::endl;
484
485         EXPECT_CALL(pReceiveInterface,getListMainSourceSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(),Return(E_ABORTED)));
486
487         PyRun_SimpleStringFlags("import dbus\n"
488                                                         "f = open('/tmp/result.txt','w')\n"
489                                         "bus = dbus.SessionBus()\n"
490                                                         "retVal=dbus.Bus().call_blocking(\n"
491                                                         "bus_name='org.genivi.audiomanager',\n"
492                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
493                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
494                                                         "method='GetListMainSourceSoundProperties',\n"
495                                                         "signature='q',\n"
496                                                         "args=[1],) \n"
497                                                         "f.write(str(retVal));\n"
498                                                         "f.close()",NULL);
499         result=0;
500         ifs.open("/tmp/result.txt");
501         while(std::getline(ifs, line))
502         {
503                 //we could parse here, but this is the fastest way....
504                 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);
505         }
506         ifs.close();
507
508         std::cout<<"[lMainSoPro]"<<std::endl;
509
510         EXPECT_CALL(pReceiveInterface,getListSourceClasses(_)).WillOnce(DoAll(returnListSourceClasses(),Return(E_ABORTED)));
511
512         PyRun_SimpleStringFlags("import dbus\n"
513                                                         "f = open('/tmp/result.txt','w')\n"
514                                         "bus = dbus.SessionBus()\n"
515                                                         "retVal=dbus.Bus().call_blocking(\n"
516                                                         "bus_name='org.genivi.audiomanager',\n"
517                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
518                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
519                                                         "method='GetListSourceClasses',\n"
520                                                         "signature='',\n"
521                                                         "args=[],) \n"
522                                                         "f.write(str(retVal));\n"
523                                                         "f.close()",NULL);
524         result=0;
525         ifs.open("/tmp/result.txt");
526         while(std::getline(ifs, line))
527         {
528                 //we could parse here, but this is the fastest way....
529                 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);
530         }
531         ifs.close();
532
533         std::cout<<"[lSourceCla]"<<std::endl;
534
535         EXPECT_CALL(pReceiveInterface,getListSinkClasses(_)).WillOnce(DoAll(returnListSinkClasses(),Return(E_ABORTED)));
536
537         PyRun_SimpleStringFlags("import dbus\n"
538                                                         "f = open('/tmp/result.txt','w')\n"
539                                         "bus = dbus.SessionBus()\n"
540                                                         "retVal=dbus.Bus().call_blocking(\n"
541                                                         "bus_name='org.genivi.audiomanager',\n"
542                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
543                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
544                                                         "method='GetListSinkClasses',\n"
545                                                         "signature='',\n"
546                                                         "args=[],) \n"
547                                                         "f.write(str(retVal));\n"
548                                                         "f.close()",NULL);
549         result=0;
550         ifs.open("/tmp/result.txt");
551         while(std::getline(ifs, line))
552         {
553                 //we could parse here, but this is the fastest way....
554                 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);
555         }
556         ifs.close();
557
558         std::cout<<"[lSinkClass]"<<std::endl;
559
560         EXPECT_CALL(pReceiveInterface,getListSystemProperties(_)).WillOnce(DoAll(returnListSystemProperties(),Return(E_ABORTED)));
561
562         PyRun_SimpleStringFlags("import dbus\n"
563                                                         "f = open('/tmp/result.txt','w')\n"
564                                         "bus = dbus.SessionBus()\n"
565                                                         "retVal=dbus.Bus().call_blocking(\n"
566                                                         "bus_name='org.genivi.audiomanager',\n"
567                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
568                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
569                                                         "method='GetListSystemProperties',\n"
570                                                         "signature='',\n"
571                                                         "args=[],) \n"
572                                                         "f.write(str(retVal));\n"
573                                                         "f.close()",NULL);
574         result=0;
575         ifs.open("/tmp/result.txt");
576         while(std::getline(ifs, line))
577         {
578                 //we could parse here, but this is the fastest way....
579                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(0), dbus.Int16(-2245)), signature=None)], signature=dbus.Signature('(nn)')))"),0);
580         }
581         ifs.close();
582
583         std::cout<<"[lSysProp  ]"<<std::endl;
584
585         EXPECT_CALL(pReceiveInterface,getTimingInformation(2,_)).WillOnce(DoAll(returnTimingInfo(),Return(E_ABORTED)));
586
587         PyRun_SimpleStringFlags("import dbus\n"
588                                                         "f = open('/tmp/result.txt','w')\n"
589                                         "bus = dbus.SessionBus()\n"
590                                                         "retVal=dbus.Bus().call_blocking(\n"
591                                                         "bus_name='org.genivi.audiomanager',\n"
592                                                         "object_path='/org/genivi/audiomanager/CommandInterface',\n"
593                                                         "dbus_interface='org.genivi.audiomanager.CommandInterface',\n"
594                                                         "method='GetTimingInformation',\n"
595                                                         "signature='q',\n"
596                                                         "args=[2],) \n"
597                                                         "f.write(str(retVal));\n"
598                                                         "f.close()",NULL);
599         result=0;
600         ifs.open("/tmp/result.txt");
601         while(std::getline(ifs, line))
602         {
603                 //we could parse here, but this is the fastest way....
604                 ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Int16(23))"),0);
605         }
606         ifs.close();
607
608         std::cout<<"[timingInfo]"<<std::endl;
609         Py_Finalize();
610 }
611
612
613 int main(int argc, char **argv)
614 {
615         ::testing::InitGoogleTest(&argc, argv);
616         return RUN_ALL_TESTS();
617 }
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634