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

Side by Side Diff: pkg/mdv/test/mdv_test_utils.dart

Issue 22253002: fix packages for latest SDK changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/mdv/test/custom_element_bindings_test.dart ('k') | pkg/mdv/test/template_element_test.dart » ('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 observe_utils; 5 library observe_utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:observe/observe.dart'; 9 import 'package:observe/observe.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import 'package:observe/src/microtask.dart';
13 export 'package:observe/src/microtask.dart';
14
12 final bool parserHasNativeTemplate = () { 15 final bool parserHasNativeTemplate = () {
13 var div = new DivElement()..innerHtml = '<table><template>'; 16 var div = new DivElement()..innerHtml = '<table><template>';
14 return div.firstChild.firstChild != null && 17 return div.firstChild.firstChild != null &&
15 div.firstChild.firstChild.tagName == 'TEMPLATE'; 18 div.firstChild.firstChild.tagName == 'TEMPLATE';
16 }(); 19 }();
17 20
18 toSymbolMap(Map map) { 21 toSymbolMap(Map map) {
19 var result = new ObservableMap.linked(); 22 var result = new ObservableMap.linked();
20 map.forEach((key, value) { 23 map.forEach((key, value) {
21 if (value is Map) value = toSymbolMap(value); 24 if (value is Map) value = toSymbolMap(value);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 set foo(value) { 57 set foo(value) {
55 _foo = notifyPropertyChange(const Symbol('foo'), _foo, value); 58 _foo = notifyPropertyChange(const Symbol('foo'), _foo, value);
56 } 59 }
57 60
58 get bar => _bar; 61 get bar => _bar;
59 set bar(value) { 62 set bar(value) {
60 _bar = notifyPropertyChange(const Symbol('bar'), _bar, value); 63 _bar = notifyPropertyChange(const Symbol('bar'), _bar, value);
61 } 64 }
62 } 65 }
63 66
64 // TODO(jmesserly): this is a copy/paste from observe_test_utils.dart
65 // Is it worth putting it in its own package, or in an existing one?
66
67 void performMicrotaskCheckpoint() {
68 Observable.dirtyCheck();
69
70 while (_pending.length > 0) {
71 var pending = _pending;
72 _pending = [];
73
74 for (var callback in pending) {
75 try {
76 callback();
77 } catch (e, s) {
78 new Completer().completeError(e, s);
79 }
80 }
81
82 Observable.dirtyCheck();
83 }
84 }
85
86 List<Function> _pending = [];
87
88 wrapMicrotask(void testCase()) {
89 return () {
90 runZonedExperimental(() {
91 try {
92 testCase();
93 } finally {
94 performMicrotaskCheckpoint();
95 }
96 }, onRunAsync: (callback) => _pending.add(callback));
97 };
98 }
99
100 observeTest(name, testCase) => test(name, wrapMicrotask(testCase)); 67 observeTest(name, testCase) => test(name, wrapMicrotask(testCase));
101 68
102 solo_observeTest(name, testCase) => solo_test(name, wrapMicrotask(testCase)); 69 solo_observeTest(name, testCase) => solo_test(name, wrapMicrotask(testCase));
OLDNEW
« no previous file with comments | « pkg/mdv/test/custom_element_bindings_test.dart ('k') | pkg/mdv/test/template_element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698