unittests/tests/segmentsWidget.js
branchpopcorn-port
changeset 100 dbd302a995f5
child 104 d571e9020092
equal deleted inserted replaced
99:912f100fecb0 100:dbd302a995f5
       
     1 /* segmentsWidget.js */
       
     2 
       
     3 function test_segments_widget() {
       
     4   module("segments widget testing", 
       
     5   {setup : function() {    
       
     6     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
       
     7     
       
     8     this.dt = new IriSP.DataLoader();
       
     9     this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
       
    10     
       
    11     
       
    12     IriSP.jQuery("#widget-div").append("<div id='Ldt-Annotations'></div>");
       
    13     this.config = {
       
    14 						metadata:{
       
    15 							format:'cinelab',
       
    16 							src:'test.json',
       
    17 							load:'json'},
       
    18 						gui:{
       
    19 							width:650,
       
    20 							height:1,
       
    21 							mode:'radio',
       
    22 							container:'widget-div',
       
    23 							debug:true,
       
    24 							css:'../src/css/LdtPlayer.css'},
       
    25 					};
       
    26     },
       
    27   teardown: function() {
       
    28     /* free the popcorn object because it has signal handlers attached to it */
       
    29     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
       
    30   }
       
    31   });
       
    32   
       
    33   test("test widget initialization", function() {  
       
    34     var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser);    
       
    35     widget.draw();
       
    36   
       
    37     console.dir(IriSP.jQuery("#Ldt-Annotations").get(0));
       
    38     equal(IriSP.jQuery("#Ldt-Annotations").length, 1, "test if the div has been added correctly");
       
    39     equal(IriSP.jQuery("#Ldt-Annotations").children().length, this.ser._data.annotations.length, "test if children have been added correctly");     
       
    40   });
       
    41   
       
    42   test("test annotation display function", function() {
       
    43   /*
       
    44     var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
       
    45     widget.draw();
       
    46     var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}};
       
    47     widget.displayAnnotation(annotation);
       
    48     equal(IriSP.jQuery("#Ldt-SaTitle").text(), "title", "title set correctly");
       
    49     equal(IriSP.jQuery("#Ldt-SaDescription").text(), "description", "description set correctly");
       
    50     equal(IriSP.jQuery("#Ldt-SaKeywordText").text(), "Mots clefs : ", "keywords field set correctly");
       
    51   */
       
    52   });
       
    53 };