unittests/tests/widgets/sliderWidget.js
author veltr
Fri, 29 Jun 2012 16:22:52 +0200
branchnew-model
changeset 923 b3ee7d1b472a
parent 433 8d4bff9ee126
permissions -rw-r--r--
UI improvements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     1
function test_slider_widget() {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     2
 module("slider widget testing",
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     3
  {setup : function() {
427
440ffc18f827 changed the unit tests to reference a local video instead of youtube.
hamidouk
parents: 318
diff changeset
     4
    this.Popcorn = Popcorn("#popcorn-div");
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     5
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     6
    this.dt = new IriSP.DataLoader();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     7
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     8
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
     9
    this.config = {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    10
						metadata:{
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    11
							format:'cinelab',
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    12
							src:'test.json',
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    13
							load:'json'},
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    14
							width:650,
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    15
							height:1,
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    16
							mode:'radio',
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    17
							container:'widget-div',
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    18
							debug:true,
428
9246dce433f8 form fixes here and there.
hamidouk
parents: 427
diff changeset
    19
							css:'../src/css/LdtPlayer.css'};
9246dce433f8 form fixes here and there.
hamidouk
parents: 427
diff changeset
    20
    IriSP.jQuery("#widget-div").html("");
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    21
    },
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    22
  teardown: function() {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    23
    /* 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: 318
diff changeset
    24
    this.Popcorn = Popcorn("#popcorn-div");
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    25
  }});
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    26
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    27
  test("test widget initialization", function() {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    28
    var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    29
    widget.draw();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    30
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    31
    ok(IriSP.jQuery("#widget-div").children().hasClass("Ldt-sliderBackground"), "test if the div has been set-up");
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    32
    ok(IriSP.jQuery("#widget-div").children().hasClass("Ldt-sliderForeground"), "test if the div has been set-up");
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    33
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    34
  });
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    35
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    36
  test("test slider seeking", function() {
433
8d4bff9ee126 fixes to make the tests pass.
hamidouk
parents: 428
diff changeset
    37
    /*
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    38
    var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    39
    widget.draw();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    40
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    41
    var spy_callback = this.spy();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    42
    widget._Popcorn.listen("timeupdate", spy_callback);
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    43
    IriSP.jQuery("#widget-div").children().click();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    44
    ok(spy_callback.called, "handling function has been called");
433
8d4bff9ee126 fixes to make the tests pass.
hamidouk
parents: 428
diff changeset
    45
    */
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    46
  });
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    47
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    48
  test("test slider dragging", function() {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    49
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    50
    /* comes from the jquery unit tests */
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    51
    var drag = function(handle, dx, dy) {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    52
      var element = el.data("draggable").element;
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    53
      $(handle).simulate("drag", {
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    54
        dx: dx || 0,
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    55
        dy: dy || 0
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    56
      });
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    57
      dragged = { dx: dx, dy: dy };
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    58
    }
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    59
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    60
    var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser);
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    61
    widget.draw();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    62
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    63
    var spy_callback = this.spy();
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    64
    widget._Popcorn.listen("timeupdate", spy_callback);
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    65
433
8d4bff9ee126 fixes to make the tests pass.
hamidouk
parents: 428
diff changeset
    66
    /*
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    67
    IriSP.jQuery("#widget-div").children(".Ldt-sliderPositionMarker").simulate("drag", 70, 50);
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    68
    ok(spy_callback.called, "handling function has been called");
433
8d4bff9ee126 fixes to make the tests pass.
hamidouk
parents: 428
diff changeset
    69
    */
318
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    70
  });
463382f92211 fixed unit tests to follow name changes in css classes.
hamidouk
parents: 259
diff changeset
    71
}