unittests/tests/widgets/tooltipWidget.js
author hamidouk
Wed, 21 Dec 2011 10:30:46 +0100
branchpopcorn-port
changeset 492 97c920842123
parent 427 440ffc18f827
permissions -rw-r--r--
fixed tooltipWidget.js tests.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     1
/* tooltipWidget.js */
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     2
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     3
function test_tooltip_widget() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     4
  module("tooltip widget testing", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     5
  {setup : function() {    
427
440ffc18f827 changed the unit tests to reference a local video instead of youtube.
hamidouk
parents: 234
diff changeset
     6
    this.Popcorn = Popcorn("#popcorn-div");
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     7
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     8
    this.dt = new IriSP.DataLoader();
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     9
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    10
            
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    11
    this.config = {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    12
							width: 160,
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    13
							height:120,
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    14
              container: "widget-div"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    15
						};
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    16
    },
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    17
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    18
  teardown: function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    19
    /* free the popcorn object because it has signal handlers attached to it */
427
440ffc18f827 changed the unit tests to reference a local video instead of youtube.
hamidouk
parents: 234
diff changeset
    20
    this.Popcorn = Popcorn("#popcorn-div");
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    21
  }
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    22
  });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    23
  
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    24
  test("test tooltip widget initialization", function() {  
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    25
    var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    26
    widget.draw();
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    27
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    28
    equal(widget.selector.children(".tip").length, 1, "test if the div has been added correctly");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    29
    equal(widget.selector.children(".tip").css("position"), "fixed", "test if the widget has the correct position attr");    
492
97c920842123 fixed tooltipWidget.js tests.
hamidouk
parents: 427
diff changeset
    30
    equal(widget.selector.children(".tip").css("display"), "none", "test if tooltip is hidden");    
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    31
  });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    32
  
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    33
  test("test widget display function", function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    34
    var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    35
    widget.draw();
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    36
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    37
    widget.show("ceci est un texte", "#fefefe", 105, 240);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    38
    equal(widget.selector.children(".tip").css("left"), "105px", "test if div has been positionned correctly");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    39
    equal(widget.selector.children(".tip").css("top"), "240px", "test if div has been positionned correctly");    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    40
    equal(widget.selector.find(".tiptext").text(), "ceci est un texte", "test if text has been set correctly");
492
97c920842123 fixed tooltipWidget.js tests.
hamidouk
parents: 427
diff changeset
    41
    notEqual(widget.selector.children(".tip").css("display"), "none", "test if tooltip is hidden"); 
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    42
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    43
    widget.hide();
492
97c920842123 fixed tooltipWidget.js tests.
hamidouk
parents: 427
diff changeset
    44
    equal(widget.selector.children(".tip").css("display"), "none", "test if tooltip is hidden"); 
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    45
  });
427
440ffc18f827 changed the unit tests to reference a local video instead of youtube.
hamidouk
parents: 234
diff changeset
    46
};