BLD-852: Fix video positioning in full view mode.
This commit is contained in:
@@ -83,7 +83,7 @@ Feature: LMS Video component
|
||||
Scenario: Language menu works correctly in Video component
|
||||
Given the course has a Video component in Youtube mode:
|
||||
| transcripts | sub |
|
||||
| {"zh": "OEoXaMPEzfM"} | OEoXaMPEzfM |
|
||||
| {"zh": "chinese_transcripts.srt"} | OEoXaMPEzfM |
|
||||
And I make sure captions are closed
|
||||
And I see video menu "language" with correct items
|
||||
And I select language with code "zh"
|
||||
@@ -95,7 +95,7 @@ Feature: LMS Video component
|
||||
Scenario: CC button works correctly w/o english transcript in HTML5 mode of Video component
|
||||
Given the course has a Video component in HTML5 mode:
|
||||
| transcripts |
|
||||
| {"zh": "OEoXaMPEzfM"} |
|
||||
| {"zh": "chinese_transcripts.srt"} |
|
||||
And I make sure captions are opened
|
||||
Then I see "好 各位同学" text in the captions
|
||||
|
||||
@@ -113,7 +113,7 @@ Feature: LMS Video component
|
||||
Scenario: CC button works correctly w/o english transcript in Youtube mode of Video component
|
||||
Given the course has a Video component in Youtube mode:
|
||||
| transcripts |
|
||||
| {"zh": "OEoXaMPEzfM"} |
|
||||
| {"zh": "chinese_transcripts.srt"} |
|
||||
And I make sure captions are opened
|
||||
Then I see "好 各位同学" text in the captions
|
||||
|
||||
@@ -129,3 +129,29 @@ Feature: LMS Video component
|
||||
Scenario: CC button is hidden if no translations
|
||||
Given the course has a Video component in Youtube mode
|
||||
Then button "CC" is hidden
|
||||
|
||||
# 16
|
||||
Scenario: Video is aligned correctly if transcript is visible in fullscreen mode
|
||||
Given the course has a Video component in HTML5 mode:
|
||||
| sub |
|
||||
| OEoXaMPEzfM |
|
||||
And I make sure captions are opened
|
||||
And I click video button "fullscreen"
|
||||
Then I see video aligned correctly with enabled transcript
|
||||
|
||||
# 17
|
||||
Scenario: Video is aligned correctly if transcript is hidden in fullscreen mode
|
||||
Given the course has a Video component in Youtube mode
|
||||
And I click video button "fullscreen"
|
||||
Then I see video aligned correctly without enabled transcript
|
||||
|
||||
# 18
|
||||
Scenario: Video is aligned correctly on transcript toggle in fullscreen mode
|
||||
Given the course has a Video component in Youtube mode:
|
||||
| sub |
|
||||
| OEoXaMPEzfM |
|
||||
And I make sure captions are opened
|
||||
And I click video button "fullscreen"
|
||||
Then I see video aligned correctly with enabled transcript
|
||||
And I click video button "CC"
|
||||
Then I see video aligned correctly without enabled transcript
|
||||
|
||||
@@ -21,25 +21,22 @@ HTML5_SOURCES = [
|
||||
'https://s3.amazonaws.com/edx-course-videos/edx-intro/edX-FA12-cware-1_100.webm',
|
||||
'https://s3.amazonaws.com/edx-course-videos/edx-intro/edX-FA12-cware-1_100.ogv',
|
||||
]
|
||||
|
||||
HTML5_SOURCES_INCORRECT = [
|
||||
'https://s3.amazonaws.com/edx-course-videos/edx-intro/edX-FA12-cware-1_100.mp99',
|
||||
]
|
||||
VIDEO_BUTTONS = {
|
||||
'CC': '.hide-subtitles',
|
||||
'volume': '.volume',
|
||||
'play': '.video_control.play',
|
||||
'pause': '.video_control.pause',
|
||||
}
|
||||
VIDEO_MENUS = {
|
||||
'language': '.lang .menu',
|
||||
'speed': '.speed .menu',
|
||||
}
|
||||
|
||||
VIDEO_BUTTONS = {
|
||||
'CC': '.hide-subtitles',
|
||||
'volume': '.volume',
|
||||
'play': '.video_control.play',
|
||||
'pause': '.video_control.pause',
|
||||
'fullscreen': '.add-fullscreen',
|
||||
}
|
||||
|
||||
VIDEO_MENUS = {
|
||||
'language': '.lang .menu',
|
||||
'speed': '.speed .menu',
|
||||
}
|
||||
|
||||
coursenum = 'test_course'
|
||||
@@ -83,23 +80,22 @@ def add_video_to_course(course, player_mode, hashes, display_name='Video'):
|
||||
|
||||
if hashes:
|
||||
kwargs['metadata'].update(hashes[0])
|
||||
course_location = world.scenario_dict['COURSE'].location
|
||||
|
||||
if 'sub' in kwargs['metadata']:
|
||||
filename = _get_sjson_filename(kwargs['metadata']['sub'], 'en')
|
||||
_upload_file(filename, course_location)
|
||||
|
||||
if 'transcripts' in kwargs['metadata']:
|
||||
kwargs['metadata']['transcripts'] = json.loads(kwargs['metadata']['transcripts'])
|
||||
course_location = world.scenario_dict['COURSE'].location
|
||||
|
||||
if 'sub' in kwargs['metadata']:
|
||||
filename = _get_transcript_filename(kwargs['metadata']['sub'], 'en')
|
||||
_upload_file(filename, course_location)
|
||||
|
||||
for lang, videoId in kwargs['metadata']['transcripts'].items():
|
||||
filename = _get_transcript_filename(videoId, lang)
|
||||
for lang, filename in kwargs['metadata']['transcripts'].items():
|
||||
_upload_file(filename, course_location)
|
||||
|
||||
world.scenario_dict['VIDEO'] = world.ItemFactory.create(**kwargs)
|
||||
|
||||
|
||||
def _get_transcript_filename(videoId, lang):
|
||||
def _get_sjson_filename(videoId, lang):
|
||||
if lang == 'en':
|
||||
return 'subs_{0}.srt.sjson'.format(videoId)
|
||||
else:
|
||||
@@ -120,7 +116,7 @@ def _upload_file(filename, location):
|
||||
|
||||
|
||||
def _navigate_to_an_item_in_a_sequence(number):
|
||||
sequence_css = 'a[data-element="{0}"]'.format(number)
|
||||
sequence_css = '#sequence-list a[data-element="{0}"]'.format(number)
|
||||
world.css_click(sequence_css)
|
||||
|
||||
|
||||
@@ -136,6 +132,33 @@ def _open_menu(menu):
|
||||
))
|
||||
|
||||
|
||||
def _get_all_dimensions():
|
||||
video = _get_dimensions('.video-player iframe, .video-player video')
|
||||
wrapper = _get_dimensions('.tc-wrapper')
|
||||
controls = _get_dimensions('.video-controls')
|
||||
progress_slider = _get_dimensions('.video-controls > .slider')
|
||||
|
||||
expected = dict(wrapper)
|
||||
expected['height'] -= controls['height'] + 0.5 * progress_slider['height']
|
||||
|
||||
return (video, expected)
|
||||
|
||||
|
||||
def _get_dimensions(selector):
|
||||
element = world.css_find(selector).first
|
||||
return element._element.size
|
||||
|
||||
|
||||
def _get_window_dimensions():
|
||||
return world.browser.driver.get_window_size()
|
||||
|
||||
|
||||
def _set_window_dimensions(width, height):
|
||||
world.browser.driver.set_window_size(width, height)
|
||||
# Wait 200 ms when JS finish resizing
|
||||
world.wait(0.2)
|
||||
|
||||
|
||||
@step('when I view the (.*) it does not have autoplay enabled$')
|
||||
def does_not_autoplay(_step, video_type):
|
||||
assert(world.css_find('.%s' % video_type)[0]['data-autoplay'] == 'False')
|
||||
@@ -143,10 +166,7 @@ def does_not_autoplay(_step, video_type):
|
||||
|
||||
@step('the course has a Video component in (.*) mode(?:\:)?$')
|
||||
def view_video(_step, player_mode):
|
||||
|
||||
i_am_registered_for_the_course(_step, coursenum)
|
||||
|
||||
# Make sure we have a video
|
||||
add_video_to_course(coursenum, player_mode.lower(), _step.hashes)
|
||||
visit_scenario_item('SECTION')
|
||||
|
||||
@@ -203,7 +223,7 @@ def video_is_rendered(_step, mode):
|
||||
|
||||
@step('all sources are correct$')
|
||||
def all_sources_are_correct(_step):
|
||||
elements = world.css_find('.video video source')
|
||||
elements = world.css_find('.video-player video source')
|
||||
sources = [source['src'].split('?')[0] for source in elements]
|
||||
|
||||
assert set(sources) == set(HTML5_SOURCES)
|
||||
@@ -273,15 +293,8 @@ def select_language(_step, code):
|
||||
world.wait_for_ajax_complete()
|
||||
|
||||
|
||||
@step('I click on video button "([^"]*)"$')
|
||||
def click_button(_step, button):
|
||||
world.css_find(VIDEO_BUTTONS[button]).click()
|
||||
|
||||
|
||||
@step('I click video button "([^"]*)"$')
|
||||
def click_button_video(_step, button_type):
|
||||
world.wait_for_ajax_complete()
|
||||
button = button_type.strip()
|
||||
def click_button(_step, button):
|
||||
world.css_click(VIDEO_BUTTONS[button])
|
||||
|
||||
|
||||
@@ -309,3 +322,26 @@ def upload_to_assets(_step, filename):
|
||||
def is_hidden_button(_step, button):
|
||||
assert not world.css_visible(VIDEO_BUTTONS[button])
|
||||
|
||||
|
||||
@step('I see video aligned correctly (with(?:out)?) enabled transcript$')
|
||||
def video_alignment(_step, transcript_visibility):
|
||||
# Width of the video container in css equal 75% of window if transcript enabled
|
||||
wrapper_width = 75 if transcript_visibility == "with" else 100
|
||||
initial = _get_window_dimensions()
|
||||
|
||||
_set_window_dimensions(300, 600)
|
||||
real, expected = _get_all_dimensions()
|
||||
|
||||
width = round(100 * real['width']/expected['width']) == wrapper_width
|
||||
|
||||
_set_window_dimensions(600, 300)
|
||||
real, expected = _get_all_dimensions()
|
||||
|
||||
height = abs(expected['height'] - real['height']) <= 5
|
||||
|
||||
# Restore initial window size
|
||||
_set_window_dimensions(
|
||||
initial['width'], initial['height']
|
||||
)
|
||||
|
||||
assert all([width, height])
|
||||
|
||||
Reference in New Issue
Block a user