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

Side by Side Diff: pkg/polymer/test/events_test.dart

Issue 27903006: Improves how to initialize polymer apps and fixes polymer build and linter to (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/polymer/test/event_path_test.html ('k') | pkg/polymer/test/events_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 polymer.test.web.events_test; 5 library polymer.test.web.events_test;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'package:polymer/polymer.dart'; 8 import 'package:polymer/polymer.dart';
9 import 'package:unittest/html_config.dart'; 9 import 'package:unittest/html_config.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 @initMethod _main() { 12 @CustomTag("test-b")
13 class TestB extends PolymerElement {
14 TestB.created() : super.created();
15
16 List clicks = [];
17 void clickHandler(event, detail, target) {
18 clicks.add('local click under $localName (id $id) on ${target.id}');
19 }
20 }
21
22 @CustomTag("test-a")
23 class TestA extends PolymerElement {
24 TestA.created() : super.created();
25
26 List clicks = [];
27 void clickHandler() {
28 clicks.add('host click on: $localName (id $id)');
29 }
30 }
31
32 main() {
33 initPolymer();
13 useHtmlConfiguration(); 34 useHtmlConfiguration();
14 35
15 setUp(() => Polymer.onReady); 36 setUp(() => Polymer.onReady);
16 37
17 test('host event', () { 38 test('host event', () {
18 // Note: this test is currently the only event in 39 // Note: this test is currently the only event in
19 // polymer/test/js/events.js at commit #7936ff8 40 // polymer/test/js/events.js at commit #7936ff8
20 var testA = query('#a'); 41 var testA = query('#a');
21 expect(testA.xtag.clicks, isEmpty); 42 expect(testA.xtag.clicks, isEmpty);
22 testA.click(); 43 testA.click();
23 expect(testA.xtag.clicks, ['host click on: test-a (id a)']); 44 expect(testA.xtag.clicks, ['host click on: test-a (id a)']);
24 }); 45 });
25 46
26 test('local event', () { 47 test('local event', () {
27 var testB = query('#b'); 48 var testB = query('#b');
28 expect(testB.xtag.clicks, isEmpty); 49 expect(testB.xtag.clicks, isEmpty);
29 testB.click(); 50 testB.click();
30 expect(testB.xtag.clicks, []); 51 expect(testB.xtag.clicks, []);
31 var b1 = testB.shadowRoot.query('#b-1'); 52 var b1 = testB.shadowRoot.query('#b-1');
32 b1.click(); 53 b1.click();
33 expect(testB.xtag.clicks, []); 54 expect(testB.xtag.clicks, []);
34 var b2 = testB.shadowRoot.query('#b-2'); 55 var b2 = testB.shadowRoot.query('#b-2');
35 b2.click(); 56 b2.click();
36 expect(testB.xtag.clicks, ['local click under test-b (id b) on b-2']); 57 expect(testB.xtag.clicks, ['local click under test-b (id b) on b-2']);
37 }); 58 });
38 } 59 }
OLDNEW
« no previous file with comments | « pkg/polymer/test/event_path_test.html ('k') | pkg/polymer/test/events_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698