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

Side by Side Diff: test/custom_element_proxy_test.dart

Issue 839013003: CustomElementProxy annotation (Closed) Base URL: git@github.com:dart-lang/web-components.git@master
Patch Set: update initialize dependency Created 5 years, 11 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
« no previous file with comments | « pubspec.yaml ('k') | test/custom_element_proxy_test.html » ('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) 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
3 // BSD-style license that can be found in the LICENSE file.
4 library custom_element_proxy_test;
5
6 import 'dart:html';
7 import 'dart:js';
8 import 'package:initialize/initialize.dart' as init;
9 import 'package:unittest/html_config.dart';
10 import 'package:unittest/unittest.dart';
11 import 'package:web_components/custom_element_proxy.dart';
12
13 @CustomElementProxy('basic-element')
14 class BasicElement extends HtmlElement {
15 BasicElement.created() : super.created();
16
17 factory BasicElement() => document.createElement('basic-element');
18
19 bool get isBasicElement =>
20 new JsObject.fromBrowserObject(this)['isBasicElement'];
21 }
22
23 @CustomElementProxy('extended-element', extendsTag: 'input')
24 class ExtendedElement extends InputElement {
25 ExtendedElement.created() : super.created();
26
27 factory ExtendedElement() =>
28 document.createElement('input', 'extended-element');
29
30 bool get isExtendedElement =>
31 new JsObject.fromBrowserObject(this)['isExtendedElement'];
32 }
33
34 main() {
35 useHtmlConfiguration();
36 init.run();
37
38 var container = querySelector('#container') as DivElement;
39
40 tearDown(() {
41 container.children.clear();
42 });
43
44 test('basic custom element', () {
45 container.append(new BasicElement());
46 container.appendHtml('<basic-element></basic_element>');
47 var elements = container.querySelectorAll('basic-element');
48 for (var element in elements) {
49 expect(element.runtimeType, BasicElement);
50 expect(element.isBasicElement, isTrue);
51 }
52 });
53
54 test('extends custom element', () {
55 container.append(new ExtendedElement());
56 container.appendHtml('<input is="extended-element" />');
57 var elements = container.querySelectorAll('extended-element');
58 for (var element in elements) {
59 expect(element.runtimeType, ExtendedElement);
60 expect(element.isExtendedElement, isTrue);
61 }
62 });
63 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/custom_element_proxy_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698