Commit e3f499a7 by zubair-arbi

show video controls for all youtube videos

TNL-184
parent 541419e3
...@@ -90,7 +90,10 @@ class StubYouTubeHandler(StubHttpRequestHandler): ...@@ -90,7 +90,10 @@ class StubYouTubeHandler(StubHttpRequestHandler):
params = urlparse(self.path) params = urlparse(self.path)
youtube_id = params.path.split('/').pop() youtube_id = params.path.split('/').pop()
self._send_video_response(youtube_id, "I'm youtube.") if self.server.config.get('youtube_api_private_video'):
self._send_private_video_response(youtube_id, "I'm youtube private video.")
else:
self._send_video_response(youtube_id, "I'm youtube.")
elif 'get_youtube_api' in self.path: elif 'get_youtube_api' in self.path:
if self.server.config.get('youtube_api_blocked'): if self.server.config.get('youtube_api_blocked'):
...@@ -130,6 +133,30 @@ class StubYouTubeHandler(StubHttpRequestHandler): ...@@ -130,6 +133,30 @@ class StubYouTubeHandler(StubHttpRequestHandler):
self.send_response(200, content=response, headers={'Content-type': 'text/html'}) self.send_response(200, content=response, headers={'Content-type': 'text/html'})
self.log_message("Youtube: sent response {}".format(message)) self.log_message("Youtube: sent response {}".format(message))
def _send_private_video_response(self, message):
"""
Send private video error message back to the client for video player requests.
"""
# Construct the response content
callback = self.get_params['callback']
data = OrderedDict({
"error": OrderedDict({
"code": 403,
"errors": [
{
"code": "ServiceForbiddenException",
"domain": "GData",
"internalReason": "Private video"
}
],
"message": message,
})
})
response = "{cb}({data})".format(cb=callback, data=json.dumps(data))
self.send_response(200, content=response, headers={'Content-type': 'text/html'})
self.log_message("Youtube: sent response {}".format(message))
class StubYouTubeService(StubHttpService): class StubYouTubeService(StubHttpService):
""" """
......
...@@ -756,7 +756,7 @@ function (VideoPlayer, VideoStorage, i18n) { ...@@ -756,7 +756,7 @@ function (VideoPlayer, VideoStorage, i18n) {
try { try {
return this.metadata[this.youtubeId()].duration; return this.metadata[this.youtubeId()].duration;
} catch (err) { } catch (err) {
return this.metadata[this.youtubeId('1.0')].duration; return _.result(this.metadata[this.youtubeId('1.0')], 'duration') || 0;
} }
} }
......
...@@ -118,7 +118,19 @@ class VideoComponentPage(VideoPage): ...@@ -118,7 +118,19 @@ class VideoComponentPage(VideoPage):
self._wait_for(lambda: self.q(css=CLASS_SELECTORS['video_init']).present, 'Video Player Initialized') self._wait_for(lambda: self.q(css=CLASS_SELECTORS['video_init']).present, 'Video Player Initialized')
self._wait_for(lambda: not self.q(css=CLASS_SELECTORS['video_spinner']).visible, self._wait_for(lambda: not self.q(css=CLASS_SELECTORS['video_spinner']).visible,
'Video Buffering Completed') 'Video Buffering Completed')
self._wait_for(lambda: self.q(css=CLASS_SELECTORS['video_controls']).visible, 'Player Controls are Visible') self._wait_for(self.is_controls_visible, 'Player Controls are Visible')
@wait_for_js
def is_controls_visible(self):
"""
Get current visibility sate of all video controls.
Returns:
bool: True means video controls are visible for all videos, False means video controls are not visible
for one or more videos
"""
return self.q(css=CLASS_SELECTORS['video_controls']).visible
def click_button(self, button_name, index=0): def click_button(self, button_name, index=0):
""" """
......
...@@ -95,12 +95,14 @@ class CMSVideoBaseTest(UniqueCourseTest): ...@@ -95,12 +95,14 @@ class CMSVideoBaseTest(UniqueCourseTest):
self._install_course_fixture() self._install_course_fixture()
self._navigate_to_course_unit_page() self._navigate_to_course_unit_page()
def edit_component(self): def edit_component(self, xblock_index=1):
""" """
Open component Edit Dialog for first component on page. Open component Edit Dialog for first component on page.
Arguments:
xblock_index: number starting from 1 (0th entry is the unit page itself)
""" """
# The 0th entry is the unit page itself. self.unit_page.xblocks[xblock_index].edit()
self.unit_page.xblocks[1].edit()
def open_advanced_tab(self): def open_advanced_tab(self):
""" """
...@@ -225,6 +227,27 @@ class CMSVideoTest(CMSVideoBaseTest): ...@@ -225,6 +227,27 @@ class CMSVideoTest(CMSVideoBaseTest):
self.assertFalse(self.video.is_captions_visible()) self.assertFalse(self.video.is_captions_visible())
def test_video_controls_shown_correctly(self):
"""
Scenario: Video controls for all videos show correctly
Given I have created two Video components
And first is private video
When I reload the page
Then video controls for all videos are visible
"""
self._create_course_unit(youtube_stub_config={'youtube_api_private_video': True})
self.video.create_video()
# change id of first default video
self.edit_component(1)
self.open_advanced_tab()
self.video.set_field_value('YouTube ID', 'sampleid123')
self.save_unit_settings()
# again open unit page and check that video controls show for both videos
self._navigate_to_course_unit_page()
self.assertTrue(self.video.is_controls_visible())
def test_captions_shown_correctly(self): def test_captions_shown_correctly(self):
""" """
Scenario: Captions are shown correctly Scenario: Captions are shown correctly
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment