* adopted test to new logic of no change stuff
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / test / AmControlInterfaceTest / CAmControlInterfaceTest.cpp
1 /**
2  * Copyright (C) 2012, BMW AG
3  *
4  * This file is part of GENIVI Project AudioManager.
5  *
6  * Contributions are licensed to the GENIVI Alliance under one or more
7  * Contribution License Agreements.
8  *
9  * \copyright
10  * This Source Code Form is subject to the terms of the
11  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
12  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13  *
14  *
15  * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
16  *
17  * For further information see http://www.genivi.org/.
18  *
19  */
20
21 #include "CAmControlInterfaceTest.h"
22 #include <algorithm>
23 #include <string>
24 #include <vector>
25 #include <set>
26 #include "shared/CAmDltWrapper.h"
27
28 using namespace am;
29 using namespace testing;
30
31 DLT_DECLARE_CONTEXT(AudioManager)
32
33 CAmControlInterfaceTest::CAmControlInterfaceTest() :
34         pSocketHandler(), //
35         pDBusWrapper((CAmDbusWrapper*) 1), //
36         plistCommandPluginDirs(), //
37         plistRoutingPluginDirs(), //
38         pDatabaseHandler(std::string(":memory:")), //
39         pRoutingSender(plistRoutingPluginDirs), //RoutingReceiver
40         pCommandSender(plistCommandPluginDirs), //
41         pMockControlInterface(), //
42         pMockRoutingInterface(), //
43         pRoutingInterfaceBackdoor(), //
44         pCommandInterfaceBackdoor(), //
45         pControlInterfaceBackdoor(), //
46         pControlSender(), //
47         pRouter(&pDatabaseHandler,&pControlSender), //
48         pDatabaseObserver(&pCommandSender, &pRoutingSender, &pSocketHandler), //
49         pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
50         pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, &pSocketHandler, pDBusWrapper)
51 {
52         CAmDltWrapper::instance(0)->registerApp("AudioManagerDeamon", "AudioManagerDeamon");
53     CAmDltWrapper::instance()->registerContext(AudioManager, "Main", "Main Context");
54     logInfo("The Audiomanager is started");
55     pDatabaseHandler.registerObserver(&pDatabaseObserver);
56     pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
57     pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockRoutingInterface, "mock");
58
59 }
60
61 CAmControlInterfaceTest::~CAmControlInterfaceTest()
62 {
63 }
64
65 void CAmControlInterfaceTest::SetUp()
66 {
67     logInfo("RoutingSendInterface Test started");
68 }
69
70 void CAmControlInterfaceTest::TearDown()
71 {
72 }
73
74 TEST_F(CAmControlInterfaceTest,registerDomain)
75 {
76
77     am_Domain_s domain;
78     am_domainID_t domainID;
79     pCF.createDomain(domain);
80
81     //When we run this test, we expect the call on the control interface
82     EXPECT_CALL(pMockControlInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
83     ASSERT_EQ(E_OK, pRoutingReceiver.registerDomain(domain,domainID));
84     ASSERT_EQ(domainID, 2);
85 }
86
87 TEST_F(CAmControlInterfaceTest,deregisterDomain)
88 {
89     am_domainID_t domainID = 34;
90
91     //When we run this test, we expect the call on the control interface
92     EXPECT_CALL(pMockControlInterface,hookSystemDeregisterDomain(34)).WillRepeatedly(Return(E_OK));
93     ASSERT_EQ(E_OK, pRoutingReceiver.deregisterDomain(domainID));
94 }
95
96 TEST_F(CAmControlInterfaceTest,registerSink)
97 {
98     am_Sink_s sink;
99     am_sinkID_t sinkID;
100     pCF.createSink(sink);
101
102     //When we run this test, we expect the call on the control interface
103     EXPECT_CALL(pMockControlInterface,hookSystemRegisterSink(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
104     ASSERT_EQ(E_OK, pRoutingReceiver.registerSink(sink,sinkID));
105     ASSERT_EQ(sinkID, 2);
106 }
107
108 TEST_F(CAmControlInterfaceTest,deregisterSink)
109 {
110     am_sinkID_t sinkID = 12;
111
112     //When we run this test, we expect the call on the control interface
113     EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSink(12)).WillRepeatedly(Return(E_OK));
114     ASSERT_EQ(E_OK, pRoutingReceiver.deregisterSink(sinkID));
115 }
116
117 TEST_F(CAmControlInterfaceTest,registerSource)
118 {
119     am_Source_s source;
120     am_sourceID_t sourceID;
121     pCF.createSource(source);
122
123     //When we run this test, we expect the call on the control interface
124     EXPECT_CALL(pMockControlInterface,hookSystemRegisterSource(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
125     ASSERT_EQ(E_OK, pRoutingReceiver.registerSource(source,sourceID));
126     ASSERT_EQ(sourceID, 2);
127 }
128
129 TEST_F(CAmControlInterfaceTest,deregisterSource)
130 {
131     am_sourceID_t sourceID = 12;
132
133     //When we run this test, we expect the call on the control interface
134     EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSource(12)).WillRepeatedly(Return(E_OK));
135     ASSERT_EQ(E_OK, pRoutingReceiver.deregisterSource(sourceID));
136 }
137
138 TEST_F(CAmControlInterfaceTest,registerGateway)
139 {
140     am_Gateway_s gateway;
141     am_gatewayID_t gatewayID;
142     pCF.createGateway(gateway);
143
144     //When we run this test, we expect the call on the control interface
145     EXPECT_CALL(pMockControlInterface,hookSystemRegisterGateway(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
146     ASSERT_EQ(E_OK, pRoutingReceiver.registerGateway(gateway,gatewayID));
147     ASSERT_EQ(gatewayID, 2);
148 }
149
150 TEST_F(CAmControlInterfaceTest,deregisterGateway)
151 {
152     am_gatewayID_t gatewayID = 12;
153
154     //When we run this test, we expect the call on the control interface
155     EXPECT_CALL(pMockControlInterface,hookSystemDeregisterGateway(12)).WillRepeatedly(Return(E_OK));
156     ASSERT_EQ(E_OK, pRoutingReceiver.deregisterGateway(gatewayID));
157 }
158
159 TEST_F(CAmControlInterfaceTest,ackConnect)
160 {
161     am_connectionID_t connectionID;
162     am_Sink_s sink;
163     am_sinkID_t sinkID;
164     am_Domain_s domain;
165     am_domainID_t domainID;
166     std::vector<am_Connection_s> connectionList;
167     std::vector<am_Handle_s> handlesList;
168     am_Handle_s handle;
169     pCF.createSink(sink);
170     pCF.createDomain(domain);
171     domain.name = "mock";
172     domain.busname = "mock";
173     sink.sinkID = 2;
174     sink.domainID = 1;
175
176     //prepare the stage
177     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
178     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
179
180     //when asyncConnect is called, we expect a call on the routingInterface
181     EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_GENIVI_STEREO)).WillOnce(Return(E_OK));
182     ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_GENIVI_STEREO,2,2));
183
184     //The handle should have the correct type
185     ASSERT_EQ(handle.handleType, H_CONNECT);
186     ASSERT_EQ(handle.handle, 1);
187     ASSERT_EQ(connectionID, 1);
188
189     //The list of handles shall have the handle inside
190     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
191     ASSERT_EQ(handlesList[0].handle, handle.handle);
192     ASSERT_EQ(handlesList[0].handleType, handle.handleType);
193
194     //we check the list of connections - but it must be empty because the ack did not arrive yet
195     ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
196     ASSERT_TRUE(connectionList.empty());
197
198     //finally we answer via the RoutingInterface and expect a call on the controlInterface
199     EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
200     pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
201
202     //the list of handles must be empty now
203     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
204     ASSERT_TRUE(handlesList.empty());
205
206     //but the connection must be in the connectionlist
207     ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
208     ASSERT_TRUE(!connectionList.empty());
209
210     //no we try the same, but do expect a no_change answer directly and no call because connection already exists
211     //ASSERT_EQ(E_ALREADY_EXISTS, pControlReceiver.connect(handle,connectionID,CF_GENIVI_STEREO,2,2));
212     //needed to be removed because logic changed here
213 }
214
215 TEST_F(CAmControlInterfaceTest,ackDisconnect)
216 {
217     am_connectionID_t connectionID;
218     am_Sink_s sink;
219     am_sinkID_t sinkID;
220     am_Domain_s domain;
221     am_domainID_t domainID;
222     std::vector<am_Connection_s> connectionList;
223     std::vector<am_Handle_s> handlesList;
224     am_Handle_s handle;
225     pCF.createSink(sink);
226     pCF.createDomain(domain);
227     domain.name = "mock";
228     domain.busname = "mock";
229     sink.sinkID = 2;
230     sink.domainID = 1;
231
232     //prepare the stage
233     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
234     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
235
236     //now we first need to connect, we expect a call on the routing interface
237     EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_GENIVI_STEREO)).WillOnce(Return(E_OK));
238     ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_GENIVI_STEREO,2,2));
239
240     //answer with an ack to insert the connection in the database
241     EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
242     pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
243
244     //now we can start to disconnect and expect a call on the routing interface
245     EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
246     ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
247
248     //during the disconnection, the connection is still in the list!
249     ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
250     ASSERT_TRUE(!connectionList.empty());
251
252     //then we fire the ack and expect a call on the controlInterface
253     EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_OK)).Times(1);
254     pRoutingReceiver.ackDisconnect(handle, connectionID, E_OK);
255
256     //make sure the handle is gone
257     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
258     ASSERT_TRUE(handlesList.empty());
259
260     //make sure the connection is gone
261     ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
262     ASSERT_TRUE(connectionList.empty());
263
264     //Now let's try to disconnect what is not existing...
265     ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.disconnect(handle,2));
266 }
267
268 TEST_F(CAmControlInterfaceTest,ackDisconnectFailAndRetry)
269 {
270         logInfo("ackDisconnectFailAndRetry test started");
271     am_connectionID_t connectionID;
272     am_Sink_s sink;
273     am_sinkID_t sinkID;
274     am_Domain_s domain;
275     am_domainID_t domainID;
276     std::vector<am_Connection_s> connectionList;
277     std::vector<am_Handle_s> handlesList;
278     am_Handle_s handle;
279     pCF.createSink(sink);
280     pCF.createDomain(domain);
281     domain.name = "mock";
282     domain.busname = "mock";
283     sink.sinkID = 2;
284     sink.domainID = 1;
285
286     //prepare the stage
287     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
288     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
289
290     //now we first need to connect, we expect a call on the routing interface
291     EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_GENIVI_STEREO)).WillOnce(Return(E_OK));
292     ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_GENIVI_STEREO,2,2));
293
294     //answer with an ack to insert the connection in the database
295     EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
296     pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
297
298     //now we can start to disconnect and expect a call on the routing interface
299     EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
300     ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
301
302     //during the disconnection, the connection is still in the list!
303     ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
304     ASSERT_TRUE(!connectionList.empty());
305
306     //then we fire the ack and expect a call on the controlInterface
307     EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_NON_EXISTENT)).Times(1);
308     pRoutingReceiver.ackDisconnect(handle, connectionID, E_NON_EXISTENT);
309
310     //make sure the handle is gone
311     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
312     ASSERT_TRUE(handlesList.empty());
313
314     //make sure the connection is still there
315     ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
316     ASSERT_FALSE(connectionList.empty());
317     
318     ASSERT_TRUE(pDatabaseHandler.existConnectionID(1));
319
320     //Now let's try to disconnect now
321     EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
322     ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
323     logInfo("ackDisconnectFailAndRetry test finished");
324 }
325
326 TEST_F(CAmControlInterfaceTest,setSourceState)
327 {
328
329     am_Source_s source;
330     am_sourceID_t sourceID;
331     am_Domain_s domain;
332     am_domainID_t domainID;
333     std::vector<am_Handle_s> handlesList;
334     am_Handle_s handle;
335     am_SourceState_e state;
336     pCF.createSource(source);
337     pCF.createDomain(domain);
338     domain.name = "mock";
339     domain.busname = "mock";
340     source.sourceID = 2;
341     source.domainID = 1;
342
343     //prepare the stage
344     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
345     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
346
347     //we set the sourcestate and expect a call on the routingInterface
348     EXPECT_CALL(pMockRoutingInterface,asyncSetSourceState(_,2,SS_PAUSED)).WillOnce(Return(E_OK));
349     ASSERT_EQ(E_OK, pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
350
351     //we want our handle in the list and let the type be the right one
352     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
353     ASSERT_EQ(handlesList[0].handle, handle.handle);
354     ASSERT_EQ(handlesList[0].handleType, H_SETSOURCESTATE);
355
356     //the state must be unchanged because did not get the ack
357     ASSERT_EQ(E_OK, pDatabaseHandler.getSoureState(source.sourceID,state));
358     ASSERT_EQ(state, SS_ON);
359
360     //now we sent out the ack and expect a call on the controlInterface
361     EXPECT_CALL(pMockControlInterface,cbAckSetSourceState(_,E_OK)).Times(1);
362     pRoutingReceiver.ackSetSourceState(handle, E_OK);
363
364     //finally we need the sourcestate to be changed
365     ASSERT_EQ(E_OK, pDatabaseHandler.getSoureState(source.sourceID,state));
366     ASSERT_EQ(state, SS_PAUSED);
367
368     //make sure the handle is gone
369     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
370     ASSERT_TRUE(handlesList.empty());
371
372     //we try again but expect a no change error
373     //ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
374     //needed to be removed because logic changed here
375 }
376
377 TEST_F(CAmControlInterfaceTest,SetSinkVolumeChange)
378 {
379     am_Sink_s sink;
380     am_sinkID_t sinkID;
381     am_Domain_s domain;
382     am_domainID_t domainID;
383     am_volume_t volume;
384     std::vector<am_Handle_s> handlesList;
385     am_Handle_s handle;
386     pCF.createSink(sink);
387     pCF.createDomain(domain);
388     domain.name = "mock";
389     domain.busname = "mock";
390     sink.sinkID = 2;
391     sink.domainID = 1;
392     sink.volume = 10;
393
394     //setup environment, we need a domain and a sink
395     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
396     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
397
398     //set the volume and expect a call on the routing interface
399     EXPECT_CALL(pMockRoutingInterface,asyncSetSinkVolume(_,2,11,RAMP_GENIVI_DIRECT,23)).WillOnce(Return(E_OK));
400     ASSERT_EQ(E_OK, pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_GENIVI_DIRECT,23));
401
402     //check the list of handles. The handle must be in there and have the right type
403     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
404     ASSERT_EQ(handlesList[0].handle, handle.handle);
405     ASSERT_EQ(handlesList[0].handleType, H_SETSINKVOLUME);
406
407     //now we read out the volume, but we expect no change because the ack did not arrive yet
408     ASSERT_EQ(E_OK, pDatabaseHandler.getSinkVolume(sinkID,volume));
409     ASSERT_EQ(sink.volume, volume);
410
411     //lets send the answer and expect a call on the controlInterface
412     EXPECT_CALL(pMockControlInterface,cbAckSetSinkVolumeChange(_,11,E_OK)).Times(1);
413     pRoutingReceiver.ackSetSinkVolumeChange(handle, 11, E_OK);
414
415     //finally, the new value must be in the database
416     ASSERT_EQ(E_OK, pDatabaseHandler.getSinkVolume(sinkID,volume));
417     ASSERT_EQ(11, volume);
418
419     //and the handle must be destroyed
420     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
421     ASSERT_TRUE(handlesList.empty());
422
423     //Now we try again, but the value is unchanged
424     //ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_GENIVI_DIRECT,23));
425     //needed to be removed because logic changed here
426 }
427
428 TEST_F(CAmControlInterfaceTest,ackSetSourceVolumeChange)
429 {
430     am_Source_s source;
431     am_sourceID_t sourceID;
432     am_Domain_s domain;
433     am_domainID_t domainID;
434     am_volume_t volume;
435     std::vector<am_Handle_s> handlesList;
436     am_Handle_s handle;
437     pCF.createSource(source);
438     pCF.createDomain(domain);
439     domain.name = "mock";
440     domain.busname = "mock";
441     source.sourceID = 2;
442     source.domainID = 1;
443     source.volume = 12;
444
445     //prepare the scene
446     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
447     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
448
449     //change the sinkVolume, expect a call on the routingInterface
450     EXPECT_CALL(pMockRoutingInterface,asyncSetSourceVolume(_,2,11,RAMP_GENIVI_DIRECT,23)).WillOnce(Return(E_OK));
451     ASSERT_EQ(E_OK, pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_GENIVI_DIRECT,23));
452
453     //check the list of handles. The handle must be in there and have the right type
454     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
455     ASSERT_EQ(handlesList[0].handle, handle.handle);
456     ASSERT_EQ(handlesList[0].handleType, H_SETSOURCEVOLUME);
457
458     //now we read out the volume, but we expect no change because the ack did not arrive yet
459     ASSERT_EQ(E_OK, pDatabaseHandler.getSourceVolume(sourceID,volume));
460     ASSERT_EQ(source.volume, volume);
461
462     //lets send the answer and expect a call on the controlInterface
463     EXPECT_CALL(pMockControlInterface,cbAckSetSourceVolumeChange(_,11,E_OK)).Times(1);
464     pRoutingReceiver.ackSetSourceVolumeChange(handle, 11, E_OK);
465
466     //finally, the new value must be in the database
467     ASSERT_EQ(E_OK, pDatabaseHandler.getSourceVolume(sourceID,volume));
468     ASSERT_EQ(11, volume);
469
470     //and the handle must be destroyed
471     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
472     ASSERT_TRUE(handlesList.empty());
473
474     //Now we try again, but the value is unchanged
475     //ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_GENIVI_DIRECT,23));
476     //needed to be removed because logic changed here
477 }
478
479 TEST_F(CAmControlInterfaceTest,ackSetSinkSoundProperty)
480 {
481     am_Sink_s sink;
482     am_sinkID_t sinkID;
483     am_Domain_s domain;
484     am_domainID_t domainID;
485     std::vector<am_Handle_s> handlesList;
486     am_Handle_s handle;
487     am_SoundProperty_s soundProperty;
488     int16_t oldvalue;
489     pCF.createSink(sink);
490     pCF.createDomain(domain);
491     domain.name = "mock";
492     domain.busname = "mock";
493     sink.sinkID = 2;
494     sink.domainID = 1;
495     soundProperty.type = SP_EXAMPLE_BASS;
496     soundProperty.value = 244;
497
498     //setup environment, we need a domain and a sink
499     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
500     ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
501
502     //change the soundproperty, expect a call on the routinginterface
503     EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,2,_)).WillOnce(Return(E_OK));
504     ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
505
506     //check the list of handles. The handle must be in there and have the right type
507     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
508     ASSERT_EQ(handlesList[0].handle, handle.handle);
509     ASSERT_EQ(handlesList[0].handleType, H_SETSINKSOUNDPROPERTY);
510
511     //read out this property. There is no change, because the ack did not arrive yet.
512     ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(2,SP_EXAMPLE_BASS,oldvalue));
513     ASSERT_EQ(sink.listSoundProperties[0].value, oldvalue);
514
515     //lets send the answer and expect a call on the controlInterface
516     EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)).Times(1);
517     pRoutingReceiver.ackSetSinkSoundProperty(handle, E_OK);
518
519     //finally, the new value must be in the database
520     ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID,SP_EXAMPLE_BASS,oldvalue));
521     ASSERT_EQ(soundProperty.value, oldvalue);
522
523     //and the handle must be destroyed
524     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
525     ASSERT_TRUE(handlesList.empty());
526
527     //Now we try again, but the value is unchanged
528     //ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
529     //needed to be removed because logic changed here
530 }
531
532 TEST_F(CAmControlInterfaceTest,ackSetSourceSoundProperty)
533 {
534     am_Source_s source;
535     am_sourceID_t sourceID;
536     am_Domain_s domain;
537     am_domainID_t domainID;
538     std::vector<am_Handle_s> handlesList;
539     am_Handle_s handle;
540     am_SoundProperty_s soundProperty;
541     int16_t oldvalue;
542     pCF.createSource(source);
543     pCF.createDomain(domain);
544     domain.name = "mock";
545     domain.busname = "mock";
546     source.sourceID = 2;
547     source.domainID = 1;
548     soundProperty.type = SP_EXAMPLE_BASS;
549     soundProperty.value = 244;
550
551     //prepare the scene
552     ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
553     ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
554
555     //we trigger the change and wait for a call on the routinginterface
556     EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,2,_)).WillOnce(Return(E_OK));
557     ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
558
559     //check the list of handles. The handle must be in there and have the right type
560     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
561     ASSERT_EQ(handlesList[0].handle, handle.handle);
562     ASSERT_EQ(handlesList[0].handleType, H_SETSOURCESOUNDPROPERTY);
563
564     //read out this property. There is no change, because the ack did not arrive yet.
565     ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(2,SP_EXAMPLE_BASS,oldvalue));
566     ASSERT_EQ(source.listSoundProperties[0].value, oldvalue);
567
568     //lets send the answer and expect a call on the controlInterface
569     EXPECT_CALL(pMockControlInterface,cbAckSetSourceSoundProperty(_,E_OK)).Times(1);
570     pRoutingReceiver.ackSetSourceSoundProperty(handle, E_OK);
571
572     //finally, the new value must be in the database
573     ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID,SP_EXAMPLE_BASS,oldvalue));
574     ASSERT_EQ(soundProperty.value, oldvalue);
575
576     //and the handle must be destroyed
577     ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
578     ASSERT_TRUE(handlesList.empty());
579
580     //Now we try again, but the value is unchanged
581     //ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
582     //needed to be removed because logic changed here
583 }
584
585 TEST_F(CAmControlInterfaceTest,crossFading)
586 {
587     //todo: implement crossfading test
588 }
589
590 int main(int argc, char **argv)
591 {
592     ::testing::InitGoogleTest(&argc, argv);
593     return RUN_ALL_TESTS();
594 }
595