OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['../../testing/chromevox_e2e_test_base.js', | 6 GEN_INCLUDE(['../../testing/chromevox_e2e_test_base.js', |
7 '../../testing/assert_additions.js']); | 7 '../../testing/assert_additions.js']); |
8 | 8 |
9 /** | 9 /** |
10 * Test fixture for cvox.BrailleTable tests. | 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 | 11 * This is an E2E test because there's no easy way to load a data file in |
12 * a webui-style test. | 12 * a webui-style test. |
13 * @constructor | 13 * @constructor |
14 * @extends {ChromeVoxE2ETest} | 14 * @extends {ChromeVoxE2ETest} |
15 */ | 15 */ |
16 function CvoxBrailleTableTest() {} | 16 function CvoxBrailleTableTest() {} |
17 | 17 |
18 CvoxBrailleTableTest.prototype = { | 18 CvoxBrailleTableTest.prototype = { |
19 __proto__: ChromeVoxE2ETest.prototype, | 19 __proto__: ChromeVoxE2ETest.prototype, |
20 }; | 20 }; |
21 | 21 |
22 /** | 22 /** |
23 * Tests that {@code getAll} can fetch and parse the tables file. | 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. | 24 * NOTE: This will need to be adjusted when more tables are added. |
25 */ | 25 */ |
26 TEST_F('CvoxBrailleTableTest', 'testGetAll', function() { | 26 TEST_F('CvoxBrailleTableTest', 'testGetAllAndValidate', function() { |
27 cvox.BrailleTable.getAll(function(tables) { | 27 cvox.BrailleTable.getAll(function(tables) { |
28 assertEquals(59, tables.length); | 28 expectEquals(68, tables.length); |
29 assertNotNullNorUndefined( | 29 assertNotNullNorUndefined( |
30 cvox.BrailleTable.forId(tables, 'en-US-g1'), | 30 cvox.BrailleTable.forId(tables, 'en-US-g1'), |
31 'Can\'t find US English grade 1 table'); | 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 } |
32 testDone(); | 37 testDone(); |
33 }); | 38 }); |
34 }); | 39 }); |
| 40 |
| 41 /** Tests getDisplayName for some specific representative cases. */ |
| 42 TEST_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 }); |
35 | 54 |
36 /** | 55 /** |
37 * Tests the getUncontracted function. | 56 * Tests the getUncontracted function. |
38 */ | 57 */ |
39 TEST_F('CvoxBrailleTableTest', 'testGetUncontracted', function() { | 58 TEST_F('CvoxBrailleTableTest', 'testGetUncontracted', function() { |
40 cvox.BrailleTable.getAll(function(tables) { | 59 cvox.BrailleTable.getAll(function(tables) { |
41 function assertUncontracted(uncontractedId, idToCheck) { | 60 function expectUncontracted(uncontractedId, idToCheck) { |
42 var checkedTable = cvox.BrailleTable.forId(tables, idToCheck); | 61 var checkedTable = cvox.BrailleTable.forId(tables, idToCheck); |
43 var uncontractedTable = cvox.BrailleTable.getUncontracted( | 62 var uncontractedTable = cvox.BrailleTable.getUncontracted( |
44 tables, checkedTable); | 63 tables, checkedTable); |
45 assertNotEquals(null, uncontractedTable); | 64 expectNotEquals(null, uncontractedTable); |
46 assertEquals(uncontractedId, uncontractedTable.id); | 65 expectEquals(uncontractedId, uncontractedTable.id); |
47 } | 66 } |
48 assertUncontracted('en-US-comp8', 'en-US-g2'); | 67 expectUncontracted('en-US-comp8', 'en-US-g2'); |
49 assertUncontracted('en-US-comp8', 'en-US-comp8'); | 68 expectUncontracted('en-US-comp8', 'en-US-comp8'); |
50 assertUncontracted('nb-comp8', 'nb-g0'); | 69 expectUncontracted('nb-comp8', 'nb-g0'); |
51 assertUncontracted('sv-comp8', 'sv-g1'); | 70 expectUncontracted('sv-comp8', 'sv-g1'); |
52 assertUncontracted('ar-g1', 'ar-g1'); | 71 expectUncontracted('ar-g1', 'ar-g1'); |
53 assertUncontracted('de-comp8', 'de-CH-g2'); | 72 expectUncontracted('de-comp8', 'de-CH-g2'); |
54 testDone(); | 73 testDone(); |
55 }); | 74 }); |
56 }); | 75 }); |
OLD | NEW |