diff options
| author | Stephen Blott | 2016-02-28 14:01:16 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-03-05 05:38:30 +0000 | 
| commit | 520b63cb1d64fb5a293988122007bd05bacc49db (patch) | |
| tree | f3fd0d50edb493e24a543e6627bcd9c975e82c23 /tests | |
| parent | cf7a03dc26415528bc690147ba72c08e67dd65c8 (diff) | |
| download | vimium-520b63cb1d64fb5a293988122007bd05bacc49db.tar.bz2 | |
Key bindings; fix tests...
... and fix two bugs:
- not suppressing keyup event after keyChar matched in keydown.
- we cannot check the passKeys keyChar in keyup because the key state
  has changed; so we track what the next keyup response should be.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 25 | ||||
| -rw-r--r-- | tests/dom_tests/dom_tests.html | 1 | ||||
| -rw-r--r-- | tests/unit_tests/commands_test.coffee | 2 | 
3 files changed, 11 insertions, 17 deletions
| diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 8a96913f..6309525f 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -24,15 +24,10 @@ for type in [ "keydown", "keypress", "keyup" ]  initializeModeState = ->    Mode.reset()    handlerStack.reset() -  initializeModes() -  # We use "m" as the only mapped key, "p" as a passkey, and "u" as an unmapped key. -  refreshCompletionKeys -    completionKeys: "mp" +  initializeModes keyMapping: {m: {}, p: {}, z: {p: {}}}    handlerStack.bubbleEvent "registerStateChange",      enabled: true      passKeys: "p" -  handlerStack.bubbleEvent "registerKeyQueue", -    keyQueue: ""  # Tell Settings that it's been loaded.  Settings.isLoaded = true @@ -375,10 +370,14 @@ context "Normal mode",      sendKeyboardEvent "p"      assert.equal pageKeyboardEventCount, 3 -  should "suppress passKeys with a non-empty keyQueue", -> -    handlerStack.bubbleEvent "registerKeyQueue", keyQueue: "p" +  should "suppress passKeys with a non-empty key state (a count)", -> +    sendKeyboardEvent "5" +    assert.equal 0, pageKeyboardEventCount + +  should "suppress passKeys with a non-empty key state (a key)", -> +    sendKeyboardEvent "z"      sendKeyboardEvent "p" -    assert.equal pageKeyboardEventCount, 0 +    assert.equal 0, pageKeyboardEventCount  context "Insert mode",    setup -> @@ -397,7 +396,7 @@ context "Insert mode",    should "resume normal mode after leaving insert mode", ->      @insertMode.exit()      sendKeyboardEvent "m" -    assert.equal pageKeyboardEventCount, 0 +    assert.equal 0, pageKeyboardEventCount  context "Triggering insert mode",    setup -> @@ -502,12 +501,6 @@ context "Mode utilities",      assert.isTrue test.enabled == "one"      assert.isTrue test.passKeys == "two" -  should "register the keyQueue", -> -    test = new Mode trackState: true -    handlerStack.bubbleEvent "registerKeyQueue", keyQueue: "hello" - -    assert.isTrue test.keyQueue == "hello" -  context "PostFindMode",    setup ->      initializeModeState() diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html index 8d355c6d..8c914d3c 100644 --- a/tests/dom_tests/dom_tests.html +++ b/tests/dom_tests/dom_tests.html @@ -46,6 +46,7 @@      <script type="text/javascript" src="../../content_scripts/mode_insert.js"></script>      <script type="text/javascript" src="../../content_scripts/mode_find.js"></script>      <script type="text/javascript" src="../../content_scripts/mode_visual_edit.js"></script> +    <script type="text/javascript" src="../../content_scripts/mode_key_handler.js"></script>      <script type="text/javascript" src="../../content_scripts/hud.js"></script>      <script type="text/javascript" src="../../content_scripts/vimium_frontend.js"></script> diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee index 45cb4cf4..f501a960 100644 --- a/tests/unit_tests/commands_test.coffee +++ b/tests/unit_tests/commands_test.coffee @@ -1,6 +1,6 @@  require "./test_helper.js"  extend global, require "./test_chrome_stubs.js" -global.Settings = {postUpdateHooks: {}} +global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->}  {Commands} = require "../../background_scripts/commands.js"  context "Key mappings", | 
