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

Side by Side Diff: polymer_1.0.4/bower_components/iron-selector/test/activate-event.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 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
(Empty)
1 <!doctype html>
2 <!--
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 -->
10
11 <html>
12 <head>
13
14 <title>iron-selector-activate-event</title>
15 <meta charset="UTF-8">
16
17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
18 <script src="../../web-component-tester/browser.js"></script>
19 <script src="../../test-fixture/test-fixture-mocha.js"></script>
20
21 <link rel="import" href="../../test-fixture/test-fixture.html">
22 <link rel="import" href="../iron-selector.html">
23
24 <style>
25 .iron-selected {
26 background: #ccc;
27 }
28 </style>
29
30 </head>
31 <body>
32
33 <test-fixture id="test">
34 <template>
35 <iron-selector id="selector" selected="0">
36 <div>Item 0</div>
37 <div>Item 1</div>
38 <div>Item 2</div>
39 <div>Item 3</div>
40 <div>Item 4</div>
41 </iron-selector>
42 </template>
43 </test-fixture>
44
45 <script>
46
47 suite('activate event', function() {
48
49 var s;
50
51 setup(function () {
52 s = fixture('test');
53 });
54
55 test('activates on tap', function() {
56 assert.equal(s.selected, '0');
57
58 // select Item 1
59 s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
60 assert.equal(s.selected, '1');
61 });
62
63 test('activates on tap and fires iron-activate', function(done) {
64 assert.equal(s.selected, '0');
65
66 // attach iron-activate listener
67 s.addEventListener("iron-activate", function(event) {
68 assert.equal(event.detail.selected, '1');
69 assert.equal(event.detail.item, s.children[1]);
70 done();
71 });
72
73 // select Item 1
74 s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
75 });
76
77 test('tap on already selected and fires iron-activate', function(done) {
78 assert.equal(s.selected, '0');
79
80 // attach iron-activate listener
81 s.addEventListener("iron-activate", function(event) {
82 assert.equal(event.detail.selected, '0');
83 assert.equal(event.detail.item, s.children[0]);
84 done();
85 });
86
87 // select Item 0
88 s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
89 });
90
91 test('activates on mousedown', function() {
92 // set activateEvent to mousedown
93 s.activateEvent = 'mousedown';
94 // select Item 2
95 s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true} ));
96 assert.equal(s.selected, '2');
97 });
98
99 test('activates on mousedown and fires iron-activate', function(done) {
100 // attach iron-activate listener
101 s.addEventListener("iron-activate", function(event) {
102 assert.equal(event.detail.selected, '2');
103 assert.equal(event.detail.item, s.children[2]);
104 done();
105 });
106
107 // set activateEvent to mousedown
108 s.activateEvent = 'mousedown';
109 // select Item 2
110 s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true} ));
111 });
112
113 test('no activation', function() {
114 assert.equal(s.selected, '0');
115 // set activateEvent to null
116 s.activateEvent = null;
117 // select Item 2
118 s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true} ));
119 assert.equal(s.selected, '0');
120 });
121
122 test('activates on tap and preventDefault', function() {
123 // attach iron-activate listener
124 s.addEventListener("iron-activate", function(event) {
125 event.preventDefault();
126 });
127 // select Item 2
128 s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
129 // shouldn't got selected since we preventDefault in iron-activate
130 assert.equal(s.selected, '0');
131 });
132
133 });
134
135 </script>
136
137 </body>
138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698