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

Side by Side Diff: test/custom_element_proxy_test.dart

Issue 882823003: Adds @HtmlImport with both dynamic and transformer based implementations. Still need an HtmlInliner… (Closed) Base URL: git@github.com:dart-lang/web-components.git@master
Patch Set: assign logger Created 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 library custom_element_proxy_test; 4 library custom_element_proxy_test;
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:js'; 8 import 'dart:js';
9 import 'package:initialize/initialize.dart' as init; 9 import 'package:initialize/initialize.dart' as init;
10 import 'package:unittest/html_config.dart'; 10 import 'package:unittest/html_config.dart';
(...skipping 17 matching lines...) Expand all
28 factory ExtendedElement() => 28 factory ExtendedElement() =>
29 document.createElement('input', 'extended-element'); 29 document.createElement('input', 'extended-element');
30 30
31 bool get isExtendedElement => 31 bool get isExtendedElement =>
32 new JsObject.fromBrowserObject(this)['isExtendedElement']; 32 new JsObject.fromBrowserObject(this)['isExtendedElement'];
33 } 33 }
34 34
35 main() { 35 main() {
36 useHtmlConfiguration(); 36 useHtmlConfiguration();
37 init.run().then((_) { 37 init.run().then((_) {
38 var container = querySelector('#container') as DivElement;
38 39
39 var container = querySelector('#container') as DivElement; 40 tearDown(() {
41 container.children.clear();
42 });
40 43
41 tearDown(() { 44 test('basic custom element', () {
42 container.children.clear(); 45 container.append(new BasicElement());
43 }); 46 container.appendHtml('<basic-element></basic_element>');
47 // TODO(jakemac): after appendHtml elements are upgraded asynchronously,
48 // why? https://github.com/dart-lang/web-components/issues/4
49 return new Future(() {}).then((_) {
50 var elements = container.querySelectorAll('basic-element');
51 expect(elements.length, 2);
52 for (BasicElement element in elements) {
53 print(element.outerHtml);
54 print(element.runtimeType);
55 expect(element.isBasicElement, isTrue);
56 }
57 });
58 });
44 59
45 test('basic custom element', () { 60 test('extends custom element', () {
46 container.append(new BasicElement()); 61 container.append(new ExtendedElement());
47 container.appendHtml('<basic-element></basic_element>'); 62 container.appendHtml('<input is="extended-element" />');
48 // TODO(jakemac): after appendHtml elements are upgraded asynchronously, 63 // TODO(jakemac): after appendHtml elements are upgraded asynchronously,
49 // why? https://github.com/dart-lang/web-components/issues/4 64 // why? https://github.com/dart-lang/web-components/issues/4
50 return new Future(() {}).then((_) { 65 return new Future(() {}).then((_) {
51 var elements = container.querySelectorAll('basic-element'); 66 var elements = container.querySelectorAll('input');
52 expect(elements.length, 2); 67 expect(elements.length, 2);
53 for (BasicElement element in elements) { 68 for (ExtendedElement element in elements) {
54 print(element.outerHtml); 69 expect(element.isExtendedElement, isTrue);
55 print(element.runtimeType); 70 }
56 expect(element.isBasicElement, isTrue); 71 });
57 }
58 }); 72 });
59 }); 73 });
60
61 test('extends custom element', () {
62 container.append(new ExtendedElement());
63 container.appendHtml('<input is="extended-element" />');
64 // TODO(jakemac): after appendHtml elements are upgraded asynchronously,
65 // why? https://github.com/dart-lang/web-components/issues/4
66 return new Future(() {}).then((_) {
67 var elements = container.querySelectorAll('input');
68 expect(elements.length, 2);
69 for (ExtendedElement element in elements) {
70 expect(element.isExtendedElement, isTrue);
71 }
72 });
73 });
74
75 });
76 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698