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"
30 //extern int GetRandomNumber(int nLow, int nHigh);
31 //extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
32 extern bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
33 extern bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b);
34 extern bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b);
35 extern std::string int2string(int i);
37 databaseTest::databaseTest()
38 :plistRoutingPluginDirs(),
39 plistCommandPluginDirs(),
40 pDatabaseHandler(std::string(":memory:")),
41 pRoutingSender(plistRoutingPluginDirs),
42 pCommandSender(plistCommandPluginDirs),
44 pRoutingInterfaceBackdoor(),
45 pCommandInterfaceBackdoor(),
46 pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
47 pObserver(&pCommandSender,&pRoutingSender)
49 pDatabaseHandler.registerObserver(&pObserver);
50 pCommandInterfaceBackdoor.injectInterface(&pCommandSender,&pMockInterface);
53 databaseTest::~databaseTest()
57 void databaseTest::createMainConnectionSetup()
59 //fill the connection database
60 am_Connection_s connection;
63 std::vector<am_Connection_s> connectionList;
65 //we create 9 sources and sinks:
66 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
67 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
69 for (uint16_t i=1;i<10;i++)
71 am_sinkID_t forgetSink;
72 am_sourceID_t forgetSource;
73 am_connectionID_t forgetConnection;
75 pCF.createConnection(connection);
77 connection.sourceID=i;
78 connectionList.push_back(connection);
82 sink.name="sink" + int2string(i);
84 pCF.createSource(source);
86 source.name="source" + int2string(i);
89 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
90 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
91 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
92 ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(forgetConnection));
96 std::vector<am_RoutingElement_s> routingList;
97 pCF.connectionList2RoutingList(routingList,connectionList);
101 route.route=routingList;
105 //create a mainConnection
106 am_MainConnection_s mainConnection;
107 am_mainConnectionID_t mainConnectionID;
108 std::vector<am_MainConnection_s> mainConnectionList;
109 pCF.createMainConnection(mainConnection,route);
111 //enter mainconnection in database
112 EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
113 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
114 ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))<< "ERROR: database error";
115 ASSERT_NE(0,mainConnectionID)<< "ERROR: connectionID zero";
117 //read out the mainconnections and check if they are equal to the data written.
118 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(mainConnectionList));
120 std::vector<am_MainConnection_s>::iterator listIterator=mainConnectionList.begin();
121 for(;listIterator<mainConnectionList.end();++listIterator)
123 if(listIterator->connectionID==mainConnectionID) {
124 equal= equal && (listIterator->connectionState == mainConnection.connectionState)
125 && (listIterator->route.sinkID == mainConnection.route.sinkID)
126 && (listIterator->route.sourceID == mainConnection.route.sourceID)
127 && (listIterator->delay == mainConnection.delay)
128 && (std::equal(listIterator->route.route.begin(),listIterator->route.route.end(),routingList.begin(),equalRoutingElement));
131 ASSERT_EQ(true,equal);
134 void databaseTest::SetUp()
136 DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
137 DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
138 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Database Test started "));
141 void databaseTest::TearDown()
143 DLT_UNREGISTER_CONTEXT(AudioManager);
146 TEST_F(databaseTest,crossfaders)
148 //todo:implement crossfader tests
151 TEST_F(databaseTest,sourceState)
154 am_sourceID_t sourceID;
155 std::vector<am_Source_s> listSources;
156 pCF.createSource(source);
157 source.sourceState=SS_OFF;
160 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
161 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
163 //change the source state
164 ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceState(sourceID,SS_ON));
166 //read out the changed values
167 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
168 ASSERT_EQ(listSources[0].sourceState,SS_ON);
171 TEST_F(databaseTest,sinkVolumeChange)
175 std::vector<am_Sink_s> listSinks;
176 pCF.createSink(sink);
180 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
181 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
183 //change the volume and check the read out
184 ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkVolume(sinkID,34));
185 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
186 ASSERT_EQ(listSinks[0].volume,34);
189 TEST_F(databaseTest,sourceVolumeChange)
192 am_sourceID_t sourceID;
193 std::vector<am_Source_s> listSources;
194 pCF.createSource(source);
198 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
199 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
201 //change the volume and check the read out
202 ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceVolume(sourceID,34));
203 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
204 ASSERT_EQ(listSources[0].volume,34);
207 TEST_F(databaseTest, peekSource)
209 std::vector<am_Source_s> listSources;
210 am_sourceID_t sourceID, source2ID, source3ID;
212 pCF.createSource(source);
214 //peek a source that does not exits
215 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
216 ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
218 //make sure it is not in the list
219 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
220 ASSERT_TRUE(listSources.empty());
221 ASSERT_EQ(sourceID,100);
223 //now enter the source with the same name and make sure it does not get a new ID
224 source.name="newsource";
225 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
226 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source2ID));
227 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
228 ASSERT_EQ(sourceID,source2ID);
229 ASSERT_TRUE(listSources[0].sourceID==sourceID);
231 //now we peek again. This time, the source exists
232 ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(source.name,source3ID));
233 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
234 ASSERT_TRUE(listSources.size()==1);
235 ASSERT_EQ(source3ID,source2ID);
238 TEST_F(databaseTest, peekSourceDouble)
240 std::vector<am_Source_s> listSources;
241 am_sourceID_t sourceID;
242 am_sourceID_t source2ID;
243 am_sourceID_t source3ID;
245 pCF.createSource(source);
247 //peek a source that does not exits
248 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
249 ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
251 //peek a second source that does not exits
252 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
253 ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
255 //make sure they are is not in the list
256 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
257 ASSERT_TRUE(listSources.empty());
258 ASSERT_EQ(sourceID,100);
259 source.name="newsource";
261 //now enter the source with the same name than the first peek and make sure it does not get a new ID
262 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
263 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source3ID));
264 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
265 ASSERT_EQ(sourceID,source3ID);
266 ASSERT_TRUE(listSources[0].sourceID==sourceID);
269 TEST_F(databaseTest, peekSink)
271 std::vector<am_Sink_s> listSinks;
272 am_sinkID_t sinkID,sink2ID, sink3ID;
274 pCF.createSink(sink);
276 //peek a sink that does not exits
277 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
278 ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
280 //make sure it is not in the list
281 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
282 ASSERT_TRUE(listSinks.empty());
283 ASSERT_EQ(sinkID,100);
286 //now enter the source with the same name and make sure it does not get a new ID
287 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
288 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink2ID));
289 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
290 ASSERT_EQ(sinkID,sink2ID);
291 ASSERT_TRUE(listSinks[0].sinkID==sinkID);
293 //now we peek again, this time, the sink exists
294 ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(sink.name,sink3ID));
295 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
296 ASSERT_TRUE(listSinks.size()==1);
297 ASSERT_EQ(sink3ID,sink2ID);
300 TEST_F(databaseTest, peekSinkDouble)
302 std::vector<am_Sink_s> listSinks;
307 pCF.createSink(sink);
309 //peek a sink that does not exits
310 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
311 ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
314 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
315 ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
317 //make sure they are is not in the list
318 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
319 ASSERT_TRUE(listSinks.empty());
320 ASSERT_EQ(sinkID,100);
323 //now enter the sink with the same name than the first peek and make sure it does not get a new ID
324 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
325 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink3ID));
326 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
327 ASSERT_EQ(sinkID,sink3ID);
328 ASSERT_TRUE(listSinks[0].sinkID==sinkID);
331 TEST_F(databaseTest,changeConnectionTimingInformationCheckMainConnection)
333 am_Connection_s connection;
334 std::vector<am_Connection_s> connectionList;
335 std::vector<am_MainConnectionType_s> mainList;
336 pCF.createConnection(connection);
338 //prepare the test, it is one mainconnection, so we expect one callback
339 createMainConnectionSetup();
340 EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
342 //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
343 ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
344 ASSERT_EQ(mainList[0].delay,-1);
346 //no go through all connections and set the delay time to 24 for each connection
347 ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
348 std::vector<am_Connection_s>::iterator iteratorConnectionList=connectionList.begin();
349 for(;iteratorConnectionList<connectionList.end();++iteratorConnectionList)
351 ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
354 //we read the result again and expect that the value is now different from -1
355 ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
356 ASSERT_EQ(mainList[0].delay,216);
359 TEST_F(databaseTest,changeConnectionTimingInformation)
361 am_Connection_s connection;
362 am_connectionID_t connectionID;
363 std::vector<am_Connection_s> connectionList;
364 pCF.createConnection(connection);
367 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID));
368 ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
370 //change the timing and check it
371 ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
372 ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
373 ASSERT_TRUE(connectionList[0].delay==24);
376 TEST_F(databaseTest,getSinkClassOfSink)
378 std::vector<am_SinkClass_s> sinkClassList;
379 std::vector<am_ClassProperty_s> classPropertyList;
380 am_SinkClass_s sinkClass, returnClass;
381 am_ClassProperty_s classProperty;
382 am_sinkClass_t sinkClassID;
385 classProperty.classProperty=CP_SINK_TYPE;
386 classProperty.value=1;
387 classPropertyList.push_back(classProperty);
388 classProperty.classProperty=CP_SOURCE_TYPE;
389 classProperty.value=4;
390 classPropertyList.push_back(classProperty);
391 sinkClass.name="test";
392 sinkClass.sinkClassID=4;
393 sinkClass.listClassProperties=classPropertyList;
394 pCF.createSink(sink);
398 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
399 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
401 //enter a new sinkclass, read out again and check
402 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
403 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
404 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
405 ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
406 ASSERT_EQ(sinkClassList[0].sinkClassID,4);
407 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
408 ASSERT_EQ(E_OK,pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
409 ASSERT_EQ(sinkClassList[0].name,returnClass.name);
410 ASSERT_EQ(sinkClassList[0].sinkClassID,returnClass.sinkClassID);
411 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
415 TEST_F(databaseTest,getSourceClassOfSource)
417 std::vector<am_SourceClass_s> sourceClassList;
418 std::vector<am_ClassProperty_s> classPropertyList;
419 am_SourceClass_s sourceClass, sinkSourceClass;
420 am_ClassProperty_s classProperty;
421 am_sourceClass_t sourceClassID;
423 am_sourceID_t sourceID;
424 classProperty.classProperty=CP_SINK_TYPE;
425 classProperty.value=1;
426 classPropertyList.push_back(classProperty);
427 classProperty.classProperty=CP_SOURCE_TYPE;
428 classProperty.value=4;
429 classPropertyList.push_back(classProperty);
430 sourceClass.name="test";
431 sourceClass.sourceClassID=1;
432 sourceClass.listClassProperties=classPropertyList;
433 pCF.createSource(source);
435 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
436 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
437 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
438 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
439 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
440 ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
441 ASSERT_EQ(sourceClassList[0].sourceClassID,1);
442 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
443 ASSERT_EQ(E_OK,pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
444 ASSERT_EQ(sourceClassList[0].name,sinkSourceClass.name);
445 ASSERT_EQ(sourceClassList[0].sourceClassID,sinkSourceClass.sourceClassID);
446 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
450 TEST_F(databaseTest,removeSourceClass)
452 std::vector<am_SourceClass_s> sourceClassList;
453 std::vector<am_ClassProperty_s> classPropertyList;
454 am_SourceClass_s sourceClass;
455 am_ClassProperty_s classProperty;
456 am_sourceClass_t sourceClassID;
457 classProperty.classProperty=CP_SINK_TYPE;
458 classProperty.value=1;
459 classPropertyList.push_back(classProperty);
460 classProperty.classProperty=CP_SOURCE_TYPE;
461 classProperty.value=4;
462 classPropertyList.push_back(classProperty);
463 sourceClass.name="test";
464 sourceClass.sourceClassID=3;
465 sourceClass.listClassProperties=classPropertyList;
467 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
468 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
469 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
470 ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
471 ASSERT_EQ(sourceClassList[0].sourceClassID,3);
472 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
473 ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceClassDB(3));
474 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
475 ASSERT_TRUE(sourceClassList.empty());
478 TEST_F(databaseTest,updateSourceClass)
480 std::vector<am_SourceClass_s> sourceClassList;
481 std::vector<am_ClassProperty_s> classPropertyList,changedPropertyList;
482 am_SourceClass_s sourceClass, changedClass;
483 am_ClassProperty_s classProperty;
484 am_sourceClass_t sourceClassID;
485 classProperty.classProperty=CP_SINK_TYPE;
486 classProperty.value=1;
487 classPropertyList.push_back(classProperty);
488 classProperty.classProperty=CP_SOURCE_TYPE;
489 classProperty.value=4;
490 classPropertyList.push_back(classProperty);
491 sourceClass.name="test";
492 sourceClass.sourceClassID=0;
493 sourceClass.listClassProperties=classPropertyList;
494 changedClass=sourceClass;
495 changedClass.listClassProperties[1].value=6;
496 changedPropertyList=changedClass.listClassProperties;
497 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
498 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
499 changedClass.sourceClassID=sourceClassID;
500 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
501 ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
502 ASSERT_EQ(sourceClassList[0].sourceClassID,100);
503 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
504 ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceClassInfoDB(changedClass));
505 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
506 ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
507 ASSERT_EQ(sourceClassList[0].sourceClassID,100);
508 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
511 TEST_F(databaseTest,enterSourceClass)
513 std::vector<am_SourceClass_s> sourceClassList;
514 std::vector<am_ClassProperty_s> classPropertyList;
515 am_SourceClass_s sourceClass;
516 am_ClassProperty_s classProperty;
517 am_sourceClass_t sourceClassID;
518 classProperty.classProperty=CP_SINK_TYPE;
519 classProperty.value=1;
520 classPropertyList.push_back(classProperty);
521 classProperty.classProperty=CP_SOURCE_TYPE;
522 classProperty.value=4;
523 classPropertyList.push_back(classProperty);
524 sourceClass.name="test";
525 sourceClass.sourceClassID=0;
526 sourceClass.listClassProperties=classPropertyList;
528 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
529 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
530 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
531 ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
532 ASSERT_EQ(sourceClassList[0].sourceClassID,100);
533 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
536 TEST_F(databaseTest,enterSourceClassStatic)
538 std::vector<am_SourceClass_s> sourceClassList;
539 std::vector<am_ClassProperty_s> classPropertyList;
540 am_SourceClass_s sourceClass;
541 am_ClassProperty_s classProperty;
542 am_sourceClass_t sourceClassID;
543 classProperty.classProperty=CP_SINK_TYPE;
544 classProperty.value=1;
545 classPropertyList.push_back(classProperty);
546 classProperty.classProperty=CP_SOURCE_TYPE;
547 classProperty.value=4;
548 classPropertyList.push_back(classProperty);
549 sourceClass.name="test";
550 sourceClass.sourceClassID=3;
551 sourceClass.listClassProperties=classPropertyList;
553 EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
554 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
555 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
556 ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
557 ASSERT_EQ(sourceClassList[0].sourceClassID,3);
558 ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
562 TEST_F(databaseTest,removeSinkClass)
564 std::vector<am_SinkClass_s> sinkClassList;
565 std::vector<am_ClassProperty_s> classPropertyList;
566 am_SinkClass_s sinkClass;
567 am_ClassProperty_s classProperty;
568 am_sinkClass_t sinkClassID;
569 classProperty.classProperty=CP_SINK_TYPE;
570 classProperty.value=1;
571 classPropertyList.push_back(classProperty);
572 classProperty.classProperty=CP_SOURCE_TYPE;
573 classProperty.value=4;
574 classPropertyList.push_back(classProperty);
575 sinkClass.name="test";
576 sinkClass.sinkClassID=0;
577 sinkClass.listClassProperties=classPropertyList;
579 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
580 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
581 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
582 ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
583 ASSERT_EQ(sinkClassList[0].sinkClassID,100);
584 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
585 ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkClassDB(sinkClassID));
586 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
587 ASSERT_TRUE(sinkClassList.empty());
590 TEST_F(databaseTest,updateSinkClass)
592 std::vector<am_SinkClass_s> sinkClassList;
593 std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
594 am_SinkClass_s sinkClass, changedClass;
595 am_ClassProperty_s classProperty;
596 am_sinkClass_t sinkClassID;
597 classProperty.classProperty=CP_SINK_TYPE;
598 classProperty.value=1;
599 classPropertyList.push_back(classProperty);
600 classProperty.classProperty=CP_SOURCE_TYPE;
601 classProperty.value=4;
602 classPropertyList.push_back(classProperty);
603 sinkClass.name="test";
604 sinkClass.sinkClassID=0;
605 sinkClass.listClassProperties=classPropertyList;
606 changedClass=sinkClass;
607 changedClass.listClassProperties[1].value=6;
608 changedPropertyList=changedClass.listClassProperties;
609 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
610 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
611 changedClass.sinkClassID=sinkClassID;
612 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
613 ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
614 ASSERT_EQ(sinkClassList[0].sinkClassID,100);
615 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
616 ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkClassInfoDB(changedClass));
617 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
618 ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
619 ASSERT_EQ(sinkClassList[0].sinkClassID,100);
620 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
623 TEST_F(databaseTest,enterSinkClass)
625 std::vector<am_SinkClass_s> sinkClassList;
626 std::vector<am_ClassProperty_s> classPropertyList;
627 am_SinkClass_s sinkClass;
628 am_ClassProperty_s classProperty;
629 am_sinkClass_t sinkClassID;
630 classProperty.classProperty=CP_SINK_TYPE;
631 classProperty.value=1;
632 classPropertyList.push_back(classProperty);
633 classProperty.classProperty=CP_SOURCE_TYPE;
634 classProperty.value=4;
635 classPropertyList.push_back(classProperty);
636 sinkClass.name="test";
637 sinkClass.sinkClassID=0;
638 sinkClass.listClassProperties=classPropertyList;
640 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
641 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
642 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
643 ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
644 ASSERT_EQ(sinkClassList[0].sinkClassID,100);
645 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
648 TEST_F(databaseTest,enterSinkClassStatic)
650 std::vector<am_SinkClass_s> sinkClassList;
651 std::vector<am_ClassProperty_s> classPropertyList;
652 am_SinkClass_s sinkClass;
653 am_ClassProperty_s classProperty;
654 am_sinkClass_t sinkClassID;
655 classProperty.classProperty=CP_SINK_TYPE;
656 classProperty.value=1;
657 classPropertyList.push_back(classProperty);
658 classProperty.classProperty=CP_SOURCE_TYPE;
659 classProperty.value=4;
660 classPropertyList.push_back(classProperty);
661 sinkClass.name="test";
662 sinkClass.sinkClassID=4;
663 sinkClass.listClassProperties=classPropertyList;
665 EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
666 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
667 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
668 ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
669 ASSERT_EQ(sinkClassList[0].sinkClassID,4);
670 ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
674 TEST_F(databaseTest, changeSystemProperty)
676 std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
677 am_SystemProperty_s systemProperty;
679 systemProperty.type=SYP_TEST;
680 systemProperty.value=33;
681 listSystemProperties.push_back(systemProperty);
682 EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
683 ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
684 systemProperty.value=444;
685 ASSERT_EQ(E_OK,pDatabaseHandler.changeSystemPropertyDB(systemProperty));
686 ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
687 ASSERT_EQ(listReturn[0].type,systemProperty.type);
688 ASSERT_EQ(listReturn[0].value,systemProperty.value);
691 TEST_F(databaseTest, systemProperties)
693 std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
694 am_SystemProperty_s systemProperty;
696 systemProperty.type=SYP_TEST;
697 systemProperty.value=33;
698 listSystemProperties.push_back(systemProperty);
700 ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
701 ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
702 ASSERT_EQ(listReturn[0].type,systemProperty.type);
703 ASSERT_EQ(listReturn[0].value,systemProperty.value);
707 TEST_F(databaseTest,enterSourcesCorrect)
709 //fill the connection database
710 am_Source_s staticSource,firstDynamicSource,secondDynamicSource;
711 am_sourceID_t staticSourceID,firstDynamicSourceID,secondDynamicSourceID;
712 std::vector<am_Source_s> sourceList;
714 pCF.createSource(staticSource);
715 staticSource.sourceID=4;
716 staticSource.name="Static";
718 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
719 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
720 ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
722 pCF.createSource(firstDynamicSource);
723 firstDynamicSource.name="firstDynamicSource";
725 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))<< "ERROR: database error";
726 ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
728 pCF.createSource(secondDynamicSource);
729 secondDynamicSource.name="secondDynamicSource";
731 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))<< "ERROR: database error";
732 ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
734 //now read back and check the returns agains the given values
735 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))<< "ERROR: database error";
738 std::vector<am_Source_s>::iterator listIterator=sourceList.begin();
739 for(;listIterator<sourceList.end();++listIterator)
741 if(listIterator->sourceID==staticSourceID)
743 equal = equal && pCF.compareSource(listIterator,staticSource);
746 if(listIterator->sourceID==firstDynamicSourceID)
748 equal = equal && pCF.compareSource(listIterator,firstDynamicSource);
751 if(listIterator->sourceID==secondDynamicSourceID)
753 equal = equal && pCF.compareSource(listIterator,secondDynamicSource);
757 ASSERT_EQ(true,equal);
761 TEST_F(databaseTest, changeSourceMainSoundProperty)
763 std::vector<am_Source_s> listSources;
765 am_sourceID_t sourceID;
766 pCF.createSource(source);
767 am_MainSoundProperty_s property;
768 property.type=MSP_NAVIGATION_OFFSET;
770 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
771 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
773 EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
774 ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
775 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
776 std::vector<am_MainSoundProperty_s>::iterator listIterator=listSources[0].listMainSoundProperties.begin();
777 for(;listIterator<listSources[0].listMainSoundProperties.end();++listIterator)
779 if(listIterator->type==property.type)
781 ASSERT_EQ(listIterator->value,property.value);
786 TEST_F(databaseTest, changeSinkMuteState)
788 std::vector<am_Sink_s> listSinks;
791 pCF.createSink(sink);
792 am_MuteState_e muteState=MS_MUTED;
793 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
794 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
796 EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
797 ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
798 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
799 ASSERT_EQ(muteState,listSinks[0].muteState);
802 TEST_F(databaseTest, changeSinkMainSoundProperty)
804 std::vector<am_Sink_s> listSinks;
807 pCF.createSink(sink);
808 am_MainSoundProperty_s property;
809 property.type=MSP_NAVIGATION_OFFSET;
812 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
813 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
815 EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
816 ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
817 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
818 std::vector<am_MainSoundProperty_s>::iterator listIterator=listSinks[0].listMainSoundProperties.begin();
819 for(;listIterator<listSinks[0].listMainSoundProperties.end();++listIterator)
821 if(listIterator->type==property.type)
823 ASSERT_EQ(listIterator->value,property.value);
828 TEST_F(databaseTest, peekDomain)
830 std::vector<am_Domain_s> listDomains;
832 am_domainID_t domainID;
833 am_domainID_t domain2ID;
834 pCF.createDomain(domain);
835 ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
836 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
837 ASSERT_TRUE(listDomains.empty());
838 ASSERT_EQ(domainID,1);
839 domain.name="newdomain";
840 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domain2ID));
841 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
842 ASSERT_EQ(domainID,domain2ID);
843 ASSERT_TRUE(listDomains[0].domainID==domainID);
846 TEST_F(databaseTest, peekDomainFirstEntered)
848 std::vector<am_Domain_s> listDomains;
850 am_domainID_t domainID;
851 am_domainID_t domain2ID;
852 pCF.createDomain(domain);
853 domain.name="newdomain";
854 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
855 ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
856 ASSERT_EQ(domainID,domain2ID);
857 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
858 ASSERT_TRUE(listDomains.size()==1);
861 TEST_F(databaseTest, changeDomainState)
863 std::vector<am_Domain_s> listDomains;
865 am_domainID_t domainID;
866 pCF.createDomain(domain);
867 am_DomainState_e newState=DS_INDEPENDENT_STARTUP;
868 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
869 ASSERT_EQ(E_OK,pDatabaseHandler.changDomainStateDB(newState,domainID));
870 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
871 ASSERT_EQ(newState,listDomains[0].state);
875 TEST_F(databaseTest, changeMainConnectionState)
877 std::vector<am_MainConnection_s> listMainConnections;
878 createMainConnectionSetup();
879 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
880 ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))<< "ERROR: database error";
881 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(listMainConnections));
882 ASSERT_EQ(CS_DISCONNECTING,listMainConnections[0].connectionState);
885 TEST_F(databaseTest, changeSinkAvailability)
887 std::vector<am_Sink_s> listSinks;
890 pCF.createSink(sink);
891 am_Availability_s availability;
892 availability.availability=A_UNKNOWN;
893 availability.availabilityReason=AR_TEMPERATURE;
895 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
896 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
897 ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
898 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
899 ASSERT_EQ(availability.availability,listSinks[0].available.availability);
900 ASSERT_EQ(availability.availabilityReason,listSinks[0].available.availabilityReason);
903 TEST_F(databaseTest, changeSourceAvailability)
905 std::vector<am_Source_s> listSources;
907 am_sourceID_t sourceID;
908 pCF.createSource(source);
909 am_Availability_s availability;
910 availability.availability=A_UNKNOWN;
911 availability.availabilityReason=AR_TEMPERATURE;
914 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
915 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
916 ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
917 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
918 ASSERT_EQ(availability.availability,listSources[0].available.availability);
919 ASSERT_EQ(availability.availabilityReason,listSources[0].available.availabilityReason);
923 TEST_F(databaseTest,changeMainConnectionRoute)
925 std::vector<am_MainConnection_s> originalList;
926 std::vector<am_MainConnection_s> newList;
927 createMainConnectionSetup();
928 //fill the connection database
929 am_Connection_s connection;
932 std::vector<am_Connection_s> connectionList;
934 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
935 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
936 for (uint16_t i=1;i<10;i++)
938 am_sinkID_t forgetSink;
939 am_sourceID_t forgetSource;
940 am_connectionID_t forgetConnection;
942 pCF.createConnection(connection);
943 connection.sinkID=i+20;
944 connection.sourceID=i+20;
946 connectionList.push_back(connection);
948 pCF.createSink(sink);
950 sink.name="sink" + int2string(i+20);
952 pCF.createSource(source);
953 source.sourceID=i+20;
954 source.name="source" + int2string(i+30);
957 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
958 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
959 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
960 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))<< "ERROR: database error";
965 std::vector<am_RoutingElement_s> routingList;
966 pCF.connectionList2RoutingList(routingList,connectionList);
970 route.route=routingList;
974 ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionRouteDB(1,route));
975 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))<< "ERROR: database error";
976 ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
977 ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
980 TEST_F(databaseTest,changeMainSinkVolume)
984 am_mainVolume_t newVol=20;
985 std::vector<am_Sink_s> listSinks;
986 pCF.createSink(sink);
988 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
989 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
992 EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
993 ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
994 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
995 ASSERT_EQ(listSinks[0].mainVolume,newVol);
998 TEST_F(databaseTest,getMainSourceSoundProperties)
1001 am_sourceID_t sourceID;
1002 pCF.createSource(source);
1003 std::vector<am_MainSoundProperty_s> mainSoundProperties=source.listMainSoundProperties;
1004 std::vector<am_MainSoundProperty_s> listMainSoundProperties;
1006 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
1007 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
1008 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
1009 ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
1012 TEST_F(databaseTest,getMainSinkSoundProperties)
1016 pCF.createSink(sink);
1017 std::vector<am_MainSoundProperty_s> mainSoundProperties=sink.listMainSoundProperties;
1018 std::vector<am_MainSoundProperty_s> listMainSoundProperties;
1020 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1021 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
1022 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
1023 ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
1026 TEST_F(databaseTest,getMainSources)
1028 am_Source_s source, source1,source2;
1029 am_sourceID_t sourceID;
1030 pCF.createSource(source);
1031 pCF.createSource(source1);
1032 pCF.createSource(source2);
1033 source1.name="source1";
1034 source2.name="source2";
1036 source1.visible=false;
1037 std::vector<am_SourceType_s> listMainSources;
1038 std::vector<am_Source_s> listSources;
1040 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
1042 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
1043 source.sourceID=sourceID;
1044 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source1,sourceID));
1045 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID));
1046 source2.sourceID=sourceID;
1047 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSources(listMainSources));
1048 listSources.push_back(source);
1049 listSources.push_back(source2);
1050 std::vector<am_SourceType_s>::iterator listIterator=listMainSources.begin();
1051 for(;listIterator<listMainSources.end();++listIterator)
1053 equal = equal && pCF.compareSinkMainSource(listIterator,listSources);
1058 TEST_F(databaseTest,getMainSinks)
1060 am_Sink_s sink, sink1,sink2;
1062 pCF.createSink(sink);
1063 pCF.createSink(sink1);
1064 pCF.createSink(sink2);
1068 sink1.visible=false;
1069 std::vector<am_SinkType_s> listMainSinks;
1070 std::vector<am_Sink_s> listSinks;
1072 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1073 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
1075 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink1,sinkID));
1076 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID));
1077 sink2.sinkID=sinkID;
1078 ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinks(listMainSinks));
1079 listSinks.push_back(sink);
1080 listSinks.push_back(sink2);
1081 std::vector<am_SinkType_s>::iterator listIterator=listMainSinks.begin();
1082 for(;listIterator<listMainSinks.end();++listIterator)
1084 equal = equal && pCF.compareSinkMainSink(listIterator,listSinks);
1089 TEST_F(databaseTest,getVisibleMainConnections)
1091 createMainConnectionSetup();
1092 am_MainConnection_s mainConnection;
1094 pCF.createMainConnection(mainConnection,route);
1095 std::vector<am_MainConnectionType_s> visibleMainConnection;
1096 ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
1097 ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
1098 ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
1099 ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
1100 ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
1101 ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
1104 TEST_F(databaseTest,getListSourcesOfDomain)
1106 am_Source_s source, source2;
1108 am_domainID_t domainID;
1109 am_sourceID_t sourceID;
1110 std::vector<am_sourceID_t> sourceList,sourceCheckList;
1111 pCF.createSource(source);
1113 source.name="testSource";
1115 pCF.createSource(source2);
1117 source2.name="testSource2";
1119 pCF.createDomain(domain);
1120 sourceCheckList.push_back(1);//sink.sinkID);
1123 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1124 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
1125 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
1126 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))<< "ERROR: database error";
1127 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))<< "ERROR: database error";
1128 ASSERT_TRUE(sourceList.empty());
1129 ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))<< "ERROR: database error";
1130 ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
1133 TEST_F(databaseTest,getListSinksOfDomain)
1135 am_Sink_s sink, sink2;
1137 am_domainID_t domainID;
1139 std::vector<am_sinkID_t> sinkList,sinkCheckList;
1140 pCF.createSink(sink);
1143 pCF.createSink(sink2);
1146 pCF.createDomain(domain);
1147 sinkCheckList.push_back(1);//sink.sinkID);
1149 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1150 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
1151 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
1152 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))<< "ERROR: database error";
1153 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))<< "ERROR: database error";
1154 ASSERT_TRUE(sinkList.empty());
1155 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))<< "ERROR: database error";
1156 ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
1159 TEST_F(databaseTest,getListGatewaysOfDomain)
1161 am_Gateway_s gateway, gateway2;
1162 am_gatewayID_t gatewayID;
1163 am_domainID_t domainID;
1165 std::vector<am_gatewayID_t> gatewayList,gatewayCheckList;
1166 pCF.createGateway(gateway);
1167 gateway.gatewayID=1;
1168 gateway.name="testGateway";
1169 gateway.controlDomainID=1;
1172 gateway.domainSinkID=1;
1173 gateway.domainSourceID=1;
1174 pCF.createGateway(gateway2);
1175 gateway2.gatewayID=2;
1176 gateway2.name="testGateway2";
1177 gateway2.controlDomainID=4;
1178 gateway2.sourceID=1;
1180 gateway2.domainSinkID=1;
1181 gateway2.domainSourceID=1;
1182 pCF.createDomain(domain);
1183 gatewayCheckList.push_back(gateway.gatewayID);
1184 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
1185 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
1186 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))<< "ERROR: database error";
1187 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))<< "ERROR: database error";
1188 ASSERT_TRUE(gatewayList.empty());
1189 ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))<< "ERROR: database error";
1190 ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
1193 TEST_F(databaseTest,removeDomain)
1196 am_domainID_t domainID;
1197 std::vector<am_Domain_s> listDomains;
1198 pCF.createDomain(domain);
1199 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
1200 ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))<< "ERROR: database error";
1201 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))<< "ERROR: database error";
1202 ASSERT_TRUE(listDomains.empty());
1205 TEST_F(databaseTest,removeGateway)
1207 am_Gateway_s gateway;
1208 am_gatewayID_t gatewayID;
1209 std::vector<am_Gateway_s> listGateways;
1210 pCF.createGateway(gateway);
1211 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
1212 ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))<< "ERROR: database error";
1213 ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))<< "ERROR: database error";
1214 ASSERT_TRUE(listGateways.empty());
1217 TEST_F(databaseTest,removeSink)
1221 std::vector<am_Sink_s> listSinks;
1222 pCF.createSink(sink);
1223 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1224 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
1225 ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))<< "ERROR: database error";
1226 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))<< "ERROR: database error";
1227 ASSERT_TRUE(listSinks.empty());
1230 TEST_F(databaseTest,removeSource)
1232 //fill the connection database
1234 am_sourceID_t sourceID;
1235 std::vector<am_Source_s> listSources;
1236 pCF.createSource(source);
1238 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1239 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
1240 ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))<< "ERROR: database error";
1241 ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))<< "ERROR: database error";
1242 ASSERT_TRUE(listSources.empty());
1245 TEST_F(databaseTest, removeMainConnection)
1247 createMainConnectionSetup();
1248 EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
1249 EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
1250 ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))<< "ERROR: database error";
1253 TEST_F(databaseTest,removeNonexistentMainConnectionFail)
1255 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))<< "ERROR: database error";
1258 TEST_F(databaseTest,removeNonexistentSource)
1260 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))<< "ERROR: database error";
1263 TEST_F(databaseTest,removeNonexistentSink)
1265 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))<< "ERROR: database error";
1268 TEST_F(databaseTest,removeNonexistentGateway)
1270 ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))<< "ERROR: database error";
1273 TEST_F(databaseTest,registerGatewayCorrect)
1275 //initialize gateway
1276 std::vector<am_Gateway_s> returnList;
1277 am_Gateway_s gateway, gateway1, gateway2;
1278 am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
1280 pCF.createGateway(gateway);
1281 pCF.createGateway(gateway1);
1282 gateway1.gatewayID=20;
1283 pCF.createGateway(gateway2);
1285 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
1286 ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
1288 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
1289 ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
1291 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
1292 ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
1294 //now check if we read out the correct values
1295 ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
1297 std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
1299 for(;listIterator<returnList.end();++listIterator)
1301 if(listIterator->gatewayID==gatewayID)
1303 equal= equal && pCF.compareGateway(listIterator,gateway);
1306 if(listIterator->gatewayID==gatewayID1)
1308 equal= equal && pCF.compareGateway(listIterator,gateway1);
1311 if(listIterator->gatewayID==gatewayID2)
1313 equal= equal && pCF.compareGateway(listIterator,gateway2);
1317 ASSERT_EQ(true,equal);
1320 TEST_F(databaseTest,getGatewayInfo)
1322 //initialize gateway
1323 std::vector<am_Gateway_s> returnList;
1324 am_Gateway_s gateway, gateway1, gateway2;
1325 am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
1327 pCF.createGateway(gateway);
1328 pCF.createGateway(gateway1);
1329 gateway1.gatewayID=20;
1330 pCF.createGateway(gateway2);
1332 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
1333 ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
1335 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
1336 ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
1338 ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
1339 ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
1341 //now check if we read out the correct values
1342 ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
1344 std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
1346 for(;listIterator<returnList.end();++listIterator)
1348 if(listIterator->gatewayID==gatewayID)
1350 equal= equal && pCF.compareGateway(listIterator,gateway);
1353 if(listIterator->gatewayID==gatewayID1)
1355 equal= equal && pCF.compareGateway(listIterator,gateway1);
1358 if(listIterator->gatewayID==gatewayID2)
1360 equal= equal && pCF.compareGateway(listIterator,gateway2);
1364 ASSERT_EQ(true,equal);
1366 am_Gateway_s gatewayInfo;
1367 ASSERT_EQ(E_OK,pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
1368 ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
1372 TEST_F(databaseTest,enterSinkThatAlreadyExistFail)
1374 //fill the connection database
1375 am_Sink_s staticSink,SecondSink;
1376 am_sinkID_t staticSinkID,SecondSinkID;
1378 pCF.createSink(staticSink);
1379 staticSink.sinkID=43;
1380 staticSink.name="Static";
1382 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
1383 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
1384 ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
1386 pCF.createSink(SecondSink);
1387 SecondSink.sinkID=43;
1388 SecondSink.name="SecondSink";
1390 ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))<< "ERROR: database error";
1393 TEST_F(databaseTest,enterSourcesThatAlreadyExistFail)
1395 //fill the connection database
1396 am_Source_s staticSource,SecondSource;
1397 am_sourceID_t staticSourceID,SecondSourceID;
1398 pCF.createSource(staticSource);
1399 staticSource.sourceID=4;
1401 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
1402 ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
1403 ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
1405 pCF.createSource(SecondSource);
1406 SecondSource.sourceID=4;
1408 ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))<< "ERROR: database error";
1411 TEST_F(databaseTest,registerDomainCorrect)
1414 std::vector<am_Domain_s> returnList;
1416 am_domainID_t domainID=0;
1417 pCF.createDomain(domain);
1419 ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
1420 ASSERT_NE(0,domainID)<< "ERROR: domainID zero";
1422 //now check if we read out the correct values
1423 ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(returnList));
1425 std::vector<am_Domain_s>::iterator listIterator=returnList.begin();
1426 for(;listIterator<returnList.end();++listIterator)
1428 if(listIterator->domainID==domainID) {
1429 equal= equal && (listIterator->name.compare(domain.name)==0)
1430 && (listIterator->busname.compare(domain.busname)==0)
1431 && (listIterator->complete == domain.complete)
1432 && (listIterator->early == domain.early)
1433 && (listIterator->state == domain.state);
1436 ASSERT_EQ(true,equal);
1439 TEST_F(databaseTest,registerConnectionCorrect)
1441 am_Connection_s connection;
1442 am_connectionID_t connectionID;
1443 std::vector<am_Connection_s> returnList;
1444 pCF.createConnection(connection);
1446 ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))<< "ERROR: database error";;
1447 ASSERT_NE(0,connectionID)<< "ERROR: connectionID zero";
1449 //now check if we read out the correct values
1450 ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
1451 ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(returnList));
1453 std::vector<am_Connection_s>::iterator listIterator=returnList.begin();
1454 for(;listIterator<returnList.end();++listIterator)
1456 if(listIterator->connectionID==connectionID) {
1457 equal= (listIterator->sourceID == connection.sourceID)
1458 && (listIterator->sinkID == connection.sinkID)
1459 && (listIterator->delay == connection.delay)
1460 && (listIterator->connectionFormat = connection.connectionFormat);
1463 ASSERT_EQ(true,equal);
1466 TEST_F(databaseTest,enterMainConnectionCorrect)
1468 createMainConnectionSetup();
1471 TEST_F(databaseTest,enterSinksCorrect)
1473 //fill the connection database
1474 am_Sink_s staticSink,firstDynamicSink,secondDynamicSink;
1475 am_sinkID_t staticSinkID,firstDynamicSinkID,secondDynamicSinkID;
1476 std::vector<am_Sink_s> sinkList;
1478 pCF.createSink(staticSink);
1479 staticSink.sinkID=4;
1481 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1482 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
1483 ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
1485 pCF.createSink(firstDynamicSink);
1486 firstDynamicSink.name="firstdynamic";
1487 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))<< "ERROR: database error";
1488 ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
1490 pCF.createSink(secondDynamicSink);
1491 secondDynamicSink.name="seconddynamic";
1493 ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))<< "ERROR: database error";
1494 ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
1496 //now read back and check the returns agains the given values
1497 ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))<< "ERROR: database error";
1500 std::vector<am_Sink_s>::iterator listIterator=sinkList.begin();
1501 for(;listIterator<sinkList.end();++listIterator)
1503 if(listIterator->sinkID==staticSinkID)
1505 equal = equal && pCF.compareSink(listIterator,staticSink);
1508 if(listIterator->sinkID==firstDynamicSinkID)
1510 equal = equal && pCF.compareSink(listIterator,firstDynamicSink);
1513 if(listIterator->sinkID==secondDynamicSinkID)
1515 equal = equal && pCF.compareSink(listIterator,secondDynamicSink);
1518 ASSERT_EQ(true,equal);
1521 //Commented out - gives always a warning..
1522 //TEST_F(databaseTest,registerDomainFailonID0)
1524 // am_Domain_s domain;
1525 // am_domainID_t domainID=5;
1526 // pCF.createDomain(domain);
1527 // domain.domainID=1;
1528 // ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
1532 int main(int argc, char **argv)
1534 ::testing::InitGoogleTest(&argc, argv);
1535 return RUN_ALL_TESTS();