braille_table_test.extjs revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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. 4 5// Include test fixture. 6GEN_INCLUDE(['../../testing/chromevox_e2e_test_base.js', 7 '../../testing/assert_additions.js']); 8 9/** 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 12 * a webui-style test. 13 * @constructor 14 * @extends {ChromeVoxE2ETest} 15 */ 16function CvoxBrailleTableTest() {} 17 18CvoxBrailleTableTest.prototype = { 19 __proto__: ChromeVoxE2ETest.prototype, 20}; 21 22/** 23 * Tests that {@code getAll} can fetch and parse the tables file. 24 * NOTE: This will need to be adjusted when more tables are added. 25 */ 26TEST_F('CvoxBrailleTableTest', 'testGetAllAndValidate', function() { 27 cvox.BrailleTable.getAll(function(tables) { 28 expectEquals(68, tables.length); 29 assertNotNullNorUndefined( 30 cvox.BrailleTable.forId(tables, 'en-US-g1'), 31 'Can\'t find US English grade 1 table'); 32 for (var i = 0, table; table = tables[i]; ++i) { 33 expectEquals('string', typeof table.id); 34 expectTrue(table.dots === '6' || table.dots === '8'); 35 expectTrue(cvox.BrailleTable.getDisplayName(table).length > 0); 36 } 37 testDone(); 38 }); 39}); 40 41/** Tests getDisplayName for some specific representative cases. */ 42TEST_F('CvoxBrailleTableTest', 'testGetDisplayName', function() { 43 cvox.BrailleTable.getAll(function(tables) { 44 var table = cvox.BrailleTable.forId(tables, 'bg-comp8'); 45 expectEquals('Bulgarian', cvox.BrailleTable.getDisplayName(table)); 46 table = cvox.BrailleTable.forId(tables, 'ar-g1'); 47 expectEquals('Arabic, Grade 1', cvox.BrailleTable.getDisplayName(table)); 48 table = cvox.BrailleTable.forId(tables, 'en-UEB-g1'); 49 expectEquals('English (UEB), Grade 1', 50 cvox.BrailleTable.getDisplayName(table)); 51 testDone(); 52 }); 53}); 54 55/** 56 * Tests the getUncontracted function. 57 */ 58TEST_F('CvoxBrailleTableTest', 'testGetUncontracted', function() { 59 cvox.BrailleTable.getAll(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); 66 } 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'); 73 testDone(); 74 }); 75}); 76