unittests/tests/annotationsWidget.js
author hamidouk
Fri, 21 Oct 2011 11:21:35 +0200
branchpopcorn-port
changeset 111 df08c7f9535c
parent 93 8c066a79a14f
child 162 2ef47ccb290f
permissions -rw-r--r--
added a basic layout manager.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     1
/* annotationsWidget.js */
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     2
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     3
function test_annotations_widget() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     4
  module("annotations widget testing", 
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     5
  {setup : function() {    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     6
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     7
    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     8
    this.dt = new IriSP.DataLoader();
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
     9
    this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    10
    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    11
    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    12
    IriSP.jQuery("#widget-div").append("<div id='Ldt-Ligne'></div>");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    13
    this.config = {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    14
						metadata:{
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    15
							format:'cinelab',
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    16
							src:'test.json',
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    17
							load:'json'},
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    18
						gui:{
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    19
							width:650,
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    20
							height:1,
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    21
							mode:'radio',
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    22
							container:'widget-div',
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    23
							debug:true,
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    24
							css:'../src/css/LdtPlayer.css'},
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    25
					};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    26
    },
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    27
  teardown: function() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    28
    /* free the popcorn object because it has signal handlers attached to it */
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    29
    this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    30
  }
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    31
  });
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    32
  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    33
  test("test widget initialization", function() {  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    34
    var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    35
    widget.draw();
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    36
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    37
    equal(IriSP.jQuery("#Ldt-Ligne").length, 1, "test if the div has been added correctly");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    38
    equal(IriSP.jQuery("#Ldt-Ligne #Ldt-SaKeyword").length, 1, "test if sub-div has been added correctly");     
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    39
  });
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    40
  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    41
  test("test annotation display function", function() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    42
    var widget = new IriSP.AnnotationsWidget(this.Popcorn, this.config, this.ser);    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    43
    widget.draw();
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    44
    var annotation = {content: {"title": "title", "description": "description", "keywords": "keywords"}};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    45
    widget.displayAnnotation(annotation);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    46
    equal(IriSP.jQuery("#Ldt-SaTitle").text(), "title", "title set correctly");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    47
    equal(IriSP.jQuery("#Ldt-SaDescription").text(), "description", "description set correctly");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    48
    equal(IriSP.jQuery("#Ldt-SaKeywordText").text(), "Mots clefs : ", "keywords field set correctly");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    49
  });
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents:
diff changeset
    50
};