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

Side by Side Diff: tests/html/element_webkit_test.dart

Issue 11046025: Adding synchronous measurement methods to Element. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('ElementWebKitTest');
6 #import('../../pkg/unittest/unittest.dart');
7 #import('../../pkg/unittest/html_config.dart');
8 #import('dart:html');
9
10
11 // NOTE:
12 // These should ALL be webkit-specific items
13 // Ideally all of these should be functional on all browsers and moved into
14 // element_test.dart.
15
16 void testConstructorHelper(String tag, String htmlSnippet,
17 String expectedText, Function isExpectedClass) {
18 expect(isExpectedClass(new Element.tag(tag)), true);
19 final elementFromSnippet = new Element.html(htmlSnippet);
20 expect(isExpectedClass(elementFromSnippet), true);
21 expect(expectedText, elementFromSnippet.text);
22 }
23
24 void testEventHelper(EventListenerList listenerList, type,
25 [Function registerOnEventListener = null]) {
26 bool firedWhenAddedToListenerList = false;
27 bool firedOnEvent = false;
28 listenerList.add((e) {
29 firedWhenAddedToListenerList = true;
30 });
31 if (registerOnEventListener != null) {
32 registerOnEventListener((e) {
33 firedOnEvent = true;
34 });
35 }
36
37 final event = new Event(type);
38 listenerList.dispatch(event);
39
40 Expect.isTrue(firedWhenAddedToListenerList);
41 if (registerOnEventListener != null) {
42 Expect.isTrue(firedOnEvent);
43 }
44 }
45
46 main() {
47 useHtmlConfiguration();
48
49 group('constructors', () {
50 test('details', () => testConstructorHelper('details',
51 '<details>foo</details>', 'foo',
52 (element) => element is DetailsElement));
53 test('embed', () => testConstructorHelper('embed',
54 '<embed>foo</embed>', '',
55 (element) => element is EmbedElement));
56 test('keygen', () => testConstructorHelper('keygen', '<keygen>', '',
57 (element) => element is KeygenElement));
58 test('marquee', () => testConstructorHelper('marquee',
59 '<marquee>foo</marquee>', 'foo',
60 (element) => element is MarqueeElement));
61 test('meter', () => testConstructorHelper('meter',
62 '<meter>foo</meter>', 'foo',
63 (element) => element is MeterElement));
64 test('object', () => testConstructorHelper('object',
65 '<object>foo</object>', 'foo',
66 (element) => element is ObjectElement));
67 });
68
69 group('events', () {
70 testEventHelper(on.transitionEnd, 'webkitTransitionEnd');
71 testEventHelper(on.fullscreenChange, 'webkitfullscreenchange',
72 (listener) => Testing.addEventListener(element,
73 'webkitfullscreenchange', listener, true));
74 });
75 }
76
77
78
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698