Chromium Code Reviews| Index: client/site_tests/desktopui_ImeTest/desktopui_ImeTest.py |
| diff --git a/client/site_tests/desktopui_ImeTest/desktopui_ImeTest.py b/client/site_tests/desktopui_ImeTest/desktopui_ImeTest.py |
| index 47e2dbb1073cd03168a3883440084bb424f60699..04d7b829a543e967e15bf010902fe573e18ce6e0 100644 |
| --- a/client/site_tests/desktopui_ImeTest/desktopui_ImeTest.py |
| +++ b/client/site_tests/desktopui_ImeTest/desktopui_ImeTest.py |
| @@ -4,7 +4,7 @@ |
| import os, string, time, gtk |
| from autotest_lib.client.bin import site_ui_test, test |
| -from autotest_lib.client.common_lib import error, site_ui, utils |
| +from autotest_lib.client.common_lib import error, site_ui, utils, site_httpd |
| class desktopui_ImeTest(site_ui_test.UITest): |
| @@ -15,6 +15,18 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| # TODO: We shouldn't use ibusclient, we should talk to Chrome directly |
| self.job.setup_dep(['ibusclient']) |
| + def initialize(self, creds='$default'): |
| + self._test_url = 'http://localhost:8000/interaction_form.html' |
| + self._testServer = site_httpd.HTTPListener(8000, docroot=self.bindir) |
|
satorux1
2010/11/17 04:35:38
_test_server per our python style guide.
timothe
2010/11/17 05:04:12
Done.
|
| + self._testServer.run() |
| + |
| + site_ui_test.UITest.initialize(self, creds) |
| + |
| + |
| + def cleanup(self): |
| + self._testServer.stop() |
| + site_ui_test.UITest.cleanup(self) |
| + |
| def log_error(self, test_name, message): |
| self.job.record('ERROR', None, test_name, message) |
| @@ -77,7 +89,6 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| cmd = site_ui.xcommand_as('%s %s' % (self.exefile, options), 'chronos') |
| return utils.system_output(cmd, retain_output=True) |
|
Zachary Kuznia
2010/11/16 10:22:58
This blank line should go back in.
timothe
2010/11/17 01:47:05
Done.
|
| - |
| # TODO: Make this function talk to chrome directly |
| def preload_engines(self, engine_list): |
| engine_names = string.join(engine_list, " ") |
| @@ -104,6 +115,8 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| return out.strip() |
| + # TODO: Make this function set the config value directly, instead of |
| + # attempting to navigate the UI. |
|
Zachary Kuznia
2010/11/16 10:22:58
This comment shouldn't be re-added.
timothe
2010/11/17 01:47:05
Done.
|
| def toggle_ime_process(self): |
| ax = self.get_autox() |
| @@ -158,7 +171,7 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| # Toggle the checkbox. |
| ax.send_text(' ') |
| - time.sleep(1) |
| + time.sleep(2) |
|
Zachary Kuznia
2010/11/16 10:22:58
This value shouldn't need to change. Was it faili
timothe
2010/11/17 01:47:05
on my PC sometimes yes, the new language would not
Zachary Kuznia
2010/11/17 03:17:46
Ok. Add a comment to note this.
timothe
2010/11/17 04:06:57
Done.
|
| # Close the window. |
| ax.send_hotkey('Ctrl+w') |
| @@ -251,6 +264,8 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| (current_engine, expected_initial_engine)) |
| ax = self.get_autox() |
| ax.send_hotkey('Ctrl-l') |
| + # If we don't sleep here sometimes the following keys are not received |
| + time.sleep(1) |
| ax.send_hotkey('Ctrl-space') |
| start_time = time.time() |
| while time.time() - start_time < 10: |
| @@ -267,7 +282,15 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| def test_engine(self, language, engine_name, input_string, expected_string): |
| self.start_ime_engine(language, engine_name) |
| self.activate_engine(engine_name) |
| + self.test_engine_omnibox(language, engine_name, input_string, |
| + expected_string) |
| + self.test_engine_form(language, engine_name, input_string, |
| + expected_string) |
| + self.activate_engine('xkb:us::eng') |
| + self.stop_ime_language(language) |
| + |
| + def test_engine_omnibox(self, language, engine_name, input_string, expected_string): |
|
Zachary Kuznia
2010/11/16 10:22:58
nit: 80 characters.
timothe
2010/11/17 01:47:05
Done.
|
| ax = self.get_autox() |
| # Focus on the omnibox so that we can enter text. |
| @@ -282,11 +305,25 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| text = self.get_current_text() |
| if text != expected_string: |
| self.log_error( |
| - 'test_engine %s' % engine_name, |
| - 'Engine %s failed: Got %s, expected %s' % (engine_name, text, |
| - expected_string)) |
| - self.activate_engine('xkb:us::eng') |
| - self.stop_ime_language(language) |
| + 'test_engine %s in omnibox' % engine_name, |
| + 'Engine %s failed : Got %s, expected %s' % ( |
| + engine_name, text, expected_string)) |
| + #clear the omnibox for future tests |
|
Zachary Kuznia
2010/11/16 10:22:58
Nit: Space after #, capitalize Clear, add a period
timothe
2010/11/17 01:47:05
Done.
|
| + ax.send_hotkey('BackSpace') |
| + |
| + |
| + def test_engine_form(self, language, engine_name, input_string, expected_string): |
|
Zachary Kuznia
2010/11/16 10:22:58
Nit: 80 characters
timothe
2010/11/17 01:47:05
Done.
|
| + ax = self.get_autox() |
| + # Refresh the page so that the focus gets on the text input widget |
| + ax.send_hotkey('Ctrl-r') |
|
Zachary Kuznia
2010/11/16 10:22:58
Navigate to the page here, so that it relies less
timothe
2010/11/17 01:47:05
Done.
|
| + time.sleep(1) |
| + ax.send_text(input_string) |
| + text = self.get_current_text() |
| + if text != expected_string: |
| + self.log_error( |
| + 'test_engine %s in form' % engine_name, |
| + 'Engine %s failed : Got %s, expected %s' % ( |
| + engine_name, text, expected_string)) |
| def run_once(self): |
| @@ -303,6 +340,11 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| # immediately after login get lost. |
| time.sleep(5) |
| + # Navigate to the webpage containing the form |
|
Zachary Kuznia
2010/11/16 10:22:58
See above.
timothe
2010/11/17 01:47:05
Done.
|
| + ax = self.get_autox() |
| + ax.send_hotkey('Ctrl+l') |
| + time.sleep(1) |
| + ax.send_text("%s \n"%self._test_url) |
| self.test_ibus_start_process() |
| self.check_process('candidate_window', user='chronos') |
| @@ -311,14 +353,14 @@ class desktopui_ImeTest(site_ui_test.UITest): |
| self.test_keyboard_shortcut() |
| self.test_engine('ja', 'mozc', 'nihongo \n', |
| - '\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E') |
| + '\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E') |
| self.test_engine('zh-TW', 'chewing', 'hol \n', '\xE6\x93\x8D') |
| + self.test_engine('zh-TW', 'm17n:zh:quick', 'aa ', '\xE9\x96\x93') |
|
Zachary Kuznia
2010/11/16 10:22:58
Leave these in the original order to minimize your
timothe
2010/11/17 01:47:05
Done.
|
| self.test_engine('ko', 'hangul', 'wl ', '\xEC\xA7\x80 ') |
| - self.test_engine('zh-CN', 'pinyin', 'nihao ', |
| - '\xE4\xBD\xA0\xE5\xA5\xBD') |
| - self.test_engine('zh-TW', 'm17n:zh:quick', 'aa', '\xE9\x96\x93') |
| + self.test_engine('zh-CN', 'pinyin', 'nihao ', '\xE4\xBD\xA0\xE5\xA5\xBD') |
|
Zachary Kuznia
2010/11/16 10:22:58
nit: 80 characters.
timothe
2010/11/17 01:47:05
Done.
|
| self.test_ibus_stop_process() |
| + |
| if len(self._failed) != 0: |
| raise error.TestFail( |
| 'Failed: %s' % ','.join(self._failed)) |