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

Side by Side Diff: lib/src/paper-ripple/test/paper-ripple.html

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 1 month 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
« no previous file with comments | « lib/src/paper-ripple/paper-ripple.html ('k') | lib/src/paper-slider/paper-slider.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <!-- 2 <!--
3 @license 3 @license
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt 5 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
8 Code distributed by Google as part of the polymer project is also 8 Code distributed by Google as part of the polymer project is also
9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
10 --> 10 -->
11 <html> 11 <html>
12 <head> 12 <head>
13 13
14 <meta charset="UTF-8"> 14 <meta charset="UTF-8">
15 <title>paper-ripple</title> 15 <title>paper-ripple</title>
16 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0"> 16 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0">
17 17
18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> 18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
19 <script src="../../web-component-tester/browser.js"></script> 19 <script src="../../web-component-tester/browser.js"></script>
20 <script src="../../test-fixture/test-fixture-mocha.js"></script> 20 <script src="../../test-fixture/test-fixture-mocha.js"></script>
21 <script src="../../iron-test-helpers/mock-interactions.js"></script>
21 22
22 <link rel="import" href="../../test-fixture/test-fixture.html"> 23 <link rel="import" href="../../test-fixture/test-fixture.html">
23 <link rel="import" href="../paper-ripple.html"> 24 <link rel="import" href="../paper-ripple.html">
24 25
25 <style> 26 <style>
26 #RippleContainer { 27 #RippleContainer {
27 display: block; 28 display: block;
28 position: relative; 29 position: relative;
29 width: 100px; 30 width: 100px;
30 height: 50px; 31 height: 50px;
(...skipping 18 matching lines...) Expand all
49 </test-fixture> 50 </test-fixture>
50 51
51 <test-fixture id="RecenteringRipple"> 52 <test-fixture id="RecenteringRipple">
52 <template> 53 <template>
53 <div id="RippleContainer"> 54 <div id="RippleContainer">
54 <paper-ripple recenters></paper-ripple> 55 <paper-ripple recenters></paper-ripple>
55 </div> 56 </div>
56 </template> 57 </template>
57 </test-fixture> 58 </test-fixture>
58 59
60 <test-fixture id="NoinkTarget">
61 <template>
62 <div id="RippleContainer">
63 <paper-ripple noink></paper-ripple>
64 </div>
65 </template>
66 </test-fixture>
67
59 <script> 68 <script>
60 function FakeMouseEvent (target, relativeX, relativeX) {
61 var rect = target.getBoundingClientRect();
62
63 return {
64 detail: {
65 x: rect.left + relativeX,
66 y: rect.top + relativeX
67 }
68 };
69 }
70
71 suite('<paper-ripple>', function () { 69 suite('<paper-ripple>', function () {
72 var mouseEvent; 70 var mouseEvent;
73 var rippleContainer; 71 var rippleContainer;
74 var ripple; 72 var ripple;
75 73
76 suite('when tapped', function () { 74 suite('when tapped', function () {
77 setup(function () { 75 setup(function () {
78 rippleContainer = fixture('TrivialRipple'); 76 rippleContainer = fixture('TrivialRipple');
79 ripple = rippleContainer.firstElementChild; 77 ripple = rippleContainer.firstElementChild;
80
81 mouseEvent = new FakeMouseEvent(ripple, 10, 10);
82 }); 78 });
83 79
84 test('creates a ripple', function () { 80 test('creates a ripple', function () {
85 expect(ripple.ripples.length).to.be.eql(0); 81 expect(ripple.ripples.length).to.be.eql(0);
86 ripple.downAction(mouseEvent); 82 MockInteractions.down(ripple);
87 expect(ripple.ripples.length).to.be.eql(1); 83 expect(ripple.ripples.length).to.be.eql(1);
88 }); 84 });
89 85
90 test('may create multiple ripples that overlap', function () { 86 test('may create multiple ripples that overlap', function () {
91 expect(ripple.ripples.length).to.be.eql(0); 87 expect(ripple.ripples.length).to.be.eql(0);
92 88
93 for (var i = 0; i < 3; ++i) { 89 for (var i = 0; i < 3; ++i) {
94 ripple.downAction(mouseEvent); 90 MockInteractions.down(ripple);
95 expect(ripple.ripples.length).to.be.eql(i + 1); 91 expect(ripple.ripples.length).to.be.eql(i + 1);
96 } 92 }
97 }); 93 });
98 }); 94 });
99 95
96 suite('when holdDown is togggled', function() {
97 setup(function () {
98 rippleContainer = fixture('TrivialRipple');
99 ripple = rippleContainer.firstElementChild;
100 });
101
102 test('generates a ripple', function() {
103 ripple.holdDown = true;
104 expect(ripple.ripples.length).to.be.eql(1);
105 });
106
107 test('generates a ripple when noink', function() {
108 ripple.noink = true;
109 ripple.holdDown = true;
110 expect(ripple.ripples.length).to.be.eql(1);
111
112 });
113
114 });
115
116 suite('when target is noink', function () {
117 setup(function () {
118 rippleContainer = fixture('NoinkTarget');
119 ripple = rippleContainer.firstElementChild;
120 });
121
122 test('tapping does not create a ripple', function () {
123 expect(ripple.keyEventTarget).to.be.equal(ripple);
124 expect(ripple.ripples.length).to.be.eql(0);
125 MockInteractions.down(ripple);
126 expect(ripple.ripples.length).to.be.eql(0);
127 });
128
129 test('ripples can be manually created', function () {
130 expect(ripple.ripples.length).to.be.eql(0);
131 ripple.simulatedRipple()
132 expect(ripple.ripples.length).to.be.eql(1);
133 });
134 });
135
136
137
100 suite('with the `center` attribute set to true', function () { 138 suite('with the `center` attribute set to true', function () {
101 setup(function () { 139 setup(function () {
102 rippleContainer = fixture('CenteringRipple'); 140 rippleContainer = fixture('CenteringRipple');
103 ripple = rippleContainer.firstElementChild; 141 ripple = rippleContainer.firstElementChild;
104
105 mouseEvent = new FakeMouseEvent(ripple, 10, 10);
106 }); 142 });
107 143
108 test('ripples will center', function (done) { 144 test('ripples will center', function (done) {
109 var waveContainerElement; 145 var waveContainerElement;
110 // let's ask the browser what `translate3d(0px, 0px, 0)` will actually look like 146 // let's ask the browser what `translate3d(0px, 0px, 0)` will actually look like
111 var div = document.createElement('div'); 147 var div = document.createElement('div');
112 div.style.webkitTransform = 'translate3d(0px, 0px, 0px)'; 148 div.style.webkitTransform = 'translate3d(0px, 0px, 0px)';
113 div.style.transform = 'translate3d(0px, 0px, 0)'; 149 div.style.transform = 'translate3d(0px, 0px, 0)';
114 150
115 ripple.downAction(mouseEvent); 151 MockInteractions.down(ripple);
116 152
117 waveContainerElement = ripple.ripples[0].waveContainer; 153 waveContainerElement = ripple.ripples[0].waveContainer;
118 154
119 ripple.upAction(mouseEvent); 155 MockInteractions.up(ripple);
120 156
121 window.requestAnimationFrame(function () { 157 window.requestAnimationFrame(function () {
122 var currentTransform = waveContainerElement.style.transform; 158 var currentTransform = waveContainerElement.style.transform;
123 try { 159 try {
124 expect(div.style.transform).to.be.ok; 160 expect(div.style.transform).to.be.ok;
125 expect(currentTransform).to.be.ok; 161 expect(currentTransform).to.be.ok;
126 expect(currentTransform).to.be.eql(div.style.transform); 162 expect(currentTransform).to.be.eql(div.style.transform);
127 163
128 done(); 164 done();
129 } catch (e) { 165 } catch (e) {
130 done(e); 166 done(e);
131 } 167 }
132 }); 168 });
133 }); 169 });
134 }); 170 });
135 171
136 suite('with the `recenters` attribute set to true', function () { 172 suite('with the `recenters` attribute set to true', function () {
137 setup(function () { 173 setup(function () {
138 rippleContainer = fixture('RecenteringRipple'); 174 rippleContainer = fixture('RecenteringRipple');
139 ripple = rippleContainer.firstElementChild; 175 ripple = rippleContainer.firstElementChild;
140 mouseEvent = new FakeMouseEvent(ripple, 10, 10);
141 }); 176 });
142 test('ripples will gravitate towards the center', function (done) { 177 test('ripples will gravitate towards the center', function (done) {
143 var waveContainerElement; 178 var waveContainerElement;
144 var waveTranslateString; 179 var waveTranslateString;
145 ripple.downAction(mouseEvent); 180 MockInteractions.down(ripple, {x: 10, y: 10});
146 waveContainerElement = ripple.ripples[0].waveContainer; 181 waveContainerElement = ripple.ripples[0].waveContainer;
147 waveTranslateString = waveContainerElement.style.transform; 182 waveTranslateString = waveContainerElement.style.transform;
148 ripple.upAction(mouseEvent); 183 MockInteractions.up(ripple);
149 window.requestAnimationFrame(function () { 184 window.requestAnimationFrame(function () {
150 try { 185 try {
151 expect(waveTranslateString).to.be.ok; 186 expect(waveTranslateString).to.be.ok;
152 expect(waveContainerElement.style.transform).to.be.ok; 187 expect(waveContainerElement.style.transform).to.be.ok;
153 expect(waveContainerElement.style.transform).to.not.be.eql(waveTra nslateString); 188 expect(waveContainerElement.style.transform).to.not.be.eql(waveTra nslateString);
154 done(); 189 done();
155 } catch (e) { 190 } catch (e) {
156 done(e); 191 done(e);
157 } 192 }
158 }); 193 });
159 }); 194 });
160 }); 195 });
161 196
162 }); 197 });
163 </script> 198 </script>
164 199
165 </body> 200 </body>
166 </html> 201 </html>
OLDNEW
« no previous file with comments | « lib/src/paper-ripple/paper-ripple.html ('k') | lib/src/paper-slider/paper-slider.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698