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

Side by Side Diff: client/site_tests/desktopui_ImeTest/desktopui_ImeTest.py

Issue 4698007: Added IME tests for web forms (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: ime testing in web forms Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS 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 import os, string, time, gtk 5 import os, string, time, gtk
6 from autotest_lib.client.bin import site_ui_test, test 6 from autotest_lib.client.bin import site_ui_test, test
7 from autotest_lib.client.common_lib import error, site_ui, utils 7 from autotest_lib.client.common_lib import error, site_ui, utils, site_httpd
8 8
9 9
10 class desktopui_ImeTest(site_ui_test.UITest): 10 class desktopui_ImeTest(site_ui_test.UITest):
11 version = 1 11 version = 1
12 preserve_srcdir = True 12 preserve_srcdir = True
13 13
14 def setup(self): 14 def setup(self):
15 # TODO: We shouldn't use ibusclient, we should talk to Chrome directly 15 # TODO: We shouldn't use ibusclient, we should talk to Chrome directly
16 self.job.setup_dep(['ibusclient']) 16 self.job.setup_dep(['ibusclient'])
17 17
18 def initialize(self, creds='$default'):
19 self._test_url = 'http://localhost:8000/interaction_form.html'
20 self._testServer = site_httpd.HTTPListener(8000, docroot=self.bindir)
21 self._testServer.run()
22
23 site_ui_test.UITest.initialize(self, creds)
24
Zachary Kuznia 2010/11/10 09:15:55 Nit: Two lines between functions.
timothe 2010/11/16 10:02:52 Done.
25 def cleanup(self):
26 self._testServer.stop()
27 site_ui_test.UITest.cleanup(self)
28
18 29
19 def log_error(self, test_name, message): 30 def log_error(self, test_name, message):
20 self.job.record('ERROR', None, test_name, message) 31 self.job.record('ERROR', None, test_name, message)
21 self._failed.append(test_name) 32 self._failed.append(test_name)
22 33
23 34
24 # TODO(zork) We should share this with platform_ProcessPrivleges. 35 # TODO(zork) We should share this with platform_ProcessPrivleges.
25 # See: crosbug.com/7453 36 # See: crosbug.com/7453
26 def check_process(self, process, user=None): 37 def check_process(self, process, user=None):
27 """Check if the process is running as the specified user / root. 38 """Check if the process is running as the specified user / root.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 current_engine = self.get_active_engine() 208 current_engine = self.get_active_engine()
198 if current_engine == expected_other_engine: 209 if current_engine == expected_other_engine:
199 ax.send_hotkey('Ctrl-space') 210 ax.send_hotkey('Ctrl-space')
200 return 211 return
201 time.sleep(1) 212 time.sleep(1)
202 self.log_error('test_keyboard_shortcut', 213 self.log_error('test_keyboard_shortcut',
203 'Current engine is %s, expected %s' % 214 'Current engine is %s, expected %s' %
204 (current_engine, expected_other_engine)) 215 (current_engine, expected_other_engine))
205 216
206 217
207 def test_engine(self, engine_name, input_string, expected_string): 218 def test_engine_omnibox(self, engine_name, input_string, expected_string):
208 self.preload_engines([engine_name]) 219 self.preload_engines([engine_name])
209 self.activate_engine(engine_name) 220 self.activate_engine(engine_name)
210 221
211 ax = self.get_autox() 222 ax = self.get_autox()
212
Zachary Kuznia 2010/11/10 09:15:55 Nit: No need to remove these lines.
timothe 2010/11/16 10:02:52 Done.
213 # Focus on the omnibox so that we can enter text. 223 # Focus on the omnibox so that we can enter text.
214 ax.send_hotkey('Ctrl-l') 224 ax.send_hotkey('Ctrl-l')
215
216 # Sometimes there is a slight delay before input can be received in the 225 # Sometimes there is a slight delay before input can be received in the
217 # omnibox. 226 # omnibox.
218 time.sleep(1) 227 time.sleep(1)
219 228
220 ax.send_text(input_string) 229 ax.send_text(input_string)
221 230
222 text = self.get_current_text() 231 text = self.get_current_text()
223 if text != expected_string: 232 if text != expected_string:
224 self.log_error( 233 self.log_error(
225 'test_engine %s' % engine_name, 234 'test_engine %s' % engine_name,
226 'Engine %s failed: Got %s, expected %s' % (engine_name, text, 235 'Engine %s failed in omnibox: Got %s, expected %s' % (engine_nam e, text,
Zachary Kuznia 2010/11/10 09:15:55 Nit: Line is greater than 80 characters.
timothe 2010/11/16 10:02:52 Done.
227 expected_string)) 236 expected_string))
237 ax.send_hotkey('BackSpace')
Zachary Kuznia 2010/11/10 09:15:55 What does this line add?
timothe 2010/11/16 10:02:52 Before we were opening a new tab and closing it, n
228 238
Zachary Kuznia 2010/11/10 09:15:55 Nit: Two lines between functions.
timothe 2010/11/16 10:02:52 Done.
239 def test_engine_form(self, engine_name, input_string, expected_string):
240 self.preload_engines([engine_name])
241 self.activate_engine(engine_name)
242
243 ax = self.get_autox()
244 ax.send_hotkey('Ctrl-r')
245 ax.send_text(input_string)
246 text = self.get_current_text()
247 if text != expected_string:
248 self.log_error(
249 'test_engine %s' % engine_name,
250 'Engine %s failed in form text input: Got %s, expected %s' % (
251 engine_name, text, expected_string))
229 252
Zachary Kuznia 2010/11/10 09:15:55 Nit: Two lines between functions.
timothe 2010/11/16 10:02:52 Done.
230 def run_once(self): 253 def run_once(self):
231 self._failed = [] 254 self._failed = []
232 dep = 'ibusclient' 255 dep = 'ibusclient'
233 dep_dir = os.path.join(self.autodir, 'deps', dep) 256 dep_dir = os.path.join(self.autodir, 'deps', dep)
234 self.job.install_pkg(dep, 'dep', dep_dir) 257 self.job.install_pkg(dep, 'dep', dep_dir)
235 258
236 self.exefile = os.path.join(self.autodir, 259 self.exefile = os.path.join(self.autodir,
237 'deps/ibusclient/ibusclient') 260 'deps/ibusclient/ibusclient')
238 261
239 # Before we try to activate the options menu, we need to wait for 262 # Before we try to activate the options menu, we need to wait for
240 # previous actions to complete. Most notable is that keystrokes 263 # previous actions to complete. Most notable is that keystrokes
241 # immediately after login get lost. 264 # immediately after login get lost.
242 time.sleep(5) 265 time.sleep(5)
243 266
267 #starting a session and waiting for the page to come up
Zachary Kuznia 2010/11/10 09:15:55 Nit: Space between # and starting, capitalize and
timothe 2010/11/16 10:02:52 Done.
268 session = site_ui.ChromeSession(self._test_url)
269 time.sleep(3)
270
244 self.test_ibus_start_process() 271 self.test_ibus_start_process()
245 272
246 self.check_process('candidate_window', user='chronos') 273 self.check_process('candidate_window', user='chronos')
247 self.check_process('ibus-daemon', user='chronos') 274 self.check_process('ibus-daemon', user='chronos')
248 self.check_process('ibus-memconf', user='chronos') 275 self.check_process('ibus-memconf', user='chronos')
249 276
250 self.test_keyboard_shortcut() 277 self.test_keyboard_shortcut()
251 self.test_engine('mozc', 'nihongo \n', 278 self.test_engine_omnibox('mozc', 'nihongo \n',
252 '\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E') 279 '\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E')
253 self.test_engine('chewing', 'hol \n', '\xE6\x93\x8D') 280 self.test_engine_omnibox('chewing', 'hol \n', '\xE6\x93\x8D')
254 self.test_engine('hangul', 'wl ', '\xEC\xA7\x80 ') 281 self.test_engine_omnibox('hangul', 'wl ', '\xEC\xA7\x80 ')
255 self.test_engine('pinyin', 'nihao ', '\xE4\xBD\xA0\xE5\xA5\xBD') 282 self.test_engine_omnibox('pinyin', 'nihao ', '\xE4\xBD\xA0\xE5\xA5\xBD')
256 self.test_engine('m17n:zh:quick', 'aa', '\xE9\x96\x93') 283 self.test_engine_omnibox('m17n:zh:quick', 'aa ', '\xE9\x96\x93')
284
285 self.test_engine_form('mozc', 'nihongo \n',
286 '\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E')
Zachary Kuznia 2010/11/10 09:15:55 Nit: The ' should line up one space after the ( ab
timothe 2010/11/16 10:02:52 Done.
287 self.test_engine_form('chewing', 'hol \n', '\xE6\x93\x8D')
288 self.test_engine_form('hangul', 'wl ', '\xEC\xA7\x80 ')
289 self.test_engine_form('pinyin', 'nihao ', '\xE4\xBD\xA0\xE5\xA5\xBD')
290 self.test_engine_form('m17n:zh:quick', 'aa ', '\xE9\x96\x93')
257 291
258 # Run a test on English last, so that we can type in English to 292 # Run a test on English last, so that we can type in English to
259 # turn off the IME. 293 # turn off the IME.
260 self.test_engine('xkb:us::eng', 'asdf', 'asdf') 294 self.test_engine_omnibox('xkb:us::eng', 'asdf', 'asdf')
295 self.test_engine_form('xkb:us::eng', 'asdf', 'asdf')
Zachary Kuznia 2010/11/10 09:15:55 FYI: This line won't be needed once you sync and m
timothe 2010/11/16 10:02:52 Done.
261 self.test_ibus_stop_process() 296 self.test_ibus_stop_process()
297 session.close()
262 if len(self._failed) != 0: 298 if len(self._failed) != 0:
263 raise error.TestFail( 299 raise error.TestFail(
264 'Failed: %s' % ','.join(self._failed)) 300 'Failed: %s' % ','.join(self._failed))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698