Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLUID-5936: fix bug in fluid.textToSpeech.checkTTSSupport, rewrite tests to use IoC testing #732

Merged
merged 45 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f3de9d5
Merge pull request #6 from fluid-project/master
waharnum Jul 27, 2016
8a0255f
FLUID-5936: use correct API event handler for end of speech
waharnum Jul 28, 2016
a66947d
FLUID-5936: add a comment about the tests currently being skipped in …
waharnum Jul 28, 2016
e85d86a
FLUID-5936: rewrite tests to use the IoC framework
waharnum Jul 28, 2016
2dba2cf
FLUID-5936: restructure tests to better handle variations in asynchro…
waharnum Aug 4, 2016
03f3dd1
FLUID-5936: linting
waharnum Aug 4, 2016
8be2d97
FLUID-5936: potential fix for test failures on Windows
waharnum Aug 5, 2016
15b6cf6
FLUID-5936: continuing the quest for a sequencing approach that will …
waharnum Aug 5, 2016
a92d6ed
FLUID-5936: issue pause/resume commands in test with slight delay
waharnum Aug 5, 2016
9143c35
FLUID-5936: set volume to 0
waharnum Aug 5, 2016
53099b7
FLUID-5936: linting
waharnum Aug 5, 2016
d6077c5
FLUID-5936: 50ms timeout for control interaction
waharnum Aug 8, 2016
d05ac06
FLUID-5936: move asynchronous command issuance into main component fr…
waharnum Aug 8, 2016
3f162b6
FLUID-5936: reset volume to 0
waharnum Aug 8, 2016
5ca02a8
FLUID-5936: use an asyncTest wrapper around the promise to prevent th…
waharnum Aug 15, 2016
13ba66a
FLUID-5936: add a comment about setTimeout of asyncTest wrapper
waharnum Aug 16, 2016
5b08b2a
FLUID-5936: fix comment line length
waharnum Aug 16, 2016
12d3b15
FLUID-5936: simplify asynctest structure
waharnum Aug 17, 2016
5f6809e
FLUID-5936: extract generalized wrapper for choosing which test to ex…
waharnum Aug 17, 2016
fca22cd
Merge pull request #7 from fluid-project/master
waharnum Aug 17, 2016
49bd622
FLUID-5936: use 'task' naming convention.
waharnum Aug 22, 2016
d4e918e
FLUID-5936: comment further on the promise-based test execution
waharnum Aug 22, 2016
ad41acf
FLUID-5936: use task naming convention properly.
waharnum Aug 22, 2016
6f8f445
FLUID-5936: queueing implementation, async wrapper for all speech com…
waharnum Aug 25, 2016
09caf85
FLUID-5936: refactoring
waharnum Aug 25, 2016
5a73622
FLUID-5936: further refactoring
waharnum Aug 25, 2016
5129f87
FLUID-5936: more refactoring, more aggressive testing
waharnum Aug 25, 2016
e35df8e
FLUID-5936: updated comment.
waharnum Aug 25, 2016
1e5af4d
FLUID-5936: refactoring
waharnum Aug 25, 2016
7db392b
FLUID-5936: store the currentUtterance on a member of the component t…
waharnum Aug 29, 2016
2accf4f
FLUID-5936: reduce volume of test to 0
waharnum Aug 29, 2016
543b95d
Merge pull request #8 from fluid-project/master
waharnum Aug 30, 2016
71f116b
Merge branch 'master' into FLUID-5936
waharnum Aug 30, 2016
df09711
NOJIRA: add keyword-spacing rule to linter, correct two files for tha…
waharnum Aug 30, 2016
98a0330
Merge branch 'keyword-spacing' into FLUID-5936
waharnum Aug 30, 2016
00bedf1
FLUID-5936: lintin
waharnum Aug 30, 2016
e9cd164
FLUID-5936: comment in accidental comment out.
waharnum Aug 30, 2016
71bc4ec
FLUID-5936: place currentUtterance in queue structure with texts.
waharnum Aug 30, 2016
5b2c2da
FLUID-5936: add some tests for the currentUtterance implementation.
waharnum Aug 30, 2016
75f3de3
FLUID-5936: remove onpause/onresume events
waharnum Aug 30, 2016
f4d3152
FLUID-5936: modelizing
waharnum Aug 30, 2016
e9e6069
FLUID-5936: implement throttle-based control
waharnum Sep 1, 2016
265f3fe
FLUID-5936: remove unneeded function.
waharnum Sep 1, 2016
839f735
FLUID-5936: store utterance as part of queue array.
waharnum Sep 1, 2016
fe384eb
FLUID-5936: refactor queue implementation to clear queue item on hand…
waharnum Sep 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/textToSpeech/js/TextToSpeech.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var fluid_2_0_0 = fluid_2_0_0 || {};
speechSynthesis.cancel();
promise.reject();
}, delay || 1000);
toSpeak.onstop = function () {
toSpeak.onend = function () {
clearTimeout(timeout);
speechSynthesis.cancel();
promise.resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<script type="text/javascript" src="../../../test-core/jqUnit/js/jqUnit-browser.js"></script>
<script type="text/javascript" src="../../../lib/jquery-ui/js/jquery.simulate.js"></script>

<!-- needed for IoC testing framework -->
<script type="text/javascript" src="../../../../src/framework/enhancement/js/ContextAwareness.js"></script>
<script src="../../../test-core/utils/js/IoCTestUtils.js"></script>

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

Expand Down
210 changes: 125 additions & 85 deletions tests/component-tests/textToSpeech/js/TextToSpeechTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,110 +34,150 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
speechSynthesis.cancel();
};

fluid.defaults("fluid.tests.textToSpeech.startStop", {
gradeNames: ["fluid.tests.textToSpeech"],
listeners: {
"onStart.test": {
listener: function (that) {
jqUnit.assert("The onStart event should have fired");
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);
},
args: ["{that}"]
fluid.defaults("fluid.tests.textToSpeech.ttsTestEnvironment", {
gradeNames: "fluid.test.testEnvironment",
components: {
tts: {
type: "fluid.tests.textToSpeech",
createOnEvent: "{ttsTester}.events.onTestCaseStart"
},
"onStop.test": {
listener: function (that) {
jqUnit.assert("The onStop event should have fired");
jqUnit.assertFalse("Should not 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);
that.cancel();
jqUnit.start();
},
args: ["{that}"]
ttsTester: {
type: "fluid.tests.textToSpeech.ttsTester"
}
}
});

fluid.defaults("fluid.tests.textToSpeech.pauseResume", {
gradeNames: ["fluid.tests.textToSpeech"],
listeners: {
"onStart.pause": {
listener: "{that}.pause"
},
"onPause.test": {
listener: function (that) {
that.wasPaused = true;
jqUnit.assert("The pause event should have fired");
jqUnit.assertTrue("Should be speaking", that.model.speaking);
jqUnit.assertFalse("Nothing should be pending", that.model.pending);
jqUnit.assertTrue("Should be paused", that.model.paused);
that.resume();
},
args: ["{that}"]
fluid.defaults("fluid.tests.textToSpeech.ttsTester", {
gradeNames: ["fluid.test.testCaseHolder"],
modules: [
{
name: "Initialization",
tests: [{
expect: 4,
name: "Test initialization",
sequence:
[{
func: "fluid.tests.textToSpeech.testInitialization",
args: ["{tts}"]
}]
}],

},
"onResume.test": {
listener: function (that) {
jqUnit.assert("The resume event should have fired");
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);
},
args: ["{that}"]
{
name: "Start and Stop Events",
tests: [{
expect: 10,
name: "Test Start and Stop Events",
sequence:
[{
func: "{tts}.queueSpeech",
args: "Testing start and end events"
}, {
listener: "fluid.tests.textToSpeech.testStart",
args: ["{tts}"],
event: "{tts}.events.onStart"
}, {
listener: "fluid.tests.textToSpeech.testStop",
args: ["{tts}"],
event: "{tts}.events.onStop"
}]
}]
},
"onStop.end": {
listener: function (that) {
that.cancel();
jqUnit.start();
},
args: ["{that}"]
}
}
{
name: "Pause and Resume Events",
tests: [{
expect: 8,
name: "Test Pause and Resume Events",
sequence:
[
{
func: "{tts}.queueSpeech",
args: "Testing pause and resume events"
},
{
func: "{tts}.pause"
},
{
listener: "fluid.tests.textToSpeech.testPause",
args: ["{tts}"],
event: "{tts}.events.onPause"
},
{
func: "{tts}.resume"
}, {
listener: "fluid.tests.textToSpeech.testResume",
args: ["{tts}"],
event: "{tts}.events.onResume"
},
// Catch the async event from onStop to know when the speech
// is actually finished and the fixture can be destroyed
{
listener: "fluid.identity",
event: "{tts}.events.onStop"
}
]
}]
}]
});

fluid.tests.textToSpeech.bypassTest = function () {
jqUnit.assert("TEST SKIPPED - browser does not support SpeechSynthesis");
jqUnit.start();
fluid.tests.textToSpeech.testInitialization = function (tts) {
var that = tts;
jqUnit.assertTrue("The Text to Speech component should have initialized", that);
jqUnit.assertFalse("Nothing should be speaking", that.model.speaking);
jqUnit.assertFalse("Nothing should be pending", that.model.pending);
jqUnit.assertFalse("Shouldn't be paused", that.model.paused);
};

// only run the tests in browsers that support the Web Speech API for speech synthesis
fluid.tests.textToSpeech.issueTest = function (name, testFunc) {
jqUnit.asyncTest(name, function () {
var runTests = fluid.textToSpeech.checkTTSSupport();
runTests.then(function () {
testFunc();
}, fluid.tests.textToSpeech.bypassTest);
});
fluid.tests.textToSpeech.testStart = function (tts) {
var that = tts;
jqUnit.assert("The onStart event should have fired");
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);
};

fluid.tests.textToSpeech.issueTest("Initialization", function () {
var that = fluid.tests.textToSpeech();
fluid.tests.textToSpeech.testStop = function (tts) {
var that = tts;
jqUnit.assert("The onStop event should have fired");
jqUnit.assertFalse("Should not 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);
that.cancel();
};

jqUnit.assertTrue("The Text to Speech component should have initialized", that);
jqUnit.assertFalse("Nothing should be speaking", that.model.speaking);
fluid.tests.textToSpeech.testPause = function (tts) {
var that = tts;
jqUnit.assert("The pause event should have fired");
jqUnit.assertTrue("Should be speaking", that.model.speaking);
jqUnit.assertFalse("Nothing should be pending", that.model.pending);
jqUnit.assertTrue("Should be paused", that.model.paused);
};

fluid.tests.textToSpeech.testResume = function (tts) {
var that = tts;
jqUnit.assert("The resume event should have fired");
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.start();
});
};

fluid.tests.textToSpeech.issueTest("Start and Stop Events", function () {
jqUnit.expect(10);
var that = fluid.tests.textToSpeech.startStop();
that.queueSpeech("Testing start and end events");
});
fluid.tests.textToSpeech.issueTest = function (name, testFunc) {
var runTests = fluid.textToSpeech.checkTTSSupport();
runTests.then(function () {
testFunc();
}, fluid.tests.textToSpeech.bypassTest);
};

// Chrome doesn't properly support pause which causes this test to break.
// see: https://code.google.com/p/chromium/issues/detail?id=425553&q=SpeechSynthesis&colspec=ID%20Pri%20M%20Week%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified
if (!window.chrome) {
fluid.tests.textToSpeech.issueTest("Pause and Resume Events", function () {
jqUnit.expect(8);
var that = fluid.tests.textToSpeech.pauseResume();
that.queueSpeech("Testing pause and resume events");
fluid.tests.textToSpeech.bypassTest = function () {
jqUnit.test("Tests were skipped - browser does not appear to support TTS", function () {
jqUnit.assert("TESTS SKIPPED - browser does not support SpeechSynthesis");
});
}
};

// fluid.setLogging(fluid.logLevel.TRACE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray comment


fluid.tests.textToSpeech.ttsTestEnvironment();

})();