Skip to content

Commit

Permalink
FLUID-5936: refactor queue implementation to clear queue item on hand…
Browse files Browse the repository at this point in the history
…leEnd, not handleStart.
  • Loading branch information
waharnum committed Sep 1, 2016
1 parent 839f735 commit fe384eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
18 changes: 7 additions & 11 deletions src/components/textToSpeech/js/TextToSpeech.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ var fluid_2_0_0 = fluid_2_0_0 || {};
"method": "getVoices"
},
handleStart: {
funcName: "fluid.textToSpeech.handleStart",
args: ["{that}"]
changePath: "speaking",
value: true
},
// The handleEnd method is assumed to be triggered asynchronously
// as it is processed/triggered by the mechanism voicing the utterance.
Expand Down Expand Up @@ -228,23 +228,19 @@ var fluid_2_0_0 = fluid_2_0_0 || {};
}
};

fluid.textToSpeech.handleStart = function (that) {
that.queue.shift();
that.applier.change("speaking", true);
fluid.textToSpeech.handleEnd = function (that) {

if (that.queue.length) {
that.applier.change("pending", true);
}
};
that.queue.shift();

fluid.textToSpeech.handleEnd = function (that) {
var resetValues = {
speaking: false,
pending: false,
paused: false
};

if (!that.queue.length) {
if (that.queue.length) {
that.applier.change("pending", true);
} else if (!that.queue.length) {
var newModel = $.extend({}, that.model, resetValues);
that.applier.change("", newModel);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/component-tests/textToSpeech/js/TextToSpeechTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
{
name: "Start and Stop Events",
tests: [{
expect: 10,
expect: 13,
name: "Test Start and Stop Events",
sequence:
[{
Expand Down Expand Up @@ -190,9 +190,10 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertTrue("Should be speaking", that.model.speaking);
jqUnit.assertFalse("Nothing should be pending", that.model.pending);
jqUnit.assertFalse("Shouldn't be paused", that.model.paused);
jqUnit.assertDeepEq("The queue should be empty", [], that.queue);
// jqUnit.assertTrue("A currentUtterance is present in the queue", that.queue.currentUtterance);
// jqUnit.assertTrue("The currentUtterance is a SpeechSynthesisUtterance object", "SpeechSynthesisUtterance", that.queue.currentUtterance.constructor.name);
jqUnit.assertEquals("The queue should contain one item", 1, that.queue.length);
jqUnit.assertTrue("A text is present in the queue's first item", that.queue[0].text);
jqUnit.assertTrue("An utterance is present in the queue's first item", that.queue[0].utterance);
jqUnit.assertTrue("The utterance is a SpeechSynthesisUtterance object", "SpeechSynthesisUtterance", that.queue[0].utterance.constructor.name);

};

Expand Down

0 comments on commit fe384eb

Please sign in to comment.