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

Unified Diff: tests/html/custom/attribute_changed_callback_test.dart

Issue 23232005: Port custom element layout tests to Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix dart2js and status Created 7 years, 4 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 | « no previous file | tests/html/custom/constructor_calls_created_synchronously_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/custom/attribute_changed_callback_test.dart
diff --git a/tests/html/custom/attribute_changed_callback_test.dart b/tests/html/custom/attribute_changed_callback_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3e78587c9b0ae07eccfefef8f2a05f9f17d12340
--- /dev/null
+++ b/tests/html/custom/attribute_changed_callback_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2013, 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 attribute_changed_callback_test;
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'dart:html';
+
+class A extends HtmlElement {
+ static final tag = 'x-a';
+ factory A() => new Element.tag(tag);
+
+ static var attributeChangedInvocations = 0;
+
+ void onAttributeChanged(name, oldValue, newValue) {
+ attributeChangedInvocations++;
+ }
+}
+
+class B extends HtmlElement {
+ static final tag = 'x-b';
+ factory B() => new Element.tag(tag);
+
+ static var invocations = [];
+
+ void onCreated() {
+ invocations.add('created');
+ }
+
+ void onAttributeChanged(name, oldValue, newValue) {
+ invocations.add('$name: $oldValue => $newValue');
+ }
+}
+
+main() {
+ useHtmlConfiguration();
+
+ // Adapted from Blink's fast/dom/custom/attribute-changed-callback test.
+
+ test('transfer attribute changed callback', () {
+ document.register(A.tag, A);
+ var element = new A();
+
+ element.attributes['a'] = 'b';
+ expect(A.attributeChangedInvocations, 1);
+ });
+
+ test('add, change and remove an attribute', () {
+ document.register(B.tag, B);
+ var b = new B();
+ b.id = 'x';
+ expect(B.invocations, ['created', 'id: null => x']);
+
+ B.invocations = [];
+ b.attributes.remove('id');
+ expect(B.invocations, ['id: x => null']);
+
+ B.invocations = [];
+ b.attributes['data-s'] = 't';
+ expect(B.invocations, ['data-s: null => t']);
+
+ B.invocations = [];
+ b.classList.toggle('u');
+ expect(B.invocations, ['class: null => u']);
+
+ b.attributes['data-v'] = 'w';
+ B.invocations = [];
+ b.attributes['data-v'] = 'x';
+ expect(B.invocations, ['data-v: w => x']);
+
+ B.invocations = [];
+ b.attributes['data-v'] = 'x';
+ expect(B.invocations, []);
+ });
+}
« no previous file with comments | « no previous file | tests/html/custom/constructor_calls_created_synchronously_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698