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

Side by Side Diff: test/src/common/polymer_descriptor_test.dart

Issue 1290643006: First cut at behaviors. This just implements the lifecycle methodsportion. We may get the rest for … (Closed) Base URL: git@github.com:dart-lang/polymer-dart.git@master
Patch Set: Created 5 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
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 @TestOn('browser') 4 @TestOn('browser')
5 library polymer.test.src.common.polymer_descriptor_test; 5 library polymer.test.src.common.polymer_descriptor_test;
6 6
7 import 'dart:js'; 7 import 'dart:js';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 import 'package:polymer/polymer.dart'; 9 import 'package:polymer/polymer.dart';
10 import 'package:polymer/src/common/polymer_descriptor.dart'; 10 import 'package:polymer/src/common/polymer_descriptor.dart';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 var listeners = descriptor['listeners']; 50 var listeners = descriptor['listeners'];
51 expect(listeners['tap'], 'onTap'); 51 expect(listeners['tap'], 'onTap');
52 expect(listeners['someId.tap'], 'onSomeIdTap'); 52 expect(listeners['someId.tap'], 'onSomeIdTap');
53 53
54 expect(descriptor['ready'] is JsFunction, isTrue); 54 expect(descriptor['ready'] is JsFunction, isTrue);
55 expect(descriptor['attached'] is JsFunction, isTrue); 55 expect(descriptor['attached'] is JsFunction, isTrue);
56 expect(descriptor['detached'] is JsFunction, isTrue); 56 expect(descriptor['detached'] is JsFunction, isTrue);
57 expect(descriptor['handleSomeEvent'] is JsFunction, isTrue); 57 expect(descriptor['handleSomeEvent'] is JsFunction, isTrue);
58 expect(descriptor['myDoubleChanged'] is JsFunction, isTrue); 58 expect(descriptor['myDoubleChanged'] is JsFunction, isTrue);
59 expect(descriptor['myNumsCombined'] is JsFunction, isTrue); 59 expect(descriptor['myNumsCombined'] is JsFunction, isTrue);
60
61 expect(descriptor['behaviors'], isNotNull);
62 expect(descriptor['behaviors'].length, 2);
63 expect(descriptor['behaviors'][0], context['Foo']['BehaviorOne']);
64 expect(descriptor['behaviors'][1], context['Foo']['BehaviorTwo']);
60 }); 65 });
61 } 66 }
62 67
68 @BehaviorProxy(const ['Foo', 'BehaviorOne'])
69 class BehaviorOne {}
70
71 @BehaviorProxy(const ['Foo', 'BehaviorTwo'])
72 class BehaviorTwo {}
73
63 @jsProxyReflectable 74 @jsProxyReflectable
64 class Test { 75 class Test extends Object with BehaviorOne, BehaviorTwo {
65 @property 76 @property
66 String myString; 77 String myString;
67 @Property(notify: true) 78 @Property(notify: true)
68 int myInt; 79 int myInt;
69 @Property(observer: 'myDoubleChanged') 80 @Property(observer: 'myDoubleChanged')
70 double myDouble; 81 double myDouble;
71 @Property(reflectToAttribute: true) 82 @Property(reflectToAttribute: true)
72 num myNum; 83 num myNum;
73 @property 84 @property
74 bool myBool; 85 bool myBool;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 expectEqual(actual, expected); 139 expectEqual(actual, expected);
129 } 140 }
130 141
131 void expectEqual(JsObject actual, Map expected) { 142 void expectEqual(JsObject actual, Map expected) {
132 expect(actual, isNotNull); 143 expect(actual, isNotNull);
133 var keys = context['Object'].callMethod('keys', [actual]); 144 var keys = context['Object'].callMethod('keys', [actual]);
134 for (var key in keys) { 145 for (var key in keys) {
135 expect(actual[key], equals(expected[key])); 146 expect(actual[key], equals(expected[key]));
136 } 147 }
137 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698