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_e2e_test_base.js',
7 '../testing/assert_additions.js']);
10 * Test fixture for cvox.BrailleTable tests.
11 * This is an E2E test because there's no easy way to load a data file in
14 * @extends {ChromeVoxE2ETest}
16 function CvoxBrailleTableTest() {
17 ChromeVoxE2ETest.call(this);
20 CvoxBrailleTableTest.prototype = {
21 __proto__: ChromeVoxE2ETest.prototype,
25 * Tests that {@code getAll} can fetch and parse the tables file.
26 * NOTE: This will need to be adjusted when more tables are added.
28 TEST_F('CvoxBrailleTableTest', 'testGetAllAndValidate', function() {
29 cvox.BrailleTable.getAll(this.newCallback(function(tables) {
30 expectEquals(68, tables.length);
31 assertNotNullNorUndefined(
32 cvox.BrailleTable.forId(tables, 'en-US-g1'),
33 'Can\'t find US English grade 1 table');
34 for (var i = 0, table; table = tables[i]; ++i) {
35 expectEquals('string', typeof table.id);
36 expectTrue(table.dots === '6' || table.dots === '8');
37 expectTrue(cvox.BrailleTable.getDisplayName(table).length > 0);
42 /** Tests getDisplayName for some specific representative cases. */
43 TEST_F('CvoxBrailleTableTest', 'testGetDisplayName', function() {
44 cvox.BrailleTable.getAll(this.newCallback(function(tables) {
45 var table = cvox.BrailleTable.forId(tables, 'bg-comp8');
46 expectEquals('Bulgarian', cvox.BrailleTable.getDisplayName(table));
47 table = cvox.BrailleTable.forId(tables, 'ar-g1');
48 expectEquals('Arabic, Grade 1', cvox.BrailleTable.getDisplayName(table));
49 table = cvox.BrailleTable.forId(tables, 'en-UEB-g1');
50 expectEquals('English (UEB), Grade 1',
51 cvox.BrailleTable.getDisplayName(table));
56 * Tests the getUncontracted function.
58 TEST_F('CvoxBrailleTableTest', 'testGetUncontracted', function() {
59 cvox.BrailleTable.getAll(this.newCallback(function(tables) {
60 function expectUncontracted(uncontractedId, idToCheck) {
61 var checkedTable = cvox.BrailleTable.forId(tables, idToCheck);
62 var uncontractedTable = cvox.BrailleTable.getUncontracted(
63 tables, checkedTable);
64 expectNotEquals(null, uncontractedTable);
65 expectEquals(uncontractedId, uncontractedTable.id);
67 expectUncontracted('en-US-comp8', 'en-US-g2');
68 expectUncontracted('en-US-comp8', 'en-US-comp8');
69 expectUncontracted('nb-comp8', 'nb-g0');
70 expectUncontracted('sv-comp8', 'sv-g1');
71 expectUncontracted('ar-g1', 'ar-g1');
72 expectUncontracted('de-comp8', 'de-CH-g2');