unittests/tests/init.js
author hamidouk
Mon, 21 Nov 2011 11:34:07 +0100
branchpopcorn-port
changeset 287 5c7495102bd7
parent 179 7b46fbf4cf6c
child 423 748cce3d80d4
permissions -rw-r--r--
added a spacer div to simplify some graphic animations.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
287
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     1
function test_init() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     2
	module("test initialization routines",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     3
  {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     4
    setup: function() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     5
      IriSP.jQuery("#widget-div").append("<div id='LdtPlayer'></div>");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     6
      this.popcornOptions = {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     7
          container: "LdtPlayer",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     8
          type: "jwplayer", file : "video/franceculture/franceculture_retourdudimanche20100620.flv",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
     9
          streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    10
          flashplayer : '../libs/player.swf',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    11
          live: true,
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    12
          "controlbar.position" : "none",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    13
          height: 300,
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    14
          width: 200,
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    15
          provider: "rtmp"
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    16
        };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    17
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    18
        this.widgetOptions = {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    19
						width:650,
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    20
						height:480,
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    21
						container:'LdtPlayer',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    22
						css:'../../src/css/LdtPlayer.css',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    23
            widgets: [
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    24
              {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    25
               mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    26
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    27
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    28
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    29
                type:'dummy'}
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    30
              },
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    31
             {type: "SegmentsWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    32
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    33
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    34
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    35
                type:'dummy'}
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    36
              },
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    37
             {type: "AnnotationsWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    38
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    39
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    40
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    41
                type:'dummy'}
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    42
              },
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    43
            ]};
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    44
    }
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    45
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    46
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    47
  test("test the creation of a correct popcorn object", function() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    48
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    49
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    50
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    51
    notDeepEqual(pop, undefined, "returned object is not undefined");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    52
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    53
    /* FIXME: add more test options ? */
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    54
    equal(pop.options.type, "jwplayer", "the player is of the correct type.");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    55
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    56
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    57
  test("test the creation of a video tag", function() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    58
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    59
    var popcornOptions = {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    60
            type: "html5",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    61
            file: "demo.mp4"
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    62
          };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    63
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    64
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    65
    var pop = IriSP.configurePopcorn(layoutManager, popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    66
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    67
    var elem = IriSP.jQuery("#LdtPlayer").find("video");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    68
    notDeepEqual(elem, [], "the element is not null");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    69
    equal(elem.attr("src"), popcornOptions.file, "the src attribute is set correctly");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    70
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    71
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    72
  test("test the instantiation of a single widget without dependencies", function() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    73
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    74
    var dt = new IriSP.DataLoader();
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    75
    var serialFactory = new IriSP.SerializerFactory(dt);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    76
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    77
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    78
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    79
    var conf = {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    80
               mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    81
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    82
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    83
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    84
                type:'dummy'}
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    85
              };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    86
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    87
    var res = IriSP.instantiateWidget(pop, serialFactory, layoutManager, conf);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    88
    ok(res instanceof IriSP.PlayerWidget, "the returned widget is of the correct instance");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    89
    equal(res._config.mode, "radio", "the parameters not interpreted by the config are copied into the object");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    90
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    91
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    92
  test("test the instantiation of a single widget with one dependency", function() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    93
    var dt = new IriSP.DataLoader();
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    94
    var serialFactory = new IriSP.SerializerFactory(dt);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    95
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    96
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    97
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    98
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    99
    var conf = {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   100
               mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   101
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   102
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   103
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   104
                type:'dummy'},
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   105
                requires: [
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   106
                {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   107
                  mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   108
                  metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   109
                    format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   110
                    src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   111
                    type:'dummy'
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   112
                } }]
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   113
              };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   114
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   115
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   116
    var res = IriSP.instantiateWidget(pop, serialFactory, layoutManager, conf);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   117
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   118
    ok(res instanceof IriSP.PlayerWidget, "the returned widget is of the correct instance");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   119
    ok(res.PlayerWidget instanceof IriSP.PlayerWidget, "the dependency widget is accessible from the parent");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   120
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   121
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   122
  test("test the instantiation of a bunch of widgets", function() {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   123
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   124
    var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   125
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   126
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   127
    var widgets = IriSP.configureWidgets(pop, layoutManager, this.widgetOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   128
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   129
    ok(widgets[0] instanceof IriSP.PlayerWidget, "first widget is a player widget");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   130
    ok(widgets[1] instanceof IriSP.SegmentsWidget, "second widget is a segments widget");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   131
    ok(widgets[2] instanceof IriSP.AnnotationsWidget, "third widget is an annotation widget");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   132
    equal(IriSP.jQuery("#" + this.widgetOptions.container).length, 1, "a new dom element has been created");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   133
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   134
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   135
127
3ce493c93d6c added tests for init.js.
hamidouk
parents:
diff changeset
   136
}