1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Include test fixture.
6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']);
11 * @extends {ChromeVoxUnitTestBase}
13 function CvoxCommandStoreUnitTest() {}
15 CvoxCommandStoreUnitTest.prototype = {
16 __proto__: ChromeVoxUnitTestBase.prototype,
20 'cvox.ChromeVoxUserCommands',
25 TEST_F('CvoxCommandStoreUnitTest', 'TableData', function() {
26 var categories = cvox.CommandStore.categories();
27 assertEquals(10, categories.length);
28 assertEquals('modifier_keys', categories[0]);
29 assertEquals('controlling_speech', categories[1]);
30 assertEquals('navigation', categories[2]);
31 assertEquals('information', categories[3]);
32 assertEquals('help_commands', categories[4]);
33 assertEquals('overview', categories[5]);
34 assertEquals('jump_commands', categories[6]);
35 assertEquals('tables', categories[7]);
37 assertEquals('stop_speech_key',
38 cvox.CommandStore.messageForCommand('stopSpeech'));
39 assertEquals('controlling_speech',
40 cvox.CommandStore.categoryForCommand('stopSpeech'));
42 var controllingSpeechCmds =
43 cvox.CommandStore.commandsForCategory('controlling_speech');
44 assertEquals(11, controllingSpeechCmds.length);
45 assertEquals('stopSpeech', controllingSpeechCmds[0]);
46 assertEquals('toggleChromeVox', controllingSpeechCmds[1]);
47 assertEquals('decreaseTtsRate', controllingSpeechCmds[2]);
48 assertEquals('increaseTtsRate', controllingSpeechCmds[3]);
49 assertEquals('decreaseTtsPitch', controllingSpeechCmds[4]);
50 assertEquals('increaseTtsPitch', controllingSpeechCmds[5]);
54 /** Tests that undefined is returned for bad queries. */
55 TEST_F('CvoxCommandStoreUnitTest', 'InvalidQueries', function() {
56 assertThat(cvox.CommandStore.commandsForCategory('foo'), eqJSON([]));
57 assertTrue(undefined == cvox.CommandStore.categoryForCommand('foo'));
58 assertTrue(undefined == cvox.CommandStore.messageForCommand('foo'));
62 /** Tests the validity of every command. */
63 TEST_F('CvoxCommandStoreUnitTest', 'CommandValidity', function() {
64 var categories = cvox.CommandStore.categories();
65 for (var i = 0; i < categories.length; i++) {
66 var commands = cvox.CommandStore.commandsForCategory(categories[i]);
67 for (j = 0; j < commands.length; j++) {
68 var command = commands[j];
69 assertEquals(command + ' function',
70 command + ' ' + typeof(cvox.ChromeVoxUserCommands.commands[command]));