Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
70889c36
Commit
70889c36
authored
Jun 10, 2013
by
Anton Stupak
Committed by
Vasyl Nakvasiuk
Jun 18, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for Event Logger
parent
499c682d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
23 deletions
+55
-23
common/lib/xmodule/xmodule/js/spec/videoalpha/display/video_caption_spec.coffee
+2
-3
common/lib/xmodule/xmodule/js/spec/videoalpha/display/video_player_spec.coffee
+41
-5
common/lib/xmodule/xmodule/js/spec/videoalpha/display/video_progress_slider_spec.coffee
+6
-10
common/lib/xmodule/xmodule/js/spec/videoalpha/display_spec.coffee
+5
-4
common/lib/xmodule/xmodule/js/src/videoalpha/display/video_progress_slider.coffee
+1
-1
No files found.
common/lib/xmodule/xmodule/js/spec/videoalpha/display/video_caption_spec.coffee
View file @
70889c36
...
...
@@ -316,7 +316,6 @@ describe 'VideoCaptionAlpha', ->
beforeEach
->
@
player
=
jasmine
.
stubVideoPlayerAlpha
@
@
caption
=
@
player
.
caption
@
time
=
null
$
(
@
caption
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
describe
'when the video speed is 1.0x'
,
->
...
...
@@ -325,7 +324,7 @@ describe 'VideoCaptionAlpha', ->
$
(
'.subtitles li[data-start="30000"]'
).
trigger
(
'click'
)
it
'trigger seek event with the correct time'
,
->
expect
(
@
t
ime
).
toEqual
30.000
expect
(
@
player
.
currentT
ime
).
toEqual
30.000
describe
'when the video speed is not 1.0x'
,
->
beforeEach
->
...
...
@@ -333,7 +332,7 @@ describe 'VideoCaptionAlpha', ->
$
(
'.subtitles li[data-start="30000"]'
).
trigger
(
'click'
)
it
'trigger seek event with the correct time'
,
->
expect
(
@
t
ime
).
toEqual
40.000
expect
(
@
player
.
currentT
ime
).
toEqual
40.000
describe
'toggle'
,
->
beforeEach
->
...
...
common/lib/xmodule/xmodule/js/spec/videoalpha/display/video_player_spec.coffee
View file @
70889c36
...
...
@@ -67,13 +67,13 @@ describe 'VideoPlayerAlpha', ->
expect
(
$
(
@
player
.
control
)).
toHandleWith
'pause'
,
@
player
.
pause
it
'bind to video caption seek event'
,
->
expect
(
$
(
@
player
.
caption
)).
toHandleWith
'seek'
,
@
player
.
onSeek
expect
(
$
(
@
player
.
caption
)).
toHandleWith
'
caption_
seek'
,
@
player
.
onSeek
it
'bind to video speed control speedChange event'
,
->
expect
(
$
(
@
player
.
speedControl
)).
toHandleWith
'speedChange'
,
@
player
.
onSpeedChange
it
'bind to video progress slider seek event'
,
->
expect
(
$
(
@
player
.
progressSlider
)).
toHandleWith
'seek'
,
@
player
.
onSeek
expect
(
$
(
@
player
.
progressSlider
)).
toHandleWith
's
lide_s
eek'
,
@
player
.
onSeek
it
'bind to video volume control volumeChange event'
,
->
expect
(
$
(
@
player
.
volumeControl
)).
toHandleWith
'volumeChange'
,
@
player
.
onVolumeChange
...
...
@@ -145,6 +145,7 @@ describe 'VideoPlayerAlpha', ->
describe
'onReady'
,
->
beforeEach
->
jasmine
.
stubVideoPlayerAlpha
@
,
[],
false
spyOn
@
video
,
'log'
$
(
'.video'
).
append
$
(
'<div class="add-fullscreen" /><div class="hide-subtitles" />'
)
@
video
.
embed
()
@
player
=
@
video
.
player
...
...
@@ -152,6 +153,9 @@ describe 'VideoPlayerAlpha', ->
spyOnEvent
@
player
,
'updatePlayTime'
@
player
.
onReady
()
it
'log the load_video event'
,
->
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'load_video'
describe
'when not on a touch based device'
,
->
beforeEach
->
spyOn
@
player
,
'play'
...
...
@@ -201,7 +205,7 @@ describe 'VideoPlayerAlpha', ->
@
player
.
onStateChange
data
:
YT
.
PlayerState
.
PLAYING
it
'log the play_video event'
,
->
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'play_video'
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'play_video'
,
{
currentTime
:
0
}
it
'pause other video player'
,
->
expect
(
@
anotherPlayer
.
onPause
).
toHaveBeenCalled
()
...
...
@@ -234,7 +238,7 @@ describe 'VideoPlayerAlpha', ->
@
player
.
onStateChange
data
:
YT
.
PlayerState
.
PAUSED
it
'log the pause_video event'
,
->
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'pause_video'
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'pause_video'
,
{
currentTime
:
0
}
it
'clear update interval'
,
->
expect
(
window
.
clearInterval
).
toHaveBeenCalledWith
100
...
...
@@ -260,6 +264,16 @@ describe 'VideoPlayerAlpha', ->
expect
(
@
player
.
caption
.
pause
).
toHaveBeenCalled
()
describe
'onSeek'
,
->
conf
=
[{
desc
:
'check if seek_video is logged with slide_seek type'
,
type
:
'slide_seek'
,
obj
:
'progressSlider'
},{
desc
:
'check if seek_video is logged with caption_seek type'
,
type
:
'caption_seek'
,
obj
:
'caption'
}]
beforeEach
->
jasmine
.
stubVideoPlayerAlpha
@
,
[],
false
$
(
'.video'
).
append
$
(
'<div class="add-fullscreen" /><div class="hide-subtitles" />'
)
...
...
@@ -267,16 +281,30 @@ describe 'VideoPlayerAlpha', ->
spyOn
window
,
'clearInterval'
@
player
.
player
.
interval
=
100
spyOn
@
player
,
'updatePlayTime'
@
player
.
onSeek
{},
60
spyOn
@
video
,
'log'
$
.
each
conf
,
(
key
,
value
)
->
it
value
.
desc
,
->
type
=
value
.
type
old_time
=
0
new_time
=
60
$
(
@
player
[
value
.
obj
]).
trigger
value
.
type
,
new_time
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'seek_video'
,
old_time
:
old_time
new_time
:
new_time
type
:
value
.
type
it
'seek the player'
,
->
$
(
@
player
.
progressSlider
).
trigger
'slide_seek'
,
60
expect
(
@
player
.
player
.
seekTo
).
toHaveBeenCalledWith
60
,
true
it
'call updatePlayTime on player'
,
->
$
(
@
player
.
progressSlider
).
trigger
'slide_seek'
,
60
expect
(
@
player
.
updatePlayTime
).
toHaveBeenCalledWith
60
describe
'when the player is playing'
,
->
beforeEach
->
$
(
@
player
.
progressSlider
).
trigger
'slide_seek'
,
60
@
player
.
player
.
getPlayerState
.
andReturn
YT
.
PlayerState
.
PLAYING
@
player
.
onSeek
{},
60
...
...
@@ -285,6 +313,7 @@ describe 'VideoPlayerAlpha', ->
describe
'when the player is not playing'
,
->
beforeEach
->
$
(
@
player
.
progressSlider
).
trigger
'slide_seek'
,
60
@
player
.
player
.
getPlayerState
.
andReturn
YT
.
PlayerState
.
PAUSED
@
player
.
onSeek
{},
60
...
...
@@ -299,11 +328,18 @@ describe 'VideoPlayerAlpha', ->
@
player
.
currentTime
=
60
spyOn
@
player
,
'updatePlayTime'
spyOn
(
@
video
,
'setSpeed'
).
andCallThrough
()
spyOn
(
@
video
,
'log'
)
describe
'always'
,
->
beforeEach
->
@
player
.
onSpeedChange
{},
'0.75'
,
false
it
'check if speed_change_video is logged'
,
->
expect
(
@
video
.
log
).
toHaveBeenCalledWith
'speed_change_video'
,
currentTime
:
@
player
.
currentTime
old_speed
:
'1.0'
new_speed
:
'0.75'
it
'convert the current time to the new speed'
,
->
expect
(
@
player
.
currentTime
).
toEqual
'80.000'
...
...
common/lib/xmodule/xmodule/js/spec/videoalpha/display/video_progress_slider_spec.coffee
View file @
70889c36
...
...
@@ -114,9 +114,7 @@ describe 'VideoProgressSliderAlpha', ->
beforeEach
->
@
player
=
jasmine
.
stubVideoPlayerAlpha
@
@
progressSlider
=
@
player
.
progressSlider
@
time
=
null
$
(
@
progressSlider
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
spyOnEvent
@
progressSlider
,
'seek'
spyOnEvent
@
progressSlider
,
'slide_seek'
@
progressSlider
.
onSlide
{},
value
:
20
it
'freeze the slider'
,
->
...
...
@@ -126,8 +124,8 @@ describe 'VideoProgressSliderAlpha', ->
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalled
()
it
'trigger seek event'
,
->
expect
(
'seek'
).
toHaveBeenTriggeredOn
@
progressSlider
expect
(
@
t
ime
).
toEqual
20
expect
(
's
lide_s
eek'
).
toHaveBeenTriggeredOn
@
progressSlider
expect
(
@
player
.
currentT
ime
).
toEqual
20
describe
'onChange'
,
->
beforeEach
->
...
...
@@ -142,17 +140,15 @@ describe 'VideoProgressSliderAlpha', ->
beforeEach
->
@
player
=
jasmine
.
stubVideoPlayerAlpha
@
@
progressSlider
=
@
player
.
progressSlider
@
time
=
null
$
(
@
progressSlider
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
spyOnEvent
@
progressSlider
,
'seek'
spyOnEvent
@
progressSlider
,
'slide_seek'
@
progressSlider
.
onStop
{},
value
:
20
it
'freeze the slider'
,
->
expect
(
@
progressSlider
.
frozen
).
toBeTruthy
()
it
'trigger seek event'
,
->
expect
(
'seek'
).
toHaveBeenTriggeredOn
@
progressSlider
expect
(
@
t
ime
).
toEqual
20
expect
(
's
lide_s
eek'
).
toHaveBeenTriggeredOn
@
progressSlider
expect
(
@
player
.
currentT
ime
).
toEqual
20
it
'set timeout to unfreeze the slider'
,
->
expect
(
window
.
setTimeout
).
toHaveBeenCalledWith
jasmine
.
any
(
Function
),
200
...
...
common/lib/xmodule/xmodule/js/spec/videoalpha/display_spec.coffee
View file @
70889c36
...
...
@@ -272,12 +272,13 @@ describe 'VideoAlpha', ->
beforeEach
->
loadFixtures
'videoalpha.html'
@
video
=
new
VideoAlpha
'#example'
,
@
videosDefinition
@
video
.
setSpeed
'1.0'
spyOn
Logger
,
'log'
@
video
.
player
=
{
currentTime
:
25
}
@
video
.
log
'someEvent'
@
video
.
log
'someEvent'
,
{
currentTime
:
25
,
speed
:
'1.0'
}
it
'call the logger with valid parameters'
,
->
it
'call the logger with valid
extra
parameters'
,
->
expect
(
Logger
.
log
).
toHaveBeenCalledWith
'someEvent'
,
id
:
'id'
code
:
@
normalSpeedYoutubeId
...
...
common/lib/xmodule/xmodule/js/src/videoalpha/display/video_progress_slider.coffee
View file @
70889c36
...
...
@@ -43,7 +43,7 @@ class @VideoProgressSliderAlpha extends SubviewAlpha
onStop
:
(
event
,
ui
)
=>
@
frozen
=
true
$
(
@
).
trigger
(
'seek'
,
ui
.
value
)
$
(
@
).
trigger
(
's
lide_s
eek'
,
ui
.
value
)
setTimeout
(
=>
@
frozen
=
false
),
200
updateTooltip
:
(
value
)
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment