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

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

Issue 12212056: Sample test for custom elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/html.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 blob_test;
6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_config.dart';
8 import 'dart:html';
9
10 class CustomType extends Element {
11 bool onCreatedCalled = false;
12 void onCreated() {
13 onCreatedCalled = true;
14 }
15 }
16
17 class NotAnElement {}
18
19 main() {
20 useHtmlConfiguration();
21
22 test('register', () {
23 document.register('x-type1', CustomType);
24
25 var element = new Element.tag('x-type1');
26 expect(element, isNotNull);
27 expect(element is CustomType, isTrue);
28 expect(element.onCreatedCalled, isTrue);
29 });
30
31 test('register twice', () {
32 document.register('x-type2', CustomType);
33 expect(() {
34 document.register('x-type2', CustomType);
35 }, throws, reason: 'Cannot register a tag more than once.');
36
37 document.register('x-type3', CustomType);
38
39 var element = new Element.tag('x-type3');
40 expect(element, isNotNull);
41 expect(element is CustomType, isTrue);
42 });
43
44 test('register null', () {
45 expect(() {
46 document.register('x-type4', null);
47 }, throws, reason: 'Cannot register a null type.');
48 });
49
50 test('register native', () {
51 expect(() {
52 document.register('x-type5', BodyElement);
53 }, throws, reason: 'Cannot register a native element.');
54 });
55
56 test('register non-element', () {
57 expect(() {
58 document.register('x-type6', NotAnElement);
59 }, throws, reason: 'Cannot register a non-element.');
60 });
61
62 test('pre-registration construction', () {
63 var dom = new Element.html('<div><x-type7></x-type7></div>');
64
65 document.register('x-type7', CustomType);
66
67 element = dom.children[0];
Anton Muhin 2013/02/08 12:51:03 what if I fetch element before document.register c
blois 2013/02/08 17:44:30 Added checks, it should be an UnknownElement. Afte
68 expect(element, isNotNull);
69 expect(element is CustomType, isTrue);
70 expect(element.onCreatedCalled, isTrue);
71 });
72 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698