added modules and tbe tests to test them. popcorn-port
authorhamidouk
Wed, 14 Dec 2011 14:56:40 +0100
branchpopcorn-port
changeset 461 a9c5eeca190c
parent 460 7071ccbc315a
child 462 3583ef3b208b
added modules and tbe tests to test them.
sbin/build/client.xml
src/js/init.js
src/js/modules.js
unittests/index.html
unittests/tests/init.js
unittests/tests/module.js
--- 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 @@
     	<filelist dir="../../build" files="compiled_templates.js" />
       
       <!-- core files -->
-    	<filelist dir="../../src/js" files="pop.js utils.js data.js site.js ui.js widgets.js layout.js init.js" />
+    	<filelist dir="../../src/js" files="pop.js utils.js data.js site.js ui.js widgets.js modules.js layout.js init.js" />
+
+      <!-- modules -->
+    	<filelist dir="../../src/js" files="mediafragment" />
 
       <!-- widgets -->
 			<fileset dir="../../src/js/widgets" casesensitive="yes">
--- 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);        
--- /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;
+};
--- 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 @@
 	<script src="tests/serializers/JSONSerializer.js" type="text/javascript"></script>
 	<script src="tests/serializerFactory.js" type="text/javascript"></script>
 	<script src="tests/widget.js" type="text/javascript"></script>
+	<script src="tests/module.js" type="text/javascript"></script>
 	<script src="tests/utils.js" type="text/javascript"></script>	
 	<script src="tests/layout.js" type="text/javascript"></script>
 	<script src="tests/init.js" type="text/javascript"></script>
@@ -57,6 +58,7 @@
 		test_serializerFactory();
     test_utils();
 		test_widget();
+		test_module();
 		test_player_widget();
 		test_annotations_widget();
 //		test_segments_widget();
--- 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("<div id='LdtPlayer'></div>");
       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);
+  });
+
 
 }
--- /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");
+  });
+};