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
7eb18fe0
Commit
7eb18fe0
authored
May 27, 2013
by
Anton Stupak
Committed by
Vasyl Nakvasiuk
Jun 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds test files for video
parent
5ff9f3be
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
213 additions
and
163 deletions
+213
-163
common/lib/xmodule/xmodule/js/fixtures/video.html
+12
-2
common/lib/xmodule/xmodule/js/spec/helper.coffee
+3
-7
common/lib/xmodule/xmodule/js/spec/video/display/video_caption_spec.coffee
+54
-28
common/lib/xmodule/xmodule/js/spec/video/display/video_control_spec.coffee
+20
-27
common/lib/xmodule/xmodule/js/spec/video/display/video_player_spec.coffee
+34
-19
common/lib/xmodule/xmodule/js/spec/video/display/video_progress_slider_spec.coffee
+58
-50
common/lib/xmodule/xmodule/js/spec/video/display/video_speed_control_spec.coffee
+3
-4
common/lib/xmodule/xmodule/js/spec/video/display/video_volume_control_spec.coffee
+1
-2
common/lib/xmodule/xmodule/js/spec/video/display_spec.coffee
+26
-22
common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
+1
-1
common/lib/xmodule/xmodule/js/src/video/display/video_progress_slider.coffee
+1
-1
No files found.
common/lib/xmodule/xmodule/js/fixtures/video.html
View file @
7eb18fe0
<div
class=
"course-content"
>
<div
class=
"course-content"
>
<div
id=
"video_example"
class=
"video"
>
<div
id=
"video_example"
>
<div
id=
"example"
>
<div
id=
"video_id"
class=
"video"
data-streams=
"0.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId"
data-show-captions=
"true"
data-start=
""
data-end=
""
data-caption-asset-path=
"/static/subs/"
>
<div
class=
"tc-wrapper"
>
<div
class=
"tc-wrapper"
>
<article
class=
"video-wrapper"
>
<article
class=
"video-wrapper"
>
<section
class=
"video-player"
>
<section
class=
"video-player"
>
<div
id=
"example
"
></div>
<div
id=
"id
"
></div>
</section>
</section>
<section
class=
"video-controls"
></section>
<section
class=
"video-controls"
></section>
</article>
</article>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
common/lib/xmodule/xmodule/js/spec/helper.coffee
View file @
7eb18fe0
...
@@ -28,7 +28,7 @@ jasmine.stubRequests = ->
...
@@ -28,7 +28,7 @@ jasmine.stubRequests = ->
spyOn
(
$
,
'ajax'
).
andCallFake
(
settings
)
->
spyOn
(
$
,
'ajax'
).
andCallFake
(
settings
)
->
if
match
=
settings
.
url
.
match
/youtube\.com\/.+\/videos\/(.+)\?v=2&alt=jsonc/
if
match
=
settings
.
url
.
match
/youtube\.com\/.+\/videos\/(.+)\?v=2&alt=jsonc/
settings
.
success
data
:
jasmine
.
stubbedMetadata
[
match
[
1
]]
settings
.
success
data
:
jasmine
.
stubbedMetadata
[
match
[
1
]]
else
if
match
=
settings
.
url
.
match
/static\/subs\/(.+)\.srt\.sjson/
else
if
match
=
settings
.
url
.
match
/static
(\/.*)?
\/subs\/(.+)\.srt\.sjson/
settings
.
success
jasmine
.
stubbedCaption
settings
.
success
jasmine
.
stubbedCaption
else
if
settings
.
url
.
match
/.+\/problem_get$/
else
if
settings
.
url
.
match
/.+\/problem_get$/
settings
.
success
html
:
readFixtures
(
'problem_content.html'
)
settings
.
success
html
:
readFixtures
(
'problem_content.html'
)
...
@@ -47,19 +47,15 @@ jasmine.stubYoutubePlayer = ->
...
@@ -47,19 +47,15 @@ jasmine.stubYoutubePlayer = ->
jasmine
.
stubVideoPlayer
=
(
context
,
enableParts
,
createPlayer
=
true
)
->
jasmine
.
stubVideoPlayer
=
(
context
,
enableParts
,
createPlayer
=
true
)
->
enableParts
=
[
enableParts
]
unless
$
.
isArray
(
enableParts
)
enableParts
=
[
enableParts
]
unless
$
.
isArray
(
enableParts
)
suite
=
context
.
suite
suite
=
context
.
suite
currentPartName
=
suite
.
description
while
suite
=
suite
.
parentSuite
currentPartName
=
suite
.
description
while
suite
=
suite
.
parentSuite
enableParts
.
push
currentPartName
enableParts
.
push
currentPartName
for
part
in
[
'VideoCaption'
,
'VideoSpeedControl'
,
'VideoVolumeControl'
,
'VideoProgressSlider'
]
unless
$
.
inArray
(
part
,
enableParts
)
>=
0
spyOn
window
,
part
loadFixtures
'video.html'
loadFixtures
'video.html'
jasmine
.
stubRequests
()
jasmine
.
stubRequests
()
YT
.
Player
=
undefined
YT
.
Player
=
undefined
context
.
video
=
new
Video
'example'
,
'.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
videosDefinition
=
'0.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
context
.
video
=
new
Video
'#example'
,
videosDefinition
jasmine
.
stubYoutubePlayer
()
jasmine
.
stubYoutubePlayer
()
if
createPlayer
if
createPlayer
return
new
VideoPlayer
(
video
:
context
.
video
)
return
new
VideoPlayer
(
video
:
context
.
video
)
...
...
common/lib/xmodule/xmodule/js/spec/video/display/video_caption_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'VideoCaption'
,
->
xdescribe
'VideoCaption'
,
->
beforeEach
->
beforeEach
->
jasmine
.
stubVideoPlayer
@
spyOn
(
VideoCaption
.
prototype
,
'fetchCaption'
).
andCallThrough
()
$
(
'.subtitles'
).
remove
()
spyOn
(
$
,
'ajaxWithPrefix'
).
andCallThrough
()
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
).
andReturn
false
afterEach
->
afterEach
->
YT
.
Player
=
undefined
YT
.
Player
=
undefined
$
.
fn
.
scrollTo
.
reset
()
$
.
fn
.
scrollTo
.
reset
()
$
(
'.subtitles'
).
remove
()
describe
'constructor'
,
->
describe
'constructor'
,
->
beforeEach
->
spyOn
(
$
,
'getWithPrefix'
).
andCallThrough
()
describe
'always'
,
->
describe
'always'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
it
'set the youtube id'
,
->
it
'set the youtube id'
,
->
expect
(
@
caption
.
youtubeId
).
toEqual
'
def456
'
expect
(
@
caption
.
youtubeId
).
toEqual
'
normalSpeedYoutubeId
'
it
'create the caption element'
,
->
it
'create the caption element'
,
->
expect
(
$
(
'.video'
)).
toContain
'ol.subtitles'
expect
(
$
(
'.video'
)).
toContain
'ol.subtitles'
...
@@ -26,7 +28,12 @@ xdescribe 'VideoCaption', ->
...
@@ -26,7 +28,12 @@ xdescribe 'VideoCaption', ->
expect
(
$
(
'.video'
)).
toContain
'a.hide-subtitles'
expect
(
$
(
'.video'
)).
toContain
'a.hide-subtitles'
it
'fetch the caption'
,
->
it
'fetch the caption'
,
->
expect
(
$
.
getWithPrefix
).
toHaveBeenCalledWith
@
caption
.
captionURL
(),
jasmine
.
any
(
Function
)
expect
(
@
caption
.
loaded
).
toBeTruthy
()
expect
(
@
caption
.
fetchCaption
).
toHaveBeenCalled
()
expect
(
$
.
ajaxWithPrefix
).
toHaveBeenCalledWith
url
:
@
caption
.
captionURL
()
notifyOnError
:
false
success
:
jasmine
.
any
(
Function
)
it
'bind window resize event'
,
->
it
'bind window resize event'
,
->
expect
(
$
(
window
)).
toHandleWith
'resize'
,
@
caption
.
resize
expect
(
$
(
window
)).
toHandleWith
'resize'
,
@
caption
.
resize
...
@@ -42,9 +49,10 @@ xdescribe 'VideoCaption', ->
...
@@ -42,9 +49,10 @@ xdescribe 'VideoCaption', ->
expect
(
$
(
'.subtitles'
)).
toHandleWith
'DOMMouseScroll'
,
@
caption
.
onMovement
expect
(
$
(
'.subtitles'
)).
toHandleWith
'DOMMouseScroll'
,
@
caption
.
onMovement
describe
'when on a non touch-based device'
,
->
describe
'when on a non touch-based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
caption
=
@
player
.
caption
it
'render the caption'
,
->
it
'render the caption'
,
->
expect
(
$
(
'.subtitles'
).
html
()).
toMatch
new
RegExp
(
'''
expect
(
$
(
'.subtitles'
).
html
()).
toMatch
new
RegExp
(
'''
...
@@ -66,9 +74,11 @@ xdescribe 'VideoCaption', ->
...
@@ -66,9 +74,11 @@ xdescribe 'VideoCaption', ->
expect
(
@
caption
.
rendered
).
toBeTruthy
()
expect
(
@
caption
.
rendered
).
toBeTruthy
()
describe
'when on a touch-based device'
,
->
describe
'when on a touch-based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
true
window
.
onTouchBasedDevice
.
andReturn
true
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
it
'show explaination message'
,
->
it
'show explaination message'
,
->
expect
(
$
(
'.subtitles li'
)).
toHaveHtml
"Caption will be displayed when you start playing the video."
expect
(
$
(
'.subtitles li'
)).
toHaveHtml
"Caption will be displayed when you start playing the video."
...
@@ -77,12 +87,15 @@ xdescribe 'VideoCaption', ->
...
@@ -77,12 +87,15 @@ xdescribe 'VideoCaption', ->
expect
(
@
caption
.
rendered
).
toBeFalsy
()
expect
(
@
caption
.
rendered
).
toBeFalsy
()
describe
'mouse movement'
,
->
describe
'mouse movement'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'setTimeout'
).
andReturn
100
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
window
.
setTimeout
.
andReturn
(
100
)
spyOn
window
,
'clearTimeout'
spyOn
window
,
'clearTimeout'
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
describe
'when cursor is outside of the caption box'
,
->
describe
'when cursor is outside of the caption box'
,
->
beforeEach
->
beforeEach
->
$
(
window
).
trigger
jQuery
.
Event
'mousemove'
$
(
window
).
trigger
jQuery
.
Event
'mousemove'
...
@@ -90,6 +103,7 @@ xdescribe 'VideoCaption', ->
...
@@ -90,6 +103,7 @@ xdescribe 'VideoCaption', ->
expect
(
@
caption
.
frozen
).
toBeFalsy
()
expect
(
@
caption
.
frozen
).
toBeFalsy
()
describe
'when cursor is in the caption box'
,
->
describe
'when cursor is in the caption box'
,
->
beforeEach
->
beforeEach
->
$
(
'.subtitles'
).
trigger
jQuery
.
Event
'mouseenter'
$
(
'.subtitles'
).
trigger
jQuery
.
Event
'mouseenter'
...
@@ -143,8 +157,10 @@ xdescribe 'VideoCaption', ->
...
@@ -143,8 +157,10 @@ xdescribe 'VideoCaption', ->
expect
(
$
.
fn
.
scrollTo
).
not
.
toHaveBeenCalled
()
expect
(
$
.
fn
.
scrollTo
).
not
.
toHaveBeenCalled
()
describe
'search'
,
->
describe
'search'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
it
'return a correct caption index'
,
->
it
'return a correct caption index'
,
->
expect
(
@
caption
.
search
(
0
)).
toEqual
0
expect
(
@
caption
.
search
(
0
)).
toEqual
0
...
@@ -157,8 +173,9 @@ xdescribe 'VideoCaption', ->
...
@@ -157,8 +173,9 @@ xdescribe 'VideoCaption', ->
describe
'play'
,
->
describe
'play'
,
->
describe
'when the caption was not rendered'
,
->
describe
'when the caption was not rendered'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
true
window
.
onTouchBasedDevice
.
andReturn
true
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
@
caption
.
play
()
@
caption
.
play
()
it
'render the caption'
,
->
it
'render the caption'
,
->
...
@@ -185,7 +202,8 @@ xdescribe 'VideoCaption', ->
...
@@ -185,7 +202,8 @@ xdescribe 'VideoCaption', ->
describe
'pause'
,
->
describe
'pause'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
@
caption
.
playing
=
true
@
caption
.
playing
=
true
@
caption
.
pause
()
@
caption
.
pause
()
...
@@ -193,8 +211,10 @@ xdescribe 'VideoCaption', ->
...
@@ -193,8 +211,10 @@ xdescribe 'VideoCaption', ->
expect
(
@
caption
.
playing
).
toBeFalsy
()
expect
(
@
caption
.
playing
).
toBeFalsy
()
describe
'updatePlayTime'
,
->
describe
'updatePlayTime'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
describe
'when the video speed is 1.0x'
,
->
describe
'when the video speed is 1.0x'
,
->
beforeEach
->
beforeEach
->
...
@@ -240,13 +260,15 @@ xdescribe 'VideoCaption', ->
...
@@ -240,13 +260,15 @@ xdescribe 'VideoCaption', ->
expect
(
$
(
'.subtitles li[data-index=1]'
)).
toHaveClass
'current'
expect
(
$
(
'.subtitles li[data-index=1]'
)).
toHaveClass
'current'
describe
'resize'
,
->
describe
'resize'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
$
(
'.subtitles li[data-index=1]'
).
addClass
'current'
$
(
'.subtitles li[data-index=1]'
).
addClass
'current'
@
caption
.
resize
()
@
caption
.
resize
()
it
'set the height of caption container'
,
->
it
'set the height of caption container'
,
->
expect
(
parseInt
(
$
(
'.subtitles'
).
css
(
'maxHeight'
))).
to
Equal
$
(
'.video-wrapper'
).
height
()
expect
(
parseInt
(
$
(
'.subtitles'
).
css
(
'maxHeight'
))).
to
BeCloseTo
$
(
'.video-wrapper'
).
height
(),
5
it
'set the height of caption spacing'
,
->
it
'set the height of caption spacing'
,
->
expect
(
parseInt
(
$
(
'.subtitles .spacing:first'
).
css
(
'height'
))).
toEqual
(
expect
(
parseInt
(
$
(
'.subtitles .spacing:first'
).
css
(
'height'
))).
toEqual
(
...
@@ -258,8 +280,10 @@ xdescribe 'VideoCaption', ->
...
@@ -258,8 +280,10 @@ xdescribe 'VideoCaption', ->
expect
(
$
.
fn
.
scrollTo
).
toHaveBeenCalled
()
expect
(
$
.
fn
.
scrollTo
).
toHaveBeenCalled
()
describe
'scrollCaption'
,
->
describe
'scrollCaption'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
describe
'when frozen'
,
->
describe
'when frozen'
,
->
beforeEach
->
beforeEach
->
...
@@ -291,15 +315,17 @@ xdescribe 'VideoCaption', ->
...
@@ -291,15 +315,17 @@ xdescribe 'VideoCaption', ->
offset
:
-
(
$
(
'.video-wrapper'
).
height
()
/
2
-
$
(
'.subtitles .current:first'
).
height
()
/
2
)
offset
:
-
(
$
(
'.video-wrapper'
).
height
()
/
2
-
$
(
'.subtitles .current:first'
).
height
()
/
2
)
describe
'seekPlayer'
,
->
describe
'seekPlayer'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
@
time
=
null
@
time
=
null
$
(
@
caption
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
$
(
@
caption
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
describe
'when the video speed is 1.0x'
,
->
describe
'when the video speed is 1.0x'
,
->
beforeEach
->
beforeEach
->
@
caption
.
currentSpeed
=
'1.0'
@
caption
.
currentSpeed
=
'1.0'
$
(
'.subtitles li[data-start="30000"]'
).
click
(
)
$
(
'.subtitles li[data-start="30000"]'
).
trigger
(
'click'
)
it
'trigger seek event with the correct time'
,
->
it
'trigger seek event with the correct time'
,
->
expect
(
@
time
).
toEqual
30.000
expect
(
@
time
).
toEqual
30.000
...
@@ -307,14 +333,15 @@ xdescribe 'VideoCaption', ->
...
@@ -307,14 +333,15 @@ xdescribe 'VideoCaption', ->
describe
'when the video speed is not 1.0x'
,
->
describe
'when the video speed is not 1.0x'
,
->
beforeEach
->
beforeEach
->
@
caption
.
currentSpeed
=
'0.75'
@
caption
.
currentSpeed
=
'0.75'
$
(
'.subtitles li[data-start="30000"]'
).
click
(
)
$
(
'.subtitles li[data-start="30000"]'
).
trigger
(
'click'
)
it
'trigger seek event with the correct time'
,
->
it
'trigger seek event with the correct time'
,
->
expect
(
@
time
).
toEqual
40.000
expect
(
@
time
).
toEqual
40.000
describe
'toggle'
,
->
describe
'toggle'
,
->
beforeEach
->
beforeEach
->
@
caption
=
new
VideoCaption
el
:
$
(
'.video'
),
youtubeId
:
'def456'
,
currentSpeed
:
'1.0'
@
player
=
jasmine
.
stubVideoPlayer
@
@
caption
=
@
player
.
caption
$
(
'.subtitles li[data-index=1]'
).
addClass
'current'
$
(
'.subtitles li[data-index=1]'
).
addClass
'current'
describe
'when the caption is visible'
,
->
describe
'when the caption is visible'
,
->
...
@@ -325,7 +352,6 @@ xdescribe 'VideoCaption', ->
...
@@ -325,7 +352,6 @@ xdescribe 'VideoCaption', ->
it
'hide the caption'
,
->
it
'hide the caption'
,
->
expect
(
@
caption
.
el
).
toHaveClass
'closed'
expect
(
@
caption
.
el
).
toHaveClass
'closed'
describe
'when the caption is hidden'
,
->
describe
'when the caption is hidden'
,
->
beforeEach
->
beforeEach
->
@
caption
.
el
.
addClass
'closed'
@
caption
.
el
.
addClass
'closed'
...
...
common/lib/xmodule/xmodule/js/spec/video/display/video_control_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'VideoControl'
,
->
xdescribe
'VideoControl'
,
->
beforeEach
->
beforeEach
->
jasmine
.
stubVideoPlayer
@
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
).
andReturn
false
loadFixtures
'video.html'
$
(
'.video-controls'
).
html
''
$
(
'.video-controls'
).
html
''
describe
'constructor'
,
->
describe
'constructor'
,
->
it
'render the video controls'
,
->
it
'render the video controls'
,
->
new
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
expect
(
$
(
'.video-controls'
).
html
()).
toContain
'''
expect
(
$
(
'.video-controls'
)).
toContain
<div class="slider"></div>
[
'.slider'
,
'ul.vcr'
,
'a.play'
,
'.vidtime'
,
'.add-fullscreen'
].
join
(
','
)
<div>
expect
(
$
(
'.video-controls'
).
find
(
'.vidtime'
)).
toHaveText
'0:00 / 0:00'
<ul class="vcr">
<li><a class="video_control play" href="#">Play</a></li>
<li>
<div class="vidtime">0:00 / 0:00</div>
</li>
</ul>
<div class="secondary-controls">
<a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
</div>
</div>
'''
it
'bind the playback button'
,
->
it
'bind the playback button'
,
->
control
=
new
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
expect
(
$
(
'.video_control'
)).
toHandleWith
'click'
,
control
.
togglePlayback
expect
(
$
(
'.video_control'
)).
toHandleWith
'click'
,
@
control
.
togglePlayback
describe
'when on a touch based device'
,
->
describe
'when on a touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
true
window
.
onTouchBasedDevice
.
andReturn
true
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
it
'does not add the play class to video control'
,
->
it
'does not add the play class to video control'
,
->
new
VideoControl
(
el
:
$
(
'.video-controls'
))
expect
(
$
(
'.video_control'
)).
not
.
toHaveClass
'play'
expect
(
$
(
'.video_control'
)).
not
.
toHaveClass
'play'
expect
(
$
(
'.video_control'
)).
not
.
toHaveHtml
'Play'
expect
(
$
(
'.video_control'
)).
not
.
toHaveHtml
'Play'
describe
'when on a non-touch based device'
,
->
describe
'when on a non-touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
it
'add the play class to video control'
,
->
it
'add the play class to video control'
,
->
new
VideoControl
(
el
:
$
(
'.video-controls'
))
expect
(
$
(
'.video_control'
)).
toHaveClass
'play'
expect
(
$
(
'.video_control'
)).
toHaveClass
'play'
expect
(
$
(
'.video_control'
)).
toHaveHtml
'Play'
expect
(
$
(
'.video_control'
)).
toHaveHtml
'Play'
describe
'play'
,
->
describe
'play'
,
->
beforeEach
->
beforeEach
->
@
control
=
new
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
.
play
()
@
control
.
play
()
it
'switch playback button to play state'
,
->
it
'switch playback button to play state'
,
->
...
@@ -56,8 +47,9 @@ xdescribe 'VideoControl', ->
...
@@ -56,8 +47,9 @@ xdescribe 'VideoControl', ->
expect
(
$
(
'.video_control'
)).
toHaveHtml
'Pause'
expect
(
$
(
'.video_control'
)).
toHaveHtml
'Pause'
describe
'pause'
,
->
describe
'pause'
,
->
beforeEach
->
beforeEach
->
@
control
=
new
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
.
pause
()
@
control
.
pause
()
it
'switch playback button to pause state'
,
->
it
'switch playback button to pause state'
,
->
...
@@ -66,8 +58,9 @@ xdescribe 'VideoControl', ->
...
@@ -66,8 +58,9 @@ xdescribe 'VideoControl', ->
expect
(
$
(
'.video_control'
)).
toHaveHtml
'Play'
expect
(
$
(
'.video_control'
)).
toHaveHtml
'Play'
describe
'togglePlayback'
,
->
describe
'togglePlayback'
,
->
beforeEach
->
beforeEach
->
@
control
=
new
VideoControl
(
el
:
$
(
'.video-controls'
))
@
control
=
new
window
.
VideoControl
(
el
:
$
(
'.video-controls'
))
describe
'when the control does not have play or pause class'
,
->
describe
'when the control does not have play or pause class'
,
->
beforeEach
->
beforeEach
->
...
...
common/lib/xmodule/xmodule/js/spec/video/display/video_player_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'VideoPlayer'
,
->
xdescribe
'VideoPlayer'
,
->
beforeEach
->
beforeEach
->
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
).
andReturn
false
# It tries to call methods of VideoProgressSlider on Spy
for
part
in
[
'VideoCaption'
,
'VideoSpeedControl'
,
'VideoVolumeControl'
,
'VideoProgressSlider'
,
'VideoControl'
]
spyOn
(
window
[
part
].
prototype
,
'initialize'
).
andCallThrough
()
jasmine
.
stubVideoPlayer
@
,
[],
false
jasmine
.
stubVideoPlayer
@
,
[],
false
afterEach
->
afterEach
->
...
@@ -8,7 +11,6 @@ xdescribe 'VideoPlayer', ->
...
@@ -8,7 +11,6 @@ xdescribe 'VideoPlayer', ->
describe
'constructor'
,
->
describe
'constructor'
,
->
beforeEach
->
beforeEach
->
spyOn
window
,
'VideoControl'
spyOn
YT
,
'Player'
spyOn
YT
,
'Player'
$
.
fn
.
qtip
.
andCallFake
->
$
.
fn
.
qtip
.
andCallFake
->
$
(
this
).
data
(
'qtip'
,
true
)
$
(
this
).
data
(
'qtip'
,
true
)
...
@@ -22,32 +24,47 @@ xdescribe 'VideoPlayer', ->
...
@@ -22,32 +24,47 @@ xdescribe 'VideoPlayer', ->
expect
(
@
player
.
currentTime
).
toEqual
0
expect
(
@
player
.
currentTime
).
toEqual
0
it
'set the element'
,
->
it
'set the element'
,
->
expect
(
@
player
.
el
).
to
Be
'#video_example
'
expect
(
@
player
.
el
).
to
HaveId
'video_id
'
it
'create video control'
,
->
it
'create video control'
,
->
expect
(
window
.
VideoControl
).
toHaveBeenCalledWith
el
:
$
(
'.video-controls'
,
@
player
.
el
)
expect
(
window
.
VideoControl
.
prototype
.
initialize
).
toHaveBeenCalled
()
expect
(
@
player
.
control
).
toBeDefined
()
expect
(
@
player
.
control
.
el
).
toBe
$
(
'.video-controls'
,
@
player
.
el
)
it
'create video caption'
,
->
it
'create video caption'
,
->
expect
(
window
.
VideoCaption
).
toHaveBeenCalledWith
el
:
@
player
.
el
,
youtubeId
:
'normalSpeedYoutubeId'
,
currentSpeed
:
'1.0'
expect
(
window
.
VideoCaption
.
prototype
.
initialize
).
toHaveBeenCalled
()
expect
(
@
player
.
caption
).
toBeDefined
()
expect
(
@
player
.
caption
.
el
).
toBe
@
player
.
el
expect
(
@
player
.
caption
.
youtubeId
).
toEqual
'normalSpeedYoutubeId'
expect
(
@
player
.
caption
.
currentSpeed
).
toEqual
'1.0'
expect
(
@
player
.
caption
.
captionAssetPath
).
toEqual
'/static/subs/'
it
'create video speed control'
,
->
it
'create video speed control'
,
->
expect
(
window
.
VideoSpeedControl
).
toHaveBeenCalledWith
el
:
$
(
'.secondary-controls'
,
@
player
.
el
),
speeds
:
[
'0.75'
,
'1.0'
],
currentSpeed
:
'1.0'
expect
(
window
.
VideoSpeedControl
.
prototype
.
initialize
).
toHaveBeenCalled
()
expect
(
@
player
.
speedControl
).
toBeDefined
()
expect
(
@
player
.
speedControl
.
el
).
toBe
$
(
'.secondary-controls'
,
@
player
.
el
)
expect
(
@
player
.
speedControl
.
speeds
).
toEqual
[
'0.75'
,
'1.0'
]
expect
(
@
player
.
speedControl
.
currentSpeed
).
toEqual
'1.0'
it
'create video progress slider'
,
->
it
'create video progress slider'
,
->
expect
(
window
.
VideoProgressSlider
).
toHaveBeenCalledWith
el
:
$
(
'.slider'
,
@
player
.
el
)
expect
(
window
.
VideoSpeedControl
.
prototype
.
initialize
).
toHaveBeenCalled
()
expect
(
@
player
.
progressSlider
).
toBeDefined
()
expect
(
@
player
.
progressSlider
.
el
).
toBe
$
(
'.slider'
,
@
player
.
el
)
it
'create Youtube player'
,
->
it
'create Youtube player'
,
->
expect
(
YT
.
Player
).
toHaveBeenCalledWith
(
'
example
'
,
{
expect
(
YT
.
Player
).
toHaveBeenCalledWith
(
'
id
'
,
{
playerVars
:
playerVars
:
controls
:
0
controls
:
0
wmode
:
'transparent'
wmode
:
'transparent'
rel
:
0
rel
:
0
showinfo
:
0
showinfo
:
0
enablejsapi
:
1
enablejsapi
:
1
modestbranding
:
1
videoId
:
'normalSpeedYoutubeId'
videoId
:
'normalSpeedYoutubeId'
events
:
events
:
onReady
:
@
player
.
onReady
onReady
:
@
player
.
onReady
onStateChange
:
@
player
.
onStateChange
onStateChange
:
@
player
.
onStateChange
onPlaybackQualityChange
:
@
player
.
onPlaybackQualityChange
})
})
it
'bind to video control play event'
,
->
it
'bind to video control play event'
,
->
...
@@ -76,7 +93,6 @@ xdescribe 'VideoPlayer', ->
...
@@ -76,7 +93,6 @@ xdescribe 'VideoPlayer', ->
describe
'when not on a touch based device'
,
->
describe
'when not on a touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
$
(
'.add-fullscreen, .hide-subtitles'
).
removeData
'qtip'
$
(
'.add-fullscreen, .hide-subtitles'
).
removeData
'qtip'
@
player
=
new
VideoPlayer
video
:
@
video
@
player
=
new
VideoPlayer
video
:
@
video
...
@@ -85,11 +101,13 @@ xdescribe 'VideoPlayer', ->
...
@@ -85,11 +101,13 @@ xdescribe 'VideoPlayer', ->
expect
(
$
(
'.hide-subtitles'
)).
toHaveData
'qtip'
expect
(
$
(
'.hide-subtitles'
)).
toHaveData
'qtip'
it
'create video volume control'
,
->
it
'create video volume control'
,
->
expect
(
window
.
VideoVolumeControl
).
toHaveBeenCalledWith
el
:
$
(
'.secondary-controls'
,
@
player
.
el
)
expect
(
window
.
VideoVolumeControl
.
prototype
.
initialize
).
toHaveBeenCalled
()
expect
(
@
player
.
volumeControl
).
toBeDefined
()
expect
(
@
player
.
volumeControl
.
el
).
toBe
$
(
'.secondary-controls'
,
@
player
.
el
)
describe
'when on a touch based device'
,
->
describe
'when on a touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
)
.
andReturn
true
window
.
onTouchBasedDevice
.
andReturn
true
$
(
'.add-fullscreen, .hide-subtitles'
).
removeData
'qtip'
$
(
'.add-fullscreen, .hide-subtitles'
).
removeData
'qtip'
@
player
=
new
VideoPlayer
video
:
@
video
@
player
=
new
VideoPlayer
video
:
@
video
...
@@ -98,7 +116,8 @@ xdescribe 'VideoPlayer', ->
...
@@ -98,7 +116,8 @@ xdescribe 'VideoPlayer', ->
expect
(
$
(
'.hide-subtitles'
)).
not
.
toHaveData
'qtip'
expect
(
$
(
'.hide-subtitles'
)).
not
.
toHaveData
'qtip'
it
'does not create video volume control'
,
->
it
'does not create video volume control'
,
->
expect
(
window
.
VideoVolumeControl
).
not
.
toHaveBeenCalled
()
expect
(
window
.
VideoVolumeControl
.
prototype
.
initialize
).
not
.
toHaveBeenCalled
()
expect
(
@
player
.
volumeControl
).
not
.
toBeDefined
()
describe
'onReady'
,
->
describe
'onReady'
,
->
beforeEach
->
beforeEach
->
...
@@ -110,7 +129,6 @@ xdescribe 'VideoPlayer', ->
...
@@ -110,7 +129,6 @@ xdescribe 'VideoPlayer', ->
describe
'when not on a touch based device'
,
->
describe
'when not on a touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
spyOn
@
player
,
'play'
spyOn
@
player
,
'play'
@
player
.
onReady
()
@
player
.
onReady
()
...
@@ -119,7 +137,7 @@ xdescribe 'VideoPlayer', ->
...
@@ -119,7 +137,7 @@ xdescribe 'VideoPlayer', ->
describe
'when on a touch based device'
,
->
describe
'when on a touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
)
.
andReturn
true
window
.
onTouchBasedDevice
.
andReturn
true
spyOn
@
player
,
'play'
spyOn
@
player
,
'play'
@
player
.
onReady
()
@
player
.
onReady
()
...
@@ -347,9 +365,6 @@ xdescribe 'VideoPlayer', ->
...
@@ -347,9 +365,6 @@ xdescribe 'VideoPlayer', ->
it
'replace the full screen button tooltip'
,
->
it
'replace the full screen button tooltip'
,
->
expect
(
$
(
'.add-fullscreen'
)).
toHaveAttr
'title'
,
'Exit fill browser'
expect
(
$
(
'.add-fullscreen'
)).
toHaveAttr
'title'
,
'Exit fill browser'
it
'add a new exit from fullscreen button'
,
->
expect
(
@
player
.
el
).
toContain
'a.exit'
it
'add the fullscreen class'
,
->
it
'add the fullscreen class'
,
->
expect
(
@
player
.
el
).
toHaveClass
'fullscreen'
expect
(
@
player
.
el
).
toHaveClass
'fullscreen'
...
@@ -438,7 +453,7 @@ xdescribe 'VideoPlayer', ->
...
@@ -438,7 +453,7 @@ xdescribe 'VideoPlayer', ->
describe
'volume'
,
->
describe
'volume'
,
->
beforeEach
->
beforeEach
->
@
player
=
new
VideoPlayer
@
video
@
player
=
new
VideoPlayer
video
:
@
video
@
player
.
player
.
getVolume
.
andReturn
42
@
player
.
player
.
getVolume
.
andReturn
42
describe
'without value'
,
->
describe
'without value'
,
->
...
...
common/lib/xmodule/xmodule/js/spec/video/display/video_progress_slider_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'VideoProgressSlider'
,
->
xdescribe
'VideoProgressSlider'
,
->
beforeEach
->
beforeEach
->
jasmine
.
stubVideoPlayer
@
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
).
andReturn
false
describe
'constructor'
,
->
describe
'constructor'
,
->
describe
'on a non-touch based device'
,
->
describe
'on a non-touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
@
player
=
jasmine
.
stubVideoPlayer
@
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
progressSlider
=
@
player
.
progressSlider
it
'build the slider'
,
->
it
'build the slider'
,
->
expect
(
@
s
lider
.
slider
).
toBe
'.slider'
expect
(
@
progressS
lider
.
slider
).
toBe
'.slider'
expect
(
$
.
fn
.
slider
).
toHaveBeenCalledWith
expect
(
$
.
fn
.
slider
).
toHaveBeenCalledWith
range
:
'min'
range
:
'min'
change
:
@
s
lider
.
onChange
change
:
@
progressS
lider
.
onChange
slide
:
@
s
lider
.
onSlide
slide
:
@
progressS
lider
.
onSlide
stop
:
@
s
lider
.
onStop
stop
:
@
progressS
lider
.
onStop
it
'build the seek handle'
,
->
it
'build the seek handle'
,
->
expect
(
@
s
lider
.
handle
).
toBe
'.slider .ui-slider-handle'
expect
(
@
progressS
lider
.
handle
).
toBe
'.slider .ui-slider-handle'
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalledWith
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalledWith
content
:
"0:00"
content
:
"0:00"
position
:
position
:
my
:
'bottom center'
my
:
'bottom center'
at
:
'top center'
at
:
'top center'
container
:
@
s
lider
.
handle
container
:
@
progressS
lider
.
handle
hide
:
hide
:
delay
:
700
delay
:
700
style
:
style
:
...
@@ -34,47 +33,51 @@ xdescribe 'VideoProgressSlider', ->
...
@@ -34,47 +33,51 @@ xdescribe 'VideoProgressSlider', ->
describe
'on a touch-based device'
,
->
describe
'on a touch-based device'
,
->
beforeEach
->
beforeEach
->
window
.
onTouchBasedDevice
.
andReturn
true
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
true
@
player
=
jasmine
.
stubVideoPlayer
@
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
progressSlider
=
@
player
.
progressSlider
it
'does not build the slider'
,
->
it
'does not build the slider'
,
->
expect
(
@
s
lider
.
slider
).
toBeUndefined
expect
(
@
progressS
lider
.
slider
).
toBeUndefined
expect
(
$
.
fn
.
slider
).
not
.
toHaveBeenCalled
()
expect
(
$
.
fn
.
slider
).
not
.
toHaveBeenCalled
()
describe
'play'
,
->
describe
'play'
,
->
beforeEach
->
beforeEach
->
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
spyOn
(
VideoProgressSlider
.
prototype
,
'buildSlider'
).
andCallThrough
()
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
@
player
=
jasmine
.
stubVideoPlayer
@
@
progressSlider
=
@
player
.
progressSlider
describe
'when the slider was already built'
,
->
describe
'when the slider was already built'
,
->
beforeEach
->
beforeEach
->
@
s
lider
.
play
()
@
progressS
lider
.
play
()
it
'does not build the slider'
,
->
it
'does not build the slider'
,
->
expect
(
$
.
fn
.
slider
).
not
.
toHaveBeenCalled
expect
(
@
progressSlider
.
buildSlider
.
calls
.
length
).
toEqual
1
describe
'when the slider was not already built'
,
->
describe
'when the slider was not already built'
,
->
beforeEach
->
beforeEach
->
@
slider
.
slider
=
null
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
@
slider
.
play
()
@
progressSlider
.
slider
=
null
@
progressSlider
.
play
()
it
'build the slider'
,
->
it
'build the slider'
,
->
expect
(
@
s
lider
.
slider
).
toBe
'.slider'
expect
(
@
progressS
lider
.
slider
).
toBe
'.slider'
expect
(
$
.
fn
.
slider
).
toHaveBeenCalledWith
expect
(
$
.
fn
.
slider
).
toHaveBeenCalledWith
range
:
'min'
range
:
'min'
change
:
@
s
lider
.
onChange
change
:
@
progressS
lider
.
onChange
slide
:
@
s
lider
.
onSlide
slide
:
@
progressS
lider
.
onSlide
stop
:
@
s
lider
.
onStop
stop
:
@
progressS
lider
.
onStop
it
'build the seek handle'
,
->
it
'build the seek handle'
,
->
expect
(
@
s
lider
.
handle
).
toBe
'.ui-slider-handle'
expect
(
@
progressS
lider
.
handle
).
toBe
'.ui-slider-handle'
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalledWith
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalledWith
content
:
"0:00"
content
:
"0:00"
position
:
position
:
my
:
'bottom center'
my
:
'bottom center'
at
:
'top center'
at
:
'top center'
container
:
@
s
lider
.
handle
container
:
@
progressS
lider
.
handle
hide
:
hide
:
delay
:
700
delay
:
700
style
:
style
:
...
@@ -83,21 +86,23 @@ xdescribe 'VideoProgressSlider', ->
...
@@ -83,21 +86,23 @@ xdescribe 'VideoProgressSlider', ->
describe
'updatePlayTime'
,
->
describe
'updatePlayTime'
,
->
beforeEach
->
beforeEach
->
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
player
=
jasmine
.
stubVideoPlayer
@
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
@
progressSlider
=
@
player
.
progressSlider
describe
'when frozen'
,
->
describe
'when frozen'
,
->
beforeEach
->
beforeEach
->
@
slider
.
frozen
=
true
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
@
slider
.
updatePlayTime
20
,
120
@
progressSlider
.
frozen
=
true
@
progressSlider
.
updatePlayTime
20
,
120
it
'does not update the slider'
,
->
it
'does not update the slider'
,
->
expect
(
$
.
fn
.
slider
).
not
.
toHaveBeenCalled
()
expect
(
$
.
fn
.
slider
).
not
.
toHaveBeenCalled
()
describe
'when not frozen'
,
->
describe
'when not frozen'
,
->
beforeEach
->
beforeEach
->
@
slider
.
frozen
=
false
spyOn
(
$
.
fn
,
'slider'
).
andCallThrough
()
@
slider
.
updatePlayTime
20
,
120
@
progressSlider
.
frozen
=
false
@
progressSlider
.
updatePlayTime
20
,
120
it
'update the max value of the slider'
,
->
it
'update the max value of the slider'
,
->
expect
(
$
.
fn
.
slider
).
toHaveBeenCalledWith
'option'
,
'max'
,
120
expect
(
$
.
fn
.
slider
).
toHaveBeenCalledWith
'option'
,
'max'
,
120
...
@@ -107,55 +112,58 @@ xdescribe 'VideoProgressSlider', ->
...
@@ -107,55 +112,58 @@ xdescribe 'VideoProgressSlider', ->
describe
'onSlide'
,
->
describe
'onSlide'
,
->
beforeEach
->
beforeEach
->
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
player
=
jasmine
.
stubVideoPlayer
@
@
progressSlider
=
@
player
.
progressSlider
@
time
=
null
@
time
=
null
$
(
@
s
lider
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
$
(
@
progressS
lider
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
spyOnEvent
@
s
lider
,
'seek'
spyOnEvent
@
progressS
lider
,
'seek'
@
s
lider
.
onSlide
{},
value
:
20
@
progressS
lider
.
onSlide
{},
value
:
20
it
'freeze the slider'
,
->
it
'freeze the slider'
,
->
expect
(
@
s
lider
.
frozen
).
toBeTruthy
()
expect
(
@
progressS
lider
.
frozen
).
toBeTruthy
()
it
'update the tooltip'
,
->
it
'update the tooltip'
,
->
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalled
()
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalled
()
it
'trigger seek event'
,
->
it
'trigger seek event'
,
->
expect
(
'seek'
).
toHaveBeenTriggeredOn
@
s
lider
expect
(
'seek'
).
toHaveBeenTriggeredOn
@
progressS
lider
expect
(
@
time
).
toEqual
20
expect
(
@
time
).
toEqual
20
describe
'onChange'
,
->
describe
'onChange'
,
->
beforeEach
->
beforeEach
->
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
player
=
jasmine
.
stubVideoPlayer
@
@
slider
.
onChange
{},
value
:
20
@
progressSlider
=
@
player
.
progressSlider
@
progressSlider
.
onChange
{},
value
:
20
it
'update the tooltip'
,
->
it
'update the tooltip'
,
->
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalled
()
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalled
()
describe
'onStop'
,
->
describe
'onStop'
,
->
beforeEach
->
beforeEach
->
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
player
=
jasmine
.
stubVideoPlayer
@
@
progressSlider
=
@
player
.
progressSlider
@
time
=
null
@
time
=
null
$
(
@
slider
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
$
(
@
progressSlider
).
bind
'seek'
,
(
event
,
time
)
=>
@
time
=
time
spyOnEvent
@
slider
,
'seek'
spyOnEvent
@
progressSlider
,
'seek'
spyOn
(
window
,
'setTimeout'
)
@
progressSlider
.
onStop
{},
value
:
20
@
slider
.
onStop
{},
value
:
20
it
'freeze the slider'
,
->
it
'freeze the slider'
,
->
expect
(
@
s
lider
.
frozen
).
toBeTruthy
()
expect
(
@
progressS
lider
.
frozen
).
toBeTruthy
()
it
'trigger seek event'
,
->
it
'trigger seek event'
,
->
expect
(
'seek'
).
toHaveBeenTriggeredOn
@
s
lider
expect
(
'seek'
).
toHaveBeenTriggeredOn
@
progressS
lider
expect
(
@
time
).
toEqual
20
expect
(
@
time
).
toEqual
20
it
'set timeout to unfreeze the slider'
,
->
it
'set timeout to unfreeze the slider'
,
->
expect
(
window
.
setTimeout
).
toHaveBeenCalledWith
jasmine
.
any
(
Function
),
200
expect
(
window
.
setTimeout
).
toHaveBeenCalledWith
jasmine
.
any
(
Function
),
200
window
.
setTimeout
.
mostRecentCall
.
args
[
0
]()
window
.
setTimeout
.
mostRecentCall
.
args
[
0
]()
expect
(
@
s
lider
.
frozen
).
toBeFalsy
()
expect
(
@
progressS
lider
.
frozen
).
toBeFalsy
()
describe
'updateTooltip'
,
->
describe
'updateTooltip'
,
->
beforeEach
->
beforeEach
->
@
slider
=
new
VideoProgressSlider
el
:
$
(
'.slider'
)
@
player
=
jasmine
.
stubVideoPlayer
@
@
slider
.
updateTooltip
90
@
progressSlider
=
@
player
.
progressSlider
@
progressSlider
.
updateTooltip
90
it
'set the tooltip value'
,
->
it
'set the tooltip value'
,
->
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalledWith
'option'
,
'content.text'
,
'1:30'
expect
(
$
.
fn
.
qtip
).
toHaveBeenCalledWith
'option'
,
'content.text'
,
'1:30'
common/lib/xmodule/xmodule/js/spec/video/display/video_speed_control_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'VideoSpeedControl'
,
->
xdescribe
'VideoSpeedControl'
,
->
beforeEach
->
beforeEach
->
window
.
onTouchBasedDevice
=
jasmine
.
createSpy
(
'onTouchBasedDevice'
).
andReturn
false
jasmine
.
stubVideoPlayer
@
jasmine
.
stubVideoPlayer
@
$
(
'.speeds'
).
remove
()
$
(
'.speeds'
).
remove
()
...
@@ -25,7 +25,7 @@ xdescribe 'VideoSpeedControl', ->
...
@@ -25,7 +25,7 @@ xdescribe 'VideoSpeedControl', ->
describe
'when running on touch based device'
,
->
describe
'when running on touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
)
.
andReturn
true
window
.
onTouchBasedDevice
.
andReturn
true
$
(
'.speeds'
).
removeClass
'open'
$
(
'.speeds'
).
removeClass
'open'
@
speedControl
=
new
VideoSpeedControl
el
:
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
'1.0'
@
speedControl
=
new
VideoSpeedControl
el
:
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
'1.0'
...
@@ -37,7 +37,6 @@ xdescribe 'VideoSpeedControl', ->
...
@@ -37,7 +37,6 @@ xdescribe 'VideoSpeedControl', ->
describe
'when running on non-touch based device'
,
->
describe
'when running on non-touch based device'
,
->
beforeEach
->
beforeEach
->
spyOn
(
window
,
'onTouchBasedDevice'
).
andReturn
false
$
(
'.speeds'
).
removeClass
'open'
$
(
'.speeds'
).
removeClass
'open'
@
speedControl
=
new
VideoSpeedControl
el
:
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
'1.0'
@
speedControl
=
new
VideoSpeedControl
el
:
$
(
'.secondary-controls'
),
speeds
:
@
video
.
speeds
,
currentSpeed
:
'1.0'
...
...
common/lib/xmodule/xmodule/js/spec/video/display/video_volume_control_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'VideoVolumeControl'
,
->
xdescribe
'VideoVolumeControl'
,
->
beforeEach
->
beforeEach
->
jasmine
.
stubVideoPlayer
@
jasmine
.
stubVideoPlayer
@
$
(
'.volume'
).
remove
()
$
(
'.volume'
).
remove
()
...
...
common/lib/xmodule/xmodule/js/spec/video/display_spec.coffee
View file @
7eb18fe0
# TODO: figure out why failing
describe
'Video'
,
->
xdescribe
'Video'
,
->
metadata
=
undefined
beforeEach
->
beforeEach
->
loadFixtures
'video.html'
loadFixtures
'video.html'
jasmine
.
stubRequests
()
jasmine
.
stubRequests
()
@
videosDefinition
=
'.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
@
videosDefinition
=
'
0
.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
@
slowerSpeedYoutubeId
=
'slowerSpeedYoutubeId'
@
slowerSpeedYoutubeId
=
'slowerSpeedYoutubeId'
@
normalSpeedYoutubeId
=
'normalSpeedYoutubeId'
@
normalSpeedYoutubeId
=
'normalSpeedYoutubeId'
metadata
=
slowerSpeedYoutubeId
:
id
:
@
slowerSpeedYoutubeId
duration
:
300
normalSpeedYoutubeId
:
id
:
@
normalSpeedYoutubeId
duration
:
200
afterEach
->
afterEach
->
window
.
player
=
undefined
window
.
player
=
undefined
...
@@ -16,17 +24,18 @@ xdescribe 'Video', ->
...
@@ -16,17 +24,18 @@ xdescribe 'Video', ->
beforeEach
->
beforeEach
->
@
stubVideoPlayer
=
jasmine
.
createSpy
(
'VideoPlayer'
)
@
stubVideoPlayer
=
jasmine
.
createSpy
(
'VideoPlayer'
)
$
.
cookie
.
andReturn
'0.75'
$
.
cookie
.
andReturn
'0.75'
window
.
player
=
100
window
.
player
=
undefined
describe
'by default'
,
->
describe
'by default'
,
->
beforeEach
->
beforeEach
->
@
video
=
new
Video
'example'
,
@
videosDefinition
spyOn
(
window
.
Video
.
prototype
,
'fetchMetadata'
).
andCallFake
->
@
metadata
=
metadata
@
video
=
new
Video
'#example'
,
@
videosDefinition
it
'reset the current video player'
,
->
it
'reset the current video player'
,
->
expect
(
window
.
player
).
toBeNull
()
expect
(
window
.
player
).
toBeNull
()
it
'set the elements'
,
->
it
'set the elements'
,
->
expect
(
@
video
.
el
).
toBe
'#video_
example
'
expect
(
@
video
.
el
).
toBe
'#video_
id
'
it
'parse the videos'
,
->
it
'parse the videos'
,
->
expect
(
@
video
.
videos
).
toEqual
expect
(
@
video
.
videos
).
toEqual
...
@@ -34,13 +43,8 @@ xdescribe 'Video', ->
...
@@ -34,13 +43,8 @@ xdescribe 'Video', ->
'1.0'
:
@
normalSpeedYoutubeId
'1.0'
:
@
normalSpeedYoutubeId
it
'fetch the video metadata'
,
->
it
'fetch the video metadata'
,
->
expect
(
@
video
.
metadata
).
toEqual
expect
(
@
video
.
fetchMetadata
).
toHaveBeenCalled
slowerSpeedYoutubeId
:
expect
(
@
video
.
metadata
).
toEqual
metadata
id
:
@
slowerSpeedYoutubeId
duration
:
300
normalSpeedYoutubeId
:
id
:
@
normalSpeedYoutubeId
duration
:
200
it
'parse available video speeds'
,
->
it
'parse available video speeds'
,
->
expect
(
@
video
.
speeds
).
toEqual
[
'0.75'
,
'1.0'
]
expect
(
@
video
.
speeds
).
toEqual
[
'0.75'
,
'1.0'
]
...
@@ -56,7 +60,7 @@ xdescribe 'Video', ->
...
@@ -56,7 +60,7 @@ xdescribe 'Video', ->
@
originalYT
=
window
.
YT
@
originalYT
=
window
.
YT
window
.
YT
=
{
Player
:
true
}
window
.
YT
=
{
Player
:
true
}
spyOn
(
window
,
'VideoPlayer'
).
andReturn
(
@
stubVideoPlayer
)
spyOn
(
window
,
'VideoPlayer'
).
andReturn
(
@
stubVideoPlayer
)
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
afterEach
->
afterEach
->
window
.
YT
=
@
originalYT
window
.
YT
=
@
originalYT
...
@@ -69,7 +73,7 @@ xdescribe 'Video', ->
...
@@ -69,7 +73,7 @@ xdescribe 'Video', ->
beforeEach
->
beforeEach
->
@
originalYT
=
window
.
YT
@
originalYT
=
window
.
YT
window
.
YT
=
{}
window
.
YT
=
{}
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
afterEach
->
afterEach
->
window
.
YT
=
@
originalYT
window
.
YT
=
@
originalYT
...
@@ -82,7 +86,7 @@ xdescribe 'Video', ->
...
@@ -82,7 +86,7 @@ xdescribe 'Video', ->
@
originalYT
=
window
.
YT
@
originalYT
=
window
.
YT
window
.
YT
=
{}
window
.
YT
=
{}
spyOn
(
window
,
'VideoPlayer'
).
andReturn
(
@
stubVideoPlayer
)
spyOn
(
window
,
'VideoPlayer'
).
andReturn
(
@
stubVideoPlayer
)
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
window
.
onYouTubePlayerAPIReady
()
window
.
onYouTubePlayerAPIReady
()
afterEach
->
afterEach
->
...
@@ -95,7 +99,7 @@ xdescribe 'Video', ->
...
@@ -95,7 +99,7 @@ xdescribe 'Video', ->
describe
'youtubeId'
,
->
describe
'youtubeId'
,
->
beforeEach
->
beforeEach
->
$
.
cookie
.
andReturn
'1.0'
$
.
cookie
.
andReturn
'1.0'
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
describe
'with speed'
,
->
describe
'with speed'
,
->
it
'return the video id for given speed'
,
->
it
'return the video id for given speed'
,
->
...
@@ -108,7 +112,7 @@ xdescribe 'Video', ->
...
@@ -108,7 +112,7 @@ xdescribe 'Video', ->
describe
'setSpeed'
,
->
describe
'setSpeed'
,
->
beforeEach
->
beforeEach
->
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
describe
'when new speed is available'
,
->
describe
'when new speed is available'
,
->
beforeEach
->
beforeEach
->
...
@@ -129,14 +133,14 @@ xdescribe 'Video', ->
...
@@ -129,14 +133,14 @@ xdescribe 'Video', ->
describe
'getDuration'
,
->
describe
'getDuration'
,
->
beforeEach
->
beforeEach
->
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
it
'return duration for current video'
,
->
it
'return duration for current video'
,
->
expect
(
@
video
.
getDuration
()).
toEqual
200
expect
(
@
video
.
getDuration
()).
toEqual
200
describe
'log'
,
->
describe
'log'
,
->
beforeEach
->
beforeEach
->
@
video
=
new
Video
'example'
,
@
videosDefinition
@
video
=
new
Video
'
#
example'
,
@
videosDefinition
@
video
.
setSpeed
'1.0'
@
video
.
setSpeed
'1.0'
spyOn
Logger
,
'log'
spyOn
Logger
,
'log'
@
video
.
player
=
{
currentTime
:
25
}
@
video
.
player
=
{
currentTime
:
25
}
...
@@ -144,7 +148,7 @@ xdescribe 'Video', ->
...
@@ -144,7 +148,7 @@ xdescribe 'Video', ->
it
'call the logger with valid parameters'
,
->
it
'call the logger with valid parameters'
,
->
expect
(
Logger
.
log
).
toHaveBeenCalledWith
'someEvent'
,
expect
(
Logger
.
log
).
toHaveBeenCalledWith
'someEvent'
,
id
:
'
example
'
id
:
'
id
'
code
:
@
normalSpeedYoutubeId
code
:
@
normalSpeedYoutubeId
currentTime
:
25
currentTime
:
25
speed
:
'1.0'
speed
:
'1.0'
common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
View file @
7eb18fe0
...
@@ -37,7 +37,7 @@ class @VideoCaption extends Subview
...
@@ -37,7 +37,7 @@ class @VideoCaption extends Subview
@
loaded
=
true
@
loaded
=
true
if
onTouchBasedDevice
()
if
onTouchBasedDevice
()
$
(
'.subtitles
li'
).
html
"Caption will be displayed when you start playing the video.
"
$
(
'.subtitles
'
).
html
"<li>Caption will be displayed when you start playing the video.</li>
"
else
else
@
renderCaption
()
@
renderCaption
()
...
...
common/lib/xmodule/xmodule/js/src/video/display/video_progress_slider.coffee
View file @
7eb18fe0
...
@@ -11,7 +11,7 @@ class @VideoProgressSlider extends Subview
...
@@ -11,7 +11,7 @@ class @VideoProgressSlider extends Subview
@
buildHandle
()
@
buildHandle
()
buildHandle
:
->
buildHandle
:
->
@
handle
=
@
$
(
'.
slider .
ui-slider-handle'
)
@
handle
=
@
$
(
'.ui-slider-handle'
)
@
handle
.
qtip
@
handle
.
qtip
content
:
"
#{
Time
.
format
(
@
slider
.
slider
(
'value'
))
}
"
content
:
"
#{
Time
.
format
(
@
slider
.
slider
(
'value'
))
}
"
position
:
position
:
...
...
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