Commit 68fb0230 by polesye

Merge pull request #1201 from edx/anton/fix_video_acceptance_tests

BLD-388: Fix acceptance tests.
parents a3525875 9a4633be
...@@ -10,7 +10,6 @@ import random ...@@ -10,7 +10,6 @@ import random
import os import os
from django.contrib.auth.models import User from django.contrib.auth.models import User
from student.models import CourseEnrollment from student.models import CourseEnrollment
from splinter.request_handler.status_code import HttpResponseError
from nose.tools import assert_equal, assert_not_equal # pylint: disable=E0611 from nose.tools import assert_equal, assert_not_equal # pylint: disable=E0611
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
...@@ -25,12 +24,13 @@ def go_to_uploads(_step): ...@@ -25,12 +24,13 @@ def go_to_uploads(_step):
world.css_click(uploads_css) world.css_click(uploads_css)
@step(u'I upload the file "([^"]*)"$') @step(u'I upload the( test?) file "([^"]*)"$')
def upload_file(_step, file_name): def upload_file(_step, is_test_file, file_name):
upload_css = 'a.upload-button' upload_css = 'a.upload-button'
world.css_click(upload_css) world.css_click(upload_css)
_write_test_file(file_name, "test file") if not is_test_file:
_write_test_file(file_name, "test file")
# uploading the file itself # uploading the file itself
path = os.path.join(TEST_ROOT, 'uploads/', file_name) path = os.path.join(TEST_ROOT, 'uploads/', file_name)
......
...@@ -23,6 +23,10 @@ def shows_captions(_step, show_captions): ...@@ -23,6 +23,10 @@ def shows_captions(_step, show_captions):
else: else:
assert world.is_css_not_present('div.video.closed') assert world.is_css_not_present('div.video.closed')
# Prevent cookies from overriding course settings
world.browser.cookies.delete('hide_captions')
world.browser.cookies.delete('current_player_mode')
@step('I see the correct video settings and default values$') @step('I see the correct video settings and default values$')
def correct_video_settings(_step): def correct_video_settings(_step):
......
...@@ -17,23 +17,31 @@ def i_created_a_video_component(step): ...@@ -17,23 +17,31 @@ def i_created_a_video_component(step):
@step('I have created a Video component with subtitles$') @step('I have created a Video component with subtitles$')
def i_created_a_video_component_subtitles(step): def i_created_a_video_with_subs(_step):
step.given('I have created a Video component') _step.given('I have created a Video component with subtitles "OEoXaMPEzfM"')
@step('I have created a Video component with subtitles "([^"]*)"$')
def i_created_a_video_with_subs_with_name(_step, sub_id):
_step.given('I have created a Video component')
# Store the current URL so we can return here # Store the current URL so we can return here
video_url = world.browser.url video_url = world.browser.url
# Upload subtitles for the video using the upload interface # Upload subtitles for the video using the upload interface
step.given('I have uploaded subtitles') _step.given('I have uploaded subtitles "{}"'.format(sub_id))
# Return to the video # Return to the video
world.visit(video_url) world.visit(video_url)
@step('I have uploaded subtitles') @step('I have uploaded subtitles "([^"]*)"$')
def i_have_uploaded_subtitles(step): def i_have_uploaded_subtitles(_step, sub_id):
step.given('I go to the files and uploads page') _step.given('I go to the files and uploads page')
step.given('I upload the file "subs_OEoXaMPEzfM.srt.sjson"')
sub_id = sub_id.strip()
if not sub_id:
sub_id = 'OEoXaMPEzfM'
_step.given('I upload the test file "subs_{}.srt.sjson"'.format(sub_id))
@step('when I view the (.*) it does not have autoplay enabled$') @step('when I view the (.*) it does not have autoplay enabled$')
......
...@@ -200,7 +200,7 @@ function () { ...@@ -200,7 +200,7 @@ function () {
'STATUS:', textStatus + ', MESSAGE:', '' + errorThrown 'STATUS:', textStatus + ', MESSAGE:', '' + errorThrown
); );
_this.videoCaption.hideCaptions(true); _this.videoCaption.hideCaptions(true, false);
_this.videoCaption.hideSubtitlesEl.hide(); _this.videoCaption.hideSubtitlesEl.hide();
} }
}); });
...@@ -337,18 +337,18 @@ function () { ...@@ -337,18 +337,18 @@ function () {
// Enables or disables automatic scrolling of the captions when the // Enables or disables automatic scrolling of the captions when the
// video is playing. This feature has to be disabled when tabbing // video is playing. This feature has to be disabled when tabbing
// through them as it interferes with that action. Initially, have this // through them as it interferes with that action. Initially, have this
// flag enabled as we assume mouse use. Then, if the first caption // flag enabled as we assume mouse use. Then, if the first caption
// (through forward tabbing) or the last caption (through backwards // (through forward tabbing) or the last caption (through backwards
// tabbing) gets the focus, disable that feature. Renable it if tabbing // tabbing) gets the focus, disable that feature. Renable it if tabbing
// then cycles out of the the captions. // then cycles out of the the captions.
this.videoCaption.autoScrolling = true; this.videoCaption.autoScrolling = true;
// Keeps track of where the focus is situated in the array of captions. // Keeps track of where the focus is situated in the array of captions.
// Used to implement the automatic scrolling behavior and decide if the // Used to implement the automatic scrolling behavior and decide if the
// outline around a caption has to be hidden or shown on a mouseenter or // outline around a caption has to be hidden or shown on a mouseenter or
// mouseleave. Initially, no caption has the focus, set the index to -1. // mouseleave. Initially, no caption has the focus, set the index to -1.
this.videoCaption.currentCaptionIndex = -1; this.videoCaption.currentCaptionIndex = -1;
// Used to track if the focus is coming from a click or tabbing. This // Used to track if the focus is coming from a click or tabbing. This
// has to be known to decide if, when a caption gets the focus, an // has to be known to decide if, when a caption gets the focus, an
// outline has to be drawn (tabbing) or not (mouse click). // outline has to be drawn (tabbing) or not (mouse click).
this.videoCaption.isMouseFocus = false; this.videoCaption.isMouseFocus = false;
...@@ -362,7 +362,7 @@ function () { ...@@ -362,7 +362,7 @@ function () {
// On mouseOut, show the outline of a caption that has been tabbed to. // On mouseOut, show the outline of a caption that has been tabbed to.
function captionMouseOverOut(event) { function captionMouseOverOut(event) {
var caption = $(event.target), var caption = $(event.target),
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
if (captionIndex === this.videoCaption.currentCaptionIndex) { if (captionIndex === this.videoCaption.currentCaptionIndex) {
if (event.type === 'mouseover') { if (event.type === 'mouseover') {
caption.removeClass('focused'); caption.removeClass('focused');
...@@ -370,7 +370,7 @@ function () { ...@@ -370,7 +370,7 @@ function () {
else { // mouseout else { // mouseout
caption.addClass('focused'); caption.addClass('focused');
} }
} }
} }
function captionMouseDown(event) { function captionMouseDown(event) {
...@@ -390,19 +390,19 @@ function () { ...@@ -390,19 +390,19 @@ function () {
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
// If the focus comes from a mouse click, hide the outline, turn on // If the focus comes from a mouse click, hide the outline, turn on
// automatic scrolling and set currentCaptionIndex to point outside of // automatic scrolling and set currentCaptionIndex to point outside of
// caption list (ie -1) to disable mouseenter, mouseleave behavior. // caption list (ie -1) to disable mouseenter, mouseleave behavior.
if (this.videoCaption.isMouseFocus) { if (this.videoCaption.isMouseFocus) {
this.videoCaption.autoScrolling = true; this.videoCaption.autoScrolling = true;
caption.removeClass('focused'); caption.removeClass('focused');
this.videoCaption.currentCaptionIndex = -1; this.videoCaption.currentCaptionIndex = -1;
} }
// If the focus comes from tabbing, show the outline and turn off // If the focus comes from tabbing, show the outline and turn off
// automatic scrolling. // automatic scrolling.
else { else {
this.videoCaption.currentCaptionIndex = captionIndex; this.videoCaption.currentCaptionIndex = captionIndex;
caption.addClass('focused'); caption.addClass('focused');
// The second and second to last elements turn automatic scrolling // The second and second to last elements turn automatic scrolling
// off again as it may have been enabled in captionBlur. // off again as it may have been enabled in captionBlur.
if (captionIndex <= 1 || captionIndex >= this.videoCaption.captions.length-2) { if (captionIndex <= 1 || captionIndex >= this.videoCaption.captions.length-2) {
this.videoCaption.autoScrolling = false; this.videoCaption.autoScrolling = false;
} }
...@@ -410,7 +410,7 @@ function () { ...@@ -410,7 +410,7 @@ function () {
} }
function captionBlur(event) { function captionBlur(event) {
var caption = $(event.target), var caption = $(event.target),
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
caption.removeClass('focused'); caption.removeClass('focused');
// If we are on first or last index, we have to turn automatic scroll on // If we are on first or last index, we have to turn automatic scroll on
...@@ -418,7 +418,7 @@ function () { ...@@ -418,7 +418,7 @@ function () {
// are tabbing. So we could be on the first element and tabbing back out // are tabbing. So we could be on the first element and tabbing back out
// of the captions or on the last element and tabbing forward out of the // of the captions or on the last element and tabbing forward out of the
// captions. // captions.
if (captionIndex === 0 || if (captionIndex === 0 ||
captionIndex === this.videoCaption.captions.length-1) { captionIndex === this.videoCaption.captions.length-1) {
this.videoCaption.autoScrolling = true; this.videoCaption.autoScrolling = true;
} }
...@@ -434,8 +434,8 @@ function () { ...@@ -434,8 +434,8 @@ function () {
function scrollCaption() { function scrollCaption() {
var el = this.videoCaption.subtitlesEl.find('.current:first'); var el = this.videoCaption.subtitlesEl.find('.current:first');
// Automatic scrolling gets disabled if one of the captions has received // Automatic scrolling gets disabled if one of the captions has received
// focus through tabbing. // focus through tabbing.
if (!this.videoCaption.frozen && el.length && this.videoCaption.autoScrolling) { if (!this.videoCaption.frozen && el.length && this.videoCaption.autoScrolling) {
this.videoCaption.subtitlesEl.scrollTo( this.videoCaption.subtitlesEl.scrollTo(
el, el,
...@@ -582,9 +582,13 @@ function () { ...@@ -582,9 +582,13 @@ function () {
} }
} }
function hideCaptions(hide_captions) { function hideCaptions(hide_captions, update_cookie) {
var type; var type;
if (typeof update_cookie === 'undefined') {
update_cookie = true;
}
if (hide_captions) { if (hide_captions) {
type = 'hide_transcript'; type = 'hide_transcript';
this.captionsHidden = true; this.captionsHidden = true;
...@@ -606,10 +610,12 @@ function () { ...@@ -606,10 +610,12 @@ function () {
this.videoCaption.setSubtitlesHeight(); this.videoCaption.setSubtitlesHeight();
$.cookie('hide_captions', hide_captions, { if (update_cookie) {
expires: 3650, $.cookie('hide_captions', hide_captions, {
path: '/' expires: 3650,
}); path: '/'
});
}
} }
function captionHeight() { function captionHeight() {
......
{ {
"start": [ "start": [
270, 270,
2720, 2720,
5430, 5430,
7160, 7160,
10830, 10830,
12880, 12880,
15890, 15890,
19000, 19000,
22070, 22070,
25170, 25170,
27890, 27890,
30590, 30590,
32920, 32920,
36360, 36360,
39630, 39630,
41170, 41170,
42790, 42790,
44590, 44590,
47320, 47320,
50250, 50250,
51880, 51880,
54320, 54320,
57410, 57410,
59160, 59160,
62320, 62320,
65099, 65099,
68430, 68430,
71360, 71360,
73640, 73640,
76580, 76580,
78660, 78660,
81480, 81480,
83940, 83940,
86230, 86230,
88570, 88570,
90520, 90520,
93430, 93430,
95940, 95940,
99090, 99090,
100910, 100910,
103740, 103740,
105610, 105610,
108310, 108310,
111100, 111100,
112360 112360
], ],
"end": [ "end": [
2720, 2720,
5430, 5430,
7160, 7160,
10830, 10830,
12880, 12880,
15890, 15890,
19000, 19000,
22070, 22070,
25170, 25170,
27890, 27890,
30590, 30590,
32920, 32920,
36360, 36360,
39630, 39630,
41170, 41170,
42790, 42790,
44590, 44590,
47320, 47320,
50250, 50250,
51880, 51880,
54320, 54320,
57410, 57410,
59160, 59160,
62320, 62320,
65099, 65099,
68430, 68430,
71360, 71360,
73640, 73640,
76580, 76580,
78660, 78660,
81480, 81480,
83940, 83940,
86230, 86230,
88570, 88570,
90520, 90520,
93430, 93430,
95940, 95940,
99090, 99090,
100910, 100910,
103740, 103740,
105610, 105610,
108310, 108310,
111100, 111100,
112360, 112360,
114220 114220
], ],
"text": [ "text": [
"LILA FISHER: Hi, welcome to Edx.", "LILA FISHER: Hi, welcome to Edx.",
"I'm Lila Fisher, an Edx fellow helping to put", "I'm Lila Fisher, an Edx fellow helping to put",
"together these courses.", "together these courses.",
"As you know, our courses are entirely online.", "As you know, our courses are entirely online.",
"So before we start learning about the subjects that", "So before we start learning about the subjects that",
"brought you here, let's learn about the tools that you will", "brought you here, let's learn about the tools that you will",
"use to navigate through the course material.", "use to navigate through the course material.",
"Let's start with what is on your screen right now.", "Let's start with what is on your screen right now.",
"You are watching a video of me talking.", "You are watching a video of me talking.",
"You have several tools associated with these videos.", "You have several tools associated with these videos.",
"Some of them are standard video buttons, like the play", "Some of them are standard video buttons, like the play",
"Pause Button on the bottom left.", "Pause Button on the bottom left.",
"Like most video players, you can see how far you are into", "Like most video players, you can see how far you are into",
"this particular video segment and how long the entire video", "this particular video segment and how long the entire video",
"segment is.", "segment is.",
"Something that you might not be used to", "Something that you might not be used to",
"is the speed option.", "is the speed option.",
"While you are going through the videos, you can speed up", "While you are going through the videos, you can speed up",
"or slow down the video player with these buttons.", "or slow down the video player with these buttons.",
"Go ahead and try that now.", "Go ahead and try that now.",
"Make me talk faster and slower.", "Make me talk faster and slower.",
"If you ever get frustrated by the pace of speech, you can", "If you ever get frustrated by the pace of speech, you can",
"adjust it this way.", "adjust it this way.",
"Another great feature is the transcript on the side.", "Another great feature is the transcript on the side.",
"This will follow along with everything that I am saying as", "This will follow along with everything that I am saying as",
"I am saying it, so you can read along if you like.", "I am saying it, so you can read along if you like.",
"You can also click on any of the words, and you will notice", "You can also click on any of the words, and you will notice",
"that the video jumps to that word.", "that the video jumps to that word.",
"The video slider at the bottom of the video will let you", "The video slider at the bottom of the video will let you",
"navigate through the video quickly.", "navigate through the video quickly.",
"If you ever find the transcript distracting, you", "If you ever find the transcript distracting, you",
"can toggle the captioning button in order to make it go", "can toggle the captioning button in order to make it go",
"away or reappear.", "away or reappear.",
"Now that you know about the video player, I want to point", "Now that you know about the video player, I want to point",
"out the sequence navigator.", "out the sequence navigator.",
"Right now you're in a lecture sequence, which interweaves", "Right now you're in a lecture sequence, which interweaves",
"many videos and practice exercises.", "many videos and practice exercises.",
"You can see how far you are in a particular sequence by", "You can see how far you are in a particular sequence by",
"observing which tab you're on.", "observing which tab you're on.",
"You can navigate directly to any video or exercise by", "You can navigate directly to any video or exercise by",
"clicking on the appropriate tab.", "clicking on the appropriate tab.",
"You can also progress to the next element by pressing the", "You can also progress to the next element by pressing the",
"Arrow button, or by clicking on the next tab.", "Arrow button, or by clicking on the next tab.",
"Try that now.", "Try that now.",
"The tutorial will continue in the next video." "The tutorial will continue in the next video."
] ]
} }
\ No newline at end of file
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