unittests/tests/widgets/tooltipWidget.js
branchpopcorn-port
changeset 234 43b198dc932d
child 427 440ffc18f827
equal deleted inserted replaced
233:126de77ee73e 234:43b198dc932d
       
     1 /* tooltipWidget.js */
       
     2 
       
     3 function test_tooltip_widget() {
       
     4   module("tooltip 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     this.config = {
       
    12 							width: 160,
       
    13 							height:120,
       
    14               container: "widget-div"
       
    15 						};
       
    16     },
       
    17     
       
    18   teardown: function() {
       
    19     /* free the popcorn object because it has signal handlers attached to it */
       
    20     this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
       
    21   }
       
    22   });
       
    23   
       
    24   test("test tooltip widget initialization", function() {  
       
    25     var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
       
    26     widget.draw();
       
    27 
       
    28     equal(widget.selector.children(".tip").length, 1, "test if the div has been added correctly");
       
    29     equal(widget.selector.children(".tip").css("position"), "fixed", "test if the widget has the correct position attr");    
       
    30     equal(widget.selector.children(".tip").css("left"), "-10000px", "test if div has been positionned correctly");
       
    31     equal(widget.selector.children(".tip").css("top"), "-100000px", "test if div has been positionned correctly");
       
    32   });
       
    33   
       
    34   test("test widget display function", function() {
       
    35     var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
       
    36     widget.draw();
       
    37     
       
    38     widget.show("ceci est un texte", "#fefefe", 105, 240);
       
    39     equal(widget.selector.children(".tip").css("left"), "105px", "test if div has been positionned correctly");
       
    40     equal(widget.selector.children(".tip").css("top"), "240px", "test if div has been positionned correctly");    
       
    41     equal(widget.selector.find(".tiptext").text(), "ceci est un texte", "test if text has been set correctly");
       
    42     
       
    43     widget.hide();
       
    44     equal(widget.selector.children(".tip").css("left"), "-10000px", "test if div has been positionned correctly");
       
    45     equal(widget.selector.children(".tip").css("top"), "-100000px", "test if div has been positionned correctly");
       
    46   });
       
    47 };