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

Unified Diff: lib/src/paper-badge/test/basic.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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/paper-badge/paper-badge.html ('k') | lib/src/paper-behaviors/paper-button-behavior.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/paper-badge/test/basic.html
diff --git a/lib/src/paper-badge/test/basic.html b/lib/src/paper-badge/test/basic.html
index 1e335eaf7b1e21a640b02cc4a6b03eb93a703951..27ff91074020eb14b5dcec74e4333a59edc6d9f0 100644
--- a/lib/src/paper-badge/test/basic.html
+++ b/lib/src/paper-badge/test/basic.html
@@ -54,6 +54,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
</test-fixture>
+ <test-fixture id="nested">
+ <template>
+ <div>
+ <div id="target">
+ <paper-badge label="1"></paper-badge>
+ </div>
+ </div>
+ </template>
+ </test-fixture>
+
<test-fixture id="custom">
<template>
<test-button></test-button>
@@ -68,6 +78,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var actualbadge = Polymer.dom(badge.root).querySelector('#badge');
assert.equal(actualbadge.textContent, "1");
+ expect(badge.target.getAttribute('id')).to.be.equal('target');
+
badge.updatePosition();
Polymer.Base.async(function() {
@@ -97,11 +109,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var badge = f.querySelector('paper-badge');
badge.updatePosition();
+ expect(badge.target.getAttribute('id')).to.not.be.equal('target');
+
Polymer.Base.async(function() {
var contentRect = badge.getBoundingClientRect();
expect(contentRect.left).to.not.be.equal(100 - 11);
badge.for = 'target';
+ expect(badge.target.getAttribute('id')).to.be.equal('target');
+
badge.updatePosition();
Polymer.Base.async(function() {
@@ -127,6 +143,36 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
});
});
+ test('badge is positioned correctly when nested in a target element', function(done) {
+ var f = fixture('nested');
+ var badge = f.querySelector('paper-badge');
+
+ expect(badge.target.getAttribute('id')).to.be.equal('target');
+
+ badge.updatePosition();
+
+ Polymer.Base.async(function() {
+ var divRect = f.querySelector('#target').getBoundingClientRect();
+ expect(divRect.width).to.be.equal(100);
+ expect(divRect.height).to.be.equal(20);
+
+ var contentRect = badge.getBoundingClientRect();
+ expect(contentRect.width).to.be.equal(22);
+ expect(contentRect.height).to.be.equal(22);
+
+ // The target div is 100 x 20, and the badge is centered on the
+ // top right corner.
+ expect(contentRect.left).to.be.equal(100 - 11);
+ expect(contentRect.top).to.be.equal(0 - 11);
+
+ // Also check the math, just in case.
+ expect(contentRect.left).to.be.equal(divRect.width - 11);
+ expect(contentRect.top).to.be.equal(divRect.top - 11);
+
+ done();
+ });
+ });
+
suite('badge is inside a custom element', function() {
test('badge is positioned correctly', function(done) {
var f = fixture('custom');
« no previous file with comments | « lib/src/paper-badge/paper-badge.html ('k') | lib/src/paper-behaviors/paper-button-behavior.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698