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(), //
58 pRouter(&pDatabaseHandler,&pControlSender), //
59 pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), //
60 pObserver(&pCommandSender, &pRoutingSender)
62 pDatabaseHandler.registerObserver(&pObserver);
63 pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
66 routingTest::~routingTest()
70 void routingTest::createMainConnectionSetup()
72 //fill the connection database
73 am_Connection_s connection;
76 std::vector<am_Connection_s> connectionList;
78 //we create 9 sources and sinks:
79 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
80 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
82 for (uint16_t i = 1; i < 10; i++)
84 am_sinkID_t forgetSink;
85 am_sourceID_t forgetSource;
86 am_connectionID_t forgetConnection;
88 pCF.createConnection(connection);
89 connection.sinkID = i;
90 connection.sourceID = i;
91 connectionList.push_back(connection);
95 sink.name = "sink" + int2string(i);
97 pCF.createSource(source);
99 source.name = "source" + int2string(i);
102 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))
103 << "ERROR: database error";
104 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))
105 << "ERROR: database error";
106 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
107 << "ERROR: database error";
108 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(forgetConnection));
112 std::vector<am_RoutingElement_s> routingList;
113 pCF.connectionList2RoutingList(routingList, connectionList);
117 route.route = routingList;
121 //create a mainConnection
122 am_MainConnection_s mainConnection;
123 am_mainConnectionID_t mainConnectionID;
124 std::vector<am_MainConnection_s> mainConnectionList;
125 pCF.createMainConnection(mainConnection, route);
127 //enter mainconnection in database
128 EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
129 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
130 ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))
131 << "ERROR: database error";
132 ASSERT_NE(0,mainConnectionID)
133 << "ERROR: connectionID zero";
135 //read out the mainconnections and check if they are equal to the data written.
136 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(mainConnectionList));
138 std::vector<am_MainConnection_s>::iterator listIterator = mainConnectionList.begin();
139 for (; listIterator < mainConnectionList.end(); ++listIterator)
141 if (listIterator->connectionID == mainConnectionID)
143 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));
146 ASSERT_EQ(true, equal);
149 void routingTest::SetUp()
151 DLT_REGISTER_APP("Dtest", "AudioManagerDeamon");
152 DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
153 DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Database Test started "));
156 void routingTest::TearDown()
158 DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
161 TEST_F(routingTest,crossfaders)
163 //todo:implement crossfader tests
166 TEST_F(routingTest,sourceState)
169 am_sourceID_t sourceID;
170 std::vector<am_Source_s> listSources;
171 pCF.createSource(source);
172 source.sourceState = SS_OFF;
175 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
176 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
178 //change the source state
179 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceState(sourceID,SS_ON));
181 //read out the changed values
182 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
183 ASSERT_EQ(listSources[0].sourceState, SS_ON);
186 TEST_F(routingTest,sinkVolumeChange)
190 std::vector<am_Sink_s> listSinks;
191 pCF.createSink(sink);
195 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
196 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
198 //change the volume and check the read out
199 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkVolume(sinkID,34));
200 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
201 ASSERT_EQ(listSinks[0].volume, 34);
204 TEST_F(routingTest,sourceVolumeChange)
207 am_sourceID_t sourceID;
208 std::vector<am_Source_s> listSources;
209 pCF.createSource(source);
213 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
214 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
216 //change the volume and check the read out
217 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceVolume(sourceID,34));
218 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
219 ASSERT_EQ(listSources[0].volume, 34);
222 TEST_F(routingTest, peekSource)
224 std::vector<am_Source_s> listSources;
225 am_sourceID_t sourceID, source2ID, source3ID;
227 pCF.createSource(source);
229 //peek a source that does not exits
230 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
231 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
233 //make sure it is not in the list
234 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
235 ASSERT_TRUE(listSources.empty());
236 ASSERT_EQ(sourceID, 100);
238 //now enter the source with the same name and make sure it does not get a new ID
239 source.name = "newsource";
240 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
241 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source2ID));
242 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
243 ASSERT_EQ(sourceID, source2ID);
244 ASSERT_TRUE(listSources[0].sourceID==sourceID);
246 //now we peek again. This time, the source exists
247 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(source.name,source3ID));
248 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
249 ASSERT_TRUE(listSources.size()==1);
250 ASSERT_EQ(source3ID, source2ID);
253 TEST_F(routingTest, peekSourceDouble)
255 std::vector<am_Source_s> listSources;
256 am_sourceID_t sourceID;
257 am_sourceID_t source2ID;
258 am_sourceID_t source3ID;
260 pCF.createSource(source);
262 //peek a source that does not exits
263 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
264 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
266 //peek a second source that does not exits
267 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
268 ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
270 //make sure they are is not in the list
271 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
272 ASSERT_TRUE(listSources.empty());
273 ASSERT_EQ(sourceID, 100);
274 source.name = "newsource";
276 //now enter the source with the same name than the first peek and make sure it does not get a new ID
277 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
278 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source3ID));
279 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
280 ASSERT_EQ(sourceID, source3ID);
281 ASSERT_TRUE(listSources[0].sourceID==sourceID);
284 TEST_F(routingTest, peekSink)
286 std::vector<am_Sink_s> listSinks;
287 am_sinkID_t sinkID, sink2ID, sink3ID;
289 pCF.createSink(sink);
291 //peek a sink that does not exits
292 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
293 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
295 //make sure it is not in the list
296 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
297 ASSERT_TRUE(listSinks.empty());
298 ASSERT_EQ(sinkID, 100);
299 sink.name = "newsink";
301 //now enter the source with the same name and make sure it does not get a new ID
302 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
303 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink2ID));
304 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
305 ASSERT_EQ(sinkID, sink2ID);
306 ASSERT_TRUE(listSinks[0].sinkID==sinkID);
308 //now we peek again, this time, the sink exists
309 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(sink.name,sink3ID));
310 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
311 ASSERT_TRUE(listSinks.size()==1);
312 ASSERT_EQ(sink3ID, sink2ID);
315 TEST_F(routingTest, peekSinkDouble)
317 std::vector<am_Sink_s> listSinks;
322 pCF.createSink(sink);
324 //peek a sink that does not exits
325 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
326 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
329 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
330 ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
332 //make sure they are is not in the list
333 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
334 ASSERT_TRUE(listSinks.empty());
335 ASSERT_EQ(sinkID, 100);
336 sink.name = "newsink";
338 //now enter the sink with the same name than the first peek and make sure it does not get a new ID
339 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
340 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink3ID));
341 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
342 ASSERT_EQ(sinkID, sink3ID);
343 ASSERT_TRUE(listSinks[0].sinkID==sinkID);
346 TEST_F(routingTest,changeConnectionTimingInformationCheckMainConnection)
348 am_Connection_s connection;
349 std::vector<am_Connection_s> connectionList;
350 std::vector<am_MainConnectionType_s> mainList;
351 pCF.createConnection(connection);
353 //prepare the test, it is one mainconnection, so we expect one callback
354 createMainConnectionSetup();
355 EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
357 //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
358 ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
359 ASSERT_EQ(mainList[0].delay, -1);
361 //no go through all connections and set the delay time to 24 for each connection
362 ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
363 std::vector<am_Connection_s>::iterator iteratorConnectionList = connectionList.begin();
364 for (; iteratorConnectionList < connectionList.end(); ++iteratorConnectionList)
366 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
369 //we read the result again and expect that the value is now different from -1
370 ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
371 ASSERT_EQ(mainList[0].delay, 216);
374 TEST_F(routingTest,changeConnectionTimingInformation)
376 am_Connection_s connection;
377 am_connectionID_t connectionID;
378 std::vector<am_Connection_s> connectionList;
379 pCF.createConnection(connection);
382 ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
383 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
385 //change the timing and check it
386 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
387 ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
388 ASSERT_TRUE(connectionList[0].delay==24);
391 TEST_F(routingTest,getSinkClassOfSink)
393 std::vector<am_SinkClass_s> sinkClassList;
394 std::vector<am_ClassProperty_s> classPropertyList;
395 am_SinkClass_s sinkClass, returnClass;
396 am_ClassProperty_s classProperty;
397 am_sinkClass_t sinkClassID;
400 classProperty.classProperty = CP_SINK_TYPE;
401 classProperty.value = 1;
402 classPropertyList.push_back(classProperty);
403 classProperty.classProperty = CP_SOURCE_TYPE;
404 classProperty.value = 4;
405 classPropertyList.push_back(classProperty);
406 sinkClass.name = "test";
407 sinkClass.sinkClassID = 4;
408 sinkClass.listClassProperties = classPropertyList;
409 pCF.createSink(sink);
410 sink.sinkClassID = 4;
413 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
414 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
416 //enter a new sinkclass, read out again and check
417 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
418 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
419 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
420 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
421 ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
422 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
423 ASSERT_EQ(E_OK, pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
424 ASSERT_EQ(sinkClassList[0].name, returnClass.name);
425 ASSERT_EQ(sinkClassList[0].sinkClassID, returnClass.sinkClassID);
426 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
429 TEST_F(routingTest,getSourceClassOfSource)
431 std::vector<am_SourceClass_s> sourceClassList;
432 std::vector<am_ClassProperty_s> classPropertyList;
433 am_SourceClass_s sourceClass, sinkSourceClass;
434 am_ClassProperty_s classProperty;
435 am_sourceClass_t sourceClassID;
437 am_sourceID_t sourceID;
438 classProperty.classProperty = CP_SINK_TYPE;
439 classProperty.value = 1;
440 classPropertyList.push_back(classProperty);
441 classProperty.classProperty = CP_SOURCE_TYPE;
442 classProperty.value = 4;
443 classPropertyList.push_back(classProperty);
444 sourceClass.name = "test";
445 sourceClass.sourceClassID = 1;
446 sourceClass.listClassProperties = classPropertyList;
447 pCF.createSource(source);
449 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
450 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
451 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
452 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
453 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
454 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
455 ASSERT_EQ(sourceClassList[0].sourceClassID, 1);
456 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
457 ASSERT_EQ(E_OK, pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
458 ASSERT_EQ(sourceClassList[0].name, sinkSourceClass.name);
459 ASSERT_EQ(sourceClassList[0].sourceClassID, sinkSourceClass.sourceClassID);
460 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
463 TEST_F(routingTest,removeSourceClass)
465 std::vector<am_SourceClass_s> sourceClassList;
466 std::vector<am_ClassProperty_s> classPropertyList;
467 am_SourceClass_s sourceClass;
468 am_ClassProperty_s classProperty;
469 am_sourceClass_t sourceClassID;
470 classProperty.classProperty = CP_SINK_TYPE;
471 classProperty.value = 1;
472 classPropertyList.push_back(classProperty);
473 classProperty.classProperty = CP_SOURCE_TYPE;
474 classProperty.value = 4;
475 classPropertyList.push_back(classProperty);
476 sourceClass.name = "test";
477 sourceClass.sourceClassID = 3;
478 sourceClass.listClassProperties = classPropertyList;
480 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
481 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
482 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
483 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
484 ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
485 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
486 ASSERT_EQ(E_OK, pDatabaseHandler.removeSourceClassDB(3));
487 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
488 ASSERT_TRUE(sourceClassList.empty());
491 TEST_F(routingTest,updateSourceClass)
493 std::vector<am_SourceClass_s> sourceClassList;
494 std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
495 am_SourceClass_s sourceClass, changedClass;
496 am_ClassProperty_s classProperty;
497 am_sourceClass_t sourceClassID;
498 classProperty.classProperty = CP_SINK_TYPE;
499 classProperty.value = 1;
500 classPropertyList.push_back(classProperty);
501 classProperty.classProperty = CP_SOURCE_TYPE;
502 classProperty.value = 4;
503 classPropertyList.push_back(classProperty);
504 sourceClass.name = "test";
505 sourceClass.sourceClassID = 0;
506 sourceClass.listClassProperties = classPropertyList;
507 changedClass = sourceClass;
508 changedClass.listClassProperties[1].value = 6;
509 changedPropertyList = changedClass.listClassProperties;
510 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
511 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
512 changedClass.sourceClassID = sourceClassID;
513 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
514 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
515 ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
516 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
517 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceClassInfoDB(changedClass));
518 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
519 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
520 ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
521 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
524 TEST_F(routingTest,enterSourceClass)
526 std::vector<am_SourceClass_s> sourceClassList;
527 std::vector<am_ClassProperty_s> classPropertyList;
528 am_SourceClass_s sourceClass;
529 am_ClassProperty_s classProperty;
530 am_sourceClass_t sourceClassID;
531 classProperty.classProperty = CP_SINK_TYPE;
532 classProperty.value = 1;
533 classPropertyList.push_back(classProperty);
534 classProperty.classProperty = CP_SOURCE_TYPE;
535 classProperty.value = 4;
536 classPropertyList.push_back(classProperty);
537 sourceClass.name = "test";
538 sourceClass.sourceClassID = 0;
539 sourceClass.listClassProperties = classPropertyList;
541 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
542 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
543 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
544 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
545 ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
546 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
549 TEST_F(routingTest,enterSourceClassStatic)
551 std::vector<am_SourceClass_s> sourceClassList;
552 std::vector<am_ClassProperty_s> classPropertyList;
553 am_SourceClass_s sourceClass;
554 am_ClassProperty_s classProperty;
555 am_sourceClass_t sourceClassID;
556 classProperty.classProperty = CP_SINK_TYPE;
557 classProperty.value = 1;
558 classPropertyList.push_back(classProperty);
559 classProperty.classProperty = CP_SOURCE_TYPE;
560 classProperty.value = 4;
561 classPropertyList.push_back(classProperty);
562 sourceClass.name = "test";
563 sourceClass.sourceClassID = 3;
564 sourceClass.listClassProperties = classPropertyList;
566 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
567 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
568 ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
569 ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
570 ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
571 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
574 TEST_F(routingTest,removeSinkClass)
576 std::vector<am_SinkClass_s> sinkClassList;
577 std::vector<am_ClassProperty_s> classPropertyList;
578 am_SinkClass_s sinkClass;
579 am_ClassProperty_s classProperty;
580 am_sinkClass_t sinkClassID;
581 classProperty.classProperty = CP_SINK_TYPE;
582 classProperty.value = 1;
583 classPropertyList.push_back(classProperty);
584 classProperty.classProperty = CP_SOURCE_TYPE;
585 classProperty.value = 4;
586 classPropertyList.push_back(classProperty);
587 sinkClass.name = "test";
588 sinkClass.sinkClassID = 0;
589 sinkClass.listClassProperties = classPropertyList;
591 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
592 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
593 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
594 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
595 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
596 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
597 ASSERT_EQ(E_OK, pDatabaseHandler.removeSinkClassDB(sinkClassID));
598 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
599 ASSERT_TRUE(sinkClassList.empty());
602 TEST_F(routingTest,updateSinkClass)
604 std::vector<am_SinkClass_s> sinkClassList;
605 std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
606 am_SinkClass_s sinkClass, changedClass;
607 am_ClassProperty_s classProperty;
608 am_sinkClass_t sinkClassID;
609 classProperty.classProperty = CP_SINK_TYPE;
610 classProperty.value = 1;
611 classPropertyList.push_back(classProperty);
612 classProperty.classProperty = CP_SOURCE_TYPE;
613 classProperty.value = 4;
614 classPropertyList.push_back(classProperty);
615 sinkClass.name = "test";
616 sinkClass.sinkClassID = 0;
617 sinkClass.listClassProperties = classPropertyList;
618 changedClass = sinkClass;
619 changedClass.listClassProperties[1].value = 6;
620 changedPropertyList = changedClass.listClassProperties;
621 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
622 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
623 changedClass.sinkClassID = sinkClassID;
624 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
625 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
626 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
627 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
628 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkClassInfoDB(changedClass));
629 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
630 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
631 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
632 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
635 TEST_F(routingTest,enterSinkClass)
637 std::vector<am_SinkClass_s> sinkClassList;
638 std::vector<am_ClassProperty_s> classPropertyList;
639 am_SinkClass_s sinkClass;
640 am_ClassProperty_s classProperty;
641 am_sinkClass_t sinkClassID;
642 classProperty.classProperty = CP_SINK_TYPE;
643 classProperty.value = 1;
644 classPropertyList.push_back(classProperty);
645 classProperty.classProperty = CP_SOURCE_TYPE;
646 classProperty.value = 4;
647 classPropertyList.push_back(classProperty);
648 sinkClass.name = "test";
649 sinkClass.sinkClassID = 0;
650 sinkClass.listClassProperties = classPropertyList;
652 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
653 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
654 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
655 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
656 ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
657 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
660 TEST_F(routingTest,enterSinkClassStatic)
662 std::vector<am_SinkClass_s> sinkClassList;
663 std::vector<am_ClassProperty_s> classPropertyList;
664 am_SinkClass_s sinkClass;
665 am_ClassProperty_s classProperty;
666 am_sinkClass_t sinkClassID;
667 classProperty.classProperty = CP_SINK_TYPE;
668 classProperty.value = 1;
669 classPropertyList.push_back(classProperty);
670 classProperty.classProperty = CP_SOURCE_TYPE;
671 classProperty.value = 4;
672 classPropertyList.push_back(classProperty);
673 sinkClass.name = "test";
674 sinkClass.sinkClassID = 4;
675 sinkClass.listClassProperties = classPropertyList;
677 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
678 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
679 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
680 ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
681 ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
682 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
685 TEST_F(routingTest, changeSystemProperty)
687 std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
688 am_SystemProperty_s systemProperty;
690 systemProperty.type = SYP_TEST;
691 systemProperty.value = 33;
692 listSystemProperties.push_back(systemProperty);
693 EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
694 ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
695 systemProperty.value = 444;
696 ASSERT_EQ(E_OK, pDatabaseHandler.changeSystemPropertyDB(systemProperty));
697 ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
698 ASSERT_EQ(listReturn[0].type, systemProperty.type);
699 ASSERT_EQ(listReturn[0].value, systemProperty.value);
702 TEST_F(routingTest, systemProperties)
704 std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
705 am_SystemProperty_s systemProperty;
707 systemProperty.type = SYP_TEST;
708 systemProperty.value = 33;
709 listSystemProperties.push_back(systemProperty);
711 ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
712 ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
713 ASSERT_EQ(listReturn[0].type, systemProperty.type);
714 ASSERT_EQ(listReturn[0].value, systemProperty.value);
717 TEST_F(routingTest,enterSourcesCorrect)
719 //fill the connection database
720 am_Source_s staticSource, firstDynamicSource, secondDynamicSource;
721 am_sourceID_t staticSourceID, firstDynamicSourceID, secondDynamicSourceID;
722 std::vector<am_Source_s> sourceList;
724 pCF.createSource(staticSource);
725 staticSource.sourceID = 4;
726 staticSource.name = "Static";
728 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
729 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
730 << "ERROR: database error";
731 ASSERT_EQ(staticSource.sourceID,staticSourceID)
732 << "ERROR: ID not the one given in staticSource";
734 pCF.createSource(firstDynamicSource);
735 firstDynamicSource.name = "firstDynamicSource";
737 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))
738 << "ERROR: database error";
739 ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)
740 << "ERROR: ID not the one given in firstDynamicSink";
742 pCF.createSource(secondDynamicSource);
743 secondDynamicSource.name = "secondDynamicSource";
745 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))
746 << "ERROR: database error";
747 ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)
748 << "ERROR: ID not the one given in secondDynamicSink";
750 //now read back and check the returns agains the given values
751 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))
752 << "ERROR: database error";
755 std::vector<am_Source_s>::iterator listIterator = sourceList.begin();
756 for (; listIterator < sourceList.end(); ++listIterator)
758 if (listIterator->sourceID == staticSourceID)
760 equal = equal && pCF.compareSource(listIterator, staticSource);
763 if (listIterator->sourceID == firstDynamicSourceID)
765 equal = equal && pCF.compareSource(listIterator, firstDynamicSource);
768 if (listIterator->sourceID == secondDynamicSourceID)
770 equal = equal && pCF.compareSource(listIterator, secondDynamicSource);
774 ASSERT_EQ(true, equal);
777 TEST_F(routingTest, changeSourceMainSoundProperty)
779 std::vector<am_Source_s> listSources;
781 am_sourceID_t sourceID;
782 pCF.createSource(source);
783 am_MainSoundProperty_s property;
784 property.type = MSP_NAVIGATION_OFFSET;
786 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
787 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
789 EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
790 ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
791 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
792 std::vector<am_MainSoundProperty_s>::iterator listIterator = listSources[0].listMainSoundProperties.begin();
793 for (; listIterator < listSources[0].listMainSoundProperties.end(); ++listIterator)
795 if (listIterator->type == property.type)
797 ASSERT_EQ(listIterator->value, property.value);
802 TEST_F(routingTest, changeSinkMuteState)
804 std::vector<am_Sink_s> listSinks;
807 pCF.createSink(sink);
808 am_MuteState_e muteState = MS_MUTED;
809 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
810 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
812 EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
813 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
814 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
815 ASSERT_EQ(muteState, listSinks[0].muteState);
818 TEST_F(routingTest, changeSinkMainSoundProperty)
820 std::vector<am_Sink_s> listSinks;
823 pCF.createSink(sink);
824 am_MainSoundProperty_s property;
825 property.type = MSP_NAVIGATION_OFFSET;
828 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
829 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
831 EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
832 ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
833 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
834 std::vector<am_MainSoundProperty_s>::iterator listIterator = listSinks[0].listMainSoundProperties.begin();
835 for (; listIterator < listSinks[0].listMainSoundProperties.end(); ++listIterator)
837 if (listIterator->type == property.type)
839 ASSERT_EQ(listIterator->value, property.value);
844 TEST_F(routingTest, peekDomain)
846 std::vector<am_Domain_s> listDomains;
848 am_domainID_t domainID;
849 am_domainID_t domain2ID;
850 pCF.createDomain(domain);
851 ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
852 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
853 ASSERT_TRUE(listDomains.empty());
854 ASSERT_EQ(domainID, 1);
855 domain.name = "newdomain";
856 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domain2ID));
857 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
858 ASSERT_EQ(domainID, domain2ID);
859 ASSERT_TRUE(listDomains[0].domainID==domainID);
862 TEST_F(routingTest, peekDomainFirstEntered)
864 std::vector<am_Domain_s> listDomains;
866 am_domainID_t domainID;
867 am_domainID_t domain2ID;
868 pCF.createDomain(domain);
869 domain.name = "newdomain";
870 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
871 ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
872 ASSERT_EQ(domainID, domain2ID);
873 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
874 ASSERT_TRUE(listDomains.size()==1);
877 TEST_F(routingTest, changeDomainState)
879 std::vector<am_Domain_s> listDomains;
881 am_domainID_t domainID;
882 pCF.createDomain(domain);
883 am_DomainState_e newState = DS_INDEPENDENT_STARTUP;
884 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
885 ASSERT_EQ(E_OK, pDatabaseHandler.changDomainStateDB(newState,domainID));
886 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
887 ASSERT_EQ(newState, listDomains[0].state);
890 TEST_F(routingTest, changeMainConnectionState)
892 std::vector<am_MainConnection_s> listMainConnections;
893 createMainConnectionSetup();
894 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
895 ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))
896 << "ERROR: database error";ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(listMainConnections));
897 ASSERT_EQ(CS_DISCONNECTING, listMainConnections[0].connectionState);
900 TEST_F(routingTest, changeSinkAvailability)
902 std::vector<am_Sink_s> listSinks;
905 pCF.createSink(sink);
906 am_Availability_s availability;
907 availability.availability = A_UNKNOWN;
908 availability.availabilityReason = AR_TEMPERATURE;
910 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
911 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
912 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
913 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
914 ASSERT_EQ(availability.availability, listSinks[0].available.availability);
915 ASSERT_EQ(availability.availabilityReason, listSinks[0].available.availabilityReason);
918 TEST_F(routingTest, changeSourceAvailability)
920 std::vector<am_Source_s> listSources;
922 am_sourceID_t sourceID;
923 pCF.createSource(source);
924 am_Availability_s availability;
925 availability.availability = A_UNKNOWN;
926 availability.availabilityReason = AR_TEMPERATURE;
927 source.visible = true;
929 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
930 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
931 ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
932 ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
933 ASSERT_EQ(availability.availability, listSources[0].available.availability);
934 ASSERT_EQ(availability.availabilityReason, listSources[0].available.availabilityReason);
937 TEST_F(routingTest,changeMainConnectionRoute)
939 std::vector<am_MainConnection_s> originalList;
940 std::vector<am_MainConnection_s> newList;
941 createMainConnectionSetup();
942 //fill the connection database
943 am_Connection_s connection;
946 std::vector<am_Connection_s> connectionList;
948 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
949 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
950 for (uint16_t i = 1; i < 10; i++)
952 am_sinkID_t forgetSink;
953 am_sourceID_t forgetSource;
954 am_connectionID_t forgetConnection;
956 pCF.createConnection(connection);
957 connection.sinkID = i + 20;
958 connection.sourceID = i + 20;
959 connection.delay = -1;
960 connectionList.push_back(connection);
962 pCF.createSink(sink);
963 sink.sinkID = i + 20;
964 sink.name = "sink" + int2string(i + 20);
966 pCF.createSource(source);
967 source.sourceID = i + 20;
968 source.name = "source" + int2string(i + 30);
971 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))
972 << "ERROR: database error";
973 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))
974 << "ERROR: database error";
975 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
976 << "ERROR: database error";
977 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))
978 << "ERROR: database error";
983 std::vector<am_RoutingElement_s> routingList;
984 pCF.connectionList2RoutingList(routingList, connectionList);
988 route.route = routingList;
992 ASSERT_EQ(E_OK, pDatabaseHandler.changeMainConnectionRouteDB(1,route));
993 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))
994 << "ERROR: database error";ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
995 ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
998 TEST_F(routingTest,changeMainSinkVolume)
1002 am_mainVolume_t newVol = 20;
1003 std::vector<am_Sink_s> listSinks;
1004 pCF.createSink(sink);
1006 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1007 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1009 EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
1010 ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
1011 ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
1012 ASSERT_EQ(listSinks[0].mainVolume, newVol);
1015 TEST_F(routingTest,getMainSourceSoundProperties)
1018 am_sourceID_t sourceID;
1019 pCF.createSource(source);
1020 std::vector<am_MainSoundProperty_s> mainSoundProperties = source.listMainSoundProperties;
1021 std::vector<am_MainSoundProperty_s> listMainSoundProperties;
1023 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
1024 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1025 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
1026 ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
1029 TEST_F(routingTest,getMainSinkSoundProperties)
1033 pCF.createSink(sink);
1034 std::vector<am_MainSoundProperty_s> mainSoundProperties = sink.listMainSoundProperties;
1035 std::vector<am_MainSoundProperty_s> listMainSoundProperties;
1037 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1038 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1039 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
1040 ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
1043 TEST_F(routingTest,getMainSources)
1045 am_Source_s source, source1, source2;
1046 am_sourceID_t sourceID;
1047 pCF.createSource(source);
1048 pCF.createSource(source1);
1049 pCF.createSource(source2);
1050 source1.name = "source1";
1051 source2.name = "source2";
1053 source1.visible = false;
1054 std::vector<am_SourceType_s> listMainSources;
1055 std::vector<am_Source_s> listSources;
1057 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
1059 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1060 source.sourceID = sourceID;
1061 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source1,sourceID));
1062 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source2,sourceID));
1063 source2.sourceID = sourceID;
1064 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSources(listMainSources));
1065 listSources.push_back(source);
1066 listSources.push_back(source2);
1067 std::vector<am_SourceType_s>::iterator listIterator = listMainSources.begin();
1068 for (; listIterator < listMainSources.end(); ++listIterator)
1070 equal = equal && pCF.compareSinkMainSource(listIterator, listSources);
1075 TEST_F(routingTest,getMainSinks)
1077 am_Sink_s sink, sink1, sink2;
1079 pCF.createSink(sink);
1080 pCF.createSink(sink1);
1081 pCF.createSink(sink2);
1082 sink1.name = "sink1";
1083 sink2.name = "sink2";
1085 sink1.visible = false;
1086 std::vector<am_SinkType_s> listMainSinks;
1087 std::vector<am_Sink_s> listSinks;
1089 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1090 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1091 sink.sinkID = sinkID;
1092 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink1,sinkID));
1093 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink2,sinkID));
1094 sink2.sinkID = sinkID;
1095 ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinks(listMainSinks));
1096 listSinks.push_back(sink);
1097 listSinks.push_back(sink2);
1098 std::vector<am_SinkType_s>::iterator listIterator = listMainSinks.begin();
1099 for (; listIterator < listMainSinks.end(); ++listIterator)
1101 equal = equal && pCF.compareSinkMainSink(listIterator, listSinks);
1106 TEST_F(routingTest,getVisibleMainConnections)
1108 createMainConnectionSetup();
1109 am_MainConnection_s mainConnection;
1111 pCF.createMainConnection(mainConnection, route);
1112 std::vector<am_MainConnectionType_s> visibleMainConnection;
1113 ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
1114 ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
1115 ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
1116 ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
1117 ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
1118 ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
1121 TEST_F(routingTest,getListSourcesOfDomain)
1123 am_Source_s source, source2;
1125 am_domainID_t domainID;
1126 am_sourceID_t sourceID;
1127 std::vector<am_sourceID_t> sourceList, sourceCheckList;
1128 pCF.createSource(source);
1129 source.sourceID = 1;
1130 source.name = "testSource";
1131 source.domainID = 1;
1132 pCF.createSource(source2);
1133 source2.sourceID = 0;
1134 source2.name = "testSource2";
1135 source2.domainID = 5;
1136 pCF.createDomain(domain);
1137 sourceCheckList.push_back(1); //sink.sinkID);
1139 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1140 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
1141 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
1142 << "ERROR: database error";
1143 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))
1144 << "ERROR: database error";
1145 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))
1146 << "ERROR: database error";ASSERT_TRUE(sourceList.empty());
1147 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))
1148 << "ERROR: database error";
1149 ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
1152 TEST_F(routingTest,getListSinksOfDomain)
1154 am_Sink_s sink, sink2;
1156 am_domainID_t domainID;
1158 std::vector<am_sinkID_t> sinkList, sinkCheckList;
1159 pCF.createSink(sink);
1162 pCF.createSink(sink2);
1164 sink2.name = "sink2";
1165 pCF.createDomain(domain);
1166 sinkCheckList.push_back(1); //sink.sinkID);
1168 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1169 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
1170 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
1171 << "ERROR: database error";
1172 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))
1173 << "ERROR: database error";
1174 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))
1175 << "ERROR: database error";ASSERT_TRUE(sinkList.empty());
1176 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))
1177 << "ERROR: database error";
1178 ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
1181 TEST_F(routingTest,getListGatewaysOfDomain)
1183 am_Gateway_s gateway, gateway2;
1184 am_gatewayID_t gatewayID;
1185 am_domainID_t domainID;
1187 std::vector<am_gatewayID_t> gatewayList, gatewayCheckList;
1188 pCF.createGateway(gateway);
1189 gateway.gatewayID = 1;
1190 gateway.name = "testGateway";
1191 gateway.controlDomainID = 1;
1192 gateway.sourceID = 1;
1194 gateway.domainSinkID = 1;
1195 gateway.domainSourceID = 1;
1196 pCF.createGateway(gateway2);
1197 gateway2.gatewayID = 2;
1198 gateway2.name = "testGateway2";
1199 gateway2.controlDomainID = 4;
1200 gateway2.sourceID = 1;
1201 gateway2.sinkID = 1;
1202 gateway2.domainSinkID = 1;
1203 gateway2.domainSourceID = 1;
1204 pCF.createDomain(domain);
1205 gatewayCheckList.push_back(gateway.gatewayID);
1206 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
1207 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1208 << "ERROR: database error";
1209 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))
1210 << "ERROR: database error";
1211 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))
1212 << "ERROR: database error";ASSERT_TRUE(gatewayList.empty());
1213 ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))
1214 << "ERROR: database error";
1215 ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
1218 TEST_F(routingTest,removeDomain)
1221 am_domainID_t domainID;
1222 std::vector<am_Domain_s> listDomains;
1223 pCF.createDomain(domain);
1224 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
1225 << "ERROR: database error";
1226 ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))
1227 << "ERROR: database error";
1228 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))
1229 << "ERROR: database error";
1230 ASSERT_TRUE(listDomains.empty());
1233 TEST_F(routingTest,removeGateway)
1235 am_Gateway_s gateway;
1236 am_gatewayID_t gatewayID;
1237 std::vector<am_Gateway_s> listGateways;
1238 pCF.createGateway(gateway);
1239 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1240 << "ERROR: database error";
1241 ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))
1242 << "ERROR: database error";
1243 ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))
1244 << "ERROR: database error";
1245 ASSERT_TRUE(listGateways.empty());
1248 TEST_F(routingTest,removeSink)
1252 std::vector<am_Sink_s> listSinks;
1253 pCF.createSink(sink);
1254 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1255 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
1256 << "ERROR: database error";
1257 ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))
1258 << "ERROR: database error";
1259 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))
1260 << "ERROR: database error";
1261 ASSERT_TRUE(listSinks.empty());
1264 TEST_F(routingTest,removeSource)
1266 //fill the connection database
1268 am_sourceID_t sourceID;
1269 std::vector<am_Source_s> listSources;
1270 pCF.createSource(source);
1272 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1273 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
1274 << "ERROR: database error";
1275 ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))
1276 << "ERROR: database error";
1277 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))
1278 << "ERROR: database error";
1279 ASSERT_TRUE(listSources.empty());
1282 TEST_F(routingTest, removeMainConnection)
1284 createMainConnectionSetup();
1285 EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
1286 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
1287 ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))
1288 << "ERROR: database error";
1291 TEST_F(routingTest,removeNonexistentMainConnectionFail)
1293 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))
1294 << "ERROR: database error";
1297 TEST_F(routingTest,removeNonexistentSource)
1299 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))
1300 << "ERROR: database error";
1303 TEST_F(routingTest,removeNonexistentSink)
1305 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))
1306 << "ERROR: database error";
1309 TEST_F(routingTest,removeNonexistentGateway)
1311 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))
1312 << "ERROR: database error";
1315 TEST_F(routingTest,registerGatewayCorrect)
1317 //initialize gateway
1318 std::vector<am_Gateway_s> returnList;
1319 am_Gateway_s gateway, gateway1, gateway2;
1320 am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
1322 pCF.createGateway(gateway);
1323 pCF.createGateway(gateway1);
1324 gateway1.gatewayID = 20;
1325 pCF.createGateway(gateway2);
1327 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1328 << "ERROR: database error";
1329 ASSERT_EQ(100,gatewayID)
1330 << "ERROR: domainID zero";
1332 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
1333 << "ERROR: database error";
1334 ASSERT_EQ(gateway1.gatewayID,gatewayID1)
1335 << "ERROR: domainID zero";
1337 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
1338 << "ERROR: database error";
1339 ASSERT_EQ(101,gatewayID2)
1340 << "ERROR: domainID zero";
1342 //now check if we read out the correct values
1343 ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
1345 std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
1347 for (; listIterator < returnList.end(); ++listIterator)
1349 if (listIterator->gatewayID == gatewayID)
1351 equal = equal && pCF.compareGateway(listIterator, gateway);
1354 if (listIterator->gatewayID == gatewayID1)
1356 equal = equal && pCF.compareGateway(listIterator, gateway1);
1359 if (listIterator->gatewayID == gatewayID2)
1361 equal = equal && pCF.compareGateway(listIterator, gateway2);
1365 ASSERT_EQ(true, equal);
1368 TEST_F(routingTest,getGatewayInfo)
1370 //initialize gateway
1371 std::vector<am_Gateway_s> returnList;
1372 am_Gateway_s gateway, gateway1, gateway2;
1373 am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
1375 pCF.createGateway(gateway);
1376 pCF.createGateway(gateway1);
1377 gateway1.gatewayID = 20;
1378 pCF.createGateway(gateway2);
1380 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
1381 << "ERROR: database error";
1382 ASSERT_EQ(100,gatewayID)
1383 << "ERROR: domainID zero";
1385 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
1386 << "ERROR: database error";
1387 ASSERT_EQ(gateway1.gatewayID,gatewayID1)
1388 << "ERROR: domainID zero";
1390 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
1391 << "ERROR: database error";
1392 ASSERT_EQ(101,gatewayID2)
1393 << "ERROR: domainID zero";
1395 //now check if we read out the correct values
1396 ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
1398 std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
1400 for (; listIterator < returnList.end(); ++listIterator)
1402 if (listIterator->gatewayID == gatewayID)
1404 equal = equal && pCF.compareGateway(listIterator, gateway);
1407 if (listIterator->gatewayID == gatewayID1)
1409 equal = equal && pCF.compareGateway(listIterator, gateway1);
1412 if (listIterator->gatewayID == gatewayID2)
1414 equal = equal && pCF.compareGateway(listIterator, gateway2);
1418 ASSERT_EQ(true, equal);
1420 am_Gateway_s gatewayInfo;
1421 ASSERT_EQ(E_OK, pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
1422 ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
1426 TEST_F(routingTest,enterSinkThatAlreadyExistFail)
1428 //fill the connection database
1429 am_Sink_s staticSink, SecondSink;
1430 am_sinkID_t staticSinkID, SecondSinkID;
1432 pCF.createSink(staticSink);
1433 staticSink.sinkID = 43;
1434 staticSink.name = "Static";
1436 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1437 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
1438 << "ERROR: database error";
1439 ASSERT_EQ(staticSink.sinkID,staticSinkID)
1440 << "ERROR: ID not the one given in staticSink";
1442 pCF.createSink(SecondSink);
1443 SecondSink.sinkID = 43;
1444 SecondSink.name = "SecondSink";
1446 ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))
1447 << "ERROR: database error";
1450 TEST_F(routingTest,enterSourcesThatAlreadyExistFail)
1452 //fill the connection database
1453 am_Source_s staticSource, SecondSource;
1454 am_sourceID_t staticSourceID, SecondSourceID;
1455 pCF.createSource(staticSource);
1456 staticSource.sourceID = 4;
1458 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
1459 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
1460 << "ERROR: database error";
1461 ASSERT_EQ(staticSource.sourceID,staticSourceID)
1462 << "ERROR: ID not the one given in staticSource";
1464 pCF.createSource(SecondSource);
1465 SecondSource.sourceID = 4;
1467 ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))
1468 << "ERROR: database error";
1471 TEST_F(routingTest,registerDomainCorrect)
1474 std::vector<am_Domain_s> returnList;
1476 am_domainID_t domainID = 0;
1477 pCF.createDomain(domain);
1479 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
1480 << "ERROR: database error";
1481 ASSERT_NE(0,domainID)
1482 << "ERROR: domainID zero";
1484 //now check if we read out the correct values
1485 ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(returnList));
1487 std::vector<am_Domain_s>::iterator listIterator = returnList.begin();
1488 for (; listIterator < returnList.end(); ++listIterator)
1490 if (listIterator->domainID == domainID)
1492 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);
1495 ASSERT_EQ(true, equal);
1498 TEST_F(routingTest,registerConnectionCorrect)
1500 am_Connection_s connection;
1501 am_connectionID_t connectionID;
1502 std::vector<am_Connection_s> returnList;
1503 pCF.createConnection(connection);
1505 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))
1506 << "ERROR: database error";;
1507 ASSERT_NE(0,connectionID)
1508 << "ERROR: connectionID zero";
1510 //now check if we read out the correct values
1511 ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
1512 ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(returnList));
1514 std::vector<am_Connection_s>::iterator listIterator = returnList.begin();
1515 for (; listIterator < returnList.end(); ++listIterator)
1517 if (listIterator->connectionID == connectionID)
1519 equal = (listIterator->sourceID == connection.sourceID) && (listIterator->sinkID == connection.sinkID) && (listIterator->delay == connection.delay) && (listIterator->connectionFormat = connection.connectionFormat);
1522 ASSERT_EQ(true, equal);
1525 TEST_F(routingTest,enterMainConnectionCorrect)
1527 createMainConnectionSetup();
1530 TEST_F(routingTest,enterSinksCorrect)
1532 //fill the connection database
1533 am_Sink_s staticSink, firstDynamicSink, secondDynamicSink;
1534 am_sinkID_t staticSinkID, firstDynamicSinkID, secondDynamicSinkID;
1535 std::vector<am_Sink_s> sinkList;
1537 pCF.createSink(staticSink);
1538 staticSink.sinkID = 4;
1540 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1541 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
1542 << "ERROR: database error";
1543 ASSERT_EQ(staticSink.sinkID,staticSinkID)
1544 << "ERROR: ID not the one given in staticSink";
1546 pCF.createSink(firstDynamicSink);
1547 firstDynamicSink.name = "firstdynamic";
1548 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))
1549 << "ERROR: database error";
1550 ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)
1551 << "ERROR: ID not the one given in firstDynamicSink";
1553 pCF.createSink(secondDynamicSink);
1554 secondDynamicSink.name = "seconddynamic";
1556 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))
1557 << "ERROR: database error";
1558 ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)
1559 << "ERROR: ID not the one given in secondDynamicSink";
1561 //now read back and check the returns agains the given values
1562 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))
1563 << "ERROR: database error";
1566 std::vector<am_Sink_s>::iterator listIterator = sinkList.begin();
1567 for (; listIterator < sinkList.end(); ++listIterator)
1569 if (listIterator->sinkID == staticSinkID)
1571 equal = equal && pCF.compareSink(listIterator, staticSink);
1574 if (listIterator->sinkID == firstDynamicSinkID)
1576 equal = equal && pCF.compareSink(listIterator, firstDynamicSink);
1579 if (listIterator->sinkID == secondDynamicSinkID)
1581 equal = equal && pCF.compareSink(listIterator, secondDynamicSink);
1584 ASSERT_EQ(true, equal);
1587 //Commented out - gives always a warning..
1588 //TEST_F(databaseTest,registerDomainFailonID0)
1590 // am_Domain_s domain;
1591 // am_domainID_t domainID=5;
1592 // pCF.createDomain(domain);
1593 // domain.domainID=1;
1594 // ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
1597 int main(int argc, char **argv)
1599 ::testing::InitGoogleTest(&argc, argv);
1600 return RUN_ALL_TESTS();