OLD | NEW |
1 library KeyboardEventTest; | 1 library KeyboardEventTest; |
2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
4 import 'dart:html'; | 4 import 'dart:html'; |
5 | 5 |
6 // Test that we are correctly determining keyCode and charCode uniformly across | 6 // Test that we are correctly determining keyCode and charCode uniformly across |
7 // browsers. | 7 // browsers. |
8 | 8 |
9 main() { | 9 main() { |
10 | 10 |
11 useHtmlConfiguration(); | 11 useHtmlConfiguration(); |
12 | 12 |
13 keydownHandlerTest(KeyEvent e) { | 13 keydownHandlerTest(KeyEvent e) { |
14 expect(e.charCode, 0); | 14 expect(e.charCode, 0); |
15 } | 15 } |
16 | 16 |
17 test('keyboardEvent constructor', () { | |
18 var event = new KeyboardEvent('keyup', document.body); | |
19 }); | |
20 test('keys', () { | 17 test('keys', () { |
21 // This test currently is pretty much a no-op because we | 18 // This test currently is pretty much a no-op because we |
22 // can't (right now) construct KeyboardEvents with specific keycode/charcode | 19 // can't (right now) construct KeyboardEvents with specific keycode/charcode |
23 // values (a KeyboardEvent can be "init"-ed but not all the information can | 20 // values (a KeyboardEvent can be "init"-ed but not all the information can |
24 // be programmatically populated. It exists as an example for how to use | 21 // be programmatically populated. It exists as an example for how to use |
25 // KeyboardEventController more than anything else. | 22 // KeyboardEventController more than anything else. |
26 var controller = new KeyboardEventController.keydown(document.body); | 23 var controller = new KeyboardEventController.keydown(document.body); |
27 var func = keydownHandlerTest; | 24 var func = keydownHandlerTest; |
28 controller.add(func); | 25 controller.add(func); |
29 document.body.on.keyDown.add((e) => print('regular listener'), false); | 26 document.body.on.keyDown.add((e) => print('regular listener'), false); |
30 }); | 27 }); |
31 } | 28 } |
32 | 29 |
33 | 30 |
OLD | NEW |