Skip to content

Commit

Permalink
FLUID-4812: Don't automatically display transcripts if choice of tran…
Browse files Browse the repository at this point in the history
…script hasn't changed.
  • Loading branch information
acheetham committed Oct 22, 2012
1 parent 436e454 commit b41c757
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 72 deletions.
3 changes: 1 addition & 2 deletions js/VideoPlayer_transcript.js
Expand Up @@ -365,8 +365,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

that.applier.modelChanged.addListener("currentTracks.transcripts", function (model, oldModel) {
if (model.currentTracks.transcripts[0] === oldModel.currentTracks.transcripts[0]) {
// actual choice of track hasn't changed; just show it and be done
fluid.videoPlayer.transcript.showTranscriptArea(that);
// actual choice of track hasn't changed
return;
}

Expand Down
1 change: 1 addition & 0 deletions tests/all-tests.html
Expand Up @@ -17,6 +17,7 @@
"./html/VideoPlayerControls-test.html",
"./html/VideoPlayerHTML5Captionator-test.html",
"./html/VideoPlayerTranscript-test.html",
"./html/VideoPlayerTranscriptIntegration-test.html",
"./html/VideoPlayerIntervalEventsConductor-test.html",
"./html/VideoPlayerIntervalEventsConductorIntegration-test.html",
"./html/VideoPlayer-test.html",
Expand Down
3 changes: 2 additions & 1 deletion tests/html/VideoPlayerIntegration-test.html
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Video Player Test Suite</title>
<title>Video Player Integration Test Suite</title>

<link rel="stylesheet" type="text/css" media="screen" href="../lib/qunit/css/qunit.css" />

Expand All @@ -24,6 +24,7 @@
<script type="text/javascript" src="../lib/jqUnit/js/jqUnit.js"></script>

<!-- These are tests that have been written using this page as data and test supports -->
<script type="text/javascript" src="../js/TestUtils.js"></script>
<script type="text/javascript" src="../js/VideoPlayerIntegrationTests.js"></script>

<!-- Utils -->
Expand Down
67 changes: 67 additions & 0 deletions tests/html/VideoPlayerTranscriptIntegration-test.html
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Video Player Transcript Integration Test Suite</title>

<link rel="stylesheet" type="text/css" media="screen" href="../lib/qunit/css/qunit.css" />

<script type="text/javascript" src="../../lib/infusion/MyInfusion.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_framework.js"></script>
<script type="text/javascript" src="../../lib/jquery-ui/js/jquery.ui.button.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_html5Captionator.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_controllers.js"></script>
<script type="text/javascript" src="../../js/ToggleButton.js"></script>
<script type="text/javascript" src="../../js/MenuButton.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_media.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_transcript.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_intervalEventsConductor.js"></script>
<script type="text/javascript" src="../../js/HTML5-backcompat.js"></script>
<script type="text/javascript" src="../../js/VideoPlayer_uiOptions.js"></script>

<!-- jqUnit test framework js files -->
<script type="text/javascript" src="../lib/qunit/js/qunit.js"></script>
<script type="text/javascript" src="../lib/jqUnit/js/jqUnit.js"></script>

<!-- These are tests that have been written using this page as data and test supports -->
<script type="text/javascript" src="../js/TestUtils.js"></script>
<script type="text/javascript" src="../js/VideoPlayerTranscriptIntegrationTests.js"></script>

<!-- Utils -->
<script type="text/javascript" src="../../lib/captionator/js/captionator.js"></script>

</head>
<body id="body">
<script>
var fluid = fluid || {};
fluid.registerNamespace("fluid.videoPlayer");
fluid.videoPlayer.testPageEnhancer = fluid.pageEnhancer({
tocTemplate: "../../lib/infusion/components/tableOfContents/html/TableOfContents.html"
});
</script>

<div class="flc-uiOptions fl-uiOptions-fatPanel">
<div class="flc-slidingPanel-panel flc-uiOptions-iframe"></div>
<div class="fl-panelBar">
<button class="flc-slidingPanel-toggleButton fl-toggleButton">Show/Hide</button>
</div>
</div>
<div class="flc-toc-tocContainer"> </div>

<!-- This is the markup that jqUnit will look for when running tests and displaying the results -->
<h1 id="qunit-header">Video Player Transcript Integration Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">

<div class="videoPlayer-transcript fl-videoPlayer"></div>

</div> <!-- /main -->

<script>
</script>
</body>
</html>
70 changes: 70 additions & 0 deletions tests/js/TestUtils.js
Expand Up @@ -20,6 +20,76 @@ fluid.registerNamespace("fluid.testUtils");
/* A number of utility functions for testing things common among many controls */

(function ($) {
var baseOpts = {
video: {
sources: [
{
src: "TestVideo.mp4",
type: "video/mp4"
},
{
src: "../../demos/videos/ReorganizeFuture/ReorganizeFuture.webm",
type: "video/webm"
}
],
captions: [
{
src: "TestCaptions.en.vtt",
type: "text/vtt",
srclang: "en",
label: "English"
},
{
src: "TestCaptions.fr.vtt",
type: "text/vtt",
srclang: "fr",
label: "French"
}
],
transcripts: [
{
src: "TestTranscripts.en.json",
type: "JSONcc",
srclang: "en",
label: "English"
},
{
src: "TestTranscripts.fr.json",
type: "JSONcc",
srclang: "fr",
label: "French"
}
]
},
templates: {
videoPlayer: {
forceCache: true,
href: "../../html/videoPlayer_template.html"
}
}
};

fluid.testUtils.initVideoPlayer = function () {
var opts = fluid.copy(baseOpts);

// the 1st argument is the container and the following is component options
for (var index in arguments) {
if (index === "0") {
var container = arguments[index];
} else {
$.extend(true, opts, arguments[index]);
}
}

return fluid.videoPlayer(container, opts);
};

fluid.testUtils.initEnhancedVideoPlayer = function (instance, relay) {
var opts = fluid.copy(baseOpts);
$.extend(true, instance.options, opts);
return fluid.videoPlayer.makeEnhancedInstances(instance, relay);
};

fluid.testUtils.getTooltipCheckString = function (jEl, expectedText) {
jqUnit.expect(1);
jEl.mouseover();
Expand Down
74 changes: 5 additions & 69 deletions tests/js/VideoPlayerIntegrationTests.js
Expand Up @@ -21,70 +21,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

var videoPlayerIntegrationTests = new jqUnit.TestCase("Video Player Integration Tests");

var baseOpts = {
video: {
sources: [
{
src: "TestVideo.mp4",
type: "video/mp4"
},
{
src: "../../demos/videos/ReorganizeFuture/ReorganizeFuture.webm",
type: "video/webm"
}
],
captions: [
{
src: "TestCaptions.en.vtt",
type: "text/vtt",
srclang: "en",
label: "English"
},
{
src: "TestCaptions.fr.vtt",
type: "text/vtt",
srclang: "fr",
label: "French"
}
],
transcripts: [
{
src: "TestTranscripts.en.json",
type: "JSONcc",
srclang: "en",
label: "English"
},
{
src: "TestTranscripts.fr.json",
type: "JSONcc",
srclang: "fr",
label: "French"
}
]
},
templates: {
videoPlayer: {
forceCache: true,
href: "../../html/videoPlayer_template.html"
}
}
};

var initVideoPlayer = function () {
var opts = fluid.copy(baseOpts);

// the 1st argument is the container and the following is component options
for (var index in arguments) {
if (index === "0") {
var container = arguments[index];
} else {
$.extend(true, opts, arguments[index]);
}
}

return fluid.videoPlayer(container, opts);
};


var testPlayPause = function (clickFunc) {
var video = $(".flc-videoPlayer-video");
Expand Down Expand Up @@ -125,7 +61,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
};

initVideoPlayer($(".videoPlayer-playButton"), testOpts);
fluid.testUtils.initVideoPlayer($(".videoPlayer-playButton"), testOpts);
});

videoPlayerIntegrationTests.asyncTest("Container click - Play/Pause", function () {
Expand All @@ -145,7 +81,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
};

initVideoPlayer($(".videoPlayer-containerClick"), testOpts);
fluid.testUtils.initVideoPlayer($(".videoPlayer-containerClick"), testOpts);
});

videoPlayerIntegrationTests.asyncTest("Mute button", function () {
Expand All @@ -168,7 +104,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
};

initVideoPlayer($(".videoPlayer-playButton"), testOpts);
fluid.testUtils.initVideoPlayer($(".videoPlayer-playButton"), testOpts);
});

videoPlayerIntegrationTests.asyncTest("Show transcript button", function () {
Expand All @@ -193,7 +129,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
};

initVideoPlayer($(".videoPlayer-transcript"), testOpts);
fluid.testUtils.initVideoPlayer($(".videoPlayer-transcript"), testOpts);
});

videoPlayerIntegrationTests.asyncTest("Switch transcript language buttons", function () {
Expand Down Expand Up @@ -260,7 +196,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
};

initVideoPlayer($(".videoPlayer-transcript"), testOpts);
fluid.testUtils.initVideoPlayer($(".videoPlayer-transcript"), testOpts);
});

});
Expand Down
66 changes: 66 additions & 0 deletions tests/js/VideoPlayerTranscriptIntegrationTests.js
@@ -0,0 +1,66 @@
/*
Copyright 2012 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/

// Declare dependencies
/*global fluid, jqUnit, jQuery, start*/

// JSLint options
/*jslint white: true, funcinvoke: true, undef: true, newcap: true, nomen: true, regexp: true, bitwise: true, browser: true, forin: true, maxerr: 100, indent: 4 */

(function ($) {
$(document).ready(function () {

var uiOptions = fluid.uiOptions.fatPanel.withMediaPanel(".flc-uiOptions", {
prefix: "../../lib/infusion/components/uiOptions/html/",
components: {
relay: {
type: "fluid.videoPlayer.relay"
}
},
templateLoader: {
options: {
templates: {
mediaControls: "../../html/UIOptionsTemplate-media.html"
}
}
}
});

var videoPlayerTranscriptIntegrationTests = new jqUnit.TestCase("Video Player Transcript Integration Tests");

videoPlayerTranscriptIntegrationTests.asyncTest("FLUID-4812: Transcripts showing on UIO reset", function () {
jqUnit.expect(2);
var instance = {
container: ".videoPlayer-transcript",
options: {
templates: {
videoPlayer: {
href: "../../html/videoPlayer_template.html"
}
},
listeners: {
onReady: function (that) {
jqUnit.notVisible("Before UIO reset, transcripts are not visible", $(".flc-videoPlayer-transcriptArea"));
uiOptions.uiOptionsLoader.uiOptions.events.onUIOptionsRefresh.addListener(function () {
jqUnit.notVisible("After UIO reset, transcripts are not visible", $(".flc-videoPlayer-transcriptArea"));
start();
});
uiOptions.uiOptionsLoader.uiOptions.reset();
}
}
}
};
var vp = fluid.testUtils.initEnhancedVideoPlayer(instance, uiOptions.relay);
});

});
})(jQuery);

0 comments on commit b41c757

Please sign in to comment.