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

Side by Side Diff: tests/html/custom/element_upgrade_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 library register_element_proxy_test; 5 library register_element_proxy_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:js' as js; 9 import 'dart:js' as js;
10 import 'package:unittest/html_config.dart'; 10 import 'package:unittest/html_config.dart';
(...skipping 15 matching lines...) Expand all
26 26
27 bool get fooCreated => _proxy['fooCreated']; 27 bool get fooCreated => _proxy['fooCreated'];
28 } 28 }
29 29
30 main() { 30 main() {
31 useHtmlConfiguration(); 31 useHtmlConfiguration();
32 32
33 var registered = false; 33 var registered = false;
34 var upgrader; 34 var upgrader;
35 setUp(() => customElementsReady.then((_) { 35 setUp(() => customElementsReady.then((_) {
36 if (!registered) { 36 if (!registered) {
37 registered = true; 37 registered = true;
38 upgrader = document.createElementUpgrader(FooElement); 38 upgrader = document.createElementUpgrader(FooElement);
39 js.context['upgradeListener'] = (e) { 39 js.context['upgradeListener'] = (e) {
40 upgrader.upgrade(e); 40 upgrader.upgrade(e);
41 }; 41 };
42 42
43 document.registerElement('custom-element', CustomElement); 43 document.registerElement('custom-element', CustomElement);
44 } 44 }
45 })); 45 }));
46 46
47 test('created gets proxied', () { 47 test('created gets proxied', () {
48 var element = document.createElement(FooElement.tag); 48 var element = document.createElement(FooElement.tag);
49 expect(element is FooElement, isTrue); 49 expect(element is FooElement, isTrue);
50 expect(element.initializedField, 666); 50 expect(element.initializedField, 666);
51 expect(element.text, 'constructed'); 51 expect(element.text, 'constructed');
52 52
53 js.context.callMethod('validateIsFoo', [element]); 53 js.context.callMethod('validateIsFoo', [element]);
54 54
55 expect(element.doSomething(), 'didSomething'); 55 expect(element.doSomething(), 'didSomething');
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 }); 92 });
93 93
94 test('cannot upgrade custom elements', () { 94 test('cannot upgrade custom elements', () {
95 var custom = new CustomElement(); 95 var custom = new CustomElement();
96 expect(() { 96 expect(() {
97 upgrader.upgrade(custom); 97 upgrader.upgrade(custom);
98 }, throws); 98 }, throws);
99 }); 99 });
100 100
101 test('can upgrade with extendsTag', () { 101 test('can upgrade with extendsTag', () {
102 var upgrader = 102 var upgrader = document.createElementUpgrader(CustomDiv, extendsTag: 'div');
103 document.createElementUpgrader(CustomDiv, extendsTag: 'div');
104 var div = new DivElement(); 103 var div = new DivElement();
105 var customDiv = upgrader.upgrade(div); 104 var customDiv = upgrader.upgrade(div);
106 expect(customDiv is CustomDiv, isTrue); 105 expect(customDiv is CustomDiv, isTrue);
107 106
108 var htmlElement = document.createElement('not-registered'); 107 var htmlElement = document.createElement('not-registered');
109 expect(() { 108 expect(() {
110 upgrader.upgrade(htmlElement); 109 upgrader.upgrade(htmlElement);
111 }, throws); 110 }, throws);
112 }); 111 });
113 112
114 test('cannot create upgrader for built-in types', () { 113 test('cannot create upgrader for built-in types', () {
115 expect(() { 114 expect(() {
116 document.createElementUpgrader(HtmlElement); 115 document.createElementUpgrader(HtmlElement);
117 }, throws); 116 }, throws);
118 }); 117 });
119 } 118 }
120 119
121 class HtmlElementInterface implements HtmlElement { 120 class HtmlElementInterface implements HtmlElement {
122 HtmlElementInterface.created(); 121 HtmlElementInterface.created();
123 } 122 }
124 123
125 class CustomDiv extends DivElement { 124 class CustomDiv extends DivElement {
126 CustomDiv.created() : super.created(); 125 CustomDiv.created() : super.created();
127 } 126 }
128 127
129 class CustomElement extends HtmlElement { 128 class CustomElement extends HtmlElement {
130 factory CustomElement() => document.createElement('custom-element'); 129 factory CustomElement() => document.createElement('custom-element');
131 CustomElement.created() : super.created(); 130 CustomElement.created() : super.created();
132 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698