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 "routingTest.h"
27 #include "MockInterfaces.h"
28 #include "DatabaseHandler.h"
29 #include "ControlReceiver.h"
30 #include "ControlSender.h"
31 #include "DatabaseObserver.h"
33 #include "../ControlInterfaceBackdoor.h"
34 #include "../CommandInterfaceBackdoor.h"
35 #include "../CommonFunctions.h"
36 #include "DLTWrapper.h"
40 using namespace testing;
42 routingTest::routingTest() :
43 plistRoutingPluginDirs(), //
44 plistCommandPluginDirs(), //
45 pDatabaseHandler(std::string(":memory:")), //
46 pControlSender(std::string("")), //
47 pRouter(&pDatabaseHandler, &pControlSender), //
48 pRoutingSender(plistRoutingPluginDirs), //
49 pCommandSender(plistCommandPluginDirs), //
51 pMockControlInterface(), //
52 pRoutingInterfaceBackdoor(), //
53 pCommandInterfaceBackdoor(), //
54 pControlInterfaceBackdoor(), //
55 pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), //
56 pObserver(&pCommandSender, &pRoutingSender)
58 pDatabaseHandler.registerObserver(&pObserver);
59 pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
60 pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
63 routingTest::~routingTest()
67 void routingTest::SetUp()
69 logInfo("Routing Test started ");
72 void routingTest::TearDown()
76 ACTION(returnConnectionFormat){
80 //test that checks 3 domains, one sink one source, longer lists of connectionformats.
81 TEST_F(routingTest,simpleRoute3DomainsListConnectionFormats_2)
83 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
84 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
85 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
87 //initialize 2 domains
88 am_Domain_s domain1, domain2, domain3;
89 am_domainID_t domainID1, domainID2, domainID3;
92 domain1.name = "domain1";
93 domain1.busname = "domain1bus";
94 domain1.state = DS_CONTROLLED;
96 domain2.name = "domain2";
97 domain2.busname = "domain2bus";
98 domain2.state = DS_CONTROLLED;
100 domain3.name = "domain3";
101 domain3.busname = "domain3bus";
102 domain3.state = DS_CONTROLLED;
104 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
105 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
106 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
108 am_Source_s source, gwSource, gwSource1;
109 am_sourceID_t sourceID, gwSourceID, gwSourceID1;
111 source.domainID = domainID1;
112 source.name = "source1";
113 source.sourceState = SS_ON;
115 source.sourceClassID = 5;
116 source.listConnectionFormats.push_back(CF_STEREO);
117 source.listConnectionFormats.push_back(CF_MONO);
119 gwSource.domainID = domainID2;
120 gwSource.name = "gwsource1";
121 gwSource.sourceState = SS_ON;
122 gwSource.sourceID = 0;
123 gwSource.sourceClassID = 5;
124 gwSource.listConnectionFormats.push_back(CF_MONO);
125 gwSource.listConnectionFormats.push_back(CF_STEREO);
126 gwSource.listConnectionFormats.push_back(CF_ANALOG);
128 gwSource1.domainID = domainID3;
129 gwSource1.name = "gwsource2";
130 gwSource1.sourceState = SS_ON;
131 gwSource1.sourceID = 0;
132 gwSource1.sourceClassID = 5;
133 gwSource1.listConnectionFormats.push_back(CF_STEREO);
134 gwSource1.listConnectionFormats.push_back(CF_MONO);
136 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
137 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
138 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
140 am_Sink_s sink, gwSink, gwSink1;
141 am_sinkID_t sinkID, gwSinkID, gwSinkID1;
143 sink.domainID = domainID3;
146 sink.sinkClassID = 5;
147 sink.muteState = MS_MUTED;
148 sink.listConnectionFormats.push_back(CF_MONO);
150 gwSink.domainID = domainID1;
151 gwSink.name = "gwSink";
153 gwSink.sinkClassID = 5;
154 gwSink.muteState = MS_MUTED;
155 gwSink.listConnectionFormats.push_back(CF_STEREO);
156 gwSink.listConnectionFormats.push_back(CF_MONO);
158 gwSink1.domainID = domainID2;
159 gwSink1.name = "gwSink1";
161 gwSink1.sinkClassID = 5;
162 gwSink1.muteState = MS_MUTED;
163 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
164 gwSink1.listConnectionFormats.push_back(CF_STEREO);
166 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
167 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
168 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
170 am_Gateway_s gateway, gateway1;
171 am_gatewayID_t gatewayID, gatewayID1;
173 gateway.controlDomainID = domainID1;
174 gateway.gatewayID = 0;
175 gateway.sinkID = gwSinkID;
176 gateway.sourceID = gwSourceID;
177 gateway.domainSourceID = domainID2;
178 gateway.domainSinkID = domainID1;
179 gateway.listSinkFormats = gwSink.listConnectionFormats;
180 gateway.listSourceFormats = gwSource.listConnectionFormats;
181 gateway.convertionMatrix.push_back(false);
182 gateway.convertionMatrix.push_back(false);
183 gateway.convertionMatrix.push_back(false);
184 gateway.convertionMatrix.push_back(true);
185 gateway.convertionMatrix.push_back(true);
186 gateway.convertionMatrix.push_back(false);
187 gateway.name = "gateway";
189 gateway1.controlDomainID = domainID2;
190 gateway1.gatewayID = 0;
191 gateway1.sinkID = gwSinkID1;
192 gateway1.sourceID = gwSourceID1;
193 gateway1.domainSourceID = domainID3;
194 gateway1.domainSinkID = domainID2;
195 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
196 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
197 gateway1.convertionMatrix.push_back(false);
198 gateway1.convertionMatrix.push_back(false);
199 gateway1.convertionMatrix.push_back(false);
200 gateway1.convertionMatrix.push_back(true);
201 gateway1.name = "gateway1";
203 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
204 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
206 std::vector<am_Route_s> listRoutes;
207 std::vector<am_RoutingElement_s> listRoutingElements;
208 am_RoutingElement_s hopp1;
209 am_RoutingElement_s hopp2;
210 am_RoutingElement_s hopp3;
212 hopp1.sourceID = sourceID;
213 hopp1.sinkID = gwSinkID;
214 hopp1.domainID = domainID1;
215 hopp1.connectionFormat = source.listConnectionFormats[1];
217 hopp2.sourceID = gwSourceID;
218 hopp2.sinkID = gwSinkID1;
219 hopp2.domainID = domainID2;
220 hopp2.connectionFormat = gwSink1.listConnectionFormats[1];
222 hopp3.sourceID = gwSourceID1;
223 hopp3.sinkID = sinkID;
224 hopp3.domainID = domainID3;
225 hopp3.connectionFormat = sink.listConnectionFormats[0];
227 listRoutingElements.push_back(hopp1);
228 listRoutingElements.push_back(hopp2);
229 listRoutingElements.push_back(hopp3);
231 am_Route_s compareRoute;
232 compareRoute.route = listRoutingElements;
233 compareRoute.sinkID = sinkID;
234 compareRoute.sourceID = sourceID;
236 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
237 ASSERT_EQ(1, listRoutes.size());
238 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
241 //test that checks 3 domains, one sink one source, longer lists of connectionformats.
242 TEST_F(routingTest,simpleRoute3DomainsListConnectionFormats_1)
244 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
245 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
246 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
248 //initialize 2 domains
249 am_Domain_s domain1, domain2, domain3;
250 am_domainID_t domainID1, domainID2, domainID3;
252 domain1.domainID = 0;
253 domain1.name = "domain1";
254 domain1.busname = "domain1bus";
255 domain1.state = DS_CONTROLLED;
256 domain2.domainID = 0;
257 domain2.name = "domain2";
258 domain2.busname = "domain2bus";
259 domain2.state = DS_CONTROLLED;
260 domain3.domainID = 0;
261 domain3.name = "domain3";
262 domain3.busname = "domain3bus";
263 domain3.state = DS_CONTROLLED;
265 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
266 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
267 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
269 am_Source_s source, gwSource, gwSource1;
270 am_sourceID_t sourceID, gwSourceID, gwSourceID1;
272 source.domainID = domainID1;
273 source.name = "source1";
274 source.sourceState = SS_ON;
276 source.sourceClassID = 5;
277 source.listConnectionFormats.push_back(CF_STEREO);
278 source.listConnectionFormats.push_back(CF_MONO);
280 gwSource.domainID = domainID2;
281 gwSource.name = "gwsource1";
282 gwSource.sourceState = SS_ON;
283 gwSource.sourceID = 0;
284 gwSource.sourceClassID = 5;
285 gwSource.listConnectionFormats.push_back(CF_STEREO);
286 gwSource.listConnectionFormats.push_back(CF_MONO);
287 gwSource.listConnectionFormats.push_back(CF_ANALOG);
289 gwSource1.domainID = domainID3;
290 gwSource1.name = "gwsource2";
291 gwSource1.sourceState = SS_ON;
292 gwSource1.sourceID = 0;
293 gwSource1.sourceClassID = 5;
294 gwSource1.listConnectionFormats.push_back(CF_MONO);
296 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
297 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
298 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
300 am_Sink_s sink, gwSink, gwSink1;
301 am_sinkID_t sinkID, gwSinkID, gwSinkID1;
303 sink.domainID = domainID3;
306 sink.sinkClassID = 5;
307 sink.muteState = MS_MUTED;
308 sink.listConnectionFormats.push_back(CF_MONO);
310 gwSink.domainID = domainID1;
311 gwSink.name = "gwSink";
313 gwSink.sinkClassID = 5;
314 gwSink.muteState = MS_MUTED;
315 gwSink.listConnectionFormats.push_back(CF_STEREO);
316 gwSink.listConnectionFormats.push_back(CF_MONO);
318 gwSink1.domainID = domainID2;
319 gwSink1.name = "gwSink1";
321 gwSink1.sinkClassID = 5;
322 gwSink1.muteState = MS_MUTED;
323 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
325 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
326 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
327 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
329 am_Gateway_s gateway, gateway1;
330 am_gatewayID_t gatewayID, gatewayID1;
332 gateway.controlDomainID = domainID1;
333 gateway.gatewayID = 0;
334 gateway.sinkID = gwSinkID;
335 gateway.sourceID = gwSourceID;
336 gateway.domainSourceID = domainID2;
337 gateway.domainSinkID = domainID1;
338 gateway.listSinkFormats = gwSink.listConnectionFormats;
339 gateway.listSourceFormats = gwSource.listConnectionFormats;
340 gateway.convertionMatrix.push_back(false);
341 gateway.convertionMatrix.push_back(false);
342 gateway.convertionMatrix.push_back(false);
343 gateway.convertionMatrix.push_back(false);
344 gateway.convertionMatrix.push_back(true);
345 gateway.convertionMatrix.push_back(false);
346 gateway.name = "gateway";
348 gateway1.controlDomainID = domainID2;
349 gateway1.gatewayID = 0;
350 gateway1.sinkID = gwSinkID1;
351 gateway1.sourceID = gwSourceID1;
352 gateway1.domainSourceID = domainID3;
353 gateway1.domainSinkID = domainID2;
354 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
355 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
356 gateway1.convertionMatrix.push_back(true);
357 gateway1.name = "gateway";
359 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
360 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
362 std::vector<am_Route_s> listRoutes;
363 std::vector<am_RoutingElement_s> listRoutingElements;
364 am_RoutingElement_s hopp1;
365 am_RoutingElement_s hopp2;
366 am_RoutingElement_s hopp3;
368 hopp1.sourceID = sourceID;
369 hopp1.sinkID = gwSinkID;
370 hopp1.domainID = domainID1;
371 hopp1.connectionFormat = source.listConnectionFormats[0];
373 hopp2.sourceID = gwSourceID;
374 hopp2.sinkID = gwSinkID1;
375 hopp2.domainID = domainID2;
376 hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
378 hopp3.sourceID = gwSourceID1;
379 hopp3.sinkID = sinkID;
380 hopp3.domainID = domainID3;
381 hopp3.connectionFormat = sink.listConnectionFormats[0];
383 listRoutingElements.push_back(hopp1);
384 listRoutingElements.push_back(hopp2);
385 listRoutingElements.push_back(hopp3);
387 am_Route_s compareRoute;
388 compareRoute.route = listRoutingElements;
389 compareRoute.sinkID = sinkID;
390 compareRoute.sourceID = sourceID;
392 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
393 ASSERT_EQ(1, listRoutes.size());
394 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
398 //test that checks 3 domains, one sink one source, longer lists of connectionformats.
399 TEST_F(routingTest,simpleRoute3DomainsListConnectionFormats)
401 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
402 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
403 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
405 //initialize 2 domains
406 am_Domain_s domain1, domain2, domain3;
407 am_domainID_t domainID1, domainID2, domainID3;
409 domain1.domainID = 0;
410 domain1.name = "domain1";
411 domain1.busname = "domain1bus";
412 domain1.state = DS_CONTROLLED;
413 domain2.domainID = 0;
414 domain2.name = "domain2";
415 domain2.busname = "domain2bus";
416 domain2.state = DS_CONTROLLED;
417 domain3.domainID = 0;
418 domain3.name = "domain3";
419 domain3.busname = "domain3bus";
420 domain3.state = DS_CONTROLLED;
422 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
423 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
424 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
426 am_Source_s source, gwSource, gwSource1;
427 am_sourceID_t sourceID, gwSourceID, gwSourceID1;
429 source.domainID = domainID1;
430 source.name = "source1";
431 source.sourceState = SS_ON;
433 source.sourceClassID = 5;
434 source.listConnectionFormats.push_back(CF_STEREO);
435 source.listConnectionFormats.push_back(CF_MONO);
437 gwSource.domainID = domainID2;
438 gwSource.name = "gwsource1";
439 gwSource.sourceState = SS_ON;
440 gwSource.sourceID = 0;
441 gwSource.sourceClassID = 5;
442 gwSource.listConnectionFormats.push_back(CF_ANALOG);
444 gwSource1.domainID = domainID3;
445 gwSource1.name = "gwsource2";
446 gwSource1.sourceState = SS_ON;
447 gwSource1.sourceID = 0;
448 gwSource1.sourceClassID = 5;
449 gwSource1.listConnectionFormats.push_back(CF_MONO);
451 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
452 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
453 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
455 am_Sink_s sink, gwSink, gwSink1;
456 am_sinkID_t sinkID, gwSinkID, gwSinkID1;
458 sink.domainID = domainID3;
461 sink.sinkClassID = 5;
462 sink.muteState = MS_MUTED;
463 sink.listConnectionFormats.push_back(CF_MONO);
465 gwSink.domainID = domainID1;
466 gwSink.name = "gwSink";
468 gwSink.sinkClassID = 5;
469 gwSink.muteState = MS_MUTED;
470 gwSink.listConnectionFormats.push_back(CF_STEREO);
471 gwSink.listConnectionFormats.push_back(CF_MONO);
473 gwSink1.domainID = domainID2;
474 gwSink1.name = "gwSink1";
476 gwSink1.sinkClassID = 5;
477 gwSink1.muteState = MS_MUTED;
478 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
480 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
481 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
482 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
484 am_Gateway_s gateway, gateway1;
485 am_gatewayID_t gatewayID, gatewayID1;
487 gateway.controlDomainID = domainID1;
488 gateway.gatewayID = 0;
489 gateway.sinkID = gwSinkID;
490 gateway.sourceID = gwSourceID;
491 gateway.domainSourceID = domainID2;
492 gateway.domainSinkID = domainID1;
493 gateway.listSinkFormats = gwSink.listConnectionFormats;
494 gateway.listSourceFormats = gwSource.listConnectionFormats;
495 gateway.convertionMatrix.push_back(false);
496 gateway.convertionMatrix.push_back(true);
497 gateway.name = "gateway";
499 gateway1.controlDomainID = domainID2;
500 gateway1.gatewayID = 0;
501 gateway1.sinkID = gwSinkID1;
502 gateway1.sourceID = gwSourceID1;
503 gateway1.domainSourceID = domainID3;
504 gateway1.domainSinkID = domainID2;
505 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
506 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
507 gateway1.convertionMatrix.push_back(true);
508 gateway1.name = "gateway";
510 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
511 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
513 std::vector<am_Route_s> listRoutes;
514 std::vector<am_RoutingElement_s> listRoutingElements;
515 am_RoutingElement_s hopp1;
516 am_RoutingElement_s hopp2;
517 am_RoutingElement_s hopp3;
519 hopp1.sourceID = sourceID;
520 hopp1.sinkID = gwSinkID;
521 hopp1.domainID = domainID1;
522 hopp1.connectionFormat = source.listConnectionFormats[1];
524 hopp2.sourceID = gwSourceID;
525 hopp2.sinkID = gwSinkID1;
526 hopp2.domainID = domainID2;
527 hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
529 hopp3.sourceID = gwSourceID1;
530 hopp3.sinkID = sinkID;
531 hopp3.domainID = domainID3;
532 hopp3.connectionFormat = sink.listConnectionFormats[0];
534 listRoutingElements.push_back(hopp1);
535 listRoutingElements.push_back(hopp2);
536 listRoutingElements.push_back(hopp3);
538 am_Route_s compareRoute;
539 compareRoute.route = listRoutingElements;
540 compareRoute.sinkID = sinkID;
541 compareRoute.sourceID = sourceID;
543 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
544 ASSERT_EQ(1, listRoutes.size());
545 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
549 //test that checks 4 domains, one sink and one source but there are 2 routes because there are 2 gateways
550 TEST_F(routingTest,simpleRoute4Domains2Routes)
552 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(5);
553 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(5);
554 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
556 //initialize 2 domains
557 am_Domain_s domain1, domain2, domain3, domain4;
558 am_domainID_t domainID1, domainID2, domainID3, domainID4;
560 domain1.domainID = 0;
561 domain1.name = "domain1";
562 domain1.busname = "domain1bus";
563 domain1.state = DS_CONTROLLED;
564 domain2.domainID = 0;
565 domain2.name = "domain2";
566 domain2.busname = "domain2bus";
567 domain2.state = DS_CONTROLLED;
568 domain3.domainID = 0;
569 domain3.name = "domain3";
570 domain3.busname = "domain3bus";
571 domain3.state = DS_CONTROLLED;
572 domain4.domainID = 0;
573 domain4.name = "domain4";
574 domain4.busname = "domain4bus";
575 domain4.state = DS_CONTROLLED;
577 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
578 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
579 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
580 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain4,domainID4));
582 am_Source_s source, gwSource, gwSource1, gwSource2, gwSource3;
583 am_sourceID_t sourceID, gwSourceID, gwSourceID1, gwSourceID2, gwSourceID3;
585 source.domainID = domainID1;
586 source.name = "source1";
587 source.sourceState = SS_ON;
589 source.sourceClassID = 5;
590 source.listConnectionFormats.push_back(CF_MONO);
592 gwSource.domainID = domainID2;
593 gwSource.name = "gwsource1";
594 gwSource.sourceState = SS_ON;
595 gwSource.sourceID = 0;
596 gwSource.sourceClassID = 5;
597 gwSource.listConnectionFormats.push_back(CF_ANALOG);
599 gwSource1.domainID = domainID3;
600 gwSource1.name = "gwsource2";
601 gwSource1.sourceState = SS_ON;
602 gwSource1.sourceID = 0;
603 gwSource1.sourceClassID = 5;
604 gwSource1.listConnectionFormats.push_back(CF_MONO);
606 gwSource2.domainID = domainID4;
607 gwSource2.name = "gwsource3";
608 gwSource2.sourceState = SS_OFF;
609 gwSource2.sourceID = 0;
610 gwSource2.sourceClassID = 5;
611 gwSource2.listConnectionFormats.push_back(CF_STEREO);
613 gwSource3.domainID = domainID3;
614 gwSource3.name = "gwsource4";
615 gwSource3.sourceState = SS_OFF;
616 gwSource3.sourceID = 0;
617 gwSource3.sourceClassID = 5;
618 gwSource3.listConnectionFormats.push_back(CF_MONO);
620 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
621 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
622 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
623 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2,gwSourceID2));
624 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource3,gwSourceID3));
626 am_Sink_s sink, gwSink, gwSink1, gwSink2, gwSink3;
627 am_sinkID_t sinkID, gwSinkID, gwSinkID1, gwSinkID2, gwSinkID3;
629 gwSink.domainID = domainID1;
630 gwSink.name = "gwSink";
632 gwSink.sinkClassID = 5;
633 gwSink.muteState = MS_MUTED;
634 gwSink.listConnectionFormats.push_back(CF_MONO);
636 gwSink1.domainID = domainID2;
637 gwSink1.name = "gwSink1";
639 gwSink1.sinkClassID = 5;
640 gwSink1.muteState = MS_MUTED;
641 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
643 gwSink2.domainID = domainID3;
644 gwSink2.name = "gwSink2";
646 gwSink2.sinkClassID = 5;
647 gwSink2.muteState = MS_MUTED;
648 gwSink2.listConnectionFormats.push_back(CF_MONO);
650 gwSink3.domainID = domainID2;
651 gwSink3.name = "gwSink3";
653 gwSink3.sinkClassID = 5;
654 gwSink3.muteState = MS_MUTED;
655 gwSink3.listConnectionFormats.push_back(CF_ANALOG);
657 sink.domainID = domainID4;
660 sink.sinkClassID = 5;
661 sink.muteState = MS_MUTED;
662 sink.listConnectionFormats.push_back(CF_STEREO);
664 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
665 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
666 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
667 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2,gwSinkID2));
668 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink3,gwSinkID3));
670 am_Gateway_s gateway, gateway1, gateway2, gateway3;
671 am_gatewayID_t gatewayID, gatewayID1, gatewayID2, gatewayID3;
673 gateway.controlDomainID = domainID1;
674 gateway.gatewayID = 0;
675 gateway.sinkID = gwSinkID;
676 gateway.sourceID = gwSourceID;
677 gateway.domainSourceID = domainID2;
678 gateway.domainSinkID = domainID1;
679 gateway.listSinkFormats = gwSink.listConnectionFormats;
680 gateway.listSourceFormats = gwSource.listConnectionFormats;
681 gateway.convertionMatrix.push_back(true);
682 gateway.name = "gateway";
684 gateway1.controlDomainID = domainID2;
685 gateway1.gatewayID = 0;
686 gateway1.sinkID = gwSinkID1;
687 gateway1.sourceID = gwSourceID1;
688 gateway1.domainSourceID = domainID3;
689 gateway1.domainSinkID = domainID2;
690 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
691 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
692 gateway1.convertionMatrix.push_back(true);
693 gateway1.name = "gateway1";
695 gateway2.controlDomainID = domainID3;
696 gateway2.gatewayID = 0;
697 gateway2.sinkID = gwSinkID2;
698 gateway2.sourceID = gwSourceID2;
699 gateway2.domainSourceID = domainID4;
700 gateway2.domainSinkID = domainID3;
701 gateway2.listSinkFormats = gwSink2.listConnectionFormats;
702 gateway2.listSourceFormats = gwSource2.listConnectionFormats;
703 gateway2.convertionMatrix.push_back(true);
704 gateway2.name = "gateway2";
706 gateway3.controlDomainID = domainID2;
707 gateway3.gatewayID = 0;
708 gateway3.sinkID = gwSinkID3;
709 gateway3.sourceID = gwSourceID3;
710 gateway3.domainSourceID = domainID3;
711 gateway3.domainSinkID = domainID2;
712 gateway3.listSinkFormats = gwSink3.listConnectionFormats;
713 gateway3.listSourceFormats = gwSource3.listConnectionFormats;
714 gateway3.convertionMatrix.push_back(true);
715 gateway3.name = "gateway3";
717 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
718 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
719 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2));
720 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway3,gatewayID3));
722 std::vector<am_Route_s> listRoutes;
723 std::vector<am_RoutingElement_s> listRoutingElements, listRoutingElements1;
724 am_RoutingElement_s hopp1;
725 am_RoutingElement_s hopp2;
726 am_RoutingElement_s hopp3;
727 am_RoutingElement_s hopp4;
728 am_RoutingElement_s hopp2alt;
729 am_RoutingElement_s hopp3alt;
731 hopp1.sourceID = sourceID;
732 hopp1.sinkID = gwSinkID;
733 hopp1.domainID = domainID1;
734 hopp1.connectionFormat = source.listConnectionFormats[0];
736 hopp2.sourceID = gwSourceID;
737 hopp2.sinkID = gwSinkID1;
738 hopp2.domainID = domainID2;
739 hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
741 hopp3.sourceID = gwSourceID1;
742 hopp3.sinkID = gwSinkID2;
743 hopp3.domainID = domainID3;
744 hopp3.connectionFormat = gwSink2.listConnectionFormats[0];
746 hopp4.sourceID = gwSourceID2;
747 hopp4.sinkID = sinkID;
748 hopp4.domainID = domainID4;
749 hopp4.connectionFormat = sink.listConnectionFormats[0];
751 hopp2alt.sourceID = gwSourceID;
752 hopp2alt.sinkID = gwSinkID3;
753 hopp2alt.domainID = domainID2;
754 hopp2alt.connectionFormat = gwSink3.listConnectionFormats[0];
756 hopp3alt.sourceID = gwSourceID3;
757 hopp3alt.sinkID = gwSinkID2;
758 hopp3alt.domainID = domainID3;
759 hopp3alt.connectionFormat = gwSink2.listConnectionFormats[0];
761 listRoutingElements.push_back(hopp1);
762 listRoutingElements.push_back(hopp2);
763 listRoutingElements.push_back(hopp3);
764 listRoutingElements.push_back(hopp4);
765 listRoutingElements1.push_back(hopp1);
766 listRoutingElements1.push_back(hopp2alt);
767 listRoutingElements1.push_back(hopp3alt);
768 listRoutingElements1.push_back(hopp4);
770 am_Route_s compareRoute, compareRoute1;
771 compareRoute.route = listRoutingElements;
772 compareRoute.sinkID = sinkID;
773 compareRoute.sourceID = sourceID;
775 compareRoute1.route = listRoutingElements1;
776 compareRoute1.sinkID = sinkID;
777 compareRoute1.sourceID = sourceID;
779 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
780 ASSERT_EQ(2, listRoutes.size());
781 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
782 ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[1]));
785 //test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit.
786 TEST_F(routingTest,simpleRoute3DomainsNoConnection)
788 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
789 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
790 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
792 //initialize 2 domains
793 am_Domain_s domain1, domain2, domain3;
794 am_domainID_t domainID1, domainID2, domainID3;
796 domain1.domainID = 0;
797 domain1.name = "domain1";
798 domain1.busname = "domain1bus";
799 domain1.state = DS_CONTROLLED;
800 domain2.domainID = 0;
801 domain2.name = "domain2";
802 domain2.busname = "domain2bus";
803 domain2.state = DS_CONTROLLED;
804 domain3.domainID = 0;
805 domain3.name = "domain3";
806 domain3.busname = "domain3bus";
807 domain3.state = DS_CONTROLLED;
809 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
810 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
811 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
813 am_Source_s source, gwSource, gwSource1;
814 am_sourceID_t sourceID, gwSourceID, gwSourceID1;
816 source.domainID = domainID1;
817 source.name = "source1";
818 source.sourceState = SS_ON;
820 source.sourceClassID = 5;
821 source.listConnectionFormats.push_back(CF_MONO);
823 gwSource.domainID = domainID2;
824 gwSource.name = "gwsource1";
825 gwSource.sourceState = SS_ON;
826 gwSource.sourceID = 0;
827 gwSource.sourceClassID = 5;
828 gwSource.listConnectionFormats.push_back(CF_ANALOG);
830 gwSource1.domainID = domainID3;
831 gwSource1.name = "gwsource2";
832 gwSource1.sourceState = SS_ON;
833 gwSource1.sourceID = 0;
834 gwSource1.sourceClassID = 5;
835 gwSource1.listConnectionFormats.push_back(CF_MONO);
837 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
838 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
839 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
841 am_Sink_s sink, gwSink, gwSink1;
842 am_sinkID_t sinkID, gwSinkID, gwSinkID1;
844 sink.domainID = domainID3;
847 sink.sinkClassID = 5;
848 sink.muteState = MS_MUTED;
849 sink.listConnectionFormats.push_back(CF_STEREO);
851 gwSink.domainID = domainID1;
852 gwSink.name = "gwSink";
854 gwSink.sinkClassID = 5;
855 gwSink.muteState = MS_MUTED;
856 gwSink.listConnectionFormats.push_back(CF_MONO);
858 gwSink1.domainID = domainID2;
859 gwSink1.name = "gwSink1";
861 gwSink1.sinkClassID = 5;
862 gwSink1.muteState = MS_MUTED;
863 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
865 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
866 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
867 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
869 am_Gateway_s gateway, gateway1;
870 am_gatewayID_t gatewayID, gatewayID1;
872 gateway.controlDomainID = domainID1;
873 gateway.gatewayID = 0;
874 gateway.sinkID = gwSinkID;
875 gateway.sourceID = gwSourceID;
876 gateway.domainSourceID = domainID2;
877 gateway.domainSinkID = domainID1;
878 gateway.listSinkFormats = gwSink.listConnectionFormats;
879 gateway.listSourceFormats = gwSource.listConnectionFormats;
880 gateway.convertionMatrix.push_back(true);
881 gateway.name = "gateway";
883 gateway1.controlDomainID = domainID2;
884 gateway1.gatewayID = 0;
885 gateway1.sinkID = gwSinkID1;
886 gateway1.sourceID = gwSourceID1;
887 gateway1.domainSourceID = domainID3;
888 gateway1.domainSinkID = domainID2;
889 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
890 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
891 gateway1.convertionMatrix.push_back(true);
892 gateway1.name = "gateway";
894 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
895 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
897 std::vector<am_Route_s> listRoutes;
898 std::vector<am_RoutingElement_s> listRoutingElements;
899 am_RoutingElement_s hopp1;
900 am_RoutingElement_s hopp2;
901 am_RoutingElement_s hopp3;
903 hopp1.sourceID = sourceID;
904 hopp1.sinkID = gwSinkID;
905 hopp1.domainID = domainID1;
906 hopp1.connectionFormat = source.listConnectionFormats[0];
908 hopp2.sourceID = gwSourceID;
909 hopp2.sinkID = gwSinkID1;
910 hopp2.domainID = domainID2;
911 hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
913 hopp3.sourceID = gwSourceID1;
914 hopp3.sinkID = sinkID;
915 hopp3.domainID = domainID3;
916 hopp3.connectionFormat = sink.listConnectionFormats[0];
918 listRoutingElements.push_back(hopp1);
919 listRoutingElements.push_back(hopp2);
920 listRoutingElements.push_back(hopp3);
922 am_Route_s compareRoute;
923 compareRoute.route = listRoutingElements;
924 compareRoute.sinkID = sinkID;
925 compareRoute.sourceID = sourceID;
927 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
928 ASSERT_EQ(0, listRoutes.size());
930 //test that checks just 2 domains, one sink one source with only one connection format each
931 TEST_F(routingTest,simpleRoute2Domains)
933 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
934 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
935 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
937 //initialize 2 domains
938 am_Domain_s domain1, domain2;
939 am_domainID_t domainID1, domainID2;
941 domain1.domainID = 0;
942 domain1.name = "domain1";
943 domain1.busname = "domain1bus";
944 domain1.state = DS_CONTROLLED;
945 domain2.domainID = 0;
946 domain2.name = "domain2";
947 domain2.busname = "domain2bus";
948 domain2.state = DS_CONTROLLED;
950 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
951 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
953 am_Source_s source, gwSource;
954 am_sourceID_t sourceID, gwSourceID;
956 source.domainID = domainID1;
957 source.name = "source1";
958 source.sourceState = SS_ON;
960 source.sourceClassID = 5;
961 source.listConnectionFormats.push_back(CF_ANALOG);
963 gwSource.domainID = domainID2;
964 gwSource.name = "gwsource1";
965 gwSource.sourceState = SS_ON;
966 gwSource.sourceID = 0;
967 gwSource.sourceClassID = 5;
968 gwSource.listConnectionFormats.push_back(CF_MONO);
970 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
971 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
973 am_Sink_s sink, gwSink;
974 am_sinkID_t sinkID, gwSinkID;
976 sink.domainID = domainID2;
979 sink.sinkClassID = 5;
980 sink.muteState = MS_MUTED;
981 sink.listConnectionFormats.push_back(CF_MONO);
983 gwSink.domainID = domainID1;
984 gwSink.name = "gwSink";
986 gwSink.sinkClassID = 5;
987 gwSink.muteState = MS_MUTED;
988 gwSink.listConnectionFormats.push_back(CF_ANALOG);
990 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
991 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
993 am_Gateway_s gateway;
994 am_gatewayID_t gatewayID;
996 gateway.controlDomainID = domainID1;
997 gateway.gatewayID = 0;
998 gateway.sinkID = gwSinkID;
999 gateway.sourceID = gwSourceID;
1000 gateway.domainSourceID = domainID2;
1001 gateway.domainSinkID = domainID1;
1002 gateway.listSinkFormats = gwSink.listConnectionFormats;
1003 gateway.listSourceFormats = gwSource.listConnectionFormats;
1004 gateway.convertionMatrix.push_back(true);
1005 gateway.name = "gateway";
1007 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
1009 std::vector<am_Route_s> listRoutes;
1010 std::vector<am_RoutingElement_s> listRoutingElements;
1011 am_RoutingElement_s hopp1;
1012 am_RoutingElement_s hopp2;
1014 hopp1.sinkID = gwSinkID;
1015 hopp1.sourceID = sourceID;
1016 hopp1.domainID = domainID1;
1017 hopp1.connectionFormat = source.listConnectionFormats[0];
1019 hopp2.sinkID = sinkID;
1020 hopp2.sourceID = gwSourceID;
1021 hopp2.domainID = domainID2;
1022 hopp2.connectionFormat = sink.listConnectionFormats[0];
1024 listRoutingElements.push_back(hopp1);
1025 listRoutingElements.push_back(hopp2);
1027 am_Route_s compareRoute;
1028 compareRoute.route = listRoutingElements;
1029 compareRoute.sinkID = sinkID;
1030 compareRoute.sourceID = sourceID;
1032 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
1033 ASSERT_EQ(1, listRoutes.size());
1034 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
1038 //test that checks just 2 domains, one sink one source but the connectionformat of source
1039 TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats)
1041 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
1042 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
1043 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
1045 //initialize 2 domains
1046 am_Domain_s domain1, domain2;
1047 am_domainID_t domainID1, domainID2;
1049 domain1.domainID = 0;
1050 domain1.name = "domain1";
1051 domain1.busname = "domain1bus";
1052 domain1.state = DS_CONTROLLED;
1053 domain2.domainID = 0;
1054 domain2.name = "domain2";
1055 domain2.busname = "domain2bus";
1056 domain2.state = DS_CONTROLLED;
1058 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
1059 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
1061 am_Source_s source, gwSource;
1062 am_sourceID_t sourceID, gwSourceID;
1064 source.domainID = domainID1;
1065 source.name = "source1";
1066 source.sourceState = SS_ON;
1067 source.sourceID = 0;
1068 source.sourceClassID = 5;
1069 source.listConnectionFormats.push_back(CF_STEREO);
1071 gwSource.domainID = domainID2;
1072 gwSource.name = "gwsource1";
1073 gwSource.sourceState = SS_ON;
1074 gwSource.sourceID = 0;
1075 gwSource.sourceClassID = 5;
1076 gwSource.listConnectionFormats.push_back(CF_MONO);
1078 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1079 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
1081 am_Sink_s sink, gwSink;
1082 am_sinkID_t sinkID, gwSinkID;
1084 sink.domainID = domainID2;
1085 sink.name = "sink1";
1087 sink.sinkClassID = 5;
1088 sink.muteState = MS_MUTED;
1089 sink.listConnectionFormats.push_back(CF_MONO);
1091 gwSink.domainID = domainID1;
1092 gwSink.name = "gwSink";
1094 gwSink.sinkClassID = 5;
1095 gwSink.muteState = MS_MUTED;
1096 gwSink.listConnectionFormats.push_back(CF_ANALOG);
1098 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1099 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
1101 am_Gateway_s gateway;
1102 am_gatewayID_t gatewayID;
1104 gateway.controlDomainID = domainID1;
1105 gateway.gatewayID = 0;
1106 gateway.sinkID = gwSinkID;
1107 gateway.sourceID = gwSourceID;
1108 gateway.domainSourceID = domainID2;
1109 gateway.domainSinkID = domainID1;
1110 gateway.listSinkFormats = gwSink.listConnectionFormats;
1111 gateway.listSourceFormats = gwSource.listConnectionFormats;
1112 gateway.convertionMatrix.push_back(true);
1113 gateway.name = "gateway";
1115 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
1117 std::vector<am_Route_s> listRoutes;
1118 std::vector<am_RoutingElement_s> listRoutingElements;
1119 am_RoutingElement_s hopp1;
1120 am_RoutingElement_s hopp2;
1122 hopp1.sinkID = gwSinkID;
1123 hopp1.sourceID = sourceID;
1124 hopp1.domainID = domainID1;
1125 hopp1.connectionFormat = source.listConnectionFormats[0];
1127 hopp2.sinkID = sinkID;
1128 hopp2.sourceID = gwSourceID;
1129 hopp2.domainID = domainID2;
1130 hopp2.connectionFormat = sink.listConnectionFormats[0];
1132 listRoutingElements.push_back(hopp1);
1133 listRoutingElements.push_back(hopp2);
1135 am_Route_s compareRoute;
1136 compareRoute.route = listRoutingElements;
1137 compareRoute.sinkID = sinkID;
1138 compareRoute.sourceID = sourceID;
1140 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
1141 ASSERT_EQ(0, listRoutes.size());
1144 //test that checks 3 domains, one sink one source.
1145 TEST_F(routingTest,simpleRoute3Domains)
1147 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
1148 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
1149 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
1151 //initialize 2 domains
1152 am_Domain_s domain1, domain2, domain3;
1153 am_domainID_t domainID1, domainID2, domainID3;
1155 domain1.domainID = 0;
1156 domain1.name = "domain1";
1157 domain1.busname = "domain1bus";
1158 domain1.state = DS_CONTROLLED;
1159 domain2.domainID = 0;
1160 domain2.name = "domain2";
1161 domain2.busname = "domain2bus";
1162 domain2.state = DS_CONTROLLED;
1163 domain3.domainID = 0;
1164 domain3.name = "domain3";
1165 domain3.busname = "domain3bus";
1166 domain3.state = DS_CONTROLLED;
1168 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
1169 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
1170 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
1172 am_Source_s source, gwSource, gwSource1;
1173 am_sourceID_t sourceID, gwSourceID, gwSourceID1;
1175 source.domainID = domainID1;
1176 source.name = "source1";
1177 source.sourceState = SS_ON;
1178 source.sourceID = 0;
1179 source.sourceClassID = 5;
1180 source.listConnectionFormats.push_back(CF_MONO);
1182 gwSource.domainID = domainID2;
1183 gwSource.name = "gwsource1";
1184 gwSource.sourceState = SS_ON;
1185 gwSource.sourceID = 0;
1186 gwSource.sourceClassID = 5;
1187 gwSource.listConnectionFormats.push_back(CF_ANALOG);
1189 gwSource1.domainID = domainID3;
1190 gwSource1.name = "gwsource2";
1191 gwSource1.sourceState = SS_ON;
1192 gwSource1.sourceID = 0;
1193 gwSource1.sourceClassID = 5;
1194 gwSource1.listConnectionFormats.push_back(CF_MONO);
1196 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1197 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
1198 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
1200 am_Sink_s sink, gwSink, gwSink1;
1201 am_sinkID_t sinkID, gwSinkID, gwSinkID1;
1203 sink.domainID = domainID3;
1204 sink.name = "sink1";
1206 sink.sinkClassID = 5;
1207 sink.muteState = MS_MUTED;
1208 sink.listConnectionFormats.push_back(CF_MONO);
1210 gwSink.domainID = domainID1;
1211 gwSink.name = "gwSink";
1213 gwSink.sinkClassID = 5;
1214 gwSink.muteState = MS_MUTED;
1215 gwSink.listConnectionFormats.push_back(CF_MONO);
1217 gwSink1.domainID = domainID2;
1218 gwSink1.name = "gwSink1";
1220 gwSink1.sinkClassID = 5;
1221 gwSink1.muteState = MS_MUTED;
1222 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
1224 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1225 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
1226 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
1228 am_Gateway_s gateway, gateway1;
1229 am_gatewayID_t gatewayID, gatewayID1;
1231 gateway.controlDomainID = domainID1;
1232 gateway.gatewayID = 0;
1233 gateway.sinkID = gwSinkID;
1234 gateway.sourceID = gwSourceID;
1235 gateway.domainSourceID = domainID2;
1236 gateway.domainSinkID = domainID1;
1237 gateway.listSinkFormats = gwSink.listConnectionFormats;
1238 gateway.listSourceFormats = gwSource.listConnectionFormats;
1239 gateway.convertionMatrix.push_back(true);
1240 gateway.name = "gateway";
1242 gateway1.controlDomainID = domainID2;
1243 gateway1.gatewayID = 0;
1244 gateway1.sinkID = gwSinkID1;
1245 gateway1.sourceID = gwSourceID1;
1246 gateway1.domainSourceID = domainID3;
1247 gateway1.domainSinkID = domainID2;
1248 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
1249 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
1250 gateway1.convertionMatrix.push_back(true);
1251 gateway1.name = "gateway";
1253 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
1254 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
1256 std::vector<am_Route_s> listRoutes;
1257 std::vector<am_RoutingElement_s> listRoutingElements;
1258 am_RoutingElement_s hopp1;
1259 am_RoutingElement_s hopp2;
1260 am_RoutingElement_s hopp3;
1262 hopp1.sourceID = sourceID;
1263 hopp1.sinkID = gwSinkID;
1264 hopp1.domainID = domainID1;
1265 hopp1.connectionFormat = source.listConnectionFormats[0];
1267 hopp2.sourceID = gwSourceID;
1268 hopp2.sinkID = gwSinkID1;
1269 hopp2.domainID = domainID2;
1270 hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
1272 hopp3.sourceID = gwSourceID1;
1273 hopp3.sinkID = sinkID;
1274 hopp3.domainID = domainID3;
1275 hopp3.connectionFormat = sink.listConnectionFormats[0];
1277 listRoutingElements.push_back(hopp1);
1278 listRoutingElements.push_back(hopp2);
1279 listRoutingElements.push_back(hopp3);
1281 am_Route_s compareRoute;
1282 compareRoute.route = listRoutingElements;
1283 compareRoute.sinkID = sinkID;
1284 compareRoute.sourceID = sourceID;
1286 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
1287 ASSERT_EQ(1, listRoutes.size());
1288 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
1291 //test that checks 4 domains, one sink and one source.
1292 TEST_F(routingTest,simpleRoute4Domains)
1294 EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(4);
1295 EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(4);
1296 EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
1298 //initialize 2 domains
1299 am_Domain_s domain1, domain2, domain3, domain4;
1300 am_domainID_t domainID1, domainID2, domainID3, domainID4;
1302 domain1.domainID = 0;
1303 domain1.name = "domain1";
1304 domain1.busname = "domain1bus";
1305 domain1.state = DS_CONTROLLED;
1306 domain2.domainID = 0;
1307 domain2.name = "domain2";
1308 domain2.busname = "domain2bus";
1309 domain2.state = DS_CONTROLLED;
1310 domain3.domainID = 0;
1311 domain3.name = "domain3";
1312 domain3.busname = "domain3bus";
1313 domain3.state = DS_CONTROLLED;
1314 domain4.domainID = 0;
1315 domain4.name = "domain4";
1316 domain4.busname = "domain4bus";
1317 domain4.state = DS_CONTROLLED;
1319 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
1320 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
1321 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
1322 ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain4,domainID4));
1324 am_Source_s source, gwSource, gwSource1, gwSource2;
1325 am_sourceID_t sourceID, gwSourceID, gwSourceID1, gwSourceID2;
1327 source.domainID = domainID1;
1328 source.name = "source1";
1329 source.sourceState = SS_ON;
1330 source.sourceID = 0;
1331 source.sourceClassID = 5;
1332 source.listConnectionFormats.push_back(CF_MONO);
1334 gwSource.domainID = domainID2;
1335 gwSource.name = "gwsource1";
1336 gwSource.sourceState = SS_ON;
1337 gwSource.sourceID = 0;
1338 gwSource.sourceClassID = 5;
1339 gwSource.listConnectionFormats.push_back(CF_ANALOG);
1341 gwSource1.domainID = domainID3;
1342 gwSource1.name = "gwsource2";
1343 gwSource1.sourceState = SS_ON;
1344 gwSource1.sourceID = 0;
1345 gwSource1.sourceClassID = 5;
1346 gwSource1.listConnectionFormats.push_back(CF_MONO);
1348 gwSource2.domainID = domainID4;
1349 gwSource2.name = "gwsource3";
1350 gwSource2.sourceState = SS_OFF;
1351 gwSource2.sourceID = 0;
1352 gwSource2.sourceClassID = 5;
1353 gwSource2.listConnectionFormats.push_back(CF_STEREO);
1355 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
1356 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
1357 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
1358 ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2,gwSourceID2));
1360 am_Sink_s sink, gwSink, gwSink1, gwSink2;
1361 am_sinkID_t sinkID, gwSinkID, gwSinkID1, gwSinkID2;
1363 gwSink.domainID = domainID1;
1364 gwSink.name = "gwSink";
1366 gwSink.sinkClassID = 5;
1367 gwSink.muteState = MS_MUTED;
1368 gwSink.listConnectionFormats.push_back(CF_MONO);
1370 gwSink1.domainID = domainID2;
1371 gwSink1.name = "gwSink1";
1373 gwSink1.sinkClassID = 5;
1374 gwSink1.muteState = MS_MUTED;
1375 gwSink1.listConnectionFormats.push_back(CF_ANALOG);
1377 gwSink2.domainID = domainID3;
1378 gwSink2.name = "gwSink2";
1380 gwSink2.sinkClassID = 5;
1381 gwSink2.muteState = MS_MUTED;
1382 gwSink2.listConnectionFormats.push_back(CF_MONO);
1384 sink.domainID = domainID4;
1385 sink.name = "sink1";
1387 sink.sinkClassID = 5;
1388 sink.muteState = MS_MUTED;
1389 sink.listConnectionFormats.push_back(CF_STEREO);
1391 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
1392 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
1393 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
1394 ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2,gwSinkID2));
1396 am_Gateway_s gateway, gateway1, gateway2;
1397 am_gatewayID_t gatewayID, gatewayID1, gatewayID2;
1399 gateway.controlDomainID = domainID1;
1400 gateway.gatewayID = 0;
1401 gateway.sinkID = gwSinkID;
1402 gateway.sourceID = gwSourceID;
1403 gateway.domainSourceID = domainID2;
1404 gateway.domainSinkID = domainID1;
1405 gateway.listSinkFormats = gwSink.listConnectionFormats;
1406 gateway.listSourceFormats = gwSource.listConnectionFormats;
1407 gateway.convertionMatrix.push_back(true);
1408 gateway.name = "gateway";
1410 gateway1.controlDomainID = domainID2;
1411 gateway1.gatewayID = 0;
1412 gateway1.sinkID = gwSinkID1;
1413 gateway1.sourceID = gwSourceID1;
1414 gateway1.domainSourceID = domainID3;
1415 gateway1.domainSinkID = domainID2;
1416 gateway1.listSinkFormats = gwSink1.listConnectionFormats;
1417 gateway1.listSourceFormats = gwSource1.listConnectionFormats;
1418 gateway1.convertionMatrix.push_back(true);
1419 gateway1.name = "gateway1";
1421 gateway2.controlDomainID = domainID3;
1422 gateway2.gatewayID = 0;
1423 gateway2.sinkID = gwSinkID2;
1424 gateway2.sourceID = gwSourceID2;
1425 gateway2.domainSourceID = domainID4;
1426 gateway2.domainSinkID = domainID3;
1427 gateway2.listSinkFormats = gwSink2.listConnectionFormats;
1428 gateway2.listSourceFormats = gwSource2.listConnectionFormats;
1429 gateway2.convertionMatrix.push_back(true);
1430 gateway2.name = "gateway2";
1432 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
1433 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
1434 ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2));
1436 std::vector<am_Route_s> listRoutes;
1437 std::vector<am_RoutingElement_s> listRoutingElements;
1438 am_RoutingElement_s hopp1;
1439 am_RoutingElement_s hopp2;
1440 am_RoutingElement_s hopp3;
1441 am_RoutingElement_s hopp4;
1443 hopp1.sourceID = sourceID;
1444 hopp1.sinkID = gwSinkID;
1445 hopp1.domainID = domainID1;
1446 hopp1.connectionFormat = source.listConnectionFormats[0];
1448 hopp2.sourceID = gwSourceID;
1449 hopp2.sinkID = gwSinkID1;
1450 hopp2.domainID = domainID2;
1451 hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
1453 hopp3.sourceID = gwSourceID1;
1454 hopp3.sinkID = gwSinkID2;
1455 hopp3.domainID = domainID3;
1456 hopp3.connectionFormat = gwSink2.listConnectionFormats[0];
1458 hopp4.sourceID = gwSourceID2;
1459 hopp4.sinkID = sinkID;
1460 hopp4.domainID = domainID4;
1461 hopp4.connectionFormat = sink.listConnectionFormats[0];
1463 listRoutingElements.push_back(hopp1);
1464 listRoutingElements.push_back(hopp2);
1465 listRoutingElements.push_back(hopp3);
1466 listRoutingElements.push_back(hopp4);
1468 am_Route_s compareRoute;
1469 compareRoute.route = listRoutingElements;
1470 compareRoute.sinkID = sinkID;
1471 compareRoute.sourceID = sourceID;
1473 ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
1474 ASSERT_EQ(1, listRoutes.size());
1475 ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
1478 int main(int argc, char **argv)
1480 ::testing::InitGoogleTest(&argc, argv);
1481 return RUN_ALL_TESTS();