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

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

Issue 2730713003: Update a couple more strong mode tests (Closed)
Patch Set: Created 3 years, 9 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 | « tests/lib_strong/html/custom/document_register_basic_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:html'; 6 import 'dart:html';
7 import 'dart:js' as js; 7 import 'dart:js' as js;
8 8
9 import 'package:expect/minitest.dart'; 9 import 'package:expect/minitest.dart';
10 10
(...skipping 26 matching lines...) Expand all
37 upgrader.upgrade(e); 37 upgrader.upgrade(e);
38 }; 38 };
39 39
40 document.registerElement('custom-element', CustomElement); 40 document.registerElement('custom-element', CustomElement);
41 } 41 }
42 })); 42 }));
43 43
44 test('created gets proxied', () { 44 test('created gets proxied', () {
45 var element = document.createElement(FooElement.tag); 45 var element = document.createElement(FooElement.tag);
46 expect(element is FooElement, isTrue); 46 expect(element is FooElement, isTrue);
47 expect(element.initializedField, 666); 47 expect((element as FooElement).initializedField, 666);
48 expect(element.text, 'constructed'); 48 expect(element.text, 'constructed');
49 49
50 js.context.callMethod('validateIsFoo', [element]); 50 js.context.callMethod('validateIsFoo', [element]);
51 51
52 expect(element.doSomething(), 'didSomething'); 52 expect((element as FooElement).doSomething(), 'didSomething');
53 expect(element.fooCreated, true); 53 expect((element as FooElement).fooCreated, true);
54 }); 54 });
55 55
56 test('dart constructor works', () { 56 test('dart constructor works', () {
57 var element = new FooElement(); 57 var element = new FooElement();
58 expect(element is FooElement, isTrue); 58 expect(element is FooElement, isTrue);
59 expect(element.text, 'constructed'); 59 expect(element.text, 'constructed');
60 60
61 js.context.callMethod('validateIsFoo', [element]); 61 js.context.callMethod('validateIsFoo', [element]);
62 62
63 expect(element.doSomething(), 'didSomething'); 63 expect(element.doSomething(), 'didSomething');
64 }); 64 });
65 65
66 test('cannot create upgrader for interfaces', () { 66 test('cannot create upgrader for interfaces', () {
67 expect(() { 67 expect(() {
68 document.createElementUpgrader(HtmlElementInterface); 68 document.createElementUpgrader(HtmlElementInterface);
69 }, throws); 69 }, throws);
70 }); 70 });
71 71
72 test('cannot upgrade interfaces', () { 72 test('cannot upgrade interfaces', () {
73 expect(() { 73 expect(() {
74 upgrader.upgrade(new HtmlElementInterface()); 74 upgrader.upgrade(new HtmlElementInterface()); /// compile-time error
75 }, throws); 75 }, throws);
76 }); 76 });
77 77
78 test('cannot upgrade more than once', () { 78 test('cannot upgrade more than once', () {
79 var fooElement = new FooElement(); 79 var fooElement = new FooElement();
80 expect(() { 80 expect(() {
81 upgrader.upgrade(fooElement); 81 upgrader.upgrade(fooElement);
82 }, throws); 82 }, throws);
83 }); 83 });
84 84
(...skipping 23 matching lines...) Expand all
108 }, throws); 108 }, throws);
109 }); 109 });
110 110
111 test('cannot create upgrader for built-in types', () { 111 test('cannot create upgrader for built-in types', () {
112 expect(() { 112 expect(() {
113 document.createElementUpgrader(HtmlElement); 113 document.createElementUpgrader(HtmlElement);
114 }, throws); 114 }, throws);
115 }); 115 });
116 } 116 }
117 117
118 class HtmlElementInterface implements HtmlElement { 118 class HtmlElementInterface implements HtmlElement { /// compile-time error
119 HtmlElementInterface.created(); 119 HtmlElementInterface.created();
120 } 120 }
121 121
122 class CustomDiv extends DivElement { 122 class CustomDiv extends DivElement {
123 CustomDiv.created() : super.created(); 123 CustomDiv.created() : super.created();
124 } 124 }
125 125
126 class CustomElement extends HtmlElement { 126 class CustomElement extends HtmlElement {
127 factory CustomElement() => document.createElement('custom-element'); 127 factory CustomElement() => document.createElement('custom-element');
128 CustomElement.created() : super.created(); 128 CustomElement.created() : super.created();
129 } 129 }
OLDNEW
« no previous file with comments | « tests/lib_strong/html/custom/document_register_basic_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698