unittests/tests/init.js
author hamidouk
Wed, 07 Dec 2011 14:31:20 +0100
branchpopcorn-port
changeset 423 748cce3d80d4
parent 287 5c7495102bd7
child 461 a9c5eeca190c
permissions -rw-r--r--
fixed unit test.
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
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    54
  test("test the creation of a video tag", function() {
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
    var popcornOptions = {
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    57
            type: "html5",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    58
            file: "demo.mp4"
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    59
          };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    60
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    61
    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
    62
    var pop = IriSP.configurePopcorn(layoutManager, popcornOptions);
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 elem = IriSP.jQuery("#LdtPlayer").find("video");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    65
    notDeepEqual(elem, [], "the element is not null");
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    66
    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
    67
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    68
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    69
  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
    70
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    71
    var dt = new IriSP.DataLoader();
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    72
    var serialFactory = new IriSP.SerializerFactory(dt);
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 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
    75
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    76
    var conf = {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    77
               mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    78
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    79
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    80
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    81
                type:'dummy'}
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    82
              };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    83
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    84
    var res = IriSP.instantiateWidget(pop, serialFactory, layoutManager, conf);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    85
    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
    86
    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
    87
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    88
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    89
  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
    90
    var dt = new IriSP.DataLoader();
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    91
    var serialFactory = new IriSP.SerializerFactory(dt);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    92
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    93
    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
    94
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    95
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    96
    var conf = {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    97
               mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    98
               metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
    99
                format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   100
                src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   101
                type:'dummy'},
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   102
                requires: [
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   103
                {type: "PlayerWidget",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   104
                  mode: "radio",
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   105
                  metadata:{
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   106
                    format:'cinelab',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   107
                    src:'test.json',
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   108
                    type:'dummy'
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   109
                } }]
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   110
              };
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   111
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
    var res = IriSP.instantiateWidget(pop, serialFactory, layoutManager, conf);
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
    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
   116
    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
   117
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   118
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   119
  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
   120
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   121
    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
   122
    var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
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 widgets = IriSP.configureWidgets(pop, layoutManager, this.widgetOptions);
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   125
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   126
    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
   127
    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
   128
    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
   129
    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
   130
  });
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   131
5c7495102bd7 added a spacer div to simplify some graphic animations.
hamidouk
parents: 179
diff changeset
   132
423
748cce3d80d4 fixed unit test.
hamidouk
parents: 287
diff changeset
   133
}