unittests/tests/sliderWidget.js
author hamidouk
Thu, 10 Nov 2011 15:06:22 +0100
branchpopcorn-port
changeset 226 d1f0e604bd06
child 230 9b86d3c52211
permissions -rw-r--r--
separated the slider from the playerWidget.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
226
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     1
function test_slider_widget() {
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     2
 module("slider widget testing", 
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     3
  {setup : function() {    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     4
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     5
    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     6
    this.dt = new IriSP.DataLoader();
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     7
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     8
            
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     9
    this.config = {
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    10
						metadata:{
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    11
							format:'cinelab',
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    12
							src:'test.json',
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    13
							load:'json'},
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    14
							width:650,
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    15
							height:1,
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    16
							mode:'radio',
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    17
							container:'widget-div',
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    18
							debug:true,
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    19
							css:'../src/css/LdtPlayer.css'}
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    20
    },  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    21
  teardown: function() {
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    22
    /* free the popcorn object because it has signal handlers attached to it */
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    23
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    24
  }});
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    25
  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    26
  test("test widget initialization", function() {  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    27
    var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    28
    widget.draw();
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    29
    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    30
    ok(IriSP.jQuery("#widget-div").hasClass("ui-slider"), "test if the div has been set-up");
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    31
  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    32
  });
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    33
  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    34
  test("test slider seeking", function() {    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    35
    var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    36
    widget.draw();
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    37
    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    38
    var spy_callback = this.spy();
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    39
    widget._Popcorn.listen("test.fixture", spy_callback);       
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    40
    IriSP.jQuery("#widget-div").slider("value", 30);
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    41
    ok(spy_callback.called, "handling function has been called");
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    42
  });
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    43
}