unittests/tests/init.js
author hamidouk
Thu, 27 Oct 2011 13:36:49 +0200
branchpopcorn-port
changeset 158 1813e6e4f0d6
parent 143 2b962708dff6
child 171 158f0193ec54
permissions -rw-r--r--
made a small change to the way popcorn is integrated into the page.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     1
function test_init() {
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     2
	module("test initialization routines", 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     3
  {
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     4
    setup: function() {
143
2b962708dff6 added a test to the init.js unit test suite.
hamidouk
parents: 142
diff changeset
     5
      IriSP.jQuery("#widget-div").append("<div id='LdtPlayer'></div>");
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     6
      this.popcornOptions = {
158
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
     7
          container: "LdtPlayer",
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     8
          type: "jwplayer", file : "video/franceculture/franceculture_retourdudimanche20100620.flv", 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
     9
          streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    10
          flashplayer : '../libs/player.swf',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    11
          live: true, 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    12
          "controlbar.position" : "none", 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    13
          height: 300, 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    14
          width: 200, 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    15
          provider: "rtmp" 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    16
        };
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    17
        
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    18
        this.widgetOptions = {
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    19
						width:650,
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    20
						height:480,							
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    21
						container:'LdtPlayer',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    22
						css:'../../src/css/LdtPlayer.css',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    23
            widgets: [
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    24
              {type: "PlayerWidget",
142
caefb8b4218f fixed div id in test data.
hamidouk
parents: 127
diff changeset
    25
               mode: "radio",
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    26
               metadata:{
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    27
                format:'cinelab',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    28
                src:'test.json',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    29
                type:'dummy'}
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    30
              },
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    31
             {type: "SegmentsWidget", 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    32
               metadata:{
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    33
                format:'cinelab',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    34
                src:'test.json',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    35
                type:'dummy'}
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    36
              },
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    37
             {type: "AnnotationsWidget", 
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    38
               metadata:{
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    39
                format:'cinelab',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    40
                src:'test.json',
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    41
                type:'dummy'}
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    42
              },
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    43
            ]};
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    44
    }
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    45
  });
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    46
  
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    47
  test("test the creation of a correct popcorn object", function() {
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    48
158
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    49
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    50
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    51
    notDeepEqual(pop, undefined, "returned object is not undefined");
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    52
    
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    53
    /* FIXME: add more test options ? */
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    54
    equal(pop.options.type, "jwplayer", "the player is of the correct type.");
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    55
  });
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    56
  
158
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    57
  test("test the creation of a video tag", function() {
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    58
  
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    59
    var popcornOptions = {
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    60
            type: "html5",
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    61
            file: "demo.mp4"
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    62
          };
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    63
    
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    64
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    65
    var pop = IriSP.configurePopcorn(layoutManager, popcornOptions);
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    66
    
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    67
    var elem = IriSP.jQuery("#LdtPlayer").find("video");
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    68
    notDeepEqual(elem, [], "the element is not null");
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    69
    equal(elem.attr("src"), popcornOptions.file, "the src attribute is set correctly");    
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    70
  });
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    71
  
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    72
  test("test the instantiation of a bunch of widgets", function() {
158
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    73
  
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    74
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    75
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    76
    
1813e6e4f0d6 made a small change to the way popcorn is integrated into the page.
hamidouk
parents: 143
diff changeset
    77
    var widgets = IriSP.configureWidgets(pop, layoutManager, this.widgetOptions);
143
2b962708dff6 added a test to the init.js unit test suite.
hamidouk
parents: 142
diff changeset
    78
2b962708dff6 added a test to the init.js unit test suite.
hamidouk
parents: 142
diff changeset
    79
    ok(widgets[0] instanceof IriSP.PlayerWidget, "first widget is a player widget");       
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    80
    ok(widgets[1] instanceof IriSP.SegmentsWidget, "second widget is a segments widget");
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    81
    ok(widgets[2] instanceof IriSP.AnnotationsWidget, "third widget is an annotation widget");
143
2b962708dff6 added a test to the init.js unit test suite.
hamidouk
parents: 142
diff changeset
    82
    equal(IriSP.jQuery("#" + this.widgetOptions.container).length, 1, "a new dom element has been created");
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    83
  });
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
    84
}