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

Unified Diff: cc/layer_unittest.cc

Issue 11377108: [cc] Fix crash when adding a child layer to its own parent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use unsigned ints. Created 8 years, 1 month 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 | « cc/layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_unittest.cc
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index 2bbbef4db906dea6fde27092e775716adcde02b4..6105f6f00f4b5a3b877871155855bd158465fc55 100644
--- a/cc/layer_unittest.cc
+++ b/cc/layer_unittest.cc
@@ -164,6 +164,24 @@ TEST_F(LayerTest, addAndRemoveChild)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromParent());
}
+TEST_F(LayerTest, addSameChildTwice)
+{
+ scoped_refptr<Layer> parent = Layer::create();
+ scoped_refptr<Layer> child = Layer::create();
+
+ m_layerTreeHost->setRootLayer(parent);
+
+ ASSERT_EQ(static_cast<size_t>(0u), parent->children().size());
danakj 2012/11/12 22:31:48 You shouldn't need the static_casts then :)
tfarina 2012/11/12 22:36:27 yep, that is what I suggested: s/static_cast<size_
Ted C 2012/11/12 22:59:03 Done :-) That's what I get for trying to get a ch
+
+ parent->addChild(child);
+ ASSERT_EQ(static_cast<size_t>(1u), parent->children().size());
+ EXPECT_EQ(parent.get(), child->parent());
+
+ parent->addChild(child);
+ ASSERT_EQ(static_cast<size_t>(1u), parent->children().size());
+ EXPECT_EQ(parent.get(), child->parent());
+}
+
TEST_F(LayerTest, insertChild)
{
scoped_refptr<Layer> parent = Layer::create();
« no previous file with comments | « cc/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698