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

Unified Diff: pkg/polymer/lib/elements/web-animations-js/test/testcases/unit-test-set-parent.html

Issue 175443005: [polymer] import all elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated from bower Created 6 years, 10 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
Index: pkg/polymer/lib/elements/web-animations-js/test/testcases/unit-test-set-parent.html
diff --git a/pkg/polymer/lib/elements/web-animations-js/test/testcases/unit-test-set-parent.html b/pkg/polymer/lib/elements/web-animations-js/test/testcases/unit-test-set-parent.html
new file mode 100644
index 0000000000000000000000000000000000000000..f7ce31a281dccb5812bee18e69d2999dfca5d469
--- /dev/null
+++ b/pkg/polymer/lib/elements/web-animations-js/test/testcases/unit-test-set-parent.html
@@ -0,0 +1,111 @@
+<!--
+Copyright 2013 Google Inc. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!DOCTYPE html><meta charset="UTF-8">
+<div id="anim"></div>
+
+<script src="../bootstrap.js"></script>
+<script>
+"use strict";
+
+var elem = document.getElementById("anim");
+var animFunc = {left: "100px"};
+
+// Test that Animation is constructed with no parent.
+var child = new Animation(elem, animFunc, 1);
+test(function() {assert_equals(child.parent, null)},
+ "Child should have no parent");
+
+// Test that group is constructed with zero children.
+var parent = new ParGroup();
+test(function() {assert_equals(parent.children.length, 0)},
+ "Parent should have zero children");
+
+// Test that updates are made to child when constructing parent.
+var parent = new ParGroup([child]);
+test(function() {assert_equals(child.parent, parent)},
+ "Parent's constructor, Child's parent should be set to parent");
+test(function() {assert_equals(parent.children.length, 1)},
+ "Parent's constructor, Parent should have 1 child");
+test(function() {assert_equals(parent.children[0], child)},
+ "Parent's constructor, Parent should have correct child");
+
+// Test that updates are made to previous and new parent when using append().
+var newParent = new ParGroup();
+newParent.append(child);
+test(function() {assert_equals(child.parent, newParent)},
+ "With .append, child's parent should be updated to new parent");
+test(function() {assert_equals(parent.children.length, 0)},
+ "With .append, Previous parent should no longer have children");
+test(function() {assert_equals(newParent.children.length, 1)},
+ "With .append, New parent should now have 1 child");
+test(function() {assert_equals(newParent.children[0], child)},
+ "With .append, New parent should now have correct child");
+
+// Test that calling append() with an existing child causes that child to be moved
+// to the end of the list of children.
+var sibling = new Animation(elem, animFunc, 1.0);
+var seqGroup = new SeqGroup([child, sibling]);
+test(function() {assert_equals(seqGroup.children.length, 2)},
+ "Moved child, new seqGroup.children.length");
+test(function() {assert_equals(seqGroup.children[0], child)},
+ "Moved child, new seqGroup's first child should be 'child'");
+test(function() {assert_equals(seqGroup.children[1], sibling)},
+ "Moved child, Second child should be 'sibling'");
+test(function() {assert_equals(child.startTime, 0.0)},
+ "Moved child, start time of 'child' == 0.0");
+test(function() {assert_equals(sibling.startTime, 1.0)},
+ "Moved child, start time of 'sibling' == 1.0");
+seqGroup.append(seqGroup.children[0]);
+test(function() {assert_equals(seqGroup.children.length, 2)},
+ "After .append, seqGroup.children.length");
+test(function() {assert_equals(seqGroup.children[0], sibling)},
+ "After .append, First child should be 'sibling'");
+test(function() {assert_equals(seqGroup.children[1], child)},
+ "After .append, Second child should be 'child'");
+test(function() {assert_equals(sibling.startTime, 0.0)},
+ "After .append, Start time of 'sibling'");
+test(function() {assert_equals(child.startTime, 1.0)},
+ "After.append, Start time of 'child'");
+
+// Test that setting TimedItem.parent is ignored.
+test(function() {
+ assert_throws(new TypeError(), function() {
+ child.parent = null;
+ });
+ assert_equals(child.parent, seqGroup);
+}, "TimedItem.parent should be read-only");
+test(function() {assert_equals(seqGroup.children.length, 2)},
+ "seqGroup.children.length");
+test(function() {assert_equals(seqGroup.children[0], sibling)},
+ "First child should be 'sibling'");
+test(function() {assert_equals(seqGroup.children[1], child)},
+ "Second child should be 'child'");
+test(function() {assert_equals(sibling.startTime, 0.0)},
+ "Start time of 'sibling'");
+test(function() {assert_equals(child.startTime, 1.0)},
+ "Start time of 'child'");
+
+// Test that TimedItem.clear() updates both parent and children.
+seqGroup.clear();
+test(function() {assert_equals(seqGroup.children.length, 0)},
+ "Parent's children should be cleared");
+test(function() {assert_equals(child.parent, null)},
+ "Child's parent should be cleared");
+test(function() {assert_equals(sibling.parent, null)},
+ "Sibling's parent should be cleared");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698