diff options
Diffstat (limited to 'addons/web/static/tests/helpers/test_utils.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index 0115dfc9152..f7003faaf5c 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -458,6 +458,20 @@ function triggerPositionalMouseEvent(x, y, type){ } /** + * simulate a keypress event for a given character + * @param {string} the character + */ +function triggerKeypressEvent(char) { + var keycode; + if (char === "Enter") { + keycode = $.ui.keyCode.ENTER; + } else { + keycode = char.charCodeAt(0); + } + return $('body').trigger($.Event('keypress', {which: keycode, keyCode: keycode})); +} + +/** * Removes the src attribute on images and iframes to prevent not found errors, * and optionally triggers an rpc with the src url as route on a widget. * @@ -498,6 +512,7 @@ return session.is_bound.then(function () { dragAndDrop: dragAndDrop, triggerMouseEvent: triggerMouseEvent, triggerPositionalMouseEvent: triggerPositionalMouseEvent, + triggerKeypressEvent: triggerKeypressEvent, removeSrcAttribute: removeSrcAttribute, }; }); |
