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