unittests/tests/tooltipWidget.js
author hamidouk
Mon, 14 Nov 2011 12:16:27 +0100
branchpopcorn-port
changeset 231 accc7358d8b5
parent 172 3ffa0e0c8803
permissions -rw-r--r--
fixed a position bug.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     1
/* tooltipWidget.js */
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     2
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     3
function test_tooltip_widget() {
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     4
  module("tooltip widget testing", 
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     5
  {setup : function() {    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     6
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     7
    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     8
    this.dt = new IriSP.DataLoader();
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     9
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    10
            
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    11
    this.config = {
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    12
							width: 160,
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    13
							height:120,
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    14
              container: "widget-div"
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    15
						};
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    16
    },
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    17
    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    18
  teardown: function() {
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    19
    /* free the popcorn object because it has signal handlers attached to it */
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    20
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    21
  }
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    22
  });
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    23
  
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    24
  test("test tooltip widget initialization", function() {  
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    25
    var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    26
    widget.draw();
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    27
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    28
    equal(widget.selector.children(".tip").length, 1, "test if the div has been added correctly");
231
accc7358d8b5 fixed a position bug.
hamidouk
parents: 172
diff changeset
    29
    equal(widget.selector.children(".tip").css("position"), "fixed", "test if the widget has the correct position attr");    
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    30
    equal(widget.selector.children(".tip").css("left"), "-10000px", "test if div has been positionned correctly");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    31
    equal(widget.selector.children(".tip").css("top"), "-100000px", "test if div has been positionned correctly");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    32
  });
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    33
  
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    34
  test("test widget display function", function() {
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    35
    var widget = new IriSP.TooltipWidget(this.Popcorn, this.config, this.ser);    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    36
    widget.draw();
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    37
    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    38
    widget.show("ceci est un texte", "#fefefe", 105, 240);
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    39
    equal(widget.selector.children(".tip").css("left"), "105px", "test if div has been positionned correctly");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    40
    equal(widget.selector.children(".tip").css("top"), "240px", "test if div has been positionned correctly");    
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    41
    equal(widget.selector.find(".tiptext").text(), "ceci est un texte", "test if text has been set correctly");
231
accc7358d8b5 fixed a position bug.
hamidouk
parents: 172
diff changeset
    42
    
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    43
    widget.hide();
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    44
    equal(widget.selector.children(".tip").css("left"), "-10000px", "test if div has been positionned correctly");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    45
    equal(widget.selector.children(".tip").css("top"), "-100000px", "test if div has been positionned correctly");
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    46
  });
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    47
};