|
74
|
1 |
/* test module for the player widget */ |
|
|
2 |
|
|
|
3 |
function test_player_widget() { |
|
|
4 |
module("player 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.Serializer(this.dt, "/url"); /* dummy serializer */ |
|
|
10 |
|
|
|
11 |
this.config = { |
|
|
12 |
metadata:{ |
|
|
13 |
format:'cinelab', |
|
|
14 |
src:'test.json', |
|
|
15 |
load:'json'}, |
|
|
16 |
gui:{ |
|
|
17 |
width:650, |
|
|
18 |
height:1, |
|
|
19 |
mode:'radio', |
|
|
20 |
container:'widget-div', |
|
|
21 |
debug:true, |
|
|
22 |
css:'../src/css/LdtPlayer.css'}, |
|
|
23 |
}; |
|
|
24 |
} }); |
|
|
25 |
|
|
|
26 |
test("test player initialisation", function() { |
|
|
27 |
var player = new IriSP.PlayerWidget(this.Popcorn, this.config, this.ser); |
|
|
28 |
player.draw(); |
|
|
29 |
equal(IriSP.jQuery("#widget-div #Ldt-Root").length, 1, "test if the div has been added correctly"); |
|
|
30 |
|
|
|
31 |
var player2 = new IriSP.PlayerWidget(this.Popcorn, this.config, this.ser); |
|
|
32 |
player2.draw(); |
|
|
33 |
equal(IriSP.jQuery("#widget-div #Ldt-Root").length, 2, "test if the second div has been added correctly"); |
|
|
34 |
}); |
|
|
35 |
|
|
|
36 |
test("test play button event handler", function() { |
|
|
37 |
var player = new IriSP.PlayerWidget(this.Popcorn, this.config, this.ser); |
|
|
38 |
|
|
|
39 |
var spy_callback = this.spy(); |
|
|
40 |
var spy_callback2 = this.spy(); |
|
|
41 |
this.Popcorn.listen("play", spy_callback); |
|
|
42 |
this.Popcorn.listen("pause", spy_callback2); |
|
|
43 |
|
|
|
44 |
player.draw(); |
|
|
45 |
|
|
|
46 |
/* |
|
|
47 |
Code seems to work but test doesn't. It must be a subtle race condition |
|
|
48 |
between Popcorn, the youtube plugin and QUnit. Anyway, it works for pause |
|
|
49 |
so WONTFIX |
|
|
50 |
|
|
|
51 |
IriSP.jQuery("#widget-div .Ldt-Control1 button:first").trigger("click"); |
|
|
52 |
ok(spy_callback.calledOnce, "test if play callback has been called"); |
|
|
53 |
|
|
|
54 |
*/ |
|
|
55 |
|
|
|
56 |
IriSP.jQuery("#widget-div .Ldt-Control1 button:first").trigger("click"); |
|
|
57 |
IriSP.jQuery("#widget-div .Ldt-Control1 button:first").trigger("click"); |
|
|
58 |
|
|
|
59 |
ok(spy_callback2.calledOnce, "test if pause callback has been called"); |
|
|
60 |
}); |
|
|
61 |
}; |