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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | test/custom_element_proxy_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/custom_element_proxy_test.dart
diff --git a/test/custom_element_proxy_test.dart b/test/custom_element_proxy_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4e3c188dcb4ad699f3e1be4d32b3b64afc1c74ea
--- /dev/null
+++ b/test/custom_element_proxy_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2015, 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 custom_element_proxy_test;
+
+import 'dart:html';
+import 'dart:js';
+import 'package:initialize/initialize.dart' as init;
+import 'package:unittest/html_config.dart';
+import 'package:unittest/unittest.dart';
+import 'package:web_components/custom_element_proxy.dart';
+
+@CustomElementProxy('basic-element')
+class BasicElement extends HtmlElement {
+ BasicElement.created() : super.created();
+
+ factory BasicElement() => document.createElement('basic-element');
+
+ bool get isBasicElement =>
+ new JsObject.fromBrowserObject(this)['isBasicElement'];
+}
+
+@CustomElementProxy('extended-element', extendsTag: 'input')
+class ExtendedElement extends InputElement {
+ ExtendedElement.created() : super.created();
+
+ factory ExtendedElement() =>
+ document.createElement('input', 'extended-element');
+
+ bool get isExtendedElement =>
+ new JsObject.fromBrowserObject(this)['isExtendedElement'];
+}
+
+main() {
+ useHtmlConfiguration();
+ init.run();
+
+ var container = querySelector('#container') as DivElement;
+
+ tearDown(() {
+ container.children.clear();
+ });
+
+ test('basic custom element', () {
+ container.append(new BasicElement());
+ container.appendHtml('<basic-element></basic_element>');
+ var elements = container.querySelectorAll('basic-element');
+ for (var element in elements) {
+ expect(element.runtimeType, BasicElement);
+ expect(element.isBasicElement, isTrue);
+ }
+ });
+
+ test('extends custom element', () {
+ container.append(new ExtendedElement());
+ container.appendHtml('<input is="extended-element" />');
+ var elements = container.querySelectorAll('extended-element');
+ for (var element in elements) {
+ expect(element.runtimeType, ExtendedElement);
+ expect(element.isExtendedElement, isTrue);
+ }
+ });
+}
« 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