UNPKG

five-bells-visualization

Version:
116 lines (95 loc) 2.97 kB
<!doctype html> <!-- Copyright (c) 2014 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --> <html> <head> <meta charset="UTF-8"> <title>paper-dropdown-menu basic tests</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <script src="../../webcomponentsjs/webcomponents.js"></script> <script src="../../web-component-tester/browser.js"></script> <link href="../core-dropdown.html" rel="import"> <style> body { text-align: center; margin-top: 200px; } </style> </head> <body> <div relative id="trigger1"> tap <core-dropdown id="dropdown1">Hello World!</core-dropdown> </div> <div relative id="trigger2"> tap <core-dropdown id="dropdown2">Hello World!</core-dropdown> </div> <div relative id="trigger3"> tap <core-dropdown id="dropdown3">Hello World!</core-dropdown> </div> <script> function assertPosition(dropdown, trigger) { var dr = dropdown.getBoundingClientRect(); var tr = trigger.getBoundingClientRect(); if (dropdown.halign === 'left') { assert.equal(dr.left, tr.left); } else { assert.equal(dr.right, tr.right); } if (dropdown.valign === 'top') { assert.equal(dr.top, tr.top); } else { assert.equal(dr.bottom, tr.bottom); } }; function flushLayoutAndRender(callback) { flush(function() { document.body.offsetTop; requestAnimationFrame(function() { callback(); }); }); } var d1 = document.getElementById('dropdown1'); var t1 = document.getElementById('trigger1'); d1.relatedTarget = t1; var d2 = document.getElementById('dropdown2'); var t2 = document.getElementById('trigger2'); d2.relatedTarget = t2; var d3 = document.getElementById('dropdown3'); var t3 = document.getElementById('trigger3'); d3.relatedTarget = t3; test('default', function(done) { d1.opened = true; flushLayoutAndRender(function() { assertPosition(d1, t1); done(); }); }); test('bottom alignment', function(done) { d2.valign = 'bottom'; d2.opened = true; flushLayoutAndRender(function() { assertPosition(d2, t2); done(); }); }); test('right alignment', function(done) { d3.halign = 'right'; d3.opened = true; flushLayoutAndRender(function() { assertPosition(d3, t3); done(); }); }); </script> </body> </html>