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