OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 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.g
ithub.io/LICENSE.txt | 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 | 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 | 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 | 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 | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --> | 9 --> |
10 <html> | 10 <html> |
11 <head> | 11 <head> |
12 <title>core-collapse</title> | 12 <meta charset="UTF-8"> |
13 | 13 <title>core-collapse-basic</title> |
14 <script src="../../platform/platform.js"></script> | 14 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
15 <link rel="import" href="../../polymer-test-tools/tools.html"> | |
16 <script src="../../polymer-test-tools/htmltest.js"></script> | |
17 | 15 |
18 | 16 <script src="../../webcomponentsjs/webcomponents.js"></script> |
19 <link rel="import" href="../../core-collapse/core-collapse.html"> | 17 <script src="../../web-component-tester/browser.js"></script> |
| 18 |
| 19 <link rel="import" href="../core-collapse.html"> |
| 20 |
20 </head> | 21 </head> |
21 <body unresolved> | 22 <body> |
22 | 23 |
23 <button onclick="document.querySelector('#collapse').toggle()">toggle collapse
</button> | |
24 | |
25 <core-collapse id="collapse" duration="0.1" opened> | 24 <core-collapse id="collapse" duration="0.1" opened> |
26 <div> | 25 <div> |
27 Forma temperiemque cornua sidera dissociata cornua recessit innabilis ligavi
t: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tanta austr
o capacius amphitrite sui quin postquam semina fossae liquidum umor galeae coept
is caligine liberioris quin liquidum matutinis invasit posset: flexi glomeravit
radiis certis invasit oppida postquam onerosior inclusum dominari opifex terris
pace finxit quam aquae nunc sine altae auroram quam habentem homo totidemque scy
thiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt poena aet
as totidem nec natura aethera locavit caelumque distinxit animalibus phoebe cing
ebant moderantum porrexerat terrae possedit sua sole diu summaque obliquis melio
ris orbem | 26 Forma temperiemque cornua sidera dissociata cornua recessit innabilis ligavi
t: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tanta austr
o capacius amphitrite sui quin postquam semina fossae liquidum umor galeae coept
is caligine liberioris quin liquidum matutinis invasit posset: flexi glomeravit
radiis certis invasit oppida postquam onerosior inclusum dominari opifex terris
pace finxit quam aquae nunc sine altae auroram quam habentem homo totidemque scy
thiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt poena aet
as totidem nec natura aethera locavit caelumque distinxit animalibus phoebe cing
ebant moderantum porrexerat terrae possedit sua sole diu summaque obliquis melio
ris orbem |
28 </div> | 27 </div> |
29 </core-collapse> | 28 </core-collapse> |
| 29 |
| 30 <script> |
30 | 31 |
31 <script> | 32 function getCollapseComputedStyle() { |
| 33 var c = document.querySelector('#collapse'); |
| 34 return getComputedStyle(c); |
| 35 } |
| 36 |
| 37 var collapse = document.querySelector('#collapse'); |
| 38 |
32 var delay = 200; | 39 var delay = 200; |
33 document.addEventListener('polymer-ready', function() { | 40 var collapseHeight; |
34 var c = document.querySelector('#collapse'); | 41 |
35 // verify take attribute for opened is correct | 42 suite('basic', function() { |
36 assert.equal(c.opened, true); | 43 |
37 setTimeout(function() { | 44 test('verify attribute', function() { |
38 // get the height for the opened state | 45 assert.equal(collapse.opened, true); |
39 var h = getCollapseComputedStyle().height; | 46 }); |
40 // verify the height is not 0px | 47 |
41 assert.notEqual(getCollapseComputedStyle().height, '0px'); | 48 test('verify height', function(done) { |
42 // close it | 49 Polymer.flush(); |
43 c.opened = false; | |
44 Platform.flush(); | |
45 setTimeout(function() { | 50 setTimeout(function() { |
46 // verify is closed | 51 collapseHeight = getCollapseComputedStyle().height; |
47 assert.notEqual(getCollapseComputedStyle().height, h); | 52 // verify height |
48 // open it | 53 assert.notEqual(collapseHeight, '0px'); |
49 c.opened = true; | 54 done(); |
50 Platform.flush(); | |
51 setTimeout(function() { | |
52 // verify is opened | |
53 assert.equal(getCollapseComputedStyle().height, h); | |
54 done(); | |
55 }, delay); | |
56 }, delay); | 55 }, delay); |
57 }, delay); | 56 }); |
| 57 |
| 58 test('test opened: false', function(done) { |
| 59 collapse.opened = false; |
| 60 Polymer.flush(); |
| 61 setTimeout(function() { |
| 62 var h = getCollapseComputedStyle().height; |
| 63 // verify height is 0px |
| 64 assert.equal(h, '0px'); |
| 65 done(); |
| 66 }, delay); |
| 67 }); |
| 68 |
| 69 test('test opened: true', function(done) { |
| 70 collapse.opened = true; |
| 71 Polymer.flush(); |
| 72 setTimeout(function() { |
| 73 var h = getCollapseComputedStyle().height; |
| 74 // verify height |
| 75 assert.equal(h, collapseHeight); |
| 76 done(); |
| 77 }, delay); |
| 78 }); |
| 79 |
58 }); | 80 }); |
59 | 81 |
60 function getCollapseComputedStyle() { | |
61 var b = document.querySelector('#collapse'); | |
62 return getComputedStyle(b); | |
63 } | |
64 | |
65 </script> | 82 </script> |
66 | 83 |
67 </body> | 84 </body> |
68 </html> | 85 </html> |
OLD | NEW |