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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (callback) { | 59 if (callback) { |
60 callback(reply); | 60 callback(reply); |
61 } | 61 } |
62 }; | 62 }; |
63 } | 63 } |
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_name': 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_name': TABLE_NAME, 'text': TEXT}, | 74 rpc('Translate', { 'table_names': TABLE_NAME, 'text': TEXT}, |
75 pass(expectSuccessReply(function(reply) { | 75 pass(expectSuccessReply(function(reply) { |
76 chrome.test.assertEq(CELLS, reply['cells']); | 76 chrome.test.assertEq(CELLS, reply['cells']); |
77 }))); | 77 }))); |
78 }, | 78 }, |
79 | 79 |
80 // 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 |
81 // 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 |
82 // 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 |
83 // braille (dots 56, 6, 2345). | 83 // braille (dots 56, 6, 2345). |
84 function testTranslateGrade2SingleCapital() { | 84 function testTranslateGrade2SingleCapital() { |
85 rpc('Translate', { 'table_name': CONTRACTED_TABLE_NAME, 'text': 'T'}, | 85 rpc('Translate', { 'table_names': CONTRACTED_TABLE_NAME, 'text': 'T'}, |
86 pass(expectSuccessReply(function(reply) { | 86 pass(expectSuccessReply(function(reply) { |
87 chrome.test.assertEq('30201e', reply['cells']); | 87 chrome.test.assertEq('30201e', reply['cells']); |
88 }))); | 88 }))); |
89 }, | 89 }, |
90 | 90 |
91 function testBackTranslateString() { | 91 function testBackTranslateString() { |
92 rpc('BackTranslate', { 'table_name': TABLE_NAME, 'cells': CELLS}, | 92 rpc('BackTranslate', { 'table_names': TABLE_NAME, 'cells': CELLS}, |
93 pass(expectSuccessReply(function(reply) { | 93 pass(expectSuccessReply(function(reply) { |
94 chrome.test.assertEq(TEXT, reply['text']); | 94 chrome.test.assertEq(TEXT, reply['text']); |
95 }))); | 95 }))); |
96 }, | 96 }, |
97 | 97 |
98 // Backtranslate a one-letter contraction that expands to a much larger | 98 // Backtranslate a one-letter contraction that expands to a much larger |
99 // string (k->knowledge). | 99 // string (k->knowledge). |
100 function testBackTranslateContracted() { | 100 function testBackTranslateContracted() { |
101 rpc('BackTranslate', { 'table_name': CONTRACTED_TABLE_NAME, | 101 rpc('BackTranslate', { 'table_names': CONTRACTED_TABLE_NAME, |
102 'cells': '05'}, // dots 1 and 3 | 102 'cells': '05'}, // dots 1 and 3 |
103 pass(expectSuccessReply(function(reply) { | 103 pass(expectSuccessReply(function(reply) { |
104 chrome.test.assertEq('knowledge', reply['text']); | 104 chrome.test.assertEq('knowledge', reply['text']); |
105 }))); | 105 }))); |
106 }, | 106 }, |
107 ])}); | 107 ])}); |
OLD | NEW |