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 ChromeVoxE2ETest.call(this); |
| 18 } |
17 | 19 |
18 CvoxBrailleTableTest.prototype = { | 20 CvoxBrailleTableTest.prototype = { |
19 __proto__: ChromeVoxE2ETest.prototype, | 21 __proto__: ChromeVoxE2ETest.prototype, |
20 }; | 22 }; |
21 | 23 |
22 /** | 24 /** |
23 * Tests that {@code getAll} can fetch and parse the tables file. | 25 * Tests that {@code getAll} can fetch and parse the tables file. |
24 * NOTE: This will need to be adjusted when more tables are added. | 26 * NOTE: This will need to be adjusted when more tables are added. |
25 */ | 27 */ |
26 TEST_F('CvoxBrailleTableTest', 'testGetAllAndValidate', function() { | 28 TEST_F('CvoxBrailleTableTest', 'testGetAllAndValidate', function() { |
27 cvox.BrailleTable.getAll(function(tables) { | 29 cvox.BrailleTable.getAll(this.newCallback(function(tables) { |
28 expectEquals(68, tables.length); | 30 expectEquals(68, tables.length); |
29 assertNotNullNorUndefined( | 31 assertNotNullNorUndefined( |
30 cvox.BrailleTable.forId(tables, 'en-US-g1'), | 32 cvox.BrailleTable.forId(tables, 'en-US-g1'), |
31 'Can\'t find US English grade 1 table'); | 33 'Can\'t find US English grade 1 table'); |
32 for (var i = 0, table; table = tables[i]; ++i) { | 34 for (var i = 0, table; table = tables[i]; ++i) { |
33 expectEquals('string', typeof table.id); | 35 expectEquals('string', typeof table.id); |
34 expectTrue(table.dots === '6' || table.dots === '8'); | 36 expectTrue(table.dots === '6' || table.dots === '8'); |
35 expectTrue(cvox.BrailleTable.getDisplayName(table).length > 0); | 37 expectTrue(cvox.BrailleTable.getDisplayName(table).length > 0); |
36 } | 38 } |
37 testDone(); | 39 })); |
38 }); | |
39 }); | 40 }); |
40 | 41 |
41 /** Tests getDisplayName for some specific representative cases. */ | 42 /** Tests getDisplayName for some specific representative cases. */ |
42 TEST_F('CvoxBrailleTableTest', 'testGetDisplayName', function() { | 43 TEST_F('CvoxBrailleTableTest', 'testGetDisplayName', function() { |
43 cvox.BrailleTable.getAll(function(tables) { | 44 cvox.BrailleTable.getAll(this.newCallback(function(tables) { |
44 var table = cvox.BrailleTable.forId(tables, 'bg-comp8'); | 45 var table = cvox.BrailleTable.forId(tables, 'bg-comp8'); |
45 expectEquals('Bulgarian', cvox.BrailleTable.getDisplayName(table)); | 46 expectEquals('Bulgarian', cvox.BrailleTable.getDisplayName(table)); |
46 table = cvox.BrailleTable.forId(tables, 'ar-g1'); | 47 table = cvox.BrailleTable.forId(tables, 'ar-g1'); |
47 expectEquals('Arabic, Grade 1', cvox.BrailleTable.getDisplayName(table)); | 48 expectEquals('Arabic, Grade 1', cvox.BrailleTable.getDisplayName(table)); |
48 table = cvox.BrailleTable.forId(tables, 'en-UEB-g1'); | 49 table = cvox.BrailleTable.forId(tables, 'en-UEB-g1'); |
49 expectEquals('English (UEB), Grade 1', | 50 expectEquals('English (UEB), Grade 1', |
50 cvox.BrailleTable.getDisplayName(table)); | 51 cvox.BrailleTable.getDisplayName(table)); |
51 testDone(); | 52 })); |
52 }); | |
53 }); | 53 }); |
54 | 54 |
55 /** | 55 /** |
56 * Tests the getUncontracted function. | 56 * Tests the getUncontracted function. |
57 */ | 57 */ |
58 TEST_F('CvoxBrailleTableTest', 'testGetUncontracted', function() { | 58 TEST_F('CvoxBrailleTableTest', 'testGetUncontracted', function() { |
59 cvox.BrailleTable.getAll(function(tables) { | 59 cvox.BrailleTable.getAll(this.newCallback(function(tables) { |
60 function expectUncontracted(uncontractedId, idToCheck) { | 60 function expectUncontracted(uncontractedId, idToCheck) { |
61 var checkedTable = cvox.BrailleTable.forId(tables, idToCheck); | 61 var checkedTable = cvox.BrailleTable.forId(tables, idToCheck); |
62 var uncontractedTable = cvox.BrailleTable.getUncontracted( | 62 var uncontractedTable = cvox.BrailleTable.getUncontracted( |
63 tables, checkedTable); | 63 tables, checkedTable); |
64 expectNotEquals(null, uncontractedTable); | 64 expectNotEquals(null, uncontractedTable); |
65 expectEquals(uncontractedId, uncontractedTable.id); | 65 expectEquals(uncontractedId, uncontractedTable.id); |
66 } | 66 } |
67 expectUncontracted('en-US-comp8', 'en-US-g2'); | 67 expectUncontracted('en-US-comp8', 'en-US-g2'); |
68 expectUncontracted('en-US-comp8', 'en-US-comp8'); | 68 expectUncontracted('en-US-comp8', 'en-US-comp8'); |
69 expectUncontracted('nb-comp8', 'nb-g0'); | 69 expectUncontracted('nb-comp8', 'nb-g0'); |
70 expectUncontracted('sv-comp8', 'sv-g1'); | 70 expectUncontracted('sv-comp8', 'sv-g1'); |
71 expectUncontracted('ar-g1', 'ar-g1'); | 71 expectUncontracted('ar-g1', 'ar-g1'); |
72 expectUncontracted('de-comp8', 'de-CH-g2'); | 72 expectUncontracted('de-comp8', 'de-CH-g2'); |
73 testDone(); | 73 })); |
74 }); | |
75 }); | 74 }); |
OLD | NEW |