unittests/tests/segmentsWidget.js
author hamidouk
Thu, 20 Oct 2011 15:50:04 +0200
branchpopcorn-port
changeset 103 2dfd89e91c3a
parent 100 dbd302a995f5
child 104 d571e9020092
permissions -rw-r--r--
added a method to sort the json annotations. changed the tests accordingly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     1
/* segmentsWidget.js */
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     2
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     3
function test_segments_widget() {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     4
  module("segments widget testing", 
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     5
  {setup : function() {    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     6
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     7
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     8
    this.dt = new IriSP.DataLoader();
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     9
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    10
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    11
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    12
    IriSP.jQuery("#widget-div").append("<div id='Ldt-Annotations'></div>");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    13
    this.config = {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    14
						metadata:{
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    15
							format:'cinelab',
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    16
							src:'test.json',
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    17
							load:'json'},
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    18
						gui:{
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    19
							width:650,
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    20
							height:1,
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    21
							mode:'radio',
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    22
							container:'widget-div',
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    23
							debug:true,
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    24
							css:'../src/css/LdtPlayer.css'},
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    25
					};
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    26
    },
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    27
  teardown: function() {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    28
    /* free the popcorn object because it has signal handlers attached to it */
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    29
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    30
  }
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    31
  });
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    32
  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    33
  test("test widget initialization", function() {  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    34
    var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser);    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    35
    widget.draw();
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    36
  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    37
    console.dir(IriSP.jQuery("#Ldt-Annotations").get(0));
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    38
    equal(IriSP.jQuery("#Ldt-Annotations").length, 1, "test if the div has been added correctly");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    39
    equal(IriSP.jQuery("#Ldt-Annotations").children().length, this.ser._data.annotations.length, "test if children have been added correctly");     
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    40
  });
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    41
  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    42
  test("test annotation display function", function() {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    43
  /*
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    44
    var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    45
    widget.draw();
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    46
    var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}};
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    47
    widget.displayAnnotation(annotation);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    48
    equal(IriSP.jQuery("#Ldt-SaTitle").text(), "title", "title set correctly");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    49
    equal(IriSP.jQuery("#Ldt-SaDescription").text(), "description", "description set correctly");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    50
    equal(IriSP.jQuery("#Ldt-SaKeywordText").text(), "Mots clefs : ", "keywords field set correctly");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    51
  */
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    52
  });
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    53
};