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

Side by Side Diff: chrome/browser/resources/chromeos/braille_ime/braille_ime_unittest.gtestjs

Issue 271723002: Make Braille IME send space bar as an empty cell instead of letting propagate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ime
Patch Set: Created 6 years, 7 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 /** 5 /**
6 * @fileoverview Unit test for the Braille IME. 6 * @fileoverview Unit test for the Braille IME.
7 */ 7 */
8 8
9 /** 9 /**
10 * Mock Chrome event supporting one listener. 10 * Mock Chrome event supporting one listener.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 this.ime.init(); 115 this.ime.init();
116 }, 116 },
117 117
118 activateIme: function() { 118 activateIme: function() {
119 this.onActivate.dispatch(ENGINE_ID); 119 this.onActivate.dispatch(ENGINE_ID);
120 assertThat(this.port.messages, 120 assertThat(this.port.messages,
121 eqJSON([{type: 'activeState', active: true}])); 121 eqJSON([{type: 'activeState', active: true}]));
122 this.port.messages.length = 0; 122 this.port.messages.length = 0;
123 }, 123 },
124 124
125 sendKeyDown: function(code) { 125 sendKeyDown: function(code, extra) {
126 return this.onKeyEvent.dispatch(ENGINE_ID, {code: code, type: 'keydown'}); 126 var event = {code: code, type: 'keydown'};
127 for (var key in extra) {
128 event[key] = extra[key];
129 }
130 return this.onKeyEvent.dispatch(ENGINE_ID, event);
127 }, 131 },
128 132
129 sendKeyUp: function(code) { 133 sendKeyUp: function(code, extra) {
130 return this.onKeyEvent.dispatch(ENGINE_ID, {code: code, type: 'keyup'}); 134 var event = {code: code, type: 'keyup'};
135 for (var key in extra) {
136 event[key] = extra[key];
137 }
138 return this.onKeyEvent.dispatch(ENGINE_ID, event);
131 }, 139 },
132 }; 140 };
133 141
134 TEST_F('BrailleImeUnitTest', 'KeysWhenStandardKeyboardDisabled', function() { 142 TEST_F('BrailleImeUnitTest', 'KeysWhenStandardKeyboardDisabled', function() {
135 this.activateIme(); 143 this.activateIme();
136 expectFalse(this.sendKeyDown('KeyF')); 144 expectFalse(this.sendKeyDown('KeyF'));
137 expectFalse(this.sendKeyDown('KeyD')); 145 expectFalse(this.sendKeyDown('KeyD'));
138 expectFalse(this.sendKeyUp('KeyD')); 146 expectFalse(this.sendKeyUp('KeyD'));
139 expectFalse(this.sendKeyUp('KeyF')); 147 expectFalse(this.sendKeyUp('KeyF'));
140 expectEquals(0, this.port.messages.length); 148 expectEquals(0, this.port.messages.length);
141 }); 149 });
142 150
143 TEST_F('BrailleImeUnitTest', 'KeysWhenStandardKeysEnabled', function() { 151 TEST_F('BrailleImeUnitTest', 'KeysWhenStandardKeysEnabled', function() {
144 this.activateIme(); 152 this.activateIme();
145 assertFalse(this.menuItems[0].checked); 153 assertFalse(this.menuItems[0].checked);
146 this.onMenuItemActivated.dispatch(ENGINE_ID, this.menuItems[0].id); 154 this.onMenuItemActivated.dispatch(ENGINE_ID, this.menuItems[0].id);
147 assertTrue(this.menuItems[0].checked); 155 assertTrue(this.menuItems[0].checked);
148 // Type the letters 'b' and 'c' and verify the right dots get sent. 156 // Type the letters 'b' and 'c' and verify the right dots get sent.
149 expectTrue(this.sendKeyDown('KeyF')); 157 expectTrue(this.sendKeyDown('KeyF'));
150 expectTrue(this.sendKeyDown('KeyD')); 158 expectTrue(this.sendKeyDown('KeyD'));
151 expectTrue(this.sendKeyUp('KeyD')); 159 expectTrue(this.sendKeyUp('KeyD'));
152 expectTrue(this.sendKeyUp('KeyF')); 160 expectTrue(this.sendKeyUp('KeyF'));
153 expectTrue(this.sendKeyDown('KeyJ')); 161 expectTrue(this.sendKeyDown('KeyJ'));
154 expectTrue(this.sendKeyDown('KeyF')); 162 expectTrue(this.sendKeyDown('KeyF'));
155 expectTrue(this.sendKeyUp('KeyJ')); 163 expectTrue(this.sendKeyUp('KeyJ'));
156 expectTrue(this.sendKeyUp('KeyF')); 164 expectTrue(this.sendKeyUp('KeyF'));
165
157 // Make sure that other keys are not handled, either by themselves or while 166 // Make sure that other keys are not handled, either by themselves or while
158 // one of the 'braille keys' is pressed. 167 // one of the 'braille keys' is pressed.
159 expectFalse(this.sendKeyDown('KeyX')); 168 expectFalse(this.sendKeyDown('KeyX'));
160 expectFalse(this.sendKeyUp('KeyX')); 169 expectFalse(this.sendKeyUp('KeyX'));
161 170
162 expectTrue(this.sendKeyDown('KeyS')); // Dot 3 171 expectTrue(this.sendKeyDown('KeyS')); // Dot 3
163 expectFalse(this.sendKeyDown('KeyG')); // To the right of dot 1. 172 expectFalse(this.sendKeyDown('KeyG')); // To the right of dot 1.
164 expectTrue(this.sendKeyUp('KeyS')); 173 expectTrue(this.sendKeyUp('KeyS'));
165 expectFalse(this.sendKeyUp('KeyG')); 174 expectFalse(this.sendKeyUp('KeyG'));
166 175
176 // Keys like Ctrl L should not be handled, despite L being a dot key.
177 var ctrlFlag = {ctrlKey: true};
178 expectFalse(this.sendKeyDown('ControlLeft', ctrlFlag));
179 expectFalse(this.sendKeyDown('KeyL', ctrlFlag));
180 expectFalse(this.sendKeyUp('KeyL', ctrlFlag));
181 expectFalse(this.sendKeyUp('ControlLeft', ctrlFlag))
182
167 assertThat(this.port.messages, 183 assertThat(this.port.messages,
David Tseng 2014/05/07 18:05:54 I was expecting a test for the space key behavior
168 eqJSON([{type: 'brailleDots', dots: 0x03}, 184 eqJSON([{type: 'brailleDots', dots: 0x03},
169 {type: 'brailleDots', dots: 0x09}])); 185 {type: 'brailleDots', dots: 0x09}]));
170 }); 186 });
171 187
172 TEST_F('BrailleImeUnitTest', 'UseStandardKeyboardSettingPreserved', function() { 188 TEST_F('BrailleImeUnitTest', 'UseStandardKeyboardSettingPreserved', function() {
173 this.activateIme(); 189 this.activateIme();
174 assertFalse(this.menuItems[0].checked); 190 assertFalse(this.menuItems[0].checked);
175 this.onMenuItemActivated.dispatch(ENGINE_ID, this.menuItems[0].id); 191 this.onMenuItemActivated.dispatch(ENGINE_ID, this.menuItems[0].id);
176 assertTrue(this.menuItems[0].checked); 192 assertTrue(this.menuItems[0].checked);
177 // Create a new instance and make sure the setting is still turned on. 193 // Create a new instance and make sure the setting is still turned on.
(...skipping 29 matching lines...) Expand all
207 deleteBefore: deleteBefore, newText: newText}); 223 deleteBefore: deleteBefore, newText: newText});
208 }.bind(this); 224 }.bind(this);
209 this.activateIme(); 225 this.activateIme();
210 sendReplaceText(0, 'hello!'); 226 sendReplaceText(0, 'hello!');
211 assertEquals('Hi, hello!', text); 227 assertEquals('Hi, hello!', text);
212 hasSelection = true; 228 hasSelection = true;
213 sendReplaceText('hello!'.length, 'good bye!'); 229 sendReplaceText('hello!'.length, 'good bye!');
214 assertFalse(hasSelection); 230 assertFalse(hasSelection);
215 assertEquals('Hi, good bye!', text); 231 assertEquals('Hi, good bye!', text);
216 }); 232 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698