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

Unified Diff: tests/html/event_customevent_test.dart

Issue 10559068: Add CustomEvent.initCustomEvent test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/event_customevent_test.dart
diff --git a/tests/html/event_customevent_test.dart b/tests/html/event_customevent_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fbe2e5e317581ba6db13b83a0bcdd6f4deb0a741
--- /dev/null
+++ b/tests/html/event_customevent_test.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('EventCustomEventTest');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+// TODO(nweiz): Make this private to testEvents when Frog supports closures with
podivilov 2012/06/20 11:56:50 Frog? :)
Anton Muhin 2012/06/20 13:18:22 Copy paste. Hmm, do not know, I'd rather nuke the
+// optional arguments.
+eventTest(String name, Event eventFn(), void validate(Event),
+ [String type = 'foo']) {
+ test(name, () {
+ final el = new Element.tag('div');
+ var fired = false;
+ el.on[type].add((ev) {
+ fired = true;
+ validate(ev);
+ });
+ el.on[type].dispatch(eventFn());
+ expect(fired, isTrue, 'Expected event to be dispatched.');
+ });
+}
+
+main() {
+ useHtmlConfiguration();
+
+ eventTest('CustomEvent.initCustomEvent', () {
+ // TODO: switch to constructors later.
+ final ev = document.$dom_createEvent('CustomEvent');
+ ev.initCustomEvent('foo', false, false, 'detail');
+ return ev;
+ },
+ (ev) { expect(ev.detail, equals('detail')); });
podivilov 2012/06/20 11:56:50 nit: =>
Anton Muhin 2012/06/20 13:18:22 Alas, I hate it myself, but => foo() is a bad idea
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698