unittests/tests/widgets/sliderWidget.js
branchnew-model
changeset 924 64c2eaafe5e2
parent 923 b3ee7d1b472a
child 925 28efc97b5d78
equal deleted inserted replaced
923:b3ee7d1b472a 924:64c2eaafe5e2
     1 function test_slider_widget() {
       
     2  module("slider widget testing",
       
     3   {setup : function() {
       
     4     this.Popcorn = Popcorn("#popcorn-div");
       
     5 
       
     6     this.dt = new IriSP.DataLoader();
       
     7     this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
       
     8 
       
     9     this.config = {
       
    10 						metadata:{
       
    11 							format:'cinelab',
       
    12 							src:'test.json',
       
    13 							load:'json'},
       
    14 							width:650,
       
    15 							height:1,
       
    16 							mode:'radio',
       
    17 							container:'widget-div',
       
    18 							debug:true,
       
    19 							css:'../src/css/LdtPlayer.css'};
       
    20     IriSP.jQuery("#widget-div").html("");
       
    21     },
       
    22   teardown: function() {
       
    23     /* free the popcorn object because it has signal handlers attached to it */
       
    24     this.Popcorn = Popcorn("#popcorn-div");
       
    25   }});
       
    26 
       
    27   test("test widget initialization", function() {
       
    28     var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);
       
    29     widget.draw();
       
    30 
       
    31     ok(IriSP.jQuery("#widget-div").children().hasClass("Ldt-sliderBackground"), "test if the div has been set-up");
       
    32     ok(IriSP.jQuery("#widget-div").children().hasClass("Ldt-sliderForeground"), "test if the div has been set-up");
       
    33 
       
    34   });
       
    35 
       
    36   test("test slider seeking", function() {
       
    37     /*
       
    38     var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);
       
    39     widget.draw();
       
    40 
       
    41     var spy_callback = this.spy();
       
    42     widget._Popcorn.listen("timeupdate", spy_callback);
       
    43     IriSP.jQuery("#widget-div").children().click();
       
    44     ok(spy_callback.called, "handling function has been called");
       
    45     */
       
    46   });
       
    47 
       
    48   test("test slider dragging", function() {
       
    49 
       
    50     /* comes from the jquery unit tests */
       
    51     var drag = function(handle, dx, dy) {
       
    52       var element = el.data("draggable").element;
       
    53       $(handle).simulate("drag", {
       
    54         dx: dx || 0,
       
    55         dy: dy || 0
       
    56       });
       
    57       dragged = { dx: dx, dy: dy };
       
    58     }
       
    59 
       
    60     var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);
       
    61     widget.draw();
       
    62 
       
    63     var spy_callback = this.spy();
       
    64     widget._Popcorn.listen("timeupdate", spy_callback);
       
    65 
       
    66     /*
       
    67     IriSP.jQuery("#widget-div").children(".Ldt-sliderPositionMarker").simulate("drag", 70, 50);
       
    68     ok(spy_callback.called, "handling function has been called");
       
    69     */
       
    70   });
       
    71 }