unittests/tests/polemicWidget.js
branchpopcorn-port
changeset 234 43b198dc932d
parent 233 126de77ee73e
child 235 33210f1cc4a0
equal deleted inserted replaced
233:126de77ee73e 234:43b198dc932d
     1 /* polemicWidget.js */
       
     2 
       
     3 function test_polemic_widget() {
       
     4   module("polemic 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.MockTweetSerializer(this.dt, "/url"); /* dummy serializer */
       
    10 
       
    11     IriSP.jQuery("#widget-div").append("<div id='TooltipDiv'></div>");
       
    12     IriSP.jQuery("#widget-div").append("<div id='PolemicDiv'></div>");
       
    13     this.config = {
       
    14 						metadata:{
       
    15 							format:'cinelab',
       
    16 							src:'test.json',
       
    17 							load:'json'},
       
    18 							width:650,
       
    19 							height:1,
       
    20 							mode:'radio',
       
    21 							container:'PolemicDiv',
       
    22 							debug:true,
       
    23 							css:'../src/css/LdtPlayer.css',
       
    24             requires: [{
       
    25 							type: "TooltipWidget",
       
    26               container: "TooltipDiv",
       
    27 							width: 180,
       
    28 							heigh: 160,
       
    29 							metadata : {
       
    30 								format:'cinelab',
       
    31 								type:'empty'
       
    32 							}
       
    33 						 }]
       
    34     }
       
    35     },  
       
    36   teardown: function() {
       
    37     /* free the popcorn object because it has signal handlers attached to it */
       
    38     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
       
    39   }});
       
    40   
       
    41   test("test widget initialization", function() {
       
    42 
       
    43     var tooltip = new IriSP.TooltipWidget(this.Popcorn, this.config.requires[0], this.ser);
       
    44     var widget = new IriSP.PolemicWidget(this.Popcorn, this.config, this.ser);
       
    45     widget.TooltipWidget = tooltip;
       
    46     
       
    47     widget.draw();    
       
    48     equal(IriSP.jQuery("#widget-div").length, 1, "test if the div has been added correctly");        
       
    49     equal(IriSP.jQuery("#PolemicDiv svg").length, 1, "test if svg div has been added correctly");
       
    50     
       
    51     // select the second element of the svg. the second because the first is a rect which serves
       
    52     // as a background.
       
    53     var paperSlider = IriSP.jQuery("#PolemicDiv svg :nth-child(2)");
       
    54     // querying svg with jquery is quite the piece of cake.
       
    55     equal(paperSlider.attr("x").baseVal.value, 0, "test if the slider has been created correctly");            
       
    56   });
       
    57   
       
    58   test("test widget interactions", function() {
       
    59   
       
    60     /* We can't test interactions because of raphael */
       
    61     // var tooltip = new IriSP.TooltipWidget(this.Popcorn, this.config.requires[0], this.ser);
       
    62     // var widget = new IriSP.PolemicWidget(this.Popcorn, this.config, this.ser);
       
    63     
       
    64     // widget.TooltipWidget = tooltip;
       
    65     // widget.draw();
       
    66     
       
    67     // var spy_callback = this.spy();    
       
    68     // this.Popcorn.listen("timeupdate", spy_callback);
       
    69     
       
    70     // var random = Math.round(Math.random() * widget.svgElements.length) + 1;
       
    71     // var e = widget.svgElements[random].node;
       
    72     // IriSP.jQuery(e).click();
       
    73     
       
    74     // ok(spy_callback.called, "the currenttime was changed");  
       
    75     
       
    76   });
       
    77   
       
    78   
       
    79 };