Port Android relocation packer to chromium build
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-selector / test / content.html
blobe6ede77295cf15f19bcc93075858c5ea6477feff
1 <!doctype html>
2 <!--
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.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/CONTRIBUTORS.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/PATENTS.txt
9 -->
10 <html>
11 <head>
12 <meta charset="UTF-8">
13 <title>core-selector-content</title>
14 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
16 <script src="../../webcomponentsjs/webcomponents.js"></script>
17 <script src="../../web-component-tester/browser.js"></script>
19 <link rel="import" href="../core-selector.html">
21 <style>
22 .core-selected {
23 background: #ccc;
25 </style>
27 </head>
28 <body>
30 <polymer-element name="test-core-selector" noscript attributes="selected">
31 <template>
32 <core-selector id="selector" selected="{{selected}}" valueattr="id">
33 <content></content>
34 </core-selector>
35 </template>
36 </polymer-element>
38 <test-core-selector selected="item0">
39 <div id="item0">item0</div>
40 <div id="item1">item1</div>
41 <div id="item2">item2</div>
42 <div id="item3">item3</div>
43 </test-core-selector>
45 <script>
47 var s = document.querySelector('test-core-selector');
49 suite('content', function() {
51 test('get selected', function(done) {
52 asyncPlatformFlush(function() {
53 // check selected class
54 assert.isTrue(s.children[0].classList.contains('core-selected'));
55 done();
56 });
57 });
59 test('set selected', function(done) {
60 // set selected
61 s.selected = 'item1';
62 asyncPlatformFlush(function() {
63 // check selected class
64 assert.isTrue(s.children[1].classList.contains('core-selected'));
65 done();
66 });
67 });
69 test('get items', function() {
70 assert.equal(s.$.selector.items.length, s.children.length);
71 });
73 test('activate event', function(done) {
74 s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
75 asyncPlatformFlush(function() {
76 // check selected class
77 assert.isTrue(s.children[2].classList.contains('core-selected'));
78 done();
79 });
80 });
82 test('add item dynamically', function(done) {
83 var item = document.createElement('div');
84 item.id = 'item4';
85 item.textContent = 'item4';
86 s.appendChild(item);
87 // set selected
88 s.selected = 'item4';
89 asyncPlatformFlush(function() {
90 // check selected class
91 assert.isTrue(s.children[4].classList.contains('core-selected'));
92 done();
93 });
94 });
96 });
98 </script>
100 </body>
101 </html>