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

Unified Diff: test/paper_badge_test.dart

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 | « test/iron_selector_template_repeat_test.dart ('k') | test/paper_badge_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/paper_badge_test.dart
diff --git a/test/paper_badge_test.dart b/test/paper_badge_test.dart
index bb5cdb575c1ecad000b94a861bb9832fbce1506d..ba6ef1e36e276276622a47a131aa27990b0fd4eb 100644
--- a/test/paper_badge_test.dart
+++ b/test/paper_badge_test.dart
@@ -20,6 +20,7 @@ main() async {
PaperBadge badge = f.querySelector('paper-badge');
HtmlElement actualbadge = badge.querySelector('#badge');
expect(actualbadge.text, equals("1"));
+ expect(badge.target.getAttribute('id'), 'target');
badge.updatePosition();
Completer done = new Completer();
@@ -49,12 +50,15 @@ main() async {
PaperBadge badge = f.querySelector('paper-badge');
badge.updatePosition();
+ expect(badge.target.getAttribute('id'), isNot('target'));
+
Completer done = new Completer();
wait(1).then((_) {
Rectangle contentRect = badge.getBoundingClientRect();
expect(contentRect.left, isNot(100 - 11));
badge.forId = 'target';
+ expect(badge.target.getAttribute('id'), 'target');
badge.updatePosition();
wait(1).then((_) {
@@ -80,6 +84,33 @@ main() async {
return done.future;
});
});
+
+ test('badge is positioned correctly when nested in a target element', () async {
+ var f = fixture('nested');
+ var badge = f.querySelector('paper-badge');
+
+ expect(badge.target.getAttribute('id'), 'target');
+
+ badge.updatePosition();
+
+ await wait(1);
+ var divRect = f.querySelector('#target').getBoundingClientRect();
+ expect(divRect.width, 100);
+ expect(divRect.height, 20);
+
+ var contentRect = badge.getBoundingClientRect();
+ expect(contentRect.width, 22);
+ expect(contentRect.height, 22);
+
+ // The target div is 100 x 20, and the badge is centered on the
+ // top right corner.
+ expect(contentRect.left, 100 - 11);
+ expect(contentRect.top, 0 - 11);
+
+ // Also check the math, just in case.
+ expect(contentRect.left, divRect.width - 11);
+ expect(contentRect.top, divRect.top - 11);
+ });
group('badge is inside a custom element', () {
test('badge is positioned correctly', () {
« no previous file with comments | « test/iron_selector_template_repeat_test.dart ('k') | test/paper_badge_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698