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