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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/iron-selector/test/multi.html

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rerun reproduce.sh Created 5 years, 7 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-multi</title>
15 <meta charset="utf-8">
16 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0">
17
18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
19 <script src="../../web-component-tester/browser.js"></script>
20 <script src="../../test-fixture/test-fixture-mocha.js"></script>
21
22 <link rel="import" href="../../test-fixture/test-fixture.html">
23 <link rel="import" href="../iron-selector.html">
24
25 <style>
26 .iron-selected {
27 background: #ccc;
28 }
29 </style>
30
31 </head>
32 <body>
33
34 <test-fixture id="test">
35 <template>
36 <iron-selector multi>
37 <div>Item 0</div>
38 <div>Item 1</div>
39 <div>Item 2</div>
40 <div>Item 3</div>
41 <div>Item 4</div>
42 </iron-selector>
43 </template>
44 </test-fixture>
45
46 <script>
47
48 suite('multi', function() {
49
50 var s;
51
52 setup(function () {
53 s = fixture('test');
54 });
55
56 test('honors the multi attribute', function() {
57 assert.isTrue(s.multi);
58 });
59
60 test('has sane defaults', function() {
61 assert.equal(s.selectedValues, undefined);
62 assert.equal(s.selectedClass, 'iron-selected');
63 assert.equal(s.items.length, 5);
64 });
65
66 test('set multi-selection via selected property', function() {
67 // set selectedValues
68 s.selectedValues = [0, 2];
69 // check selected class
70 assert.isTrue(s.children[0].classList.contains('iron-selected'));
71 assert.isTrue(s.children[2].classList.contains('iron-selected'));
72 // check selectedItems
73 assert.equal(s.selectedItems.length, 2);
74 assert.equal(s.selectedItems[0], s.children[0]);
75 assert.equal(s.selectedItems[1], s.children[2]);
76 });
77
78 test('set multi-selection via tap', function() {
79 // set selectedValues
80 s.children[0].dispatchEvent(new CustomEvent('click', {bubbles: true}));
81 s.children[2].dispatchEvent(new CustomEvent('click', {bubbles: true}));
82 // check selected class
83 assert.isTrue(s.children[0].classList.contains('iron-selected'));
84 assert.isTrue(s.children[2].classList.contains('iron-selected'));
85 // check selectedItems
86 assert.equal(s.selectedItems.length, 2);
87 assert.equal(s.selectedItems[0], s.children[0]);
88 assert.equal(s.selectedItems[1], s.children[2]);
89 });
90
91 test('fire iron-select/deselect events', function() {
92 // setup listener for iron-select event
93 var selectEventCounter = 0;
94 s.addEventListener('iron-select', function(e) {
95 selectEventCounter++;
96 });
97 // setup listener for core-deselect event
98 var deselectEventCounter = 0;
99 s.addEventListener('iron-deselect', function(e) {
100 deselectEventCounter++;
101 });
102 // tap to select an item
103 s.children[0].dispatchEvent(new CustomEvent('click', {bubbles: true}));
104 // check events
105 assert.equal(selectEventCounter, 1);
106 assert.equal(deselectEventCounter, 0);
107 // tap on already selected item should deselect it
108 s.children[0].dispatchEvent(new CustomEvent('click', {bubbles: true}));
109 // check selectedValues
110 assert.equal(s.selectedValues.length, 0);
111 // check class
112 assert.isFalse(s.children[0].classList.contains('iron-selected'));
113 // check events
114 assert.equal(selectEventCounter, 1);
115 assert.equal(deselectEventCounter, 1);
116 });
117
118 /* test('toggle multi from true to false', function() {
119 // set selected
120 s.selected = [0, 2];
121 var first = s.selected[0];
122 // set mutli to false, so to make it single-selection
123 s.multi = false;
124 // selected should not be an array
125 assert.isNotArray(s.selected);
126 // selected should be the first value from the old array
127 assert.equal(s.selected, first);
128 }); */
129
130 });
131
132 </script>
133
134 </body>
135 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698