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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/iron-iconset/test/iron-iconset.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, 8 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-iconset</title>
15 <meta charset="utf-8">
16 <meta name="viewport" content="width=device-width, initial-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="../iron-iconset.html">
23 <link rel="import" href="../../iron-meta/iron-meta.html">
24 <link rel="import" href="../../test-fixture/test-fixture.html">
25
26 </head>
27 <body>
28
29 <test-fixture id="TrivialIconset">
30 <template>
31 <iron-iconset name="foo" src="../demo/my-icons.png"></iron-iconset>
32 <iron-meta type="iconset"></iron-meta>
33 </template>
34 </test-fixture>
35
36 <test-fixture id="StandardIconset">
37 <template>
38 <iron-iconset name="my-icons"
39 src="../demo/my-icons.png"
40 width="96"
41 size="24"
42 icons="location place starta stopb bus car train walk"></iro n-iconset>
43 <div></div>
44 </template>
45 </test-fixture>
46
47 <test-fixture id="ThemedIconset">
48 <template>
49 <iron-iconset name="my-icons"
50 src="../demo/my-icons.png"
51 width="96"
52 size="24"
53 icons="location place starta stopb bus car train walk">
54 <property theme="large" offset-x="10" offset-y="10"></property>
55 </iron-iconset>
56 <div></div>
57 </template>
58 </test-fixture>
59
60 <script>
61 suite('<iron-iconset>', function () {
62 suite('basic behavior', function () {
63 var iconset;
64 var meta;
65
66 setup(function () {
67 var elements = fixture('TrivialIconset');
68
69 iconset = elements[0];
70 meta = elements[1];
71 });
72
73 test('it can be accessed via iron-meta', function () {
74 expect(meta.byKey('foo')).to.be.equal(iconset);
75 });
76 });
77
78 suite('when src, width, iconSize and icons are assigned', function () {
79 var iconset;
80 var div;
81
82 setup(function () {
83 var elements = fixture('StandardIconset');
84
85 iconset = elements[0];
86 div = elements[1];
87 });
88
89 /*
90 test('appends a child to the target element', function () {
91 expect(div.firstElementChild).to.not.be.ok;
92
93 iconset.applyIcon(div, 'location');
94
95 expect(div.firstElementChild).to.be.ok;
96 });
97 */
98
99 test('sets the background image of the target element', function () {
100 var iconStyle;
101
102 iconset.applyIcon(div, 'location');
103 iconStyle = window.getComputedStyle(div);
104
105 expect(iconStyle.backgroundImage).to.match(/url\(.*demo\/my-icons.png\)/);
106 });
107
108 test('offsets the background image to the icon\'s position', function () {
109 var iconStyle;
110
111 iconset.applyIcon(div, 'bus');
112 iconStyle = window.getComputedStyle(div);
113
114 expect(iconStyle.backgroundPositionX).to.be.eql(
115 '0px'
116 );
117
118 expect(iconStyle.backgroundPositionY).to.be.eql(
119 '-24px'
120 );
121 });
122 });
123
124 suite('when an iconset is themed', function () {
125 var iconset;
126 var div;
127
128 setup(function () {
129 var elements = fixture('ThemedIconset');
130
131 iconset = elements[0];
132 div = elements[1];
133 });
134
135 test('can use a theme when applying icon', function () {
136 iconset.applyIcon(div, 'bus', 'large');
137
138 expect(div).to.be.ok;
139 });
140
141 test('adjusts the icon by the theme offset', function () {
142 var iconStyle;
143
144 iconset.applyIcon(div, 'bus', 'large');
145 iconStyle = window.getComputedStyle(div);
146
147 expect(iconStyle.backgroundPositionX).to.be.eql(
148 '-10px'
149 );
150
151 expect(iconStyle.backgroundPositionY).to.be.eql('-34px');
152 });
153 });
154 });
155 </script>
156
157 </body>
158 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698