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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tests/html/element_webkit_test.dart
diff --git a/tests/html/element_webkit_test.dart b/tests/html/element_webkit_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..726bfb2604b1db4b975f0dc62cb66291221e7a7a
--- /dev/null
+++ b/tests/html/element_webkit_test.dart
@@ -0,0 +1,78 @@
+// Copyright (c) 2011, 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('ElementWebKitTest');
+#import('../../pkg/unittest/unittest.dart');
+#import('../../pkg/unittest/html_config.dart');
+#import('dart:html');
+
+
+// NOTE:
+// These should ALL be webkit-specific items
+// Ideally all of these should be functional on all browsers and moved into
+// element_test.dart.
+
+void testConstructorHelper(String tag, String htmlSnippet,
+ String expectedText, Function isExpectedClass) {
+ expect(isExpectedClass(new Element.tag(tag)), true);
+ final elementFromSnippet = new Element.html(htmlSnippet);
+ expect(isExpectedClass(elementFromSnippet), true);
+ expect(expectedText, elementFromSnippet.text);
+}
+
+void testEventHelper(EventListenerList listenerList, type,
+ [Function registerOnEventListener = null]) {
+ bool firedWhenAddedToListenerList = false;
+ bool firedOnEvent = false;
+ listenerList.add((e) {
+ firedWhenAddedToListenerList = true;
+ });
+ if (registerOnEventListener != null) {
+ registerOnEventListener((e) {
+ firedOnEvent = true;
+ });
+ }
+
+ final event = new Event(type);
+ listenerList.dispatch(event);
+
+ Expect.isTrue(firedWhenAddedToListenerList);
+ if (registerOnEventListener != null) {
+ Expect.isTrue(firedOnEvent);
+ }
+}
+
+main() {
+ useHtmlConfiguration();
+
+ group('constructors', () {
+ test('details', () => testConstructorHelper('details',
+ '<details>foo</details>', 'foo',
+ (element) => element is DetailsElement));
+ test('embed', () => testConstructorHelper('embed',
+ '<embed>foo</embed>', '',
+ (element) => element is EmbedElement));
+ test('keygen', () => testConstructorHelper('keygen', '<keygen>', '',
+ (element) => element is KeygenElement));
+ test('marquee', () => testConstructorHelper('marquee',
+ '<marquee>foo</marquee>', 'foo',
+ (element) => element is MarqueeElement));
+ test('meter', () => testConstructorHelper('meter',
+ '<meter>foo</meter>', 'foo',
+ (element) => element is MeterElement));
+ test('object', () => testConstructorHelper('object',
+ '<object>foo</object>', 'foo',
+ (element) => element is ObjectElement));
+ });
+
+ group('events', () {
+ testEventHelper(on.transitionEnd, 'webkitTransitionEnd');
+ testEventHelper(on.fullscreenChange, 'webkitfullscreenchange',
+ (listener) => Testing.addEventListener(element,
+ 'webkitfullscreenchange', listener, true));
+ });
+}
+
+
+

Powered by Google App Engine
This is Rietveld 408576698