Chromium Code Reviews| 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
|
| +} |