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

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

Issue 27618002: package:observe fix various api issues (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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/element_bindings_test.dart ('k') | pkg/mdv/test/node_bindings_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:html'; 7 import 'dart:html';
8 import 'package:observe/observe.dart'; 8 import 'package:observe/observe.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 import 'package:observe/src/microtask.dart'; 11 import 'package:observe/src/microtask.dart';
12 export 'package:observe/src/microtask.dart'; 12 export 'package:observe/src/microtask.dart';
13 13
14 final bool parserHasNativeTemplate = () { 14 final bool parserHasNativeTemplate = () {
15 var div = new DivElement()..innerHtml = '<table><template>'; 15 var div = new DivElement()..innerHtml = '<table><template>';
16 return div.firstChild.firstChild != null && 16 return div.firstChild.firstChild != null &&
17 div.firstChild.firstChild.tagName == 'TEMPLATE'; 17 div.firstChild.firstChild.tagName == 'TEMPLATE';
18 }(); 18 }();
19 19
20 toSymbolMap(Map map) {
21 var result = new ObservableMap.linked();
22 map.forEach((key, value) {
23 if (value is Map) value = toSymbolMap(value);
24 result[new Symbol(key)] = value;
25 });
26 return result;
27 }
28
29 recursivelySetTemplateModel(element, model, [delegate]) { 20 recursivelySetTemplateModel(element, model, [delegate]) {
30 for (var node in element.queryAll('*')) { 21 for (var node in element.queryAll('*')) {
31 if (node.isTemplate) { 22 if (node.isTemplate) {
32 node.bindingDelegate = delegate; 23 node.bindingDelegate = delegate;
33 node.model = model; 24 node.model = model;
34 } 25 }
35 } 26 }
36 } 27 }
37 28
38 dispatchEvent(type, target) { 29 dispatchEvent(type, target) {
39 target.dispatchEvent(new Event(type, cancelable: false)); 30 target.dispatchEvent(new Event(type, cancelable: false));
40 } 31 }
41 32
42 class FooBarModel extends ObservableBase { 33 class FooBarModel extends Observable {
43 @observable var foo; 34 @observable var foo;
44 @observable var bar; 35 @observable var bar;
45 36
46 FooBarModel([this.foo, this.bar]); 37 FooBarModel([this.foo, this.bar]);
47 } 38 }
48 39
49 @reflectable 40 @reflectable
50 class FooBarNotifyModel extends ChangeNotifierBase implements FooBarModel { 41 class FooBarNotifyModel extends ChangeNotifier implements FooBarModel {
51 var _foo; 42 var _foo;
52 var _bar; 43 var _bar;
53 44
54 FooBarNotifyModel([this._foo, this._bar]); 45 FooBarNotifyModel([this._foo, this._bar]);
55 46
56 get foo => _foo; 47 get foo => _foo;
57 set foo(value) { 48 set foo(value) {
58 _foo = notifyPropertyChange(#foo, _foo, value); 49 _foo = notifyPropertyChange(#foo, _foo, value);
59 } 50 }
60 51
61 get bar => _bar; 52 get bar => _bar;
62 set bar(value) { 53 set bar(value) {
63 _bar = notifyPropertyChange(#bar, _bar, value); 54 _bar = notifyPropertyChange(#bar, _bar, value);
64 } 55 }
65 } 56 }
66 57
67 observeTest(name, testCase) => test(name, wrapMicrotask(testCase)); 58 observeTest(name, testCase) => test(name, wrapMicrotask(testCase));
68 59
69 solo_observeTest(name, testCase) => solo_test(name, wrapMicrotask(testCase)); 60 solo_observeTest(name, testCase) => solo_test(name, wrapMicrotask(testCase));
OLDNEW
« no previous file with comments | « pkg/mdv/test/element_bindings_test.dart ('k') | pkg/mdv/test/node_bindings_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698