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