# HG changeset patch # User hamidouk # Date 1323871000 -3600 # Node ID a9c5eeca190c82b7cc2b8fc666831ab5d53768b4 # Parent 7071ccbc315a658abfdf98eeed2d7f4b4c146bd3 added modules and tbe tests to test them. diff -r 7071ccbc315a -r a9c5eeca190c sbin/build/client.xml --- a/sbin/build/client.xml Wed Dec 14 14:10:55 2011 +0100 +++ b/sbin/build/client.xml Wed Dec 14 14:56:40 2011 +0100 @@ -81,7 +81,10 @@ - + + + + diff -r 7071ccbc315a -r a9c5eeca190c src/js/init.js --- a/src/js/init.js Wed Dec 14 14:10:55 2011 +0100 +++ b/src/js/init.js Wed Dec 14 14:56:40 2011 +0100 @@ -97,6 +97,23 @@ return ret_widgets; }; +IriSP.configureModules = function (popcornInstance, modulesList) { + + var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader); + var ret_modules = []; + var index; + + for (index = 0; index < modulesList.length; index++) { + var moduleConfig = modulesList[index]; + + var serializer = serialFactory.getSerializer(moduleConfig.metadata); + var module = new IriSP[moduleConfig.type](popcornInstance, moduleConfig, serializer); + ret_modules.push(module); + }; + + return ret_modules; +}; + IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) { /* create div returns us a container for the widget and a spacer */ var ret = layoutManager.createDiv(widgetConfig.type); diff -r 7071ccbc315a -r a9c5eeca190c src/js/modules.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/js/modules.js Wed Dec 14 14:56:40 2011 +0100 @@ -0,0 +1,12 @@ +/* modules are non-graphical entities, similar to widgets */ + +IriSP.Module = function(Popcorn, config, Serializer) { + + if (config === undefined || config === null) { + config = {} + } + + this._Popcorn = Popcorn; + this._config = config; + this._serializer = Serializer; +}; diff -r 7071ccbc315a -r a9c5eeca190c unittests/index.html --- a/unittests/index.html Wed Dec 14 14:10:55 2011 +0100 +++ b/unittests/index.html Wed Dec 14 14:56:40 2011 +0100 @@ -31,6 +31,7 @@ + @@ -57,6 +58,7 @@ test_serializerFactory(); test_utils(); test_widget(); + test_module(); test_player_widget(); test_annotations_widget(); // test_segments_widget(); diff -r 7071ccbc315a -r a9c5eeca190c unittests/tests/init.js --- a/unittests/tests/init.js Wed Dec 14 14:10:55 2011 +0100 +++ b/unittests/tests/init.js Wed Dec 14 14:56:40 2011 +0100 @@ -5,14 +5,8 @@ IriSP.jQuery("#widget-div").append("
"); this.popcornOptions = { container: "LdtPlayer", - type: "jwplayer", file : "video/franceculture/franceculture_retourdudimanche20100620.flv", - streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", - flashplayer : '../libs/player.swf', - live: true, - "controlbar.position" : "none", - height: 300, - width: 200, - provider: "rtmp" + type: "html5", + file : "trailer.mp4", }; this.widgetOptions = { @@ -41,6 +35,11 @@ type:'dummy'} }, ]}; + + this.modulesOptions = [ + {type: "Module", a : 36}, + {type: "Module", b : 54} + ]; } }); @@ -129,5 +128,16 @@ equal(IriSP.jQuery("#" + this.widgetOptions.container).length, 1, "a new dom element has been created"); }); + test("test the instantiation of a couple modules", function() { + + var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542}); + var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions); + + var modules = IriSP.configureModules(pop, this.modulesOptions); + + ok(modules[0] instanceof IriSP.Module && modules[0]._config.a === 36); + ok(modules[1] instanceof IriSP.Module && modules[1]._config.b === 54); + }); + } diff -r 7071ccbc315a -r a9c5eeca190c unittests/tests/module.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/unittests/tests/module.js Wed Dec 14 14:56:40 2011 +0100 @@ -0,0 +1,17 @@ +/* test module for base widgets */ +function test_module() { + module("Base module testing", + {setup : function() { + this.Popcorn = Popcorn("#popcorn-div"); + + this.dt = new IriSP.DataLoader(); + this.ser = new IriSP.JSONSerializer(this.dt, "/url"); + } } + ); + + test("test initialisation", function() { + var config = { a : 540}; + var mod = new IriSP.Module(this.Popcorn, config, this.ser); + deepEqual(mod._config, config, "Check that config is copied correctly"); + }); +};