unittests/tests/annotationsWidget.js
branchpopcorn-port
changeset 162 2ef47ccb290f
parent 93 8c066a79a14f
equal deleted inserted replaced
161:892efe407182 162:2ef47ccb290f
     5   {setup : function() {    
     5   {setup : function() {    
     6     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
     6     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
     7     
     7     
     8     this.dt = new IriSP.DataLoader();
     8     this.dt = new IriSP.DataLoader();
     9     this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
     9     this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
       
    10         
       
    11     IriSP.jQuery("#widget-div").append("<div id='Ldt-Ligne'></div>");
    10     
    12     
    11     
       
    12     IriSP.jQuery("#widget-div").append("<div id='Ldt-Ligne'></div>");
       
    13     this.config = {
    13     this.config = {
    14 						metadata:{
       
    15 							format:'cinelab',
       
    16 							src:'test.json',
       
    17 							load:'json'},
       
    18 						gui:{
       
    19 							width:650,
    14 							width:650,
    20 							height:1,
    15 							height:1,
    21 							mode:'radio',
    16 							mode:'radio',
    22 							container:'widget-div',
    17 							container:'widget-div',
    23 							debug:true,
    18 							debug:true,
    24 							css:'../src/css/LdtPlayer.css'},
    19 							css:'../src/css/LdtPlayer.css'};
    25 					};
       
    26     },
    20     },
    27   teardown: function() {
    21   teardown: function() {
    28     /* free the popcorn object because it has signal handlers attached to it */
    22     /* 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");
    23     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
    30   }
    24   }
    32   
    26   
    33   test("test widget initialization", function() {  
    27   test("test widget initialization", function() {  
    34     var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
    28     var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
    35     widget.draw();
    29     widget.draw();
    36 
    30 
    37     equal(IriSP.jQuery("#Ldt-Ligne").length, 1, "test if the div has been added correctly");
    31     equal(widget.selector.children(".Ldt-AnnotationsWidget").length, 1, "test if the div has been added correctly");
    38     equal(IriSP.jQuery("#Ldt-Ligne #Ldt-SaKeyword").length, 1, "test if sub-div has been added correctly");     
    32     equal(widget.selector.children(".Ldt-AnnotationsWidget").find(".Ldt-SaKeyword").length, 1, "test if sub-div has been added correctly");
    39   });
    33   });
    40   
    34   
    41   test("test annotation display function", function() {
    35   test("test annotation display function", function() {
    42     var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
    36     var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
    43     widget.draw();
    37     widget.draw();
    44     var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}};
    38     var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}};
    45     widget.displayAnnotation(annotation);
    39     widget.displayAnnotation(annotation);
    46     equal(IriSP.jQuery("#Ldt-SaTitle").text(), "title", "title set correctly");
    40     equal(widget.selector.find(".Ldt-SaTitle").text(), "title", "title set correctly");
    47     equal(IriSP.jQuery("#Ldt-SaDescription").text(), "description", "description set correctly");
    41     equal(widget.selector.find(".Ldt-SaDescription").text(), "description", "description set correctly");
    48     equal(IriSP.jQuery("#Ldt-SaKeywordText").text(), "Mots clefs : ", "keywords field set correctly");
    42     equal(widget.selector.find(".Ldt-SaKeywordText").text(), "", "keywords field set correctly");
    49   });
    43   });
    50 }; 
    44 };