OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 var pass = chrome.test.callbackPass; | 5 var pass = chrome.test.callbackPass; |
6 | 6 |
7 var TABLE_NAME = 'en-us-comp8.ctb'; | 7 var TABLE_NAME = 'en-us-comp8.ctb'; |
| 8 var CONTRACTED_TABLE_NAME = 'en-us-g2.ctb'; |
8 var TEXT = 'hello'; | 9 var TEXT = 'hello'; |
9 // Translation of the above string as a hexadecimal sequence of cells. | 10 // Translation of the above string as a hexadecimal sequence of cells. |
10 var CELLS = '1311070715'; | 11 var CELLS = '1311070715'; |
11 | 12 |
12 var pendingCallback = null; | 13 var pendingCallback = null; |
13 var pendingMessageId = -1; | 14 var pendingMessageId = -1; |
14 var nextMessageId = 0; | 15 var nextMessageId = 0; |
15 var naclEmbed = null; | 16 var naclEmbed = null; |
16 | 17 |
17 function loadLibrary(callback) { | 18 function loadLibrary(callback) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 pass(expectSuccessReply(function(reply) { | 75 pass(expectSuccessReply(function(reply) { |
75 chrome.test.assertEq(CELLS, reply['cells']); | 76 chrome.test.assertEq(CELLS, reply['cells']); |
76 }))); | 77 }))); |
77 }, | 78 }, |
78 | 79 |
79 // Regression test for the case where the translated result is more than | 80 // Regression test for the case where the translated result is more than |
80 // the double size of the input. In this particular case, a single capital | 81 // the double size of the input. In this particular case, a single capital |
81 // letter 'T' should be translated to 3 cells in US English grade 2 | 82 // letter 'T' should be translated to 3 cells in US English grade 2 |
82 // braille (dots 56, 6, 2345). | 83 // braille (dots 56, 6, 2345). |
83 function testTranslateGrade2SingleCapital() { | 84 function testTranslateGrade2SingleCapital() { |
84 rpc('Translate', { 'table_name': 'en-us-g2.ctb', 'text': 'T'}, | 85 rpc('Translate', { 'table_name': CONTRACTED_TABLE_NAME, 'text': 'T'}, |
85 pass(expectSuccessReply(function(reply) { | 86 pass(expectSuccessReply(function(reply) { |
86 chrome.test.assertEq('30201e', reply['cells']); | 87 chrome.test.assertEq('30201e', reply['cells']); |
87 }))); | 88 }))); |
88 }, | 89 }, |
89 | 90 |
90 function testBackTranslateString() { | 91 function testBackTranslateString() { |
91 rpc('BackTranslate', { 'table_name': TABLE_NAME, 'cells': CELLS}, | 92 rpc('BackTranslate', { 'table_name': TABLE_NAME, 'cells': CELLS}, |
92 pass(expectSuccessReply(function(reply) { | 93 pass(expectSuccessReply(function(reply) { |
93 chrome.test.assertEq(TEXT, reply['text']); | 94 chrome.test.assertEq(TEXT, reply['text']); |
94 }))); | 95 }))); |
95 }, | 96 }, |
| 97 |
| 98 // Backtranslate a one-letter contraction that expands to a much larger |
| 99 // string (k->knowledge). |
| 100 function testBackTranslateContracted() { |
| 101 rpc('BackTranslate', { 'table_name': CONTRACTED_TABLE_NAME, |
| 102 'cells': '05'}, // dots 1 and 3 |
| 103 pass(expectSuccessReply(function(reply) { |
| 104 chrome.test.assertEq('knowledge', reply['text']); |
| 105 }))); |
| 106 }, |
96 ])}); | 107 ])}); |
OLD | NEW |