Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/test/data/chromeos/liblouis_nacl/test.js

Issue 124403002: Allow braille translation result to be larger than twice the size of the input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 TEXT = 'hello'; 8 var TEXT = 'hello';
9 // Translation of the above string as a hexadecimal sequence of cells. 9 // Translation of the above string as a hexadecimal sequence of cells.
10 var CELLS = '1311070715'; 10 var CELLS = '1311070715';
(...skipping 24 matching lines...) Expand all
35 pendingCallback(reply); 35 pendingCallback(reply);
36 }, false /* useCapture */); 36 }, false /* useCapture */);
37 document.body.appendChild(embed); 37 document.body.appendChild(embed);
38 } 38 }
39 39
40 40
41 function rpc(command, args, callback) { 41 function rpc(command, args, callback) {
42 var messageId = '' + nextMessageId++; 42 var messageId = '' + nextMessageId++;
43 args['command'] = command; 43 args['command'] = command;
44 args['message_id'] = messageId; 44 args['message_id'] = messageId;
45 var json = JSON.stringify(args) 45 var json = JSON.stringify(args);
46 console.log('Message to liblouis: ' + json); 46 console.log('Message to liblouis: ' + json);
47 naclEmbed.postMessage(json); 47 naclEmbed.postMessage(json);
48 pendingCallback = callback; 48 pendingCallback = callback;
49 pendingMessageId = messageId; 49 pendingMessageId = messageId;
50 } 50 }
51 51
52 52
53 function expectSuccessReply(callback) { 53 function expectSuccessReply(callback) {
54 return function(reply) { 54 return function(reply) {
55 chrome.test.assertEq(pendingMessageId, reply['in_reply_to']); 55 chrome.test.assertEq(pendingMessageId, reply['in_reply_to']);
(...skipping 13 matching lines...) Expand all
69 pass(expectSuccessReply())); 69 pass(expectSuccessReply()));
70 }, 70 },
71 71
72 function testTranslateString() { 72 function testTranslateString() {
73 rpc('Translate', { 'table_name': TABLE_NAME, 'text': TEXT}, 73 rpc('Translate', { 'table_name': TABLE_NAME, 'text': TEXT},
74 pass(expectSuccessReply(function(reply) { 74 pass(expectSuccessReply(function(reply) {
75 chrome.test.assertEq(CELLS, reply['cells']); 75 chrome.test.assertEq(CELLS, reply['cells']);
76 }))); 76 })));
77 }, 77 },
78 78
79 // 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 // letter 'T' should be translated to 3 cells in US English grade 2
82 // braille (dots 56, 6, 2345).
83 function testTranslateGrade2SingleCapital() {
84 rpc('Translate', { 'table_name': 'en-us-g2.ctb', 'text': 'T'},
85 pass(expectSuccessReply(function(reply) {
86 chrome.test.assertEq('30201e', reply['cells']);
87 })));
88 },
89
79 function testBackTranslateString() { 90 function testBackTranslateString() {
80 rpc('BackTranslate', { 'table_name': TABLE_NAME, 'cells': CELLS}, 91 rpc('BackTranslate', { 'table_name': TABLE_NAME, 'cells': CELLS},
81 pass(expectSuccessReply(function(reply) { 92 pass(expectSuccessReply(function(reply) {
82 chrome.test.assertEq(TEXT, reply['text']); 93 chrome.test.assertEq(TEXT, reply['text']);
83 }))); 94 })));
84 }, 95 },
85 ])}); 96 ])});
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698