Chromium Code Reviews| Index: pkg/web_components/test/created_watcher_test.dart |
| diff --git a/pkg/web_components/test/created_watcher_test.dart b/pkg/web_components/test/created_watcher_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..303903de760767e5cbbbfcfc52eaaa0ab0bf180e |
| --- /dev/null |
| +++ b/pkg/web_components/test/created_watcher_test.dart |
| @@ -0,0 +1,76 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library template_wrappers_test; |
| + |
| +import 'dart:html'; |
| +import 'dart:async'; |
| +import 'dart:js' show context, JsObject; |
| +import 'package:unittest/html_config.dart'; |
| +import 'package:unittest/unittest.dart'; |
| +import 'package:web_components/created_watcher.dart'; |
| + |
| +main() { |
| + useHtmlConfiguration(); |
| + |
| + test('created_watcher is supported', () { |
| + expect(isSupported, isTrue); |
| + }); |
| + |
| + test('no events for previously upgraded elements', () { |
|
justinfagnani
2014/06/06 23:33:05
so how do we create dart wrappers for previously u
Siggi Cherem (dart-lang)
2014/06/09 17:10:28
We could technically keep a buffer around but I'm
|
| + var sA = watch('x-a').listen(expectAsync((e) { |
| + fail('this should not be called'); |
| + }, count: 0)); |
| + var sB = watch('x-b', extendsTag: 'div').listen(expectAsync((e) { |
| + fail('this should not be called'); |
| + }, count: 0)); |
| + var sC = watch('x-c').listen(expectAsync((e) { |
| + fail('this should not be called'); |
| + }, count: 0)); |
| + return new Future.value().then((_) { |
| + sA.cancel(); |
| + sB.cancel(); |
| + sC.cancel(); |
| + }); |
| + }); |
| + |
| + test('events seen when registration was done before', () { |
| + var sA = watch('x-a').listen(expectAsync((e) { |
| + expect(e is HtmlElement, isTrue); |
| + expect(new JsObject.fromBrowserObject(e)['x'], 2); |
| + })); |
| + |
| + var sB = watch('x-b', extendsTag: 'div').listen(expectAsync((e) { |
| + expect(new JsObject.fromBrowserObject(e)['x'], 3); |
| + })); |
| + |
| + var sC = watch('x-c').listen(expectAsync((e) { |
| + fail('x-c is not registered yet'); |
| + }, count: 0)); |
| + |
| + context.callMethod('addA'); |
| + context.callMethod('addB'); |
| + |
| + return new Future.value().then((_) { |
| + sA.cancel(); |
| + sB.cancel(); |
| + sC.cancel(); |
| + }); |
| + }); |
| + |
| + test('events seen when registration is done afterwards', () { |
| + int lastValue; |
| + var sC = watch('x-c').listen(expectAsync((e) { |
| + lastValue = new JsObject.fromBrowserObject(e)['x']; |
| + }, count: 2)); |
| + |
| + context.callMethod('registerC'); |
| + expect(lastValue, 4); |
| + context.callMethod('addC'); |
| + expect(lastValue, 5); |
| + return new Future.value().then((_) { |
| + sC.cancel(); |
| + }); |
| + }); |
| +} |