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

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

Issue 151563006: Updating custom element wrapper test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/html/custom/template_wrappers_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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 template_wrappers_test; 5 library template_wrappers_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';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 import '../utils.dart'; 12 import '../utils.dart';
13 13
14 int createdCount = 0; 14 int createdCount = 0;
15 15
16 class CustomElement extends HtmlElement { 16 class CustomElement extends HtmlElement {
17 CustomElement.created() : super.created() { 17 CustomElement.created() : super.created() {
18 ++createdCount; 18 ++createdCount;
19 } 19 }
20 20
21 void checkCreated() { 21 void checkCreated() {
22 } 22 }
23 } 23 }
24 24
25 main() { 25 main() {
26 useHtmlConfiguration(); 26 useHtmlConfiguration();
27 27
28 setUp(customElementsReady); 28 setUp(() => customElementsReady);
29 29
30 test('element is upgraded once', () { 30 test('element is upgraded once', () {
31 31
32 expect(createdCount, 0); 32 expect(createdCount, 0);
33 document.register('x-custom', CustomElement); 33 document.register('x-custom', CustomElement);
34 expect(createdCount, 0);
35
36 var element = document.createElement('x-custom');
34 expect(createdCount, 1); 37 expect(createdCount, 1);
35 38
36 forceGC(); 39 forceGC();
37 40
38 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { 41 return new Future.delayed(new Duration(milliseconds: 50)).then((_) {
39 var t = document.querySelector('.t1'); 42 var t = document.querySelector('.t1');
40 43
41 var fragment = t.content; 44 var fragment = t.content;
42 45
43 fragment.querySelector('x-custom').checkCreated(); 46 fragment.querySelector('x-custom').attributes['foo'] = 'true';
44 expect(createdCount, 1); 47 expect(createdCount, 1);
45 }); 48 });
46 }); 49 });
47 /* 50 /*
48 test('old wrappers do not cause multiple upgrades', () { 51 test('old wrappers do not cause multiple upgrades', () {
49 createdCount = 0; 52 createdCount = 0;
50 var d1 = document.querySelector('x-custom-two'); 53 var d1 = document.querySelector('x-custom-two');
51 d1.attributes['foo'] = 'bar'; 54 d1.attributes['foo'] = 'bar';
52 d1 = null; 55 d1 = null;
53 56
(...skipping 12 matching lines...) Expand all
66 } 69 }
67 70
68 71
69 void forceGC() { 72 void forceGC() {
70 var N = 1000000; 73 var N = 1000000;
71 var M = 100; 74 var M = 100;
72 for (var i = 0; i < M; ++i) { 75 for (var i = 0; i < M; ++i) {
73 var l = new List(N); 76 var l = new List(N);
74 } 77 }
75 } 78 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/custom/template_wrappers_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698