From 6f430d360f945ae0c09a5b0851971498df339463 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Wed, 9 Sep 2015 08:32:44 -0400 Subject: [PATCH] FLOE-416: Updating from Infusion Updated to latest version of Infusion to get fix for FLUID-5756 --- src/lib/infusion/VERSION.md | 5 +- src/lib/infusion/infusion-custom.js | 2 +- .../src/components/textToSpeech/js/MockTTS.js | 113 ++++++++++++++++++ 3 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 src/lib/infusion/src/components/textToSpeech/js/MockTTS.js diff --git a/src/lib/infusion/VERSION.md b/src/lib/infusion/VERSION.md index fc9e356..ddc2d1f 100644 --- a/src/lib/infusion/VERSION.md +++ b/src/lib/infusion/VERSION.md @@ -2,7 +2,7 @@ The version of Infusion included in this folder was created using a custom build https://github.com/fluid-project/infusion -commit#: cb316066f3fe3e1d4b144a4ba42e3cfe79143add +commit#: a1e3d601478e57276d4143fca5bcbe00f9c6b0cd ``` grunt custom --source=true --include="preferences, tooltip" @@ -16,7 +16,8 @@ The following directories were stripped out of the build since they contain code * src/lib/infusion/src/components/tableOfContents/js/ * src/lib/infusion/src/components/tableOfContents/tableOfContentsDependencies.json * src/lib/infusion/src/components/textfieldSlider/ -* src/lib/infusion/src/components/textToSpeech/ +* src/lib/infusion/src/components/textToSpeech/js/TextToSpeech.js +* src/lib/infusion/src/components/textToSpeech/textToSpeechDependencies.json * src/lib/infusion/src/components/tooltip/ * src/lib/infusion/src/framework/core/frameworkDependencies.json * src/lib/infusion/src/framework/core/js/ diff --git a/src/lib/infusion/infusion-custom.js b/src/lib/infusion/infusion-custom.js index ba5c995..bd21aac 100644 --- a/src/lib/infusion/infusion-custom.js +++ b/src/lib/infusion/infusion-custom.js @@ -1,4 +1,4 @@ -/*! infusion - v2.0.0-SNAPSHOT Wednesday, September 2nd, 2015, 10:16:49 AM*/ +/*! infusion - v2.0.0-SNAPSHOT Wednesday, September 9th, 2015, 8:27:28 AM*/ /*! * jQuery JavaScript Library v1.11.0 * http://jquery.com/ diff --git a/src/lib/infusion/src/components/textToSpeech/js/MockTTS.js b/src/lib/infusion/src/components/textToSpeech/js/MockTTS.js new file mode 100644 index 0000000..4e4da82 --- /dev/null +++ b/src/lib/infusion/src/components/textToSpeech/js/MockTTS.js @@ -0,0 +1,113 @@ +/* +Copyright 2015 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 + +*/ + +/* global fluid */ + +(function () { + "use strict"; + + // Mocks the fluid.textToSpeech component, removing calls to the + // Web Speech API. This will allow for tests to run in browsers + // that don't support the Web Speech API. + fluid.defaults("fluid.mock.textToSpeech", { + gradeNames: ["fluid.textToSpeech", "autoInit"], + members: { + // An archive of all the calls to queueSpeech. + // Will contain an ordered set of objects -- {text: String, options: Object}. + speechRecord: [], + // An archive of all the events fired + // Will contain a key/value pairing where key is the name of the event and the + // value is the number of times the event was fired. + eventRecord: {} + }, + listeners: { + "onStart.recordEvent": { + listener: "{that}.recordEvent", + args: ["onStart"] + }, + "onStop.recordEvent": { + listener: "{that}.recordEvent", + args: ["onStop"] + }, + "onSpeechQueued.recordEvent": { + listener: "{that}.recordEvent", + args: ["onSpeechQueued"] + } + }, + invokers: { + queueSpeech: { + funcName: "fluid.mock.textToSpeech.queueSpeech", + args: ["{that}", "{that}.handleStart", "{that}.handleEnd", "{that}.speechRecord", "{arguments}.0", "{arguments}.1", "{arguments}.2"] + }, + cancel: { + funcName: "fluid.mock.textToSpeech.cancel", + args: ["{that}", "{that}.handleEnd"] + }, + pause: { + "this": null, // TODO: This needs to be removed once FLUID-5714 is fixed + method: null, + func: "{that}.events.onPause.fire" + }, + resume: { + "this": null, + method: null, + func: "{that}.events.onResume.fire" + }, + getVoices: { + "this": null, + method: null, + funcName: "fluid.identity", + args: [] + }, + recordEvent: { + funcName: "fluid.mock.textToSpeech.recordEvent", + args: ["{that}.eventRecord", "{arguments}.0"] + } + } + }); + + fluid.mock.textToSpeech.queueSpeech = function (that, handleStart, handleEnd, speechRecord, text, interrupt, options) { + if (interrupt) { + that.cancel(); + } + + var record = { + text: text, + interrupt: !!interrupt + }; + + if (options) { + record.options = options; + } + + speechRecord.push(record); + + that.queue.push(text); + that.events.onSpeechQueued.fire(text); + + // mocking speechSynthesis speak + handleStart(); + // using setTimeout to preserve asynchronous behaviour + setTimeout(handleEnd, 0); + + }; + + fluid.mock.textToSpeech.cancel = function (that, handleEnd) { + that.queue = []; + handleEnd(); + }; + + fluid.mock.textToSpeech.recordEvent = function (eventRecord, name) { + eventRecord[name] = (eventRecord[name] || 0) + 1; + }; + +})();