mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Add Keymap benchmark for handling an event with no binding
This commit is contained in:
parent
045cdda41d
commit
eebd312af9
@ -70,30 +70,15 @@ window.waitsForPromise = (fn) ->
|
|||||||
window.waitsFor (moveOn) ->
|
window.waitsFor (moveOn) ->
|
||||||
fn().done(moveOn)
|
fn().done(moveOn)
|
||||||
|
|
||||||
window.eventPropertiesForPattern = (pattern) ->
|
window.keyIdentifierForKey = (key) ->
|
||||||
[modifiers..., key] = pattern.split '-'
|
if key.length > 1 # named key
|
||||||
|
key
|
||||||
modifiers.push 'shift' if key == key.toUpperCase() and key.toUpperCase() != key.toLowerCase()
|
|
||||||
charCode = key.toUpperCase().charCodeAt 0
|
|
||||||
|
|
||||||
isNamedKey = key.length > 1
|
|
||||||
if isNamedKey
|
|
||||||
keyIdentifier = key
|
|
||||||
else
|
else
|
||||||
keyIdentifier = "U+00" + charCode.toString(16)
|
charCode = key.toUpperCase().charCodeAt(0)
|
||||||
|
"U+00" + charCode.toString(16)
|
||||||
|
|
||||||
ctrlKey: 'ctrl' in modifiers
|
window.keydownEvent = (key, properties={}) ->
|
||||||
altKey: 'alt' in modifiers
|
$.Event "keydown", _.extend({originalEvent: { keyIdentifier: keyIdentifierForKey(key) }}, properties)
|
||||||
shiftKey: 'shift' in modifiers
|
|
||||||
metaKey: 'meta' in modifiers
|
|
||||||
which: charCode
|
|
||||||
originalEvent:
|
|
||||||
keyIdentifier: keyIdentifier
|
|
||||||
|
|
||||||
window.keydownEvent = (pattern, properties={}) ->
|
|
||||||
event = $.Event "keydown", _.extend(eventPropertiesForPattern(pattern), properties)
|
|
||||||
# event.keystroke = (new Keymap).keystrokeStringForEvent(event)
|
|
||||||
event
|
|
||||||
|
|
||||||
window.clickEvent = (properties={}) ->
|
window.clickEvent = (properties={}) ->
|
||||||
$.Event "click", properties
|
$.Event "click", properties
|
||||||
|
@ -23,6 +23,15 @@ describe "editor.", ->
|
|||||||
window.shutdown()
|
window.shutdown()
|
||||||
atom.setRootViewStateForPath(rootView.project.getPath(), null)
|
atom.setRootViewStateForPath(rootView.project.getPath(), null)
|
||||||
|
|
||||||
|
describe "keymap.", ->
|
||||||
|
event = null
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
event = keydownEvent('x', target: editor.hiddenInput[0])
|
||||||
|
|
||||||
|
benchmark "keydown-event-with-no-binding", 10, ->
|
||||||
|
keymap.handleKeyEvent(event)
|
||||||
|
|
||||||
describe "opening-buffers.", ->
|
describe "opening-buffers.", ->
|
||||||
benchmark "300-line-file.", ->
|
benchmark "300-line-file.", ->
|
||||||
buffer = rootView.project.bufferForPath('medium.coffee')
|
buffer = rootView.project.bufferForPath('medium.coffee')
|
||||||
|
Loading…
Reference in New Issue
Block a user