2 * Copyright (C) 2011, BMW AG
4 * GeniviAudioMananger AudioManagerDaemon
6 * \file databasetest.cpp
8 * \date 20-Oct-2011 3:42:04 PM
9 * \author Christian Mueller (christian.ei.mueller@bmw.de)
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
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.
23 * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
26 #include "databaseTest.h"
27 #include "MockInterfaces.h"
28 #include "DatabaseHandler.h"
29 #include "ControlReceiver.h"
30 #include "ControlSender.h"
31 #include "DatabaseObserver.h"
32 #include "../ControlInterfaceBackdoor.h"
33 #include "../CommandInterfaceBackdoor.h"
34 #include "../CommonFunctions.h"
37 using namespace testing;
39 DLT_DECLARE_CONTEXT(DLT_CONTEXT)
41 //extern int GetRandomNumber(int nLow, int nHigh);
42 //extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
43 extern bool equalMainSoundProperty(const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
44 extern bool equalRoutingElement(const am_RoutingElement_s a, const am_RoutingElement_s b);
45 extern bool equalClassProperties(const am_ClassProperty_s a, const am_ClassProperty_s b);
46 extern std::string int2string(int i);
48 routingTest::routingTest() :
49 plistRoutingPluginDirs(), //
50 plistCommandPluginDirs(), //
51 pDatabaseHandler(std::string(":memory:")), //
52 pRoutingSender(plistRoutingPluginDirs), //
53 pCommandSender(plistCommandPluginDirs), //
55 pRoutingInterfaceBackdoor(),//
56 pCommandInterfaceBackdoor(), //
57 pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
58 pObserver(&pCommandSender, &pRoutingSender)
60 pDatabaseHandler.registerObserver(&pObserver);
61 pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
64 routingTest::~routingTest()
68 void routingTest::createMainConnectionSetup()
70 //fill the connection database
71 am_Connection_s connection;
74 std::vector<am_Connection_s> connectionList;
76 //we create 9 sources and sinks:
77 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
78 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
80 for (uint16_t i = 1; i < 10; i++)
82 am_sinkID_t forgetSink;
83 am_sourceID_t forgetSource;
84 am_connectionID_t forgetConnection;
86 pCF.createConnection(connection);
87 connection.sinkID = i;
88 connection.sourceID = i;
89 connectionList.push_back(connection);
93 sink.name = "sink" + int2string(i);
95 pCF.createSource(source);
97 source.name = "source" + int2string(i);
100 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))
101 << "ERROR: database error";
102 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))
103 << "ERROR: database error";
104 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
105 << "ERROR: database error";
106 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(forgetConnection));
110 std::vector<am_RoutingElement_s> routingList;
111 pCF.connectionList2RoutingList(routingList, connectionList);
115 route.route = routingList;
119 //create a mainConnection
120 am_MainConnection_s mainConnection;
121 am_mainConnectionID_t mainConnectionID;
122 std::vector<am_MainConnection_s> mainConnectionList;
123 pCF.createMainConnection(mainConnection, route);
125 //enter mainconnection in database
126 EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
127 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
128 ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))
129 << "ERROR: database error";
130 ASSERT_NE(0,mainConnectionID)
131 << "ERROR: connectionID zero";
133 //read out the mainconnections and check if they are equal to the data written.
134 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(mainConnectionList));
136 std::vector<am_MainConnection_s>::iterator listIterator = mainConnectionList.begin();
137 for (; listIterator < mainConnectionList.end(); ++listIterator)
139 if (listIterator->connectionID == mainConnectionID)
141 equal = equal && (listIterator->connectionState == mainConnection.connectionState) && (listIterator->route.sinkID == mainConnection.route.sinkID) && (listIterator->route.sourceID == mainConnection.route.sourceID) && (listIterator->delay == mainConnection.delay) && (std::equal(listIterator->route.route.begin(), listIterator->route.route.end(), routingList.begin(), equalRoutingElement));
144 ASSERT_EQ(true, equal);
147 void routingTest::SetUp()
149 DLT_REGISTER_APP("Dtest", "AudioManagerDeamon");
150 DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
151 DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Database Test started "));
154 void routingTest::TearDown()
156 DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
159 TEST_F(routingTest,crossfaders)
161 //todo:implement crossfader tests
164 TEST_F(routingTest,sourceState)
167 am_sourceID_t sourceID;
168 std::vector<am_Source_s> listSources;
169 pCF.createSource(source);
170 source.sourceState = SS_OFF;
173 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
174 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
176 //change the source state
177 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceState(sourceID,SS_ON));
179 //read out the changed values
180 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
181 ASSERT_EQ(listSources[0].sourceState, SS_ON);
184 TEST_F(routingTest,sinkVolumeChange)
188 std::vector<am_Sink_s> listSinks;
189 pCF.createSink(sink);
193 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
194 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
196 //change the volume and check the read out
197 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkVolume(sinkID,34));
198 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
199 ASSERT_EQ(listSinks[0].volume, 34);
202 TEST_F(routingTest,sourceVolumeChange)
205 am_sourceID_t sourceID;
206 std::vector<am_Source_s> listSources;
207 pCF.createSource(source);
211 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
212 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
214 //change the volume and check the read out
215 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceVolume(sourceID,34));
216 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
217 ASSERT_EQ(listSources[0].volume, 34);
220 TEST_F(routingTest, peekSource)
222 std::vector<am_Source_s> listSources;
223 am_sourceID_t sourceID, source2ID, source3ID;
225 pCF.createSource(source);
227 //peek a source that does not exits
228 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
229 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
231 //make sure it is not in the list
232 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
233 ASSERT_TRUE(listSources.empty());
234 ASSERT_EQ(sourceID, 100);
236 //now enter the source with the same name and make sure it does not get a new ID
237 source.name = "newsource";
238 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
239 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source2ID));
240 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
241 ASSERT_EQ(sourceID, source2ID);
242 ASSERT_TRUE(listSources[0].sourceID==sourceID);
244 //now we peek again. This time, the source exists
245 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(source.name,source3ID));
246 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
247 ASSERT_TRUE(listSources.size()==1);
248 ASSERT_EQ(source3ID, source2ID);
251 TEST_F(routingTest, peekSourceDouble)
253 std::vector<am_Source_s> listSources;
254 am_sourceID_t sourceID;
255 am_sourceID_t source2ID;
256 am_sourceID_t source3ID;
258 pCF.createSource(source);
260 //peek a source that does not exits
261 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
262 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
264 //peek a second source that does not exits
265 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
266 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
268 //make sure they are is not in the list
269 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
270 ASSERT_TRUE(listSources.empty());
271 ASSERT_EQ(sourceID, 100);
272 source.name = "newsource";
274 //now enter the source with the same name than the first peek and make sure it does not get a new ID
275 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
276 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source3ID));
277 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
278 ASSERT_EQ(sourceID, source3ID);
279 ASSERT_TRUE(listSources[0].sourceID==sourceID);
282 TEST_F(routingTest, peekSink)
284 std::vector<am_Sink_s> listSinks;
285 am_sinkID_t sinkID, sink2ID, sink3ID;
287 pCF.createSink(sink);
289 //peek a sink that does not exits
290 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
291 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
293 //make sure it is not in the list
294 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
295 ASSERT_TRUE(listSinks.empty());
296 ASSERT_EQ(sinkID, 100);
297 sink.name = "newsink";
299 //now enter the source with the same name and make sure it does not get a new ID
300 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
301 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink2ID));
302 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
303 ASSERT_EQ(sinkID, sink2ID);
304 ASSERT_TRUE(listSinks[0].sinkID==sinkID);
306 //now we peek again, this time, the sink exists
307 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(sink.name,sink3ID));
308 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
309 ASSERT_TRUE(listSinks.size()==1);
310 ASSERT_EQ(sink3ID, sink2ID);
313 TEST_F(routingTest, peekSinkDouble)
315 std::vector<am_Sink_s> listSinks;
320 pCF.createSink(sink);
322 //peek a sink that does not exits
323 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
324 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
327 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
328 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
330 //make sure they are is not in the list
331 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
332 ASSERT_TRUE(listSinks.empty());
333 ASSERT_EQ(sinkID, 100);
334 sink.name = "newsink";
336 //now enter the sink with the same name than the first peek and make sure it does not get a new ID
337 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
338 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink3ID));
339 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
340 ASSERT_EQ(sinkID, sink3ID);
341 ASSERT_TRUE(listSinks[0].sinkID==sinkID);
344 TEST_F(routingTest,changeConnectionTimingInformationCheckMainConnection)
346 am_Connection_s connection;
347 std::vector<am_Connection_s> connectionList;
348 std::vector<am_MainConnectionType_s> mainList;
349 pCF.createConnection(connection);
351 //prepare the test, it is one mainconnection, so we expect one callback
352 createMainConnectionSetup();
353 EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
355 //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
356 ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
357 ASSERT_EQ(mainList[0].delay, -1);
359 //no go through all connections and set the delay time to 24 for each connection
360 ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
361 std::vector<am_Connection_s>::iterator iteratorConnectionList = connectionList.begin();
362 for (; iteratorConnectionList < connectionList.end(); ++iteratorConnectionList)
364 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
367 //we read the result again and expect that the value is now different from -1
368 ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
369 ASSERT_EQ(mainList[0].delay, 216);
372 TEST_F(routingTest,changeConnectionTimingInformation)
374 am_Connection_s connection;
375 am_connectionID_t connectionID;
376 std::vector<am_Connection_s> connectionList;
377 pCF.createConnection(connection);
380 ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
381 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
383 //change the timing and check it
384 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
385 ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
386 ASSERT_TRUE(connectionList[0].delay==24);
389 TEST_F(routingTest,getSinkClassOfSink)
391 std::vector<am_SinkClass_s> sinkClassList;
392 std::vector<am_ClassProperty_s> classPropertyList;
393 am_SinkClass_s sinkClass, returnClass;
394 am_ClassProperty_s classProperty;
395 am_sinkClass_t sinkClassID;
398 classProperty.classProperty = CP_SINK_TYPE;
399 classProperty.value = 1;
400 classPropertyList.push_back(classProperty);
401 classProperty.classProperty = CP_SOURCE_TYPE;
402 classProperty.value = 4;
403 classPropertyList.push_back(classProperty);
404 sinkClass.name = "test";
405 sinkClass.sinkClassID = 4;
406 sinkClass.listClassProperties = classPropertyList;
407 pCF.createSink(sink);
408 sink.sinkClassID = 4;
411 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
412 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
414 //enter a new sinkclass, read out again and check
415 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
416 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
417 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
418 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
419 ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
420 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
421 ASSERT_EQ(E_OK, pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
422 ASSERT_EQ(sinkClassList[0].name, returnClass.name);
423 ASSERT_EQ(sinkClassList[0].sinkClassID, returnClass.sinkClassID);
424 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
427 TEST_F(routingTest,getSourceClassOfSource)
429 std::vector<am_SourceClass_s> sourceClassList;
430 std::vector<am_ClassProperty_s> classPropertyList;
431 am_SourceClass_s sourceClass, sinkSourceClass;
432 am_ClassProperty_s classProperty;
433 am_sourceClass_t sourceClassID;
435 am_sourceID_t sourceID;
436 classProperty.classProperty = CP_SINK_TYPE;
437 classProperty.value = 1;
438 classPropertyList.push_back(classProperty);
439 classProperty.classProperty = CP_SOURCE_TYPE;
440 classProperty.value = 4;
441 classPropertyList.push_back(classProperty);
442 sourceClass.name = "test";
443 sourceClass.sourceClassID = 1;
444 sourceClass.listClassProperties = classPropertyList;
445 pCF.createSource(source);
447 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
448 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
449 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
450 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
451 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
452 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
453 ASSERT_EQ(sourceClassList[0].sourceClassID, 1);
454 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
455 ASSERT_EQ(E_OK, pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
456 ASSERT_EQ(sourceClassList[0].name, sinkSourceClass.name);
457 ASSERT_EQ(sourceClassList[0].sourceClassID, sinkSourceClass.sourceClassID);
458 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
461 TEST_F(routingTest,removeSourceClass)
463 std::vector<am_SourceClass_s> sourceClassList;
464 std::vector<am_ClassProperty_s> classPropertyList;
465 am_SourceClass_s sourceClass;
466 am_ClassProperty_s classProperty;
467 am_sourceClass_t sourceClassID;
468 classProperty.classProperty = CP_SINK_TYPE;
469 classProperty.value = 1;
470 classPropertyList.push_back(classProperty);
471 classProperty.classProperty = CP_SOURCE_TYPE;
472 classProperty.value = 4;
473 classPropertyList.push_back(classProperty);
474 sourceClass.name = "test";
475 sourceClass.sourceClassID = 3;
476 sourceClass.listClassProperties = classPropertyList;
478 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
479 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
480 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
481 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
482 ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
483 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
484 ASSERT_EQ(E_OK, pDatabaseHandler.removeSourceClassDB(3));
485 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
486 ASSERT_TRUE(sourceClassList.empty());
489 TEST_F(routingTest,updateSourceClass)
491 std::vector<am_SourceClass_s> sourceClassList;
492 std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
493 am_SourceClass_s sourceClass, changedClass;
494 am_ClassProperty_s classProperty;
495 am_sourceClass_t sourceClassID;
496 classProperty.classProperty = CP_SINK_TYPE;
497 classProperty.value = 1;
498 classPropertyList.push_back(classProperty);
499 classProperty.classProperty = CP_SOURCE_TYPE;
500 classProperty.value = 4;
501 classPropertyList.push_back(classProperty);
502 sourceClass.name = "test";
503 sourceClass.sourceClassID = 0;
504 sourceClass.listClassProperties = classPropertyList;
505 changedClass = sourceClass;
506 changedClass.listClassProperties[1].value = 6;
507 changedPropertyList = changedClass.listClassProperties;
508 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
509 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
510 changedClass.sourceClassID = sourceClassID;
511 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
512 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
513 ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
514 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
515 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceClassInfoDB(changedClass));
516 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
517 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
518 ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
519 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
522 TEST_F(routingTest,enterSourceClass)
524 std::vector<am_SourceClass_s> sourceClassList;
525 std::vector<am_ClassProperty_s> classPropertyList;
526 am_SourceClass_s sourceClass;
527 am_ClassProperty_s classProperty;
528 am_sourceClass_t sourceClassID;
529 classProperty.classProperty = CP_SINK_TYPE;
530 classProperty.value = 1;
531 classPropertyList.push_back(classProperty);
532 classProperty.classProperty = CP_SOURCE_TYPE;
533 classProperty.value = 4;
534 classPropertyList.push_back(classProperty);
535 sourceClass.name = "test";
536 sourceClass.sourceClassID = 0;
537 sourceClass.listClassProperties = classPropertyList;
539 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
540 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
541 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
542 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
543 ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
544 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
547 TEST_F(routingTest,enterSourceClassStatic)
549 std::vector<am_SourceClass_s> sourceClassList;
550 std::vector<am_ClassProperty_s> classPropertyList;
551 am_SourceClass_s sourceClass;
552 am_ClassProperty_s classProperty;
553 am_sourceClass_t sourceClassID;
554 classProperty.classProperty = CP_SINK_TYPE;
555 classProperty.value = 1;
556 classPropertyList.push_back(classProperty);
557 classProperty.classProperty = CP_SOURCE_TYPE;
558 classProperty.value = 4;
559 classPropertyList.push_back(classProperty);
560 sourceClass.name = "test";
561 sourceClass.sourceClassID = 3;
562 sourceClass.listClassProperties = classPropertyList;
564 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
565 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
566 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
567 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
568 ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
569 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
572 TEST_F(routingTest,removeSinkClass)
574 std::vector<am_SinkClass_s> sinkClassList;
575 std::vector<am_ClassProperty_s> classPropertyList;
576 am_SinkClass_s sinkClass;
577 am_ClassProperty_s classProperty;
578 am_sinkClass_t sinkClassID;
579 classProperty.classProperty = CP_SINK_TYPE;
580 classProperty.value = 1;
581 classPropertyList.push_back(classProperty);
582 classProperty.classProperty = CP_SOURCE_TYPE;
583 classProperty.value = 4;
584 classPropertyList.push_back(classProperty);
585 sinkClass.name = "test";
586 sinkClass.sinkClassID = 0;
587 sinkClass.listClassProperties = classPropertyList;
589 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
590 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
591 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
592 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
593 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
594 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
595 ASSERT_EQ(E_OK, pDatabaseHandler.removeSinkClassDB(sinkClassID));
596 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
597 ASSERT_TRUE(sinkClassList.empty());
600 TEST_F(routingTest,updateSinkClass)
602 std::vector<am_SinkClass_s> sinkClassList;
603 std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
604 am_SinkClass_s sinkClass, changedClass;
605 am_ClassProperty_s classProperty;
606 am_sinkClass_t sinkClassID;
607 classProperty.classProperty = CP_SINK_TYPE;
608 classProperty.value = 1;
609 classPropertyList.push_back(classProperty);
610 classProperty.classProperty = CP_SOURCE_TYPE;
611 classProperty.value = 4;
612 classPropertyList.push_back(classProperty);
613 sinkClass.name = "test";
614 sinkClass.sinkClassID = 0;
615 sinkClass.listClassProperties = classPropertyList;
616 changedClass = sinkClass;
617 changedClass.listClassProperties[1].value = 6;
618 changedPropertyList = changedClass.listClassProperties;
619 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
620 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
621 changedClass.sinkClassID = sinkClassID;
622 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
623 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
624 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
625 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
626 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkClassInfoDB(changedClass));
627 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
628 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
629 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
630 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
633 TEST_F(routingTest,enterSinkClass)
635 std::vector<am_SinkClass_s> sinkClassList;
636 std::vector<am_ClassProperty_s> classPropertyList;
637 am_SinkClass_s sinkClass;
638 am_ClassProperty_s classProperty;
639 am_sinkClass_t sinkClassID;
640 classProperty.classProperty = CP_SINK_TYPE;
641 classProperty.value = 1;
642 classPropertyList.push_back(classProperty);
643 classProperty.classProperty = CP_SOURCE_TYPE;
644 classProperty.value = 4;
645 classPropertyList.push_back(classProperty);
646 sinkClass.name = "test";
647 sinkClass.sinkClassID = 0;
648 sinkClass.listClassProperties = classPropertyList;
650 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
651 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
652 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
653 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
654 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
655 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
658 TEST_F(routingTest,enterSinkClassStatic)
660 std::vector<am_SinkClass_s> sinkClassList;
661 std::vector<am_ClassProperty_s> classPropertyList;
662 am_SinkClass_s sinkClass;
663 am_ClassProperty_s classProperty;
664 am_sinkClass_t sinkClassID;
665 classProperty.classProperty = CP_SINK_TYPE;
666 classProperty.value = 1;
667 classPropertyList.push_back(classProperty);
668 classProperty.classProperty = CP_SOURCE_TYPE;
669 classProperty.value = 4;
670 classPropertyList.push_back(classProperty);
671 sinkClass.name = "test";
672 sinkClass.sinkClassID = 4;
673 sinkClass.listClassProperties = classPropertyList;
675 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
676 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
677 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
678 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
679 ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
680 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
683 TEST_F(routingTest, changeSystemProperty)
685 std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
686 am_SystemProperty_s systemProperty;
688 systemProperty.type = SYP_TEST;
689 systemProperty.value = 33;
690 listSystemProperties.push_back(systemProperty);
691 EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
692 ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
693 systemProperty.value = 444;
694 ASSERT_EQ(E_OK, pDatabaseHandler.changeSystemPropertyDB(systemProperty));
695 ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
696 ASSERT_EQ(listReturn[0].type, systemProperty.type);
697 ASSERT_EQ(listReturn[0].value, systemProperty.value);
700 TEST_F(routingTest, systemProperties)
702 std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
703 am_SystemProperty_s systemProperty;
705 systemProperty.type = SYP_TEST;
706 systemProperty.value = 33;
707 listSystemProperties.push_back(systemProperty);
709 ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
710 ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
711 ASSERT_EQ(listReturn[0].type, systemProperty.type);
712 ASSERT_EQ(listReturn[0].value, systemProperty.value);
715 TEST_F(routingTest,enterSourcesCorrect)
717 //fill the connection database
718 am_Source_s staticSource, firstDynamicSource, secondDynamicSource;
719 am_sourceID_t staticSourceID, firstDynamicSourceID, secondDynamicSourceID;
720 std::vector<am_Source_s> sourceList;
722 pCF.createSource(staticSource);
723 staticSource.sourceID = 4;
724 staticSource.name = "Static";
726 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
727 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
728 << "ERROR: database error";
729 ASSERT_EQ(staticSource.sourceID,staticSourceID)
730 << "ERROR: ID not the one given in staticSource";
732 pCF.createSource(firstDynamicSource);
733 firstDynamicSource.name = "firstDynamicSource";
735 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))
736 << "ERROR: database error";
737 ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)
738 << "ERROR: ID not the one given in firstDynamicSink";
740 pCF.createSource(secondDynamicSource);
741 secondDynamicSource.name = "secondDynamicSource";
743 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))
744 << "ERROR: database error";
745 ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)
746 << "ERROR: ID not the one given in secondDynamicSink";
748 //now read back and check the returns agains the given values
749 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))
750 << "ERROR: database error";
753 std::vector<am_Source_s>::iterator listIterator = sourceList.begin();
754 for (; listIterator < sourceList.end(); ++listIterator)
756 if (listIterator->sourceID == staticSourceID)
758 equal = equal && pCF.compareSource(listIterator, staticSource);
761 if (listIterator->sourceID == firstDynamicSourceID)
763 equal = equal && pCF.compareSource(listIterator, firstDynamicSource);
766 if (listIterator->sourceID == secondDynamicSourceID)
768 equal = equal && pCF.compareSource(listIterator, secondDynamicSource);
772 ASSERT_EQ(true, equal);
775 TEST_F(routingTest, changeSourceMainSoundProperty)
777 std::vector<am_Source_s> listSources;
779 am_sourceID_t sourceID;
780 pCF.createSource(source);
781 am_MainSoundProperty_s property;
782 property.type = MSP_NAVIGATION_OFFSET;
784 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
785 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
787 EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
788 ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
789 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
790 std::vector<am_MainSoundProperty_s>::iterator listIterator = listSources[0].listMainSoundProperties.begin();
791 for (; listIterator < listSources[0].listMainSoundProperties.end(); ++listIterator)
793 if (listIterator->type == property.type)
795 ASSERT_EQ(listIterator->value, property.value);
800 TEST_F(routingTest, changeSinkMuteState)
802 std::vector<am_Sink_s> listSinks;
805 pCF.createSink(sink);
806 am_MuteState_e muteState = MS_MUTED;
807 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
808 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
810 EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
811 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
812 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
813 ASSERT_EQ(muteState, listSinks[0].muteState);
816 TEST_F(routingTest, changeSinkMainSoundProperty)
818 std::vector<am_Sink_s> listSinks;
821 pCF.createSink(sink);
822 am_MainSoundProperty_s property;
823 property.type = MSP_NAVIGATION_OFFSET;
826 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
827 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
829 EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
830 ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
831 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
832 std::vector<am_MainSoundProperty_s>::iterator listIterator = listSinks[0].listMainSoundProperties.begin();
833 for (; listIterator < listSinks[0].listMainSoundProperties.end(); ++listIterator)
835 if (listIterator->type == property.type)
837 ASSERT_EQ(listIterator->value, property.value);
842 TEST_F(routingTest, peekDomain)
844 std::vector<am_Domain_s> listDomains;
846 am_domainID_t domainID;
847 am_domainID_t domain2ID;
848 pCF.createDomain(domain);
849 ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
850 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
851 ASSERT_TRUE(listDomains.empty());
852 ASSERT_EQ(domainID, 1);
853 domain.name = "newdomain";
854 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domain2ID));
855 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
856 ASSERT_EQ(domainID, domain2ID);
857 ASSERT_TRUE(listDomains[0].domainID==domainID);
860 TEST_F(routingTest, peekDomainFirstEntered)
862 std::vector<am_Domain_s> listDomains;
864 am_domainID_t domainID;
865 am_domainID_t domain2ID;
866 pCF.createDomain(domain);
867 domain.name = "newdomain";
868 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
869 ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
870 ASSERT_EQ(domainID, domain2ID);
871 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
872 ASSERT_TRUE(listDomains.size()==1);
875 TEST_F(routingTest, changeDomainState)
877 std::vector<am_Domain_s> listDomains;
879 am_domainID_t domainID;
880 pCF.createDomain(domain);
881 am_DomainState_e newState = DS_INDEPENDENT_STARTUP;
882 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
883 ASSERT_EQ(E_OK, pDatabaseHandler.changDomainStateDB(newState,domainID));
884 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
885 ASSERT_EQ(newState, listDomains[0].state);
888 TEST_F(routingTest, changeMainConnectionState)
890 std::vector<am_MainConnection_s> listMainConnections;
891 createMainConnectionSetup();
892 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
893 ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))
894 << "ERROR: database error";ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(listMainConnections));
895 ASSERT_EQ(CS_DISCONNECTING, listMainConnections[0].connectionState);
898 TEST_F(routingTest, changeSinkAvailability)
900 std::vector<am_Sink_s> listSinks;
903 pCF.createSink(sink);
904 am_Availability_s availability;
905 availability.availability = A_UNKNOWN;
906 availability.availabilityReason = AR_TEMPERATURE;
908 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
909 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
910 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
911 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
912 ASSERT_EQ(availability.availability, listSinks[0].available.availability);
913 ASSERT_EQ(availability.availabilityReason, listSinks[0].available.availabilityReason);
916 TEST_F(routingTest, changeSourceAvailability)
918 std::vector<am_Source_s> listSources;
920 am_sourceID_t sourceID;
921 pCF.createSource(source);
922 am_Availability_s availability;
923 availability.availability = A_UNKNOWN;
924 availability.availabilityReason = AR_TEMPERATURE;
925 source.visible = true;
927 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
928 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
929 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
930 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
931 ASSERT_EQ(availability.availability, listSources[0].available.availability);
932 ASSERT_EQ(availability.availabilityReason, listSources[0].available.availabilityReason);
935 TEST_F(routingTest,changeMainConnectionRoute)
937 std::vector<am_MainConnection_s> originalList;
938 std::vector<am_MainConnection_s> newList;
939 createMainConnectionSetup();
940 //fill the connection database
941 am_Connection_s connection;
944 std::vector<am_Connection_s> connectionList;
946 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
947 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
948 for (uint16_t i = 1; i < 10; i++)
950 am_sinkID_t forgetSink;
951 am_sourceID_t forgetSource;
952 am_connectionID_t forgetConnection;
954 pCF.createConnection(connection);
955 connection.sinkID = i + 20;
956 connection.sourceID = i + 20;
957 connection.delay = -1;
958 connectionList.push_back(connection);
960 pCF.createSink(sink);
961 sink.sinkID = i + 20;
962 sink.name = "sink" + int2string(i + 20);
964 pCF.createSource(source);
965 source.sourceID = i + 20;
966 source.name = "source" + int2string(i + 30);
969 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))
970 << "ERROR: database error";
971 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))
972 << "ERROR: database error";
973 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
974 << "ERROR: database error";
975 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))
976 << "ERROR: database error";
981 std::vector<am_RoutingElement_s> routingList;
982 pCF.connectionList2RoutingList(routingList, connectionList);
986 route.route = routingList;
990 ASSERT_EQ(E_OK, pDatabaseHandler.changeMainConnectionRouteDB(1,route));
991 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))
992 << "ERROR: database error";ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
993 ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
996 TEST_F(routingTest,changeMainSinkVolume)
1000 am_mainVolume_t newVol = 20;
1001 std::vector<am_Sink_s> listSinks;
1002 pCF.createSink(sink);
1004 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1005 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1007 EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
1008 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
1009 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
1010 ASSERT_EQ(listSinks[0].mainVolume, newVol);
1013 TEST_F(routingTest,getMainSourceSoundProperties)
1016 am_sourceID_t sourceID;
1017 pCF.createSource(source);
1018 std::vector<am_MainSoundProperty_s> mainSoundProperties = source.listMainSoundProperties;
1019 std::vector<am_MainSoundProperty_s> listMainSoundProperties;
1021 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
1022 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1023 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
1024 ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
1027 TEST_F(routingTest,getMainSinkSoundProperties)
1031 pCF.createSink(sink);
1032 std::vector<am_MainSoundProperty_s> mainSoundProperties = sink.listMainSoundProperties;
1033 std::vector<am_MainSoundProperty_s> listMainSoundProperties;
1035 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1036 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1037 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
1038 ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
1041 TEST_F(routingTest,getMainSources)
1043 am_Source_s source, source1, source2;
1044 am_sourceID_t sourceID;
1045 pCF.createSource(source);
1046 pCF.createSource(source1);
1047 pCF.createSource(source2);
1048 source1.name = "source1";
1049 source2.name = "source2";
1051 source1.visible = false;
1052 std::vector<am_SourceType_s> listMainSources;
1053 std::vector<am_Source_s> listSources;
1055 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
1057 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1058 source.sourceID = sourceID;
1059 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source1,sourceID));
1060 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source2,sourceID));
1061 source2.sourceID = sourceID;
1062 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSources(listMainSources));
1063 listSources.push_back(source);
1064 listSources.push_back(source2);
1065 std::vector<am_SourceType_s>::iterator listIterator = listMainSources.begin();
1066 for (; listIterator < listMainSources.end(); ++listIterator)
1068 equal = equal && pCF.compareSinkMainSource(listIterator, listSources);
1073 TEST_F(routingTest,getMainSinks)
1075 am_Sink_s sink, sink1, sink2;
1077 pCF.createSink(sink);
1078 pCF.createSink(sink1);
1079 pCF.createSink(sink2);
1080 sink1.name = "sink1";
1081 sink2.name = "sink2";
1083 sink1.visible = false;
1084 std::vector<am_SinkType_s> listMainSinks;
1085 std::vector<am_Sink_s> listSinks;
1087 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1088 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1089 sink.sinkID = sinkID;
1090 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink1,sinkID));
1091 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink2,sinkID));
1092 sink2.sinkID = sinkID;
1093 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinks(listMainSinks));
1094 listSinks.push_back(sink);
1095 listSinks.push_back(sink2);
1096 std::vector<am_SinkType_s>::iterator listIterator = listMainSinks.begin();
1097 for (; listIterator < listMainSinks.end(); ++listIterator)
1099 equal = equal && pCF.compareSinkMainSink(listIterator, listSinks);
1104 TEST_F(routingTest,getVisibleMainConnections)
1106 createMainConnectionSetup();
1107 am_MainConnection_s mainConnection;
1109 pCF.createMainConnection(mainConnection, route);
1110 std::vector<am_MainConnectionType_s> visibleMainConnection;
1111 ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
1112 ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
1113 ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
1114 ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
1115 ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
1116 ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
1119 TEST_F(routingTest,getListSourcesOfDomain)
1121 am_Source_s source, source2;
1123 am_domainID_t domainID;
1124 am_sourceID_t sourceID;
1125 std::vector<am_sourceID_t> sourceList, sourceCheckList;
1126 pCF.createSource(source);
1127 source.sourceID = 1;
1128 source.name = "testSource";
1129 source.domainID = 1;
1130 pCF.createSource(source2);
1131 source2.sourceID = 0;
1132 source2.name = "testSource2";
1133 source2.domainID = 5;
1134 pCF.createDomain(domain);
1135 sourceCheckList.push_back(1); //sink.sinkID);
1137 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1138 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
1139 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
1140 << "ERROR: database error";
1141 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))
1142 << "ERROR: database error";
1143 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))
1144 << "ERROR: database error";ASSERT_TRUE(sourceList.empty());
1145 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))
1146 << "ERROR: database error";
1147 ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
1150 TEST_F(routingTest,getListSinksOfDomain)
1152 am_Sink_s sink, sink2;
1154 am_domainID_t domainID;
1156 std::vector<am_sinkID_t> sinkList, sinkCheckList;
1157 pCF.createSink(sink);
1160 pCF.createSink(sink2);
1162 sink2.name = "sink2";
1163 pCF.createDomain(domain);
1164 sinkCheckList.push_back(1); //sink.sinkID);
1166 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1167 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
1168 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
1169 << "ERROR: database error";
1170 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))
1171 << "ERROR: database error";
1172 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))
1173 << "ERROR: database error";ASSERT_TRUE(sinkList.empty());
1174 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))
1175 << "ERROR: database error";
1176 ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
1179 TEST_F(routingTest,getListGatewaysOfDomain)
1181 am_Gateway_s gateway, gateway2;
1182 am_gatewayID_t gatewayID;
1183 am_domainID_t domainID;
1185 std::vector<am_gatewayID_t> gatewayList, gatewayCheckList;
1186 pCF.createGateway(gateway);
1187 gateway.gatewayID = 1;
1188 gateway.name = "testGateway";
1189 gateway.controlDomainID = 1;
1190 gateway.sourceID = 1;
1192 gateway.domainSinkID = 1;
1193 gateway.domainSourceID = 1;
1194 pCF.createGateway(gateway2);
1195 gateway2.gatewayID = 2;
1196 gateway2.name = "testGateway2";
1197 gateway2.controlDomainID = 4;
1198 gateway2.sourceID = 1;
1199 gateway2.sinkID = 1;
1200 gateway2.domainSinkID = 1;
1201 gateway2.domainSourceID = 1;
1202 pCF.createDomain(domain);
1203 gatewayCheckList.push_back(gateway.gatewayID);
1204 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
1205 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1206 << "ERROR: database error";
1207 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))
1208 << "ERROR: database error";
1209 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))
1210 << "ERROR: database error";ASSERT_TRUE(gatewayList.empty());
1211 ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))
1212 << "ERROR: database error";
1213 ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
1216 TEST_F(routingTest,removeDomain)
1219 am_domainID_t domainID;
1220 std::vector<am_Domain_s> listDomains;
1221 pCF.createDomain(domain);
1222 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
1223 << "ERROR: database error";
1224 ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))
1225 << "ERROR: database error";
1226 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))
1227 << "ERROR: database error";
1228 ASSERT_TRUE(listDomains.empty());
1231 TEST_F(routingTest,removeGateway)
1233 am_Gateway_s gateway;
1234 am_gatewayID_t gatewayID;
1235 std::vector<am_Gateway_s> listGateways;
1236 pCF.createGateway(gateway);
1237 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1238 << "ERROR: database error";
1239 ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))
1240 << "ERROR: database error";
1241 ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))
1242 << "ERROR: database error";
1243 ASSERT_TRUE(listGateways.empty());
1246 TEST_F(routingTest,removeSink)
1250 std::vector<am_Sink_s> listSinks;
1251 pCF.createSink(sink);
1252 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1253 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
1254 << "ERROR: database error";
1255 ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))
1256 << "ERROR: database error";
1257 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))
1258 << "ERROR: database error";
1259 ASSERT_TRUE(listSinks.empty());
1262 TEST_F(routingTest,removeSource)
1264 //fill the connection database
1266 am_sourceID_t sourceID;
1267 std::vector<am_Source_s> listSources;
1268 pCF.createSource(source);
1270 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1271 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
1272 << "ERROR: database error";
1273 ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))
1274 << "ERROR: database error";
1275 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))
1276 << "ERROR: database error";
1277 ASSERT_TRUE(listSources.empty());
1280 TEST_F(routingTest, removeMainConnection)
1282 createMainConnectionSetup();
1283 EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
1284 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
1285 ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))
1286 << "ERROR: database error";
1289 TEST_F(routingTest,removeNonexistentMainConnectionFail)
1291 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))
1292 << "ERROR: database error";
1295 TEST_F(routingTest,removeNonexistentSource)
1297 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))
1298 << "ERROR: database error";
1301 TEST_F(routingTest,removeNonexistentSink)
1303 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))
1304 << "ERROR: database error";
1307 TEST_F(routingTest,removeNonexistentGateway)
1309 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))
1310 << "ERROR: database error";
1313 TEST_F(routingTest,registerGatewayCorrect)
1315 //initialize gateway
1316 std::vector<am_Gateway_s> returnList;
1317 am_Gateway_s gateway, gateway1, gateway2;
1318 am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
1320 pCF.createGateway(gateway);
1321 pCF.createGateway(gateway1);
1322 gateway1.gatewayID = 20;
1323 pCF.createGateway(gateway2);
1325 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1326 << "ERROR: database error";
1327 ASSERT_EQ(100,gatewayID)
1328 << "ERROR: domainID zero";
1330 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
1331 << "ERROR: database error";
1332 ASSERT_EQ(gateway1.gatewayID,gatewayID1)
1333 << "ERROR: domainID zero";
1335 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
1336 << "ERROR: database error";
1337 ASSERT_EQ(101,gatewayID2)
1338 << "ERROR: domainID zero";
1340 //now check if we read out the correct values
1341 ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
1343 std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
1345 for (; listIterator < returnList.end(); ++listIterator)
1347 if (listIterator->gatewayID == gatewayID)
1349 equal = equal && pCF.compareGateway(listIterator, gateway);
1352 if (listIterator->gatewayID == gatewayID1)
1354 equal = equal && pCF.compareGateway(listIterator, gateway1);
1357 if (listIterator->gatewayID == gatewayID2)
1359 equal = equal && pCF.compareGateway(listIterator, gateway2);
1363 ASSERT_EQ(true, equal);
1366 TEST_F(routingTest,getGatewayInfo)
1368 //initialize gateway
1369 std::vector<am_Gateway_s> returnList;
1370 am_Gateway_s gateway, gateway1, gateway2;
1371 am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
1373 pCF.createGateway(gateway);
1374 pCF.createGateway(gateway1);
1375 gateway1.gatewayID = 20;
1376 pCF.createGateway(gateway2);
1378 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1379 << "ERROR: database error";
1380 ASSERT_EQ(100,gatewayID)
1381 << "ERROR: domainID zero";
1383 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
1384 << "ERROR: database error";
1385 ASSERT_EQ(gateway1.gatewayID,gatewayID1)
1386 << "ERROR: domainID zero";
1388 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
1389 << "ERROR: database error";
1390 ASSERT_EQ(101,gatewayID2)
1391 << "ERROR: domainID zero";
1393 //now check if we read out the correct values
1394 ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
1396 std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
1398 for (; listIterator < returnList.end(); ++listIterator)
1400 if (listIterator->gatewayID == gatewayID)
1402 equal = equal && pCF.compareGateway(listIterator, gateway);
1405 if (listIterator->gatewayID == gatewayID1)
1407 equal = equal && pCF.compareGateway(listIterator, gateway1);
1410 if (listIterator->gatewayID == gatewayID2)
1412 equal = equal && pCF.compareGateway(listIterator, gateway2);
1416 ASSERT_EQ(true, equal);
1418 am_Gateway_s gatewayInfo;
1419 ASSERT_EQ(E_OK, pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
1420 ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
1424 TEST_F(routingTest,enterSinkThatAlreadyExistFail)
1426 //fill the connection database
1427 am_Sink_s staticSink, SecondSink;
1428 am_sinkID_t staticSinkID, SecondSinkID;
1430 pCF.createSink(staticSink);
1431 staticSink.sinkID = 43;
1432 staticSink.name = "Static";
1434 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1435 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
1436 << "ERROR: database error";
1437 ASSERT_EQ(staticSink.sinkID,staticSinkID)
1438 << "ERROR: ID not the one given in staticSink";
1440 pCF.createSink(SecondSink);
1441 SecondSink.sinkID = 43;
1442 SecondSink.name = "SecondSink";
1444 ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))
1445 << "ERROR: database error";
1448 TEST_F(routingTest,enterSourcesThatAlreadyExistFail)
1450 //fill the connection database
1451 am_Source_s staticSource, SecondSource;
1452 am_sourceID_t staticSourceID, SecondSourceID;
1453 pCF.createSource(staticSource);
1454 staticSource.sourceID = 4;
1456 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
1457 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
1458 << "ERROR: database error";
1459 ASSERT_EQ(staticSource.sourceID,staticSourceID)
1460 << "ERROR: ID not the one given in staticSource";
1462 pCF.createSource(SecondSource);
1463 SecondSource.sourceID = 4;
1465 ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))
1466 << "ERROR: database error";
1469 TEST_F(routingTest,registerDomainCorrect)
1472 std::vector<am_Domain_s> returnList;
1474 am_domainID_t domainID = 0;
1475 pCF.createDomain(domain);
1477 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
1478 << "ERROR: database error";
1479 ASSERT_NE(0,domainID)
1480 << "ERROR: domainID zero";
1482 //now check if we read out the correct values
1483 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(returnList));
1485 std::vector<am_Domain_s>::iterator listIterator = returnList.begin();
1486 for (; listIterator < returnList.end(); ++listIterator)
1488 if (listIterator->domainID == domainID)
1490 equal = equal && (listIterator->name.compare(domain.name) == 0) && (listIterator->busname.compare(domain.busname) == 0) && (listIterator->complete == domain.complete) && (listIterator->early == domain.early) && (listIterator->state == domain.state);
1493 ASSERT_EQ(true, equal);
1496 TEST_F(routingTest,registerConnectionCorrect)
1498 am_Connection_s connection;
1499 am_connectionID_t connectionID;
1500 std::vector<am_Connection_s> returnList;
1501 pCF.createConnection(connection);
1503 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))
1504 << "ERROR: database error";;
1505 ASSERT_NE(0,connectionID)
1506 << "ERROR: connectionID zero";
1508 //now check if we read out the correct values
1509 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
1510 ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(returnList));
1512 std::vector<am_Connection_s>::iterator listIterator = returnList.begin();
1513 for (; listIterator < returnList.end(); ++listIterator)
1515 if (listIterator->connectionID == connectionID)
1517 equal = (listIterator->sourceID == connection.sourceID) && (listIterator->sinkID == connection.sinkID) && (listIterator->delay == connection.delay) && (listIterator->connectionFormat = connection.connectionFormat);
1520 ASSERT_EQ(true, equal);
1523 TEST_F(routingTest,enterMainConnectionCorrect)
1525 createMainConnectionSetup();
1528 TEST_F(routingTest,enterSinksCorrect)
1530 //fill the connection database
1531 am_Sink_s staticSink, firstDynamicSink, secondDynamicSink;
1532 am_sinkID_t staticSinkID, firstDynamicSinkID, secondDynamicSinkID;
1533 std::vector<am_Sink_s> sinkList;
1535 pCF.createSink(staticSink);
1536 staticSink.sinkID = 4;
1538 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1539 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
1540 << "ERROR: database error";
1541 ASSERT_EQ(staticSink.sinkID,staticSinkID)
1542 << "ERROR: ID not the one given in staticSink";
1544 pCF.createSink(firstDynamicSink);
1545 firstDynamicSink.name = "firstdynamic";
1546 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))
1547 << "ERROR: database error";
1548 ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)
1549 << "ERROR: ID not the one given in firstDynamicSink";
1551 pCF.createSink(secondDynamicSink);
1552 secondDynamicSink.name = "seconddynamic";
1554 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))
1555 << "ERROR: database error";
1556 ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)
1557 << "ERROR: ID not the one given in secondDynamicSink";
1559 //now read back and check the returns agains the given values
1560 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))
1561 << "ERROR: database error";
1564 std::vector<am_Sink_s>::iterator listIterator = sinkList.begin();
1565 for (; listIterator < sinkList.end(); ++listIterator)
1567 if (listIterator->sinkID == staticSinkID)
1569 equal = equal && pCF.compareSink(listIterator, staticSink);
1572 if (listIterator->sinkID == firstDynamicSinkID)
1574 equal = equal && pCF.compareSink(listIterator, firstDynamicSink);
1577 if (listIterator->sinkID == secondDynamicSinkID)
1579 equal = equal && pCF.compareSink(listIterator, secondDynamicSink);
1582 ASSERT_EQ(true, equal);
1585 //Commented out - gives always a warning..
1586 //TEST_F(databaseTest,registerDomainFailonID0)
1588 // am_Domain_s domain;
1589 // am_domainID_t domainID=5;
1590 // pCF.createDomain(domain);
1591 // domain.domainID=1;
1592 // ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
1595 int main(int argc, char **argv)
1597 ::testing::InitGoogleTest(&argc, argv);
1598 return RUN_ALL_TESTS();