| 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 CONTRACTED_TABLE_NAME = 'en-us-g2.ctb'; |
| 9 var TEXT = 'hello'; | 9 var TEXT = 'hello'; |
| 10 // Translation of the above string as a hexadecimal sequence of cells. | 10 // Translation of the above string as a hexadecimal sequence of cells. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 | 65 |
| 66 loadLibrary(function() { | 66 loadLibrary(function() { |
| 67 chrome.test.runTests([ | 67 chrome.test.runTests([ |
| 68 function testGetTranslator() { | 68 function testGetTranslator() { |
| 69 rpc('CheckTable', { 'table_names': TABLE_NAME}, | 69 rpc('CheckTable', { 'table_names': TABLE_NAME}, |
| 70 pass(expectSuccessReply())); | 70 pass(expectSuccessReply())); |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 function testTranslateString() { | 73 function testTranslateString() { |
| 74 rpc('Translate', { 'table_names': TABLE_NAME, 'text': TEXT}, | 74 rpc('Translate', { 'table_names': TABLE_NAME, 'text': TEXT, |
| 75 form_type_map: []}, |
| 75 pass(expectSuccessReply(function(reply) { | 76 pass(expectSuccessReply(function(reply) { |
| 76 chrome.test.assertEq(CELLS, reply['cells']); | 77 chrome.test.assertEq(CELLS, reply['cells']); |
| 77 }))); | 78 }))); |
| 78 }, | 79 }, |
| 79 | 80 |
| 80 // Regression test for the case where the translated result is more than | 81 // Regression test for the case where the translated result is more than |
| 81 // the double size of the input. In this particular case, a single capital | 82 // the double size of the input. In this particular case, a single capital |
| 82 // letter 'T' should be translated to 3 cells in US English grade 2 | 83 // letter 'T' should be translated to 3 cells in US English grade 2 |
| 83 // braille (dots 56, 6, 2345). | 84 // braille (dots 56, 6, 2345). |
| 84 function testTranslateGrade2SingleCapital() { | 85 function testTranslateGrade2SingleCapital() { |
| 85 rpc('Translate', { 'table_names': CONTRACTED_TABLE_NAME, 'text': 'T'}, | 86 rpc('Translate', { 'table_names': CONTRACTED_TABLE_NAME, 'text': 'T', |
| 87 form_type_map: []}, |
| 86 pass(expectSuccessReply(function(reply) { | 88 pass(expectSuccessReply(function(reply) { |
| 87 chrome.test.assertEq('30201e', reply['cells']); | 89 chrome.test.assertEq('30201e', reply['cells']); |
| 88 }))); | 90 }))); |
| 89 }, | 91 }, |
| 90 | 92 |
| 91 function testBackTranslateString() { | 93 function testBackTranslateString() { |
| 92 rpc('BackTranslate', { 'table_names': TABLE_NAME, 'cells': CELLS}, | 94 rpc('BackTranslate', { 'table_names': TABLE_NAME, 'cells': CELLS}, |
| 93 pass(expectSuccessReply(function(reply) { | 95 pass(expectSuccessReply(function(reply) { |
| 94 chrome.test.assertEq(TEXT, reply['text']); | 96 chrome.test.assertEq(TEXT, reply['text']); |
| 95 }))); | 97 }))); |
| 96 }, | 98 }, |
| 97 | 99 |
| 98 // Backtranslate a one-letter contraction that expands to a much larger | 100 // Backtranslate a one-letter contraction that expands to a much larger |
| 99 // string (k->knowledge). | 101 // string (k->knowledge). |
| 100 function testBackTranslateContracted() { | 102 function testBackTranslateContracted() { |
| 101 rpc('BackTranslate', { 'table_names': CONTRACTED_TABLE_NAME, | 103 rpc('BackTranslate', { 'table_names': CONTRACTED_TABLE_NAME, |
| 102 'cells': '05'}, // dots 1 and 3 | 104 'cells': '05'}, // dots 1 and 3 |
| 103 pass(expectSuccessReply(function(reply) { | 105 pass(expectSuccessReply(function(reply) { |
| 104 chrome.test.assertEq('knowledge', reply['text']); | 106 chrome.test.assertEq('knowledge', reply['text']); |
| 105 }))); | 107 }))); |
| 106 }, | 108 }, |
| 107 ])}); | 109 ])}); |
| OLD | NEW |