Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: tests/html/interactive_test.dart

Issue 12419011: Modern-ify KeyEvent handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: \ Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/html/interactive_test.dart
diff --git a/tests/html/interactive_test.dart b/tests/html/interactive_test.dart
index 47bbe08475b4b8e2368c02e5c99d9a30192094af..ebc0ff238c61dd8ee68e27dc612bf41ef299eb1a 100644
--- a/tests/html/interactive_test.dart
+++ b/tests/html/interactive_test.dart
@@ -93,4 +93,46 @@ main() {
});
}
});
+
+ group('KeyEvent', () {
+ keydownHandlerTest(KeyEvent e) {
+ document.body.innerHtml =
+ '${document.body.innerHtml}KeyDOWN: CharCode: ${e.charCode}, KeyCode:'
+ ' ${e.keyCode}<br />';
+ expect(e.charCode, 0);
+ }
+ keypressHandlerTest(KeyEvent e) {
+ document.body.innerHtml =
+ '${document.body.innerHtml}KeyPRESS: CharCode: ${e.charCode}, '
+ 'KeyCode: ${e.keyCode}<br />';
+ }
+ keyupHandlerTest(KeyEvent e) {
+ document.body.innerHtml =
+ '${document.body.innerHtml}KeyUP: CharCode: ${e.charCode}, KeyCode:'
+ ' ${e.keyCode}<br />';
+ expect(e.charCode, 0);
+ }
+ keyupHandlerTest2(KeyEvent e) {
+ document.body.innerHtml =
+ '${document.body.innerHtml}A second KeyUP handler: CharCode: '
+ '${e.charCode}, KeyCode: ${e.keyCode}<br />';
+ expect(e.charCode, 0);
+ }
+ test('keys', () {
+ document.body.innerHtml =
+ '${document.body.innerHtml}To test keyboard event values, press some '
+ 'keys on your keyboard.<br /><br />The charcode for keydown and keyup'
+ ' should be 0, and the keycode should (generally) be populated with a'
+ ' value. Keycode and charcode should both have values for the '
+ 'keypress event.';
+ new KeyboardEventStream.onKeyDown(document.body).listen(
+ keydownHandlerTest);
+ new KeyboardEventStream.onKeyPress(document.body).listen(
+ keypressHandlerTest);
+ new KeyboardEventStream.onKeyUp(document.body).listen(
+ keyupHandlerTest);
+ new KeyboardEventStream.onKeyUp(document.body).listen(
+ keyupHandlerTest2);
+ });
+ });
}

Powered by Google App Engine
This is Rietveld 408576698