|
100
|
1 |
/* segmentsWidget.js */ |
|
|
2 |
|
|
|
3 |
function test_segments_widget() { |
|
|
4 |
module("segments widget testing", |
|
|
5 |
{setup : function() { |
|
|
6 |
this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); |
|
|
7 |
|
|
|
8 |
this.dt = new IriSP.DataLoader(); |
|
|
9 |
this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ |
|
164
|
10 |
|
|
100
|
11 |
this.config = { |
|
|
12 |
metadata:{ |
|
|
13 |
format:'cinelab', |
|
|
14 |
src:'test.json', |
|
|
15 |
load:'json'}, |
|
|
16 |
width:650, |
|
|
17 |
height:1, |
|
|
18 |
mode:'radio', |
|
|
19 |
container:'widget-div', |
|
|
20 |
debug:true, |
|
164
|
21 |
css:'../src/css/LdtPlayer.css'} |
|
|
22 |
}, |
|
100
|
23 |
teardown: function() { |
|
|
24 |
/* free the popcorn object because it has signal handlers attached to it */ |
|
|
25 |
this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); |
|
164
|
26 |
}}); |
|
100
|
27 |
|
|
|
28 |
test("test widget initialization", function() { |
|
|
29 |
var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser); |
|
|
30 |
widget.draw(); |
|
|
31 |
|
|
164
|
32 |
equal(IriSP.jQuery("#widget-div").length, 1, "test if the div has been added correctly"); |
|
|
33 |
equal(IriSP.jQuery("#widget-div").children().length, this.ser._data.annotations.length, "test if children have been added correctly"); |
|
100
|
34 |
}); |
|
|
35 |
|
|
104
|
36 |
test("test click on a random segment", function() { |
|
|
37 |
var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser); |
|
100
|
38 |
widget.draw(); |
|
104
|
39 |
|
|
|
40 |
var spy_callback = this.spy(); |
|
|
41 |
var spy_handler = sinon.spy(widget, "clickHandler"); |
|
|
42 |
this.Popcorn.listen("timeupdate", spy_callback); |
|
|
43 |
|
|
164
|
44 |
var selector = IriSP.jQuery("#widget-div :not(first-child)"); |
|
157
|
45 |
var random = Math.round(Math.random() * selector.length) + 1; |
|
104
|
46 |
selector.eq(random).click(); |
|
|
47 |
|
|
|
48 |
ok(spy_callback.called, "the currenttime was changed"); |
|
|
49 |
ok(spy_handler.called, "handling function has been called"); |
|
100
|
50 |
}); |
|
157
|
51 |
|
|
|
52 |
test("test search highlight features", function() { |
|
|
53 |
|
|
|
54 |
var tag_id = "#s_" + "82613B88-9578-DC2C-D7D0-B2C5BE0B7BDA".toUpperCase(); |
|
|
55 |
|
|
|
56 |
var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser); |
|
|
57 |
widget.draw(); |
|
|
58 |
|
|
164
|
59 |
var oldStyle = IriSP.jQuery("#widget-div").children(tag_id).attr("style"); |
|
157
|
60 |
widget._Popcorn.trigger("IriSP.search", "sociologie"); |
|
164
|
61 |
var newStyle = IriSP.jQuery("#widget-div").children(tag_id).attr("style"); |
|
157
|
62 |
notEqual(oldStyle, newStyle, "the segment style has been modified"); |
|
|
63 |
}); |
|
100
|
64 |
}; |